Add strapi-plugin-factory CLI#8
Conversation
Add packages/cli/ with @clack/prompts UX and giget-based template fetch. Phase 1+2 of the CLI: skeleton, flag parsing, and live fetch from the boilerplate repo. Transform engine and prompt flow land in follow-ups.
Add the full scaffold pipeline: clack prompt flow with git defaults, JSON-aware package.json patching for plugin/playground/root, token replacement in known source files, removal of obsolete CLI + rename artifacts, optional git init and pnpm install. --yes mode enables non-interactive runs.
Render a two-column rectangle: SPF block art on the left, title + version + feature highlights on the right. Bordered with rounded corners in dim magenta, art rendered in bold magenta. Skipped when --help or --version short-circuit so scripted invocations stay quiet.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 089cc5f8da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ): void { | ||
| if (!existsSync(rootPkgPath)) return; | ||
| const pkg = readJson<PluginPkg>(rootPkgPath); | ||
| pkg.name = answers.pluginName; |
There was a problem hiding this comment.
Avoid duplicating the plugin package name
With the default prompt path (npmScope is empty), patchPluginPackageJson names plugins/<name>/package.json as the same unscoped answers.pluginName; this line also renames the workspace root to that exact value. The generated repo then contains two workspace projects with the same package name, so the default post-scaffold pnpm install path can fail before the user can run the new project. Keep the root package name distinct from the plugin package name, or include the npm scope when deriving it.
Useful? React with 👍 / 👎.
Summary
Adds
packages/cli/— an interactive scaffolder published asstrapi-plugin-factoryso users can runnpx strapi-plugin-factory my-plugininstead ofgit clone+ manual rename. Uses@clack/promptsfor the UX,gigetto fetch the template at scaffold time (no embedded copy, no drift), and patches the fetched tree to the user's answers.Changes
packages/cli/package with atsup-bundled CJS entry atdist/index.cjsgit config), GitHub org/repo, license, git init, pnpm installpackage.jsonpatching for the plugin, playground, root, anddev-utils; token replacement in known source files (pluginId.ts,controller.ts, tests, READMEs); plugin directory renamerename.ts+rename-plugin.shbin, and therename-pluginscript entry--yes,--dry-run,--no-cache,--force,--ref <ref>,--help,--versionTest plan
pnpm --filter cli buildproduces a 24 KB CJS bundlenode dist/index.cjs --yes --no-cache /tmp/test/my-pluginend-to-end: fetch → transform → git init →pnpm install(~48s, clean)package.jsonidentity fields patched,pluginId.ts+controller.tsupdated,packages/cli/and rename artifacts removednpxflow (follow-up PR)Notes
--refismainwhile unpublished. Before the first npm publish, this should be pinned to a stable tag so CLI versions map deterministically to template snapshots.packages/cli/from the fetched output so users never see the scaffolder inside their scaffolded project.