-
Notifications
You must be signed in to change notification settings - Fork 0
fix(cli): support --version and -V #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { readFileSync } from 'node:fs'; | ||
|
|
||
| /** | ||
| * Read the installed SDK package version from the manifest beside this module. | ||
| * | ||
| * The same relative URL works from `src/` during development and `dist/` in a | ||
| * built or npm-installed package. Reading the manifest at runtime keeps the | ||
| * CLI output tied to the bytes that are actually installed instead of a | ||
| * hardcoded release value that can drift between package files. | ||
| */ | ||
| export function packageVersion(): string { | ||
| try { | ||
| const manifest: unknown = JSON.parse( | ||
| readFileSync(new URL('../package.json', import.meta.url), 'utf8'), | ||
| ); | ||
| const version = (manifest as { version?: unknown }).version; | ||
| return typeof version === 'string' && version.length > 0 ? version : '0.0.0'; | ||
| } catch { | ||
| // Version display is cosmetic. Keep the CLI usable if a host strips the | ||
| // manifest from an otherwise runnable package artifact. | ||
| return '0.0.0'; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Standalone executable reports placeholder version
For Bun-compiled
flows,packageVersion()cannot find the SDK manifest beside its bundled module. Both version flags print0.0.0instead of the release version.Learn more
The standalone build imports
runCliinto a temporary entrypoint, then compiles that entrypoint as a single executable. The compiled module does not have the SDK package manifest at the relative URL used bypackageVersion(). The failed read reaches the placeholder fallback, so the new flags report0.0.0in standalone artifacts even though the installed Node CLI reports the correct version. The release workflow builds standalone binaries for both supported platforms.Example: Compile the standalone executable into
packages/runtime-linux-x64/bin/flowsand invokeflows --version. The SDK package version is2.0.31, but the manifest read fails and stdout contains0.0.0.Recommended fix: Embed the SDK version at standalone build time and pass it to
runClifor version output, while retaining the manifest read for source and Node-installed packages. Add an assertion for both version flags against a built standalone executable.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5413fba. The standalone builder now reads packages/sdk/package.json at build time and passes the embedded version to runCli. Added bin.test.ts coverage that compiles the standalone executable and asserts both --version and -V return 2.0.31 with rc 0 and empty stderr. The Linux artifact CI is green on this head.