Skip to content

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

Open
Adi-ty wants to merge 2 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 2 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
- 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
@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
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 requested a review from AnuragVasanwala August 19, 2026 09:25
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.

1 participant