Decouple workspace install lifecycle from root npm install#63
Conversation
Agent-Logs-Url: https://github.com/tomgrv/devcontainer-features/sessions/73785d8c-b0a4-4e2a-8955-82823605ca7d Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
tomgrv
left a comment
There was a problem hiding this comment.
During common-utils install, common scripts should be made available in path as they are installed in a bin folder. If not, find a fallback way to make them available globally.
Verify, confirm and update accordingly if needed.
Agent-Logs-Url: https://github.com/tomgrv/devcontainer-features/sessions/daeb1c9f-3fab-49b2-a946-1a94cccd8d15 Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Implemented in 655514c. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/tomgrv/devcontainer-features/sessions/3a277216-ecb3-4d12-877c-b427b3ca59b4 Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Addressed in 37b4361.
No UI changes in this update. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
tomgrv
left a comment
There was a problem hiding this comment.
Externalise bin folder selection to a _select-bin.sh script
|
@copilot update documentation accordingly. |
Agent-Logs-Url: https://github.com/tomgrv/devcontainer-features/sessions/36ca616c-1e49-477a-976d-c8ec39b73152 Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Updated in 78df9ff: |
There was a problem hiding this comment.
Pull request overview
This PR adjusts npm lifecycle scripts so each workspace under src/* can be installed/configured independently, while keeping root-level stub deployment triggered from the root npm install. It also updates common-utils bin-link installation to choose a writable bin directory more flexibly.
Changes:
- Added root
installlifecycle to deploy stubs on rootnpm install. - Added guarded
install/postinstallscripts to multiple workspacepackage.jsonfiles so feature install/config only runs when installing that workspace directly. - Refactored
common-utilsbin linking to select a writable bin directory via a new_select-bin.sh, and temporarily amendsPATHduring install to keep helper commands runnable.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds root install script to run stub deployment on npm install. |
| src/act/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| src/common-utils/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| src/common-utils/_install-bin.sh | Uses _select-bin.sh to choose a writable bin dir and prepends it to PATH for the install session. |
| src/common-utils/_select-bin.sh | New helper to resolve a writable bin directory using a fallback order. |
| src/common-utils/README.md | Documents the bin-directory selection behavior and fallback order. |
| src/gateway/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| src/githooks/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| src/gitutils/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| src/gitversion/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| src/larasets/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| src/minikube/package.json | Adds guarded workspace install/postinstall lifecycle scripts. |
| for dir in $(echo "$PATH" | tr ':' '\n'); do | ||
| case "$dir" in | ||
| "" | "." | "$PWD" | */node_modules/.bin) continue ;; | ||
| esac | ||
| add_candidate "$dir" | ||
| done |
| [ -d "$candidate" ] || mkdir -p "$candidate" 2>/dev/null || true | ||
| if [ -d "$candidate" ] && [ -w "$candidate" ]; then |
| # Find all shell scripts in the target directory, make them executable, and create symbolic links in /usr/local/bin | ||
| find $target -type f -name "_*.sh" -exec echo {} \; -exec chmod +x {} \; | while read file; do | ||
| # Create a symbolic link in /usr/local/bin with the script name (without the leading underscore and .sh extension) |
| find $target -type f -name "_*.sh" -exec echo {} \; -exec chmod +x {} \; | while read file; do | ||
| # Create a symbolic link in /usr/local/bin with the script name (without the leading underscore and .sh extension) | ||
| link=/usr/local/bin/$(basename $file | sed 's/^_//;s/.sh$//') | ||
| link=$link_dir/$(basename $file | sed 's/^_//;s/.sh$//') | ||
| ln -sf $file $link && zz_log s "Linked {U $file} to {U $link}" |
|
@copilot install.sh, handle dependencies based on decontainer files |
…stall.sh Agent-Logs-Url: https://github.com/tomgrv/devcontainer-features/sessions/a7655ecf-fb1d-4b9f-9583-dfd8bba2aa3c Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Implemented in 78e5a23. Two new helper functions were added:
The |
….json in install.sh Agent-Logs-Url: https://github.com/tomgrv/devcontainer-features/sessions/db7bb9c2-a804-4a41-8459-156d6f45c41d Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Implemented in 481827c. Two new helpers are added to
After features are determined from any source (devcontainer.json, package.json, positional args, or auto-detection), the list is expanded through |
…d feature install to _install-feat.sh Agent-Logs-Url: https://github.com/tomgrv/devcontainer-features/sessions/e5fc286c-1e46-438a-a07d-ef0ff70f873b Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Implemented in f72aac6.
|
This PR makes each workspace installable on its own while preserving root-level stub management. It aligns npm lifecycle behavior so install-time setup and post-install configuration run in the right scope without cascading unintended workspace execution.
Root lifecycle behavior
installscript inpackage.jsonto keep root stub deployment onnpm install:sh ./install.sh -sWorkspace-independent install/config lifecycle
install+postinstallscripts to workspacepackage.jsonfiles (common-utils,gitutils,githooks,gitversion,act,larasets,gateway,minikube).INIT_CWD == PWD, so scripts run when the workspace is explicitly installed, not when npm traverses from root.Common-utils bin/script execution behavior
zz_*,merge-json,normalize-json, etc.)./usr/local/bin→~/.local/bin→ first writable directory inPATH(excludingnode_modules/.bin) →$target/bin_select-bin.shusing a candidate list + two-pass loop: first pass finds an existing writable+executable directory; second pass only creates known/safe directories, never PATH-sourced entries.PATHfor the current install session when needed, so installed common scripts remain executable during lifecycle execution.Devcontainer-aware feature discovery in
install.shdevcontainer_features()helper to extracttomgrv/devcontainer-featuresentries from a givendevcontainer.json.find_devcontainer_features()to discover devcontainer files across standard VS Code locations in priority order:.devcontainer/devcontainer.json→devcontainer.json→.devcontainer.json→.devcontainer/*/devcontainer.json.-a(all) and-u(update) modes now usefind_devcontainer_featuresinstead of hardcoded paths.install.shautomatically detects features to install from devcontainer files in the current directory.Manifest-based transitive dependency resolution via dedicated helpers
src/common-utils/_install-deps.sh: accepts<source_dir>and a feature list, reads each feature'sdevcontainer-feature.json, performs BFS to collect all transitivetomgrv/devcontainer-featuresdependencies, then outputs a topologically-sorted list (deps before dependents). Example:install-deps $source githooks→common-utils → gitversion → gitutils → githooks.src/common-utils/_install-feat.sh: installs a single feature and its dependencies recursively. UsesINSTALL_FEAT_TRACKERto prevent re-installation within the same session. Callsinstall.shfor each dependency (makinginstall.shthe recursive orchestrator), then installs the feature itself — handling container, stubs, and no-container cases.install.shis the orchestrator: usesinstall-depsto expand the feature list andinstall-featfor each resolved feature. AINSTALL_ROOT_CALLguard ensures symlink setup/cleanup only runs at the outermost invocation, not in recursive calls.{ "scripts": { "install": "if [ \"$INIT_CWD\" = \"$PWD\" ]; then sh ./install.sh; fi", "postinstall": "if [ \"$INIT_CWD\" = \"$PWD\" ]; then configure-feature -s . gitutils; fi" } }