Skip to content

feat(init): add generic editJson + deferred note primitives - #54

Open
Adi-ty wants to merge 3 commits into
v1.0.0/task/init-list-json-contractfrom
v1.0.0/task/dev-tools-init-feature
Open

feat(init): add generic editJson + deferred note primitives#54
Adi-ty wants to merge 3 commits into
v1.0.0/task/init-list-json-contractfrom
v1.0.0/task/dev-tools-init-feature

Conversation

@Adi-ty

@Adi-ty Adi-ty commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

Extends wp-tooling's feature kernel with the editing and reporting primitives wp-devtools needs, effort: a generic journaled editJson for managing both halves of a feature's state, a deferred "next steps" channel consumed by the dev-tools init feature, and a corrected npm install hint.

Part of

  • Part of rtcamp/wp-devtools#48
  • Part of rtcamp/wp-devtools#49

Changes

  • Generalise editPackageJson into api.editJson(rel, mutator, opts) — preserves indentation, optional create + indentFrom for absent files, and a parse error that names the offending file; editPackageJson is now a thin wrapper. Fully journaled: rollback restores an existing file or removes a created one.
  • Add api.note(message) — defers "do this next" lines past the spinner; toggleFeatures flushes them once under a Next steps heading after transitions, draining the queue so a manage-mode toggle loop never reprints. Notes roll back with the journal when a hook throws.
  • Narrow touchesPackage to dep changes only — a scripts-only feature no longer prompts npm install.
  • Ship tests/init/features.test.js (22 tests) covering editJson indent/create/rollback, note queueing/flush/rollback, the npm-install hint, and a full enable/disable/detect round trip against a committed-manifest + gitignored-local-override composite.

How I verified

$ npm run lint
(clean — zero errors)
$ npm test
Test Suites: 53 passed, 53 total
Tests:       749 passed, 749 total

Acceptance criteria

Runtime behavior

  • CPI-enablet + local override can be written idempotently, detected, and removed cleanly on disable
  • Notes print once, after transitions, and never on a failed hook
  • Scripts-only features stay quiet about npm install
  • Existing non-TTY / CI behaviour unchanged (full suite green)

Code quality

  • Lint — zero errors
  • Static analysis — zero errors
  • Tests pass (749/749)

@Adi-ty
Adi-ty force-pushed the v1.0.0/task/init-list-json-contract branch from 65a9dd4 to 965928c Compare August 11, 2026 12:03
@Adi-ty
Adi-ty force-pushed the v1.0.0/task/dev-tools-init-feature branch from 56634de to d0f5d24 Compare August 11, 2026 12:05
@Adi-ty
Adi-ty marked this pull request as ready for review August 11, 2026 12:08
@Adi-ty
Adi-ty requested a review from AnuragVasanwala August 19, 2026 09:25
@Adi-ty
Adi-ty force-pushed the v1.0.0/task/init-list-json-contract branch from d344a22 to 0dd4158 Compare August 27, 2026 12:09
Adi-ty added 2 commits August 27, 2026 18:27
- Generalise editPackageJson into a journaled editJson(rel, mutator, opts) that preserves indentation, supports create/indentFrom, and names the file in parse errors; editPackageJson is now a thin wrapper
- Add api.note() to defer "next steps" past the spinner; toggleFeatures flushes them once under a "Next steps" heading, draining the queue so a manage-mode toggle loop never reprints
- Narrow touchesPackage to deps only; a scripts-only feature no longer suggests `npm install`
- Add features.test.js covering editJson, note rollback/flush, the npm install hint, and an enable/disable/detect round trip
Lets a consumer unit-test its own scaffold config's feature hooks against the
real api; the exports map has no wildcard, so a deep import is not possible.
@Adi-ty
Adi-ty force-pushed the v1.0.0/task/dev-tools-init-feature branch from 7f6e50b to 7bf4b18 Compare August 27, 2026 12:59
@Adi-ty
Adi-ty requested a review from Swanand01 August 27, 2026 13:23
Comment thread node-packages/wp-tooling/src/init/features.js
Comment thread node-packages/wp-tooling/src/init/index.js

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds generic JSON editing and deferred next-step reporting to the feature kernel.

Changes:

  • Adds journaled editJson and deferred note APIs.
  • Limits npm-install hints to dependency changes.
  • Adds feature lifecycle and rollback tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/init/features.js Implements editing, notes, rollback, and hint behavior.
src/init/index.js Exports the feature API constructor.
tests/init/features.test.js Tests the new feature-kernel behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread node-packages/wp-tooling/src/init/index.js
@Adi-ty
Adi-ty requested a review from Swanand01 August 28, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants