Repository navigation
feat(cli): add integration init command - #6961
josephfarina wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
4e8cd7b to
22b7798
Compare
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression44 of 448 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 24 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
22b7798 to
e40ddfe
Compare
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape.
A few things need work before this can merge:
- The branch currently conflicts with its base in
packages/cli/README.md. Please rebase and resolve it without dropping the landed demo-media receipt wording. - The manifest change switches examples and response types from being derived from each command's docs to hand-kept maps. That reverses the generated-manifest design, and the manifest test now fails (blog examples are lost and the docs response types no longer match). Restoring the derived manifest should be enough — the new command's docs already supply its entries.
- The response-type and README edits remove the descriptions of
demoMediaReplaced,sourcePathFound, andvalidated, but the code still returns those fields. Please restore them and keep only the additions forintegration.initandERR_INSTALL_FAILED. - The new function needs its own tests: options, the invalid-name and install-failure errors, a re-run, and a CLI success and failure. Right now only a dry-run parity case covers it.
- With defaults, re-running installs again and reports updated rather than unchanged, and an install failure leaves the written package file behind. Please either skip an already-satisfied install or align the docs and changeset with that behavior.
- One small admission item: note in the pull request that this create command is not batch-eligible under the multi-selector rules (E1/E4).
Happy to take another look once those are in.
[Automated review]
e40ddfe to
2b62494
Compare
2b62494 to
2936554
Compare
2936554 to
89cfa9a
Compare
89cfa9a to
9789d33
Compare
fa2aa15 to
1b0c210
Compare
82af6e1 to
e3ef401
Compare
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape. Deferring the Core peer to the first integration add is a nice refinement, and the existing-package protections are now complete: no rename via a differing name argument, no exports map invented for a package that lacks one, coded errors for a non-object package.json, a non-string name, or a malformed peerDependencies on any of the peer paths (component, template, theme, and doc --parent included), a test proving --dry-run together with --no-install, and the lint layering fix for the shared shape check.
One item remains before this can merge:
- The guard's refusal cases are well tested, but nothing yet asserts the normal first-add write itself. One add-path test with an installed-Core fixture confirming the
^<installed>peer range is written would keep that documented behavior from regressing unnoticed (it works today — this is about locking it in).
Happy to take another look once that is in.
[Automated review]
60d0d90 to
e66c192
Compare
e66c192 to
0d14699
Compare
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape. Deferring the Core peer to the first integration add is a nice refinement, and the existing-package protections are complete: no rename via a differing name argument, no exports map invented for an existing package that lacks one, and coded errors for a non-object package.json, a non-string name, or a malformed peerDependencies on the peer-writing paths.
Tests now also prove the normal first-add Core peer write for component, template, and theme adds, including preserving an existing author range. This looks ready to merge once a CLI code owner has approved and the branch is refreshed onto current main so the hosted UI suite runs with the newer BottomSheet fixes (its one current failure is in that component, which this change does not touch).
[Automated review]
0d14699 to
4c760fc
Compare
4c760fc to
2fe5df9
Compare
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape. Deferring the Core peer to the first integration add is a nice refinement, and the existing-package protections hold up: no rename via a differing name argument, no exports map invented for an existing package that lacks one, and coded errors for a non-object package.json or a non-string name.
One behavior worth being deliberate about: when peerDependencies is not an object, a theme or doc add refuses with a coded error while a component or template add succeeds and leaves the field (and the missing Core peer) as-is until a later add. That never corrupts the file, so it is not a blocker — but either refusing consistently or noting the malformed case in the command description would make the three kinds read the same. Two stale code comments (the peer helper still says it throws, and the init file header still implies init sets the Core peer) could be tidied in passing.
Tests prove the normal first-add Core peer write for component, template, and theme adds, including preserving an existing author range. This looks ready to merge once a CLI code owner has approved and the branch is refreshed onto current main so the hosted UI suite picks up the BottomSheet test fix (its one current failure is in that component, which this change does not touch).
[Automated review]
844f180 to
0c8d701
Compare
f7d4ee3 to
86d34b5
Compare
99a8e91 to
185c6e5
Compare
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape. Deferring the Core peer to the first integration add, respecting the field each dependency is already declared in, and refusing malformed package shapes before writing all hold up well, and the tests now prove the first-add peer write, the install matrix, and the failure rollback.
One correction before this can merge: when the CLI and Core are already declared under dependencies (or only one of them needed adding), a successful install still prints that both were "installed as devDependencies", although the declarations correctly stay where they were. Making that line field-neutral (or reporting what was actually added), with a text-mode test for the pre-declared case, would keep the human output as truthful as the JSON receipt already is. While you are there, refreshing the pull-request description's peer and install paragraphs to the shipped deferred-peer, declared-field behavior would help human reviewers.
Happy to take another look once that line is fixed — everything else looks ready, subject to code-owner approval, with the hosted suite green.
[Automated review]
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape. Deferring the Core peer to the first integration add, respecting the field each dependency is already declared in, and refusing malformed package shapes before writing all hold up well. The install success line now reads field-neutral with a CLI test for the pre-declared case, which closes the last round's item — thank you.
One small edge remains: an existing package.json whose name is empty or only whitespace currently gets a success receipt, even though npm could never have published that name, and passing the correct name is refused as a rename. Refusing that input with ERR_INVALID_ARGUMENT (or treating an empty name as missing), with a test next to the non-string-name cases, would keep the receipt truthful there too.
Happy to take another look once that check is in — everything else looks ready, subject to code-owner approval.
[Automated review]
| function isAcceptableExistingName(name) { | ||
| return ( | ||
| typeof name === 'string' && | ||
| name.length <= PACKAGE_NAME_MAX_LENGTH && |
There was a problem hiding this comment.
An existing package whose name is "" or whitespace-only passes this check, so init reports success (writing version and echoing the blank name in the receipt) for a package npm could never have published — the legacy path exists for names npm already published, such as uppercase ones. Passing a correct name is then refused as a rename (Package "" already exists), leaving hand-editing as the only way forward; a probe in check.log shows both outcomes. The FunctionDoc promises ERR_INVALID_ARGUMENT for an invalid npm name, so please refuse an empty/blank existing name here (or treat it as missing and fill it), with a test alongside the non-string-name cases.
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape. Deferring the Core peer to the first integration add, respecting the field each dependency is already declared in, and refusing malformed package shapes before writing all hold up well.
The last round's edge is now closed: an existing package.json with an empty or whitespace-only name is treated as missing and filled (from the argument or the directory), with tests for both cases, and the existing-name checks now name the specific rule they enforce. The field-neutral install success line and its CLI test are in as well — thank you.
This looks ready to merge once a CLI code owner has approved.
[Automated review]
There was a problem hiding this comment.
Thanks for building the missing first step for integration authors — the case for a dedicated integration init subcommand is clear, and the thin command over integrationInit() with --dry-run, --no-install, and JSON support is the right shape. Deferring the Core peer to the first integration add, respecting the field each dependency is already declared in, and refusing malformed package shapes before writing all hold up well.
The blank-name edge is fully closed now: an existing package.json with an empty or whitespace-only name is treated as missing and filled under the strict new-name rules, and the new test locks in that a strict-invalid replacement (a Node core-module name) is refused with the file unchanged. One small non-blocking note for a follow-up: init writes through a symlinked package.json while the add writers refuse symlinked targets, so aligning those would make the journey consistent for that setup.
This looks ready to merge once a CLI code owner has approved.
[Automated review]
# Conflicts: # packages/cli/README.md # packages/cli/api/index.mjs # packages/cli/clients/cli/commands/integration.mjs
There was a problem hiding this comment.
Thanks for turning the quick-start's setup into one command — the case for the subcommand is clear, and init followed by integration add and integration verify works. Approval needs a maintainer decision first: no current spec covers integration add writing a ^<installed> @astryxdesign/core peer on the first component, template, or theme add, so a maintainer needs to provide or identify the governing spec for that write and its range, or the write should leave this PR. Separately from that decision, these changes are needed:
- Move init's file and subprocess work into
api/integration/_adapter.mjsinstead of adding a newINV21_KNOWN_GAPSentry, which that list does not allow (cli-surface INV21). - Refuse a symlinked
package.jsonthe wayintegration adddoes; today init edits the link's target outside the package (INV10). - Stop creating
exportsin init, or get INV16 (“Writers never createfilesorexports”) amended first. - Print the receipt with
record(...)rather than one Text block per field (AST-042 FR3). - At 2,577 authored lines, split the
integration addpeer changes into their own PR and trim the init tests to get under the 2,000-line scope threshold.
[Automated review]
| ['integration/add-helpers.mjs', new Set(['fs'])], | ||
| ['integration/add-theme.mjs', new Set(['fs', 'discovery'])], | ||
| ['integration/authoring-checks.mjs', new Set(['discovery'])], | ||
| ['integration/init.mjs', new Set(['fs', 'child_process'])], |
There was a problem hiding this comment.
This map is documented as known gaps recorded in AST-042 — “remove an entry when the file is fixed; do not add entries”. integration/init.mjs is new, so this line admits a new INV21 violation rather than recording an old one, and main's check fails on the file without it. Please move the fs reads and writes and spawnSync into api/integration/_adapter.mjs (or an underscore helper only it imports) and drop this entry.
| if (!exists && pkg.exports == null) { | ||
| pkg.exports = {}; | ||
| fieldsAdded.push('exports'); |
There was a problem hiding this comment.
cli-surface INV16 reads “Writers never create files or exports” with no new-package exception (theme exports come from AST-050's own claim), so creating exports: {} here contradicts it; the header's “on an existing package” is not in the claim. Please leave exports to the author, as the current quick-start does, or get INV16 amended on main first.
| ? (originalSource.match(/\n([ \t]+)"/u)?.[1] ?? ' ') | ||
| : ' '; | ||
| fs.mkdirSync(dir, {recursive: true}); | ||
| fs.writeFileSync( |
There was a problem hiding this comment.
This write follows a symlinked package.json to its target, even outside the package directory, and reports success; integration add refuses the same file with ERR_PATH_TRAVERSAL (assertNotSymlink in add-helpers.mjs). cli-surface INV10 requires every write to be confined. Please refuse a symlinked target here and in rollbackPackageJson (the shared applyWrites path would do both), with a test.
| text(`packageCreated: ${data.packageCreated}`), | ||
| text(`installed: ${data.installed}`), | ||
| text(`dryRun: ${data.dryRun}`), |
There was a problem hiding this comment.
AST-042 FR3: “A Text block carries prose. Items and field values MUST use Record, Section, or List blocks.” These lines print receipt fields as prose and leave name, fieldsAdded, and notes unlabeled (INV5). record(data, {fields: ['name', 'packageCreated', 'fieldsAdded', 'installed', 'dryRun', 'notes']}) renders the same receipt with keys that match the JSON.
| // Component contributions compose Core components in real integrations. | ||
| // Write the Core peer on the first component add when no peer exists yet. | ||
| { | ||
| const coreExpected = | ||
| pkgUpdate?.expectedOriginal ?? fs.readFileSync(packageFile); | ||
| const coreText = pkgUpdate?.contents ?? coreExpected.toString('utf-8'); | ||
| const coreCurrent = JSON.parse(coreText); | ||
| const corePeerResult = withCorePeer(coreCurrent, packageDir); |
There was a problem hiding this comment.
No current spec assigns integration add a Core peer or its ^<installed> range — AST-046 FR11 covers only the @astryxdesign/cli peer. Approval of this write (and of the template and theme copies) waits on a maintainer providing or identifying the governing spec.
|
Parking this for now; it's tracked separately and can be reopened when picked up. |
What this does
astryx integration init [name]creates or completes the package.json for an Astryx integration package in one command. It replaces the 5 manual steps from the quick-start doc (mkdir, npm init, set name, set exports, install dependencies).After init,
integration add,integration verify, and every other CLI command work immediately.AST-042 FR4 subcommand justification
initis for consumer apps (index.mjs explicitly skips integration packages).integration addrequires a package.json to already exist — itsfindPackageDir()throws if none is found. Creating the package is a distinct step that logically precedes any add.integrationInit()exported from@astryxdesign/cli/api.Behavior
Creates/completes package.json:
name— from argument, existing value, or directory nameversion—1.0.0(only when creating)exports—{}(the empty map thatintegration addpopulates)@astryxdesign/core: ^<installed>) is written by the firstintegration add component,add template, oradd theme, not by init. It never overwrites an existing range.Install step (unless
--dry-runor--no-install):<pm> add -D <missing>); if both are declared but not installed, runs a plain<pm> install. Declared entries stay in their field (dependencies, devDependencies or optionalDependencies).Idempotent: re-running on an initialized package reports unchanged.
JSON type:
integration.initwith{name, packageCreated, fieldsAdded, installed, dryRun}.Design decisions
^<installed>once.type,description,license) — theme-neutral has authored content; auto-generating it invites wrong values. The author adds what they mean.--no-installfor environments that want control.integration addcreatesastryx.integration.mjson first contribution. Init creates the package; add creates the integration content.Bootstrap
From an empty directory with no CLI installed:
Tested
init --dry-run --json✅init --no-install✅initwith install (npm via proxy) ✅init→integration add component→integration verify(full journey, zero issues) ✅Multi-selector admission (AST-042 FR7)
integration initis not batch-eligible under AST-053 FR11. It fails E1 (it writes package.json and runs an install, so it is not read-only) and E4 (an install per selector has no single safe aggregate work bound for two or more selectors).