Skip to content

Fix cli breaking change and setup fixed entrypoint to prevent future cases from happening#1410

Merged
timotheeguerin merged 7 commits into
microsoft:release/dec-2022from
timotheeguerin:fix/cli-tool
Dec 9, 2022
Merged

Fix cli breaking change and setup fixed entrypoint to prevent future cases from happening#1410
timotheeguerin merged 7 commits into
microsoft:release/dec-2022from
timotheeguerin:fix/cli-tool

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

No description provided.

@timotheeguerin
timotheeguerin changed the base branch from main to release/dec-2022 December 9, 2022 19:33
}
const scriptUrl = url.pathToFileURL(script).toString();
import(scriptUrl);
await import(scriptUrl);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I wonder why eslint didn't find this one.

@timotheeguerin
timotheeguerin merged commit 28eff67 into microsoft:release/dec-2022 Dec 9, 2022
@timotheeguerin
timotheeguerin deleted the fix/cli-tool branch December 9, 2022 21:24
timotheeguerin added a commit that referenced this pull request Dec 16, 2022
* HotFix: Scalar migration script and scalar in namespace (#1401)

* Bump versions (#1403)

* Fix cli breaking change and setup fixed entrypoint to prevent future cases from happening (#1410)

* Fix: `constants` is not available in `fs/promises` in node 16 (#1414)

* Fix: auth.cadl invalid doc comment causing ide to not show errors (#1438)

* HotFix: `--arg` not being picked up (#1445)

* .

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
timotheeguerin added a commit to timotheeguerin/typespec that referenced this pull request Dec 19, 2022
* HotFix: Scalar migration script and scalar in namespace (microsoft#1401)

* Bump versions (microsoft#1403)

* Fix cli breaking change and setup fixed entrypoint to prevent future cases from happening (microsoft#1410)

* Fix: `constants` is not available in `fs/promises` in node 16 (microsoft#1414)

* Fix: auth.cadl invalid doc comment causing ide to not show errors (microsoft#1438)

* HotFix: `--arg` not being picked up (microsoft#1445)

* HotFix: Emitter not found is a warning  (microsoft#1460)

* Refdoc

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
chidozieononiwu pushed a commit to chidozieononiwu/typespec that referenced this pull request Jul 20, 2026
…osoft#11312)

## Summary

Removes the unused `backupPath` fallback argument from the internal
`runScript` helper (`packages/compiler/src/runner.ts`) and its two
callers.

`runScript(relativePath, backupPath)` used to fall back to `backupPath`
when `relativePath` did not exist under the resolved package root. Both
call sites (`cmd/tsp.js`, `cmd/tsp-server.js`) always pass a
`relativePath` that exists, so the fallback (and its `checkFileExists`
helper + `access` import) is dead code.

This is a pure, self-contained cleanup extracted out of microsoft#11299
(standalone SEA rewrite) so that PR stays focused on the feature. The
standalone CLI does not use `runScript`.

## History / why it is safe to remove

The `backupPath` fallback was added in microsoft#1410 and shipped in
`@cadl-lang/compiler` **0.38.2** (Dec 2022) as a patch: _"Revert
breaking change to global cli usage."_

That PR introduced the stable indirection entrypoints
`entrypoints/cli.js` and `entrypoints/server.js`. Before 0.38.2 the
global CLI booted the compiler directly at `dist/core/cli/cli.js` (and
`dist/server/server.js`). Because a **globally-installed** CLI resolves
and runs the **locally-installed** compiler, a global 0.38.2 CLI could
hit an older local compiler that did not yet have the `entrypoints/`
files. The `backupPath` (`dist/core/cli/cli.js` /
`dist/server/server.js`) was the fallback so the global CLI could still
boot those pre-0.38.2 local installs.

Every supported compiler version has shipped `entrypoints/cli.js` /
`entrypoints/server.js` since 0.38.2, so the fallback branch is now
unreachable dead code.

## Changes
- `runner.ts`: `runScript(relativePath)` — dropped `backupPath` param,
`checkFileExists`, and the now-unused `access` import.
- `cmd/tsp.js` / `cmd/tsp-server.js`: drop the second argument.

## Validation
- `tsc -p packages/compiler/tsconfig.build.json` passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants