feat(commands): add monorail:sync-assets to keep npm version aligned with Composer - #6
Merged
Merged
Conversation
…with Composer The Composer package and the npm package are released together but live in two separate manifests, so host apps that bump `monorailphp/monorail` via `composer update` still have to remember to bump `monorailphp` in package.json and re-run `npm install`. `monorail:sync-assets` reads the installed Composer package's version from `vendor/monorailphp/monorail/package.json`, rewrites the host's package.json so `monorailphp` is pinned to a matching `^x.y.z` range, and runs `npm install`. Pass `--skip-install` to only rewrite package.json — useful for wiring it into a Composer `post-update-cmd` hook without forcing `npm install` on every Composer run. Docs updated with usage and an example `post-update-cmd` snippet.
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.
Problem
The Composer package and the npm package are released together (
composer require monorailphp/monorail↔npm install monorailphp), but they live in two separate manifests. Host apps that bump the Composer constraint viacomposer updatestill have to remember to bumpmonorailphpin theirpackage.jsonand re-runnpm install— and forgetting leaves the frontend pinned to an older version with stale TSX/CSS.Solution
A new Artisan command,
monorail:sync-assets:vendor/monorailphp/monorail/package.json.package.jsonso themonorailphpdependency is pinned to a matching^x.y.zrange.npm install.Flags:
--skip-install— only rewritepackage.json; skipnpm install. Intended for wiring into a Composerpost-update-cmdhook so the sync runs automatically without forcingnpm installon everycomposer update.Example post-update hook (documented in installation.md):
```json
"scripts": {
"post-update-cmd": [
"@php artisan monorail:sync-assets --skip-install"
]
}
```
Files
src/Commands/SyncAssetsCommand.php— new command.src/MonorailServiceProvider.php— register it.docs/getting-started/installation.md— new "Keep the npm package in sync with Composer" section with usage and thepost-update-cmdsnippet.Test plan
php artisan monorail:sync-assetsin a host app pinned to an oldermonorailphpversion →package.jsonis rewritten andnpm installruns.--skip-install→package.jsonis rewritten,npm installis skipped.package.jsonor the vendor package → command fails with a clear error message.