diff --git a/.github/workflows/publish-create-antdadmin.yml b/.github/workflows/publish-antd-admin-cli.yml similarity index 79% rename from .github/workflows/publish-create-antdadmin.yml rename to .github/workflows/publish-antd-admin-cli.yml index 0f621fc..4a60f73 100644 --- a/.github/workflows/publish-create-antdadmin.yml +++ b/.github/workflows/publish-antd-admin-cli.yml @@ -1,4 +1,4 @@ -# Publish npm package `create-antdadmin` from packages/create +# Publish npm package `antd-admin-cli` from packages/create # # Setup (one-time): # 1. npmjs.com → Access Tokens → Granular or Automation token with publish rights @@ -6,24 +6,24 @@ # Name: NPM_TOKEN Value: # # Release: -# A) Manual: Actions → "Publish create-antdadmin" → Run workflow -# B) Tag: git tag create-antdadmin-v1.0.3 && git push origin create-antdadmin-v1.0.3 +# A) Manual: Actions → "Publish antd-admin-cli" → Run workflow +# B) Tag: git tag antd-admin-cli-v1.0.3 && git push origin antd-admin-cli-v1.0.3 # (tag suffix must match packages/create/package.json "version") -name: Publish create-antdadmin +name: Publish antd-admin-cli on: workflow_dispatch: push: tags: - - "create-antdadmin-v*" + - "antd-admin-cli-v*" permissions: contents: read id-token: write concurrency: - group: publish-create-antdadmin + group: publish-antd-admin-cli cancel-in-progress: true jobs: @@ -53,11 +53,11 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Test create-antdadmin + - name: Test antd-admin-cli run: pnpm test working-directory: packages/create - - name: Build create-antdadmin + - name: Build antd-admin-cli run: pnpm run build working-directory: packages/create diff --git a/README.md b/README.md index ff45f2c..6217bb1 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Balanced admin monorepo: MSW mocks, minimal RBAC, full CRUD, and Playwright E2E ## Templates -`npm create antdadmin@latest` · `pnpm dlx create-antdadmin@latest` +`npx antd-admin-cli@latest` · `pnpm dlx antd-admin-cli@latest` | Directory | Use when | diff --git a/docs/specs/2026-04-14-create-antd-admin-design.md b/docs/specs/2026-04-14-create-antd-admin-design.md index 64eee32..c202c5c 100644 --- a/docs/specs/2026-04-14-create-antd-admin-design.md +++ b/docs/specs/2026-04-14-create-antd-admin-design.md @@ -1,4 +1,4 @@ -# create-antdadmin(packages/create)设计规格 +# antd-admin-cli(packages/create)设计规格 > 状态:已定稿待实现审阅 > 日期:2026-04-14 @@ -6,18 +6,18 @@ ## 1. 背景与动机 -在 monorepo 中新增 **`packages/create`**,以 npm 包 **`create-antdadmin`** 发布,提供与 [create-turbo](https://github.com/vercel/turborepo/tree/main/packages/create-turbo) 相近体验的命令行工具:从 **GitHub 上的 `apps/`** 拉取模板,在用户本机生成 **独立可运行** 的前端应用,并支持 **交互式选择模板**、**包管理器选择与安装**、**项目名称 transforms**。 +在 monorepo 中新增 **`packages/create`**,以 npm 包 **`antd-admin-cli`** 发布,提供与 [create-turbo](https://github.com/vercel/turborepo/tree/main/packages/create-turbo) 相近体验的命令行工具:从 **GitHub 上的 `apps/`** 拉取模板,在用户本机生成 **独立可运行** 的前端应用,并支持 **交互式选择模板**、**包管理器选择与安装**、**项目名称 transforms**。 ## 2. 目标与非目标 ### 2.1 目标(v1) -- 发布 **`create-antdadmin`**,`pnpm dlx create-antdadmin@latest` 可用;`bin` 指向构建产物 `dist/cli.js`;npm **`files`** 以 **`dist`**(及必要的内嵌清单)为主,对齐 create-turbo 的发布边界。 +- 发布 **`antd-admin-cli`**,`pnpm dlx antd-admin-cli@latest` 可用;`bin` 指向构建产物 `dist/cli.js`;npm **`files`** 以 **`dist`**(及必要的内嵌清单)为主,对齐 create-turbo 的发布边界。 - **产物**:在当前工作区生成 **独立应用** 目录(或 `.`),不依赖用户已克隆本 monorepo。 - **示例来源**:**运行时**从 **GitHub** 拉取 archive/tarball,解压后取 **`apps/`** 子树物化到目标目录(create-turbo 模式)。 - **示例清单**:**构建期**扫描本仓库 **`apps/*`**,生成 **`examples` 清单**写入 `dist`,**排除 `apps/docs`**;运行时短名示例必须落在该清单内。 - **CLI**: - - 支持 `pnpm dlx create-antdadmin@latest --example basic`(及清单中的其它示例名)。 + - 支持 `pnpm dlx antd-admin-cli@latest --example basic`(及清单中的其它示例名)。 - **未传 `--example`** 时走 **交互**(选示例、目标目录、项目名称等)。 - **`--example`** 支持 **短名** 或 **GitHub URL**;提供 **`--example-path`** 处理分支名含 `/` 等与 create-turbo 相同的边界。 - **包管理器**:支持 **npm / yarn / pnpm / bun**,探测本机可用性;默认执行 **install**;支持 **`--skip-install`**。 @@ -43,8 +43,8 @@ ### 4.1 命名与入口 -- 包名:**`create-antdadmin`**。 -- `bin`:**`create-antdadmin`** → `dist/cli.js`。 +- 包名:**`antd-admin-cli`**。 +- `bin`:**`antd-admin-cli`** → `dist/cli.js`。 ### 4.2 参数(v1) @@ -110,7 +110,7 @@ | 话题 | 结论 | |------|------| -| 包位置 | `packages/create`,发布名 `create-antdadmin`。 | +| 包位置 | `packages/create`,发布名 `antd-admin-cli`。 | | 示例列表 | 构建期扫描 `apps/*`,排除 `docs`(用户曾希望「扫描」;发布物上落实为构建期扫描,避免 dlx 用户机无 monorepo)。 | | 产物位置 | 独立应用目录或 `.`(非向本仓库新增 `apps/`)。 | | 模板分发 | create-turbo 式 **GitHub 拉取**,非主打本地打包模板。 | diff --git a/docs/specs/2026-04-14-create-antd-admin-plan.md b/docs/specs/2026-04-14-create-antd-admin-plan.md index 4d6859f..c9b51c8 100644 --- a/docs/specs/2026-04-14-create-antd-admin-plan.md +++ b/docs/specs/2026-04-14-create-antd-admin-plan.md @@ -1,8 +1,8 @@ -# create-antdadmin(packages/create)Implementation Plan +# antd-admin-cli(packages/create)Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. -**Goal:** Add workspace package `packages/create`, publishable as npm `create-antdadmin`, which downloads `apps/` from `zuiidea/antd-admin` on GitHub (tag aligned to CLI version), runs interactive or flag-driven prompts, applies `package.json` name transforms, installs with the user’s package manager, and initializes git by default. +**Goal:** Add workspace package `packages/create`, publishable as npm `antd-admin-cli`, which downloads `apps/` from `zuiidea/antd-admin` on GitHub (tag aligned to CLI version), runs interactive or flag-driven prompts, applies `package.json` name transforms, installs with the user’s package manager, and initializes git by default. **Architecture:** A small Node ESM CLI built with `tsup` into `dist/`; `commander` parses flags; `@inquirer/prompts` fills gaps; `giget` downloads `github:zuiidea/antd-admin/apps/#` where `` defaults to `v` with env overrides; a post-build script writes `dist/examples.json` by scanning `../../apps/*` and excluding `docs`; transforms are plain filesystem + JSON rewrites; install uses `child_process.spawn` with stdio inherited. @@ -41,7 +41,7 @@ | `packages/create/src/resolve-example-source.test.ts` | Tests for URL / path resolution | | `packages/create/src/integration/create-pipeline.test.ts` | Mocked download fixture → transforms (no network) | | `turbo.json` | Add `packages/create` to implicit discovery via workspace (no change if tasks already glob); ensure `build` `outputs` include `dist/**` for the new package (root `turbo.json` already has `dist/**`) | -| `README.md` | One subsection line under Templates: `pnpm dlx create-antdadmin@latest` | +| `README.md` | One subsection line under Templates: `pnpm dlx antd-admin-cli@latest` | --- @@ -55,13 +55,13 @@ ```json { - "name": "create-antdadmin", + "name": "antd-admin-cli", "version": "6.0.0", "description": "Create an Antd Admin app from official examples", "license": "MIT", "type": "module", "bin": { - "create-antdadmin": "./dist/cli.js" + "antd-admin-cli": "./dist/cli.js" }, "files": [ "dist" @@ -125,7 +125,7 @@ Expected: lockfile updates; workspace links `packages/create`. ```bash git add packages/create/package.json packages/create/tsconfig.json pnpm-lock.yaml -git commit -m "chore(create): scaffold create-antdadmin package" +git commit -m "chore(create): scaffold antd-admin-cli package" ``` --- @@ -160,7 +160,7 @@ export default defineConfig({ ```typescript #!/usr/bin/env node -console.log("create-antdadmin stub"); +console.log("antd-admin-cli stub"); ``` - [ ] **Step 3: Add `packages/create/scripts/write-examples-json.mjs`** @@ -602,7 +602,7 @@ import { CliError } from "./errors.js"; export async function downloadExampleToTemp( gigetSource: string ): Promise { - const dir = path.join(os.tmpdir(), `create-antdadmin-${randomUUID()}`); + const dir = path.join(os.tmpdir(), `antd-admin-cli-${randomUUID()}`); try { const { dir: outDir } = await downloadTemplate(gigetSource, { dir, @@ -797,7 +797,7 @@ export function tryGitInit(root: string, enabled: boolean): boolean { spawnSync("git", ["add", "-A"], { cwd: root, stdio: "ignore" }); spawnSync( "git", - ["commit", "-m", "chore: initial commit from create-antdadmin"], + ["commit", "-m", "chore: initial commit from antd-admin-cli"], { cwd: root, stdio: "ignore" } ); return true; @@ -935,7 +935,7 @@ import { CliError } from "./errors.js"; const program = new Command(); program - .name("create-antdadmin") + .name("antd-admin-cli") .description("Create an Antd Admin app from official examples") .argument("[project-directory]", "Directory for the new project") .option( @@ -1084,7 +1084,7 @@ git commit -m "test(create): integration test for transforms without network" Run: ```bash -cd /Users/zuiidea/web/antd-admin && pnpm turbo run build --filter=create-antdadmin +cd /Users/zuiidea/web/antd-admin && pnpm turbo run build --filter=antd-admin-cli ``` Expected: SUCCESS. @@ -1094,7 +1094,7 @@ Expected: SUCCESS. ```markdown **CLI:** Scaffold a standalone app from an official example: -`pnpm dlx create-antdadmin@latest` +`pnpm dlx antd-admin-cli@latest` ``` - [ ] **Step 3: Add `prepublishOnly` to `packages/create/package.json`** @@ -1107,14 +1107,14 @@ Expected: SUCCESS. ```bash git add README.md packages/create/package.json -git commit -m "docs: document create-antdadmin dlx usage; prepublish build" +git commit -m "docs: document antd-admin-cli dlx usage; prepublish build" ``` --- ## Release checklist (manual, not a code task) -- Publish `create-antdadmin@6.0.0` to npm after ensuring GitHub tag **`v6.0.0`** exists on `zuiidea/antd-admin` pointing to a commit that contains the referenced `apps/basic` and `apps/with-lingui` trees (or temporarily document use of `CREATE_ANTD_ADMIN_REF=main` until tags are automated). +- Publish `antd-admin-cli@6.0.0` to npm after ensuring GitHub tag **`v6.0.0`** exists on `zuiidea/antd-admin` pointing to a commit that contains the referenced `apps/basic` and `apps/with-lingui` trees (or temporarily document use of `CREATE_ANTD_ADMIN_REF=main` until tags are automated). --- diff --git a/packages/create/README.md b/packages/create/README.md index 7a93034..acbab77 100644 --- a/packages/create/README.md +++ b/packages/create/README.md @@ -1,4 +1,4 @@ -# create-antdadmin +# antd-admin-cli Scaffold a **standalone** [Antd Admin](https://github.com/zuiidea/antd-admin) style app from official monorepo examples (`apps/basic`, `apps/with-lingui`, …). Templates are fetched from GitHub at install time (similar idea to [create-turbo](https://github.com/vercel/turborepo/tree/main/packages/create-turbo)). @@ -7,25 +7,22 @@ Scaffold a **standalone** [Antd Admin](https://github.com/zuiidea/antd-admin) st ## Usage ```bash -npm create antdadmin@latest -``` - -Or with other package managers: - -```bash -pnpm dlx create-antdadmin@latest +npx antd-admin-cli@latest +pnpm dlx antd-admin-cli@latest +yarn dlx antd-admin-cli@latest +bunx antd-admin-cli@latest ``` Non-interactive example: ```bash -pnpm dlx create-antdadmin@latest my-app --example basic -m pnpm +pnpm dlx antd-admin-cli@latest my-app --example basic -m pnpm ``` Skip dependency install (faster smoke test): ```bash -pnpm dlx create-antdadmin@latest my-app --example basic --skip-install +pnpm dlx antd-admin-cli@latest my-app --example basic --skip-install ``` ### CLI options @@ -36,7 +33,7 @@ pnpm dlx create-antdadmin@latest my-app --example basic --skip-install | `[project-directory]` | Target folder (relative path or `.`; empty dirs only) | | `-e, --example ` | Example id from the built-in list, or a template URL | | `--example-path ` | Extra path inside the repo when using a URL | -| `-m, --package-manager` | `npm` | `yarn` | `pnpm` | `bun` | +| `-m, --package-manager` | `npm` \| `yarn` \| `pnpm` \| `bun` | | `--skip-install` | Do not run install after scaffold | | `--skip-transforms` | Skip rewrites (e.g. `package.json` name) | | `--no-git` | Do not run `git init` | @@ -44,7 +41,7 @@ pnpm dlx create-antdadmin@latest my-app --example basic --skip-install | `-h, --help` | Print help | -Run `create-antdadmin --help` for the full help text. +Run `antd-admin-cli --help` for the full help text. ## Environment @@ -75,16 +72,16 @@ Design and implementation notes live under `docs/specs/` in the monorepo (e.g. ` ## Publish (maintainers) -CI workflow: `.github/workflows/publish-create-antdadmin.yml` in the monorepo (open on GitHub from the default branch). +CI workflow: `.github/workflows/publish-antd-admin-cli.yml` in the monorepo (open on GitHub from the default branch). -1. Add repository secret **`NPM_TOKEN`** (npm automation or granular token with publish permission for `create-antdadmin`). +1. Add repository secret **`NPM_TOKEN`** (npm automation or granular token with publish permission for `antd-admin-cli`). 2. Bump **`version`** in this directory’s `package.json`, commit, then either: - - **Actions → “Publish create-antdadmin” → Run workflow**, or - - Push tag **`create-antdadmin-v`** (e.g. `create-antdadmin-v1.0.3` must match `package.json` version `1.0.3`). + - **Actions → “Publish antd-admin-cli” → Run workflow**, or + - Push tag **`antd-admin-cli-v`** (e.g. `antd-admin-cli-v1.0.3` must match `package.json` version `1.0.3`). 3. Push a matching **`v`** tag on the monorepo (e.g. `v1.0.3`) if users rely on the default template ref `v${version}` from the CLI. If **provenance** publish fails from your machine, publish from CI (this workflow passes `--provenance`) or see [npm provenance docs](https://docs.npmjs.com/generating-provenance-statements). ## License -MIT (same as the parent repository). \ No newline at end of file +MIT (same as the parent repository). diff --git a/packages/create/package.json b/packages/create/package.json index 2640315..0d4e7ab 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -1,11 +1,11 @@ { - "name": "create-antdadmin", + "name": "antd-admin-cli", "version": "1.0.3", "description": "Create an Antd Admin app from official examples", "license": "MIT", "type": "module", "bin": { - "create-antdadmin": "dist/cli.js" + "antd-admin-cli": "dist/cli.js" }, "files": [ "dist/cli.js", diff --git a/packages/create/src/cli.ts b/packages/create/src/cli.ts index 014f6f9..ebf4754 100644 --- a/packages/create/src/cli.ts +++ b/packages/create/src/cli.ts @@ -17,7 +17,7 @@ const pkg = JSON.parse( const program = new Command(); program - .name("create-antdadmin") + .name("antd-admin-cli") .description("Create an Antd Admin app from official examples") .version(pkg.version, "-v, --version") .argument("[project-directory]", "Directory for the new project") diff --git a/packages/create/src/download.ts b/packages/create/src/download.ts index 0bd33fa..01615fe 100644 --- a/packages/create/src/download.ts +++ b/packages/create/src/download.ts @@ -7,7 +7,7 @@ import { CliError } from "./errors.js"; export async function downloadExampleToTemp( gigetSource: string ): Promise { - const dir = path.join(os.tmpdir(), `create-antdadmin-${randomUUID()}`); + const dir = path.join(os.tmpdir(), `antd-admin-cli-${randomUUID()}`); try { const { dir: outDir } = await downloadTemplate(gigetSource, { dir, diff --git a/packages/create/src/git.ts b/packages/create/src/git.ts index 267edbd..b978547 100644 --- a/packages/create/src/git.ts +++ b/packages/create/src/git.ts @@ -15,7 +15,7 @@ export function tryGitInit(root: string, enabled: boolean): boolean { spawnSync("git", ["add", "-A"], { cwd: root, stdio: "ignore" }); spawnSync( "git", - ["commit", "-m", "chore: initial commit from create-antdadmin"], + ["commit", "-m", "chore: initial commit from antd-admin-cli"], { cwd: root, stdio: "ignore" } ); return true;