fix: replace ~version.json with .tmp/version.json for shell portability - #6
Open
hoegertn wants to merge 2 commits into
Open
fix: replace ~version.json with .tmp/version.json for shell portability#6hoegertn wants to merge 2 commits into
hoegertn wants to merge 2 commits into
Conversation
The version artifact was written to a file literally named `~version.json`. A leading unquoted `~` triggers tilde expansion in non-bash shell emulators (Yarn Berry's @yarnpkg/shell, pnpm shell-emulator, Bun's built-in shell), causing builds to abort with "Unsupported tilde expansion". Changes: - Default output path is now `.tmp/version.json` - .tmp/ added to .gitignore and .npmignore via .projenrc.ts - Shell command strings use explicit `./` prefix via shellSafePath() helper - readVersionFile() falls back to ~version.json with a deprecation warning - Path validation rejects filenames starting with ~, -, or # - --output / -o CLI flag and VERSION_OUTPUT_PATH env var for overrides The legacy `~version.json` read fallback will be removed in the next minor. BREAKING CHANGE: The version artifact location changed from `~version.json` to `.tmp/version.json`. The CLI still reads the old path as a fallback.
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request was created by @kiro-agent on behalf of @hoegertn 👻
Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro Web
Problem
The
compute-versionCLI wrote the version artifact to a file literally named~version.json. A leading unquoted~is a tilde-prefix in shell grammar — while/bin/shand bash tolerate it by falling back to the literal string, JS-based shell emulators (Yarn Berry's@yarnpkg/shell, pnpm'sshell-emulator, Bun's built-in shell) reject~nameoutright and abort the build:Solution
New default path:
.tmp/version.json.gitignore/.npmignoreentry covers the temp directory.is inert in every shellConfigurable output path
--output <path>/-o <path>CLI flagVERSION_OUTPUT_PATHenvironment variable~,-, or#(all shell-hazardous)Shell-safe path rendering
A
shellSafePath()helper ensures all relative paths emitted in command strings use an explicit./prefix (e.g.,cat ./.tmp/version.json), preventing any ambiguity for shell parsers.Backwards compatibility (deprecation window)
readVersionFile()checks the new path first, then falls back to reading~version.jsonwith a deprecation warning. This fallback will be removed in the next minor release. The CLI no longer writes to~version.json.Migration
If you have CI scripts or projen tasks that reference
~version.json:~version.jsonwith.tmp/version.json(orcat ./.tmp/version.json)readVersionFile()API handles the fallback automatically during the transitionChanges
src/versioning/output-path.ts— new module withDEFAULT_VERSION_OUTPUT_PATH,validateOutputPath(),shellSafePath()src/versioning/compute-version.ts— refactored to use new path, added--outputflag,readVersionFile()with fallback.projenrc.ts— added.tmp/to gitignore and npmignoretest/versioning/output-path.test.ts— 15 tests for path validation and shell-safetytest/versioning/compute-version.test.ts— 9 tests for readVersionFile and validationREADME.md,docs/VERSIONING.md— updated CLI documentationVerification
npx projen buildpasses: jsii compile, 168 tests (10 suites), ESLint, jsii-pacmak all green.