mirror of
https://github.com/zuiidea/antd-admin
synced 2026-09-24 01:55:12 +00:00
chore(create): rename npm package to init-antd-admin
Replace antd-admin-cli (name taken on npm). Bin init-antd-admin; release tags init-antd-admin-v*; workflow publish-init-antd-admin.yml. Made-with: Cursor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Publish npm package `antd-admin-cli` from packages/create
|
||||
# Publish npm package `init-antd-admin` 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: <token>
|
||||
#
|
||||
# Release:
|
||||
# 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
|
||||
# A) Manual: Actions → "Publish init-antd-admin" → Run workflow
|
||||
# B) Tag: git tag init-antd-admin-v1.0.3 && git push origin init-antd-admin-v1.0.3
|
||||
# (tag suffix must match packages/create/package.json "version")
|
||||
|
||||
name: Publish antd-admin-cli
|
||||
name: Publish init-antd-admin
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "antd-admin-cli-v*"
|
||||
- "init-antd-admin-v*"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: publish-antd-admin-cli
|
||||
group: publish-init-antd-admin
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
@@ -53,11 +53,11 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Test antd-admin-cli
|
||||
- name: Test init-antd-admin
|
||||
run: pnpm test
|
||||
working-directory: packages/create
|
||||
|
||||
- name: Build antd-admin-cli
|
||||
- name: Build init-antd-admin
|
||||
run: pnpm run build
|
||||
working-directory: packages/create
|
||||
|
||||
@@ -41,7 +41,7 @@ Balanced admin monorepo: MSW mocks, minimal RBAC, full CRUD, and Playwright E2E
|
||||
|
||||
## Templates
|
||||
|
||||
`npx antd-admin-cli@latest` · `pnpm dlx antd-admin-cli@latest`
|
||||
`npx init-antd-admin@latest` · `pnpm dlx init-antd-admin@latest`
|
||||
|
||||
|
||||
| Directory | Use when |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# antd-admin-cli(packages/create)设计规格
|
||||
# init-antd-admin(packages/create)设计规格
|
||||
|
||||
> 状态:已定稿待实现审阅
|
||||
> 日期:2026-04-14
|
||||
@@ -6,18 +6,18 @@
|
||||
|
||||
## 1. 背景与动机
|
||||
|
||||
在 monorepo 中新增 **`packages/create`**,以 npm 包 **`antd-admin-cli`** 发布,提供与 [create-turbo](https://github.com/vercel/turborepo/tree/main/packages/create-turbo) 相近体验的命令行工具:从 **GitHub 上的 `apps/<example>`** 拉取模板,在用户本机生成 **独立可运行** 的前端应用,并支持 **交互式选择模板**、**包管理器选择与安装**、**项目名称 transforms**。
|
||||
在 monorepo 中新增 **`packages/create`**,以 npm 包 **`init-antd-admin`** 发布,提供与 [create-turbo](https://github.com/vercel/turborepo/tree/main/packages/create-turbo) 相近体验的命令行工具:从 **GitHub 上的 `apps/<example>`** 拉取模板,在用户本机生成 **独立可运行** 的前端应用,并支持 **交互式选择模板**、**包管理器选择与安装**、**项目名称 transforms**。
|
||||
|
||||
## 2. 目标与非目标
|
||||
|
||||
### 2.1 目标(v1)
|
||||
|
||||
- 发布 **`antd-admin-cli`**,`pnpm dlx antd-admin-cli@latest` 可用;`bin` 指向构建产物 `dist/cli.js`;npm **`files`** 以 **`dist`**(及必要的内嵌清单)为主,对齐 create-turbo 的发布边界。
|
||||
- 发布 **`init-antd-admin`**,`pnpm dlx init-antd-admin@latest` 可用;`bin` 指向构建产物 `dist/cli.js`;npm **`files`** 以 **`dist`**(及必要的内嵌清单)为主,对齐 create-turbo 的发布边界。
|
||||
- **产物**:在当前工作区生成 **独立应用** 目录(或 `.`),不依赖用户已克隆本 monorepo。
|
||||
- **示例来源**:**运行时**从 **GitHub** 拉取 archive/tarball,解压后取 **`apps/<example>`** 子树物化到目标目录(create-turbo 模式)。
|
||||
- **示例清单**:**构建期**扫描本仓库 **`apps/*`**,生成 **`examples` 清单**写入 `dist`,**排除 `apps/docs`**;运行时短名示例必须落在该清单内。
|
||||
- **CLI**:
|
||||
- 支持 `pnpm dlx antd-admin-cli@latest --example basic`(及清单中的其它示例名)。
|
||||
- 支持 `pnpm dlx init-antd-admin@latest --example basic`(及清单中的其它示例名)。
|
||||
- **未传 `--example`** 时走 **交互**(选示例、目标目录、项目名称等)。
|
||||
- **`--example`** 支持 **短名** 或 **GitHub URL**;提供 **`--example-path`** 处理分支名含 `/` 等与 create-turbo 相同的边界。
|
||||
- **包管理器**:支持 **npm / yarn / pnpm / bun**,探测本机可用性;默认执行 **install**;支持 **`--skip-install`**。
|
||||
@@ -43,8 +43,8 @@
|
||||
|
||||
### 4.1 命名与入口
|
||||
|
||||
- 包名:**`antd-admin-cli`**。
|
||||
- `bin`:**`antd-admin-cli`** → `dist/cli.js`。
|
||||
- 包名:**`init-antd-admin`**。
|
||||
- `bin`:**`init-antd-admin`** → `dist/cli.js`。
|
||||
|
||||
### 4.2 参数(v1)
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
|
||||
| 话题 | 结论 |
|
||||
|------|------|
|
||||
| 包位置 | `packages/create`,发布名 `antd-admin-cli`。 |
|
||||
| 包位置 | `packages/create`,发布名 `init-antd-admin`。 |
|
||||
| 示例列表 | 构建期扫描 `apps/*`,排除 `docs`(用户曾希望「扫描」;发布物上落实为构建期扫描,避免 dlx 用户机无 monorepo)。 |
|
||||
| 产物位置 | 独立应用目录或 `.`(非向本仓库新增 `apps/<name>`)。 |
|
||||
| 模板分发 | create-turbo 式 **GitHub 拉取**,非主打本地打包模板。 |
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# antd-admin-cli(packages/create)Implementation Plan
|
||||
# init-antd-admin(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 `antd-admin-cli`, which downloads `apps/<example>` 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 `init-antd-admin`, which downloads `apps/<example>` 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/<example>#<ref>` where `<ref>` defaults to `v<cliVersion>` 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 antd-admin-cli@latest` |
|
||||
| `README.md` | One subsection line under Templates: `pnpm dlx init-antd-admin@latest` |
|
||||
|
||||
---
|
||||
|
||||
@@ -55,13 +55,13 @@
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "antd-admin-cli",
|
||||
"name": "init-antd-admin",
|
||||
"version": "6.0.0",
|
||||
"description": "Create an Antd Admin app from official examples",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"antd-admin-cli": "./dist/cli.js"
|
||||
"init-antd-admin": "./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 antd-admin-cli package"
|
||||
git commit -m "chore(create): scaffold init-antd-admin package"
|
||||
```
|
||||
|
||||
---
|
||||
@@ -160,7 +160,7 @@ export default defineConfig({
|
||||
|
||||
```typescript
|
||||
#!/usr/bin/env node
|
||||
console.log("antd-admin-cli stub");
|
||||
console.log("init-antd-admin 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<string> {
|
||||
const dir = path.join(os.tmpdir(), `antd-admin-cli-${randomUUID()}`);
|
||||
const dir = path.join(os.tmpdir(), `init-antd-admin-${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 antd-admin-cli"],
|
||||
["commit", "-m", "chore: initial commit from init-antd-admin"],
|
||||
{ cwd: root, stdio: "ignore" }
|
||||
);
|
||||
return true;
|
||||
@@ -935,7 +935,7 @@ import { CliError } from "./errors.js";
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name("antd-admin-cli")
|
||||
.name("init-antd-admin")
|
||||
.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=antd-admin-cli
|
||||
cd /Users/zuiidea/web/antd-admin && pnpm turbo run build --filter=init-antd-admin
|
||||
```
|
||||
|
||||
Expected: SUCCESS.
|
||||
@@ -1094,7 +1094,7 @@ Expected: SUCCESS.
|
||||
```markdown
|
||||
**CLI:** Scaffold a standalone app from an official example:
|
||||
|
||||
`pnpm dlx antd-admin-cli@latest`
|
||||
`pnpm dlx init-antd-admin@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 antd-admin-cli dlx usage; prepublish build"
|
||||
git commit -m "docs: document init-antd-admin dlx usage; prepublish build"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Release checklist (manual, not a code task)
|
||||
|
||||
- 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).
|
||||
- Publish `init-antd-admin@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).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# antd-admin-cli
|
||||
# init-antd-admin
|
||||
|
||||
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,22 +7,22 @@ Scaffold a **standalone** [Antd Admin](https://github.com/zuiidea/antd-admin) st
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
npx antd-admin-cli@latest
|
||||
pnpm dlx antd-admin-cli@latest
|
||||
yarn dlx antd-admin-cli@latest
|
||||
bunx antd-admin-cli@latest
|
||||
npx init-antd-admin@latest
|
||||
pnpm dlx init-antd-admin@latest
|
||||
yarn dlx init-antd-admin@latest
|
||||
bunx init-antd-admin@latest
|
||||
```
|
||||
|
||||
Non-interactive example:
|
||||
|
||||
```bash
|
||||
pnpm dlx antd-admin-cli@latest my-app --example basic -m pnpm
|
||||
pnpm dlx init-antd-admin@latest my-app --example basic -m pnpm
|
||||
```
|
||||
|
||||
Skip dependency install (faster smoke test):
|
||||
|
||||
```bash
|
||||
pnpm dlx antd-admin-cli@latest my-app --example basic --skip-install
|
||||
pnpm dlx init-antd-admin@latest my-app --example basic --skip-install
|
||||
```
|
||||
|
||||
### CLI options
|
||||
@@ -41,7 +41,7 @@ pnpm dlx antd-admin-cli@latest my-app --example basic --skip-install
|
||||
| `-h, --help` | Print help |
|
||||
|
||||
|
||||
Run `antd-admin-cli --help` for the full help text.
|
||||
Run `init-antd-admin --help` for the full help text.
|
||||
|
||||
## Environment
|
||||
|
||||
@@ -72,12 +72,12 @@ Design and implementation notes live under `docs/specs/` in the monorepo (e.g. `
|
||||
|
||||
## Publish (maintainers)
|
||||
|
||||
CI workflow: `.github/workflows/publish-antd-admin-cli.yml` in the monorepo (open on GitHub from the default branch).
|
||||
CI workflow: `.github/workflows/publish-init-antd-admin.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 `antd-admin-cli`).
|
||||
1. Add repository secret **`NPM_TOKEN`** (npm automation or granular token with publish permission for `init-antd-admin`).
|
||||
2. Bump **`version`** in this directory’s `package.json`, commit, then either:
|
||||
- **Actions → “Publish antd-admin-cli” → Run workflow**, or
|
||||
- Push tag **`antd-admin-cli-v<version>`** (e.g. `antd-admin-cli-v1.0.3` must match `package.json` version `1.0.3`).
|
||||
- **Actions → “Publish init-antd-admin” → Run workflow**, or
|
||||
- Push tag **`init-antd-admin-v<version>`** (e.g. `init-antd-admin-v1.0.3` must match `package.json` version `1.0.3`).
|
||||
3. Push a matching **`v<version>`** 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).
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "antd-admin-cli",
|
||||
"name": "init-antd-admin",
|
||||
"version": "1.0.3",
|
||||
"description": "Create an Antd Admin app from official examples",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"antd-admin-cli": "dist/cli.js"
|
||||
"init-antd-admin": "dist/cli.js"
|
||||
},
|
||||
"files": [
|
||||
"dist/cli.js",
|
||||
|
||||
@@ -17,7 +17,7 @@ const pkg = JSON.parse(
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name("antd-admin-cli")
|
||||
.name("init-antd-admin")
|
||||
.description("Create an Antd Admin app from official examples")
|
||||
.version(pkg.version, "-v, --version")
|
||||
.argument("[project-directory]", "Directory for the new project")
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CliError } from "./errors.js";
|
||||
export async function downloadExampleToTemp(
|
||||
gigetSource: string
|
||||
): Promise<string> {
|
||||
const dir = path.join(os.tmpdir(), `antd-admin-cli-${randomUUID()}`);
|
||||
const dir = path.join(os.tmpdir(), `init-antd-admin-${randomUUID()}`);
|
||||
try {
|
||||
const { dir: outDir } = await downloadTemplate(gigetSource, {
|
||||
dir,
|
||||
|
||||
@@ -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 antd-admin-cli"],
|
||||
["commit", "-m", "chore: initial commit from init-antd-admin"],
|
||||
{ cwd: root, stdio: "ignore" }
|
||||
);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user