feat: Add configurable package root for release scripts#114
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #113
The command-stream library's cd command is a virtual command that calls process.chdir(), permanently changing the Node.js process's working directory. This caused release scripts to fail when trying to read ./js/package.json after running cd js && npm run ... Root cause: After `cd js && npm run changeset:version` completed, the process was still in the js/ directory, so reading ./js/package.json tried to access js/js/package.json which doesn't exist. Fixed by saving the original cwd before cd commands and restoring it after each command that changes directory. Also fixed publish-to-npm.mjs which was missing the cd js prefix for npm run changeset:publish (the script is in js/package.json). Fixes #113 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This reverts commit 43e241a.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
I think in all JavaScript related scripts we need to have configurable repository root, that will be automatically determined if not specified. We should check for repository root So if not in root, try to search in js folder, if that also don't exist throw an error, and suggest user to configure the root folder explicitly. That way scripts will support both single language repository and multi language repositories. We can also do similar thing for Rust .mjs scripts. |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-10T22:57:08.495Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
Add js-paths.mjs and rust-paths.mjs utilities that automatically detect the package root for both single-language and multi-language repositories: - Check for ./package.json or ./Cargo.toml first (single-language repo) - If not found, check ./js/ or ./rust/ subfolder (multi-language repo) - Support explicit configuration via --js-root/--rust-root CLI options - Support environment variables JS_ROOT and RUST_ROOT Updated scripts to use the shared utilities: - version-and-commit.mjs - instant-version-bump.mjs - publish-to-npm.mjs - rust-version-and-commit.mjs - rust-collect-changelog.mjs - rust-get-bump-type.mjs This makes the scripts work seamlessly in both single-language repositories (where package.json/Cargo.toml is in the root) and multi-language repositories (where they are in js/ and rust/ subfolders). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Summary
This PR enhances the release scripts to support both single-language and multi-language repository structures by adding automatic package root detection.
New utility modules:
scripts/js-paths.mjs- JavaScript package root detectionscripts/rust-paths.mjs- Rust package root detectionUpdated scripts:
scripts/version-and-commit.mjsscripts/instant-version-bump.mjsscripts/publish-to-npm.mjsscripts/rust-version-and-commit.mjsscripts/rust-collect-changelog.mjsscripts/rust-get-bump-type.mjsHow It Works
The utilities automatically detect the package root:
./package.jsonor./Cargo.tomlin root./js/package.jsonor./rust/Cargo.tomlConfiguration Options
Scripts support explicit configuration via:
--js-root <path>or--rust-root <path>JS_ROOTorRUST_ROOTExample Usage
Root Cause (Original Issue)
The original issue (#113) was that
command-streamlibrary'scdcommand callsprocess.chdir(), which permanently changes the working directory. This caused file operations to fail after running commands likecd js && npm run ....This PR addresses the issue comprehensively by:
cdcommands (previous fix)Test Plan
js-paths.mjsutility - correctly detectsjs/as package rootrust-paths.mjsutility - correctly detectsrust/as package rootFixes #113
🤖 Generated with Claude Code