feat(2nd-gen): add plop component scaffolder#6391
Conversation
Add a plop@4.0.5 generator at 2nd-gen/scaffolding/ that produces the deterministic two-layer skeleton for a 2nd-gen component (core base/types + swc concrete/registration/css/mdx/stories/tests), matching the badge reference layout and the stories-format, stories-documentation, and code-conformance rules. - One `component` generator, one prompt (name); built-in case helpers plus custom `titleName` (space-separated proper-noun title) and `lb`/`rb` (literal braces for .mdx JSX). - `wire-core-export` action adds the new `./components/<name>` entries to the core package.json exports and re-sorts alphabetically (minimal diff); the swc package uses wildcard exports and needs no edit. - `format-component` action runs Prettier on the generated files. - Runs headless for agents: `yarn plop component "<name>" --force`. Validated end-to-end: generated output passes ESLint, Stylelint, and Prettier clean. Wire it into the migration-setup skill (Phase 2 now runs the generator instead of hand-authoring 11 files) and update ai-to-script-tools.md to mark Recommendation 1 as shipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Description
Adds a plop component scaffolder at
2nd-gen/scaffolding/that generates the deterministic file skeleton for a 2nd-gen component in a single command. It produces the two-layer structure (corebase/types/index +swcconcrete/registration/css/mdx/stories/tests), wires the@spectrum-web-components/coreexportsmap, and formats the output.This is build-time authoring tooling. It adds no runtime code and changes no shipping component.
What's included:
2nd-gen/scaffolding/plopfile.js— onecomponentgenerator (singlenameprompt) plus two custom actions:wire-core-export— adds the new./components/<name>and./components/<name>/index.jsentries to the corepackage.jsonand re-sorts theexportskeys alphabetically (minimal, deterministic diff). Theswcpackage uses wildcard exports and needs no edit.format-component— runs Prettier on the two generated directories so output lands pre-formatted.2nd-gen/scaffolding/templates/component/**— 11.hbstemplates matching thebadgereference layout exactly.2nd-gen/scaffolding/README.md— human (yarn plop component) and headless (yarn plop component "<name>" --force) usage, encoded conventions, and a template-editing guide.package.json—plopscript andplop@4.0.5devDependency (the existing 1st-genplopdep was aligned to4.0.5byyarn constraints)..ai/skills/migration-setup/SKILL.md— Phase 2 now runs the generator instead of hand-authoring 11 files, then applies the plan's base-vs-concrete split.ai-to-script-tools.md— marks the corresponding recommendation as shipped.Name derivation uses plop's built-in case helpers (
dashCase,pascalCase,constantCase) plus two custom helpers:titleName(space-separated proper-noun Storybook title, because the built-intitleCasekeeps the dash and yieldsAction-Button) andlb/rb(literal braces for.mdxJSX expressions adjacent to handlebars).Motivation and context
Phase 2 of every 1st-gen → 2nd-gen component migration recreates the same ~11-file two-layer skeleton from skill prose, re-deriving names and hand-editing the core
package.jsonexport each time. That is hundreds to thousands of output tokens per component, repeated across 100+ components, and every repetition is a fresh chance to drift from the reference.Encoding the skeleton as a generator makes the output byte-identical to the reference every time, lets the
migration-setupskill spend its tokens on judgment (the base-vs-concrete split) rather than mechanics, and gives humans and the agent one identical scaffolding command. The templates align only with 2nd-gen patterns and thebadgereference — not the deprecated 1st-gen plop.Related issue(s)
Screenshots (if appropriate)
N/A — no runtime or visual change.
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Generator produces a conformant, lint-clean skeleton
yarn plop component "test-widget" --force2nd-gen/packages/core/components/test-widget/(3) and2nd-gen/packages/swc/components/test-widget/(8), matching thebadgelayout2nd-gen/packages/core/package.jsongained./components/test-widgetand./components/test-widget/index.jsentries in alphabetical positionyarn lint,yarn lint:css, andyarn prettier --check "2nd-gen/packages/**/test-widget/**"; expect all to passrm -rf 2nd-gen/packages/{core,swc}/components/test-widgetandgit checkout -- 2nd-gen/packages/core/package.jsonHeadless and interactive parity
yarn plop component(interactive) and enter a name in mixed form (e.g.Action Button,actionButton, orsp-action-button)--forceinvocation: kebab dirs/files,PascalCaseclasses,ACTION_BUTTON_*constants, and atitle: 'Action Button'Storybook title (space-separated, notAction-Button)Device review
Accessibility testing checklist
This PR adds build-time scaffolding tooling. It introduces no runtime UI, component, or behavior, so there is no interactive surface to test here. The accessibility of any component created from the generator is validated during that component's own migration (Phases 4 and 6), not in this PR. The templates intentionally seed accessible defaults (e.g.
label/slot content in stories, an ARIA-snapshot a11y spec) as a starting point, each marked withTODOfor the migrating author to complete.Keyboard (required — document steps below)
2nd-gen/scaffolding/, the rootpackage.json, and docs/skill files.Screen reader (required — document steps below)
*.a11y.spec.tstemplate provides an ARIA-snapshot scaffold so each migrated component carries screen-reader coverage from the start.