create-done-coding 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.mjs CHANGED
@@ -1,23 +1,28 @@
1
1
  #!/usr/bin/env node
2
- import { C as i, F as c, G as d, S as u, f as l, d as C, a as f, b, h as E, e as S, i as j, p as I } from "./index-49fe32cc.js";
2
+ import { C as p, F as c, G as l, L as C, S as d, k as u, f as T, a as f, e as E, h as L, g as P, j as I, i as A, p as F, b as R, d as b, r as g } from "./index-8c566507.js";
3
3
  import "@done-coding/cli-utils";
4
- import "node:crypto";
5
- import "node:fs";
6
4
  import "node:os";
7
5
  import "node:path";
6
+ import "node:crypto";
7
+ import "node:fs";
8
8
  import "@done-coding/cli-template";
9
9
  import "@done-coding/cli-git";
10
10
  export {
11
- i as CreateTemplateSourceTypeEnum,
11
+ p as CreateTemplateSourceTypeEnum,
12
12
  c as FormNameEnum,
13
- d as GitRemoteRepoAliasNameEnum,
14
- u as SubcommandEnum,
15
- l as commandCliInfo,
16
- C as completeCreateProject,
13
+ l as GitRemoteRepoAliasNameEnum,
14
+ C as LOCAL_POINTER_CONFIG_RELATIVE_PATH,
15
+ d as SubcommandEnum,
16
+ u as commandCliInfo,
17
+ T as completeCreateProject,
17
18
  f as createAsSubcommand,
18
- b as createCommandCliInfo,
19
- E as createHandler,
20
- S as handler,
21
- j as injectInfo,
22
- I as prepareCreateProject
19
+ E as createCommandCliInfo,
20
+ L as createHandler,
21
+ P as getLocalPointerConfigPath,
22
+ I as handler,
23
+ A as injectInfo,
24
+ F as prepareCreateProject,
25
+ R as readTemplateListFromFile,
26
+ b as readTemplateListResource,
27
+ g as resolveTemplateConfigPath
23
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-done-coding",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "项目创建命令行工具",
5
5
  "module": "es/index.mjs",
6
6
  "type": "module",
@@ -22,6 +22,8 @@
22
22
  "scripts": {
23
23
  "dev": "vite build -w -m hotBuild",
24
24
  "build": "vite build",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
25
27
  "prepack": "pnpm build"
26
28
  },
27
29
  "repository": {
@@ -37,20 +39,21 @@
37
39
  "license": "MIT",
38
40
  "sideEffects": false,
39
41
  "devDependencies": {
40
- "@done-coding/cli-inject": "0.6.3",
42
+ "@done-coding/cli-inject": "0.6.4",
41
43
  "@types/node": "^18.0.0",
42
44
  "@types/yargs": "^17.0.28",
43
45
  "typescript": "^5.8.3",
44
46
  "vite": "^4.4.11",
45
- "vite-plugin-dts": "^3.6.0"
47
+ "vite-plugin-dts": "^3.6.0",
48
+ "vitest": "^1.6.1"
46
49
  },
47
50
  "dependencies": {
48
- "@done-coding/cli-git": "0.7.3",
49
- "@done-coding/cli-template": "0.10.0",
50
- "@done-coding/cli-utils": "0.10.0"
51
+ "@done-coding/cli-git": "0.7.4",
52
+ "@done-coding/cli-template": "0.11.0",
53
+ "@done-coding/cli-utils": "0.11.0"
51
54
  },
52
55
  "engines": {
53
56
  "node": ">=18.0.0"
54
57
  },
55
- "gitHead": "ce637a19aaa611dec1ec33a1bb4164d622d05198"
58
+ "gitHead": "d5d89297f6cf953893f2d9ceb591c96ce0114656"
56
59
  }
package/types/index.d.ts CHANGED
@@ -37,12 +37,10 @@ export declare interface CreateConfigJson {
37
37
 
38
38
  /** create 命令 handler:交互模式保持原 CLI 流程,非交互模式走 prepare/complete 协议 */
39
39
  export declare const createHandler: (argv: CliHandlerArgv<CreateOptions>, ctxInit?: HandlerContextInit) => Promise<{
40
- status: "need_input";
41
- draftId: string;
42
- projectPath: string;
43
- draftProjectPath: string;
44
- questions: CreatePrepareQuestion[];
45
- } | {
40
+ default?: string | undefined;
41
+ key: string;
42
+ required: boolean;
43
+ }[] | {
46
44
  success: boolean;
47
45
  projectPath: string;
48
46
  draftId: string;
@@ -65,6 +63,26 @@ export declare interface CreateOptions {
65
63
  [FormNameEnum.TEMPLATE_GIT_BRANCH]?: string;
66
64
  /** 仓库内模板目录 */
67
65
  templateDirectory?: string;
66
+ /**
67
+ * 模板列表配置文件路径(本地)
68
+ * ---
69
+ * 指向一个 `{ templateList: [...] }` 配置文件。优先级:本选项 > home 指针文件
70
+ * (`~/.done-coding/create/index.json`) > 内置远端配置。
71
+ * MCP 列表工具下为必填;CLI 选填(不传则回落 home 指针 / 内置远端)。
72
+ */
73
+ templateConfig?: string;
74
+ /**
75
+ * 模板预设答案(JSON 字符串),非交互供答。
76
+ * ---
77
+ * 如 `--env '{"organization":"acme","name":"app"}'`。key 对齐模板
78
+ * `.done-coding/template.json` 的 `collectEnvDataForm[].key`(不是 label)。
79
+ * 与 `envFile` 同时给出时,本字段浅覆盖 `envFile`。
80
+ */
81
+ env?: string;
82
+ /** 模板预设答案 JSON 文件路径(非交互供答),内容为 `{ key: value }` 对象 */
83
+ envFile?: string;
84
+ /** 仅打印该模板预设问题清单(JSON)到 stdout,不创建项目、不留草稿 */
85
+ listQuestions?: boolean;
68
86
  /** 是否跳过模板编译(不跳过则会在克隆完成后进行模板编译)
69
87
  * --
70
88
  * 为MCP模式预留 设置为true则不会进行模板编译
@@ -139,6 +157,16 @@ export declare interface CreateTemplateChoiceItem {
139
157
  instances?: string[];
140
158
  }
141
159
 
160
+ /** create-mcp「模板列表资源」读取结果的载荷结构 */
161
+ export declare interface CreateTemplateListResource {
162
+ /** 固定为 "local":本资源只读本地、不联网、不读全局/远程 */
163
+ source: "local";
164
+ /** 解析所用的本地配置文件绝对路径 */
165
+ configPath: string;
166
+ /** 模板列表(缺失/非数组/解析失败 → 空数组) */
167
+ templateList: CreateTemplateChoiceItem[];
168
+ }
169
+
142
170
  /** 创建模板来源类型 */
143
171
  export declare enum CreateTemplateSourceTypeEnum {
144
172
  /** git 仓库模板 */
@@ -177,6 +205,9 @@ export declare enum FormNameEnum {
177
205
  TEMPLATE_GIT_BRANCH = "templateGitBranch"
178
206
  }
179
207
 
208
+ /** 本机指针配置文件绝对路径 */
209
+ export declare const getLocalPointerConfigPath: () => string;
210
+
180
211
  /** 远程仓库别名枚举 */
181
212
  export declare enum GitRemoteRepoAliasNameEnum {
182
213
  /** 默认 */
@@ -187,12 +218,10 @@ export declare enum GitRemoteRepoAliasNameEnum {
187
218
 
188
219
  /** create 包根 handler */
189
220
  export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<{
190
- status: "need_input";
191
- draftId: string;
192
- projectPath: string;
193
- draftProjectPath: string;
194
- questions: CreatePrepareQuestion[];
195
- } | {
221
+ default?: string | undefined;
222
+ key: string;
223
+ required: boolean;
224
+ }[] | {
196
225
  success: boolean;
197
226
  projectPath: string;
198
227
  draftId: string;
@@ -201,7 +230,7 @@ export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any
201
230
 
202
231
  export declare const injectInfo: {
203
232
  "name": "create-done-coding",
204
- "version": "0.13.0",
233
+ "version": "0.14.0",
205
234
  "description": "项目创建命令行工具",
206
235
  "bin": {
207
236
  "create-done-coding": "es/cli.mjs"
@@ -212,9 +241,42 @@ export declare const injectInfo: {
212
241
  }
213
242
  };
214
243
 
244
+ /**
245
+ * 本机【指针】配置文件相对 home 的路径。
246
+ * ---
247
+ * 该文件内容是一个【指针】:`{ "configPath": "/abs/真正的配置文件.json" }`,
248
+ * 指向真正的模板配置文件(`{ templateList: [...] }` = CreateConfigJson)。
249
+ * 不做多文件合并——用户若需合并,自行维护一份合并好的配置文件并在此指向它。
250
+ */
251
+ export declare const LOCAL_POINTER_CONFIG_RELATIVE_PATH = ".done-coding/create/index.json";
252
+
215
253
  /** 准备创建项目:非交互模式下克隆模板、读取模板预置问题并返回草稿信息 */
216
254
  export declare const prepareCreateProject: (argv: CliHandlerArgv<CreateOptions>, ctxInit?: HandlerContextInit) => Promise<CreatePrepareResult>;
217
255
 
256
+ /**
257
+ * 从指定【本地】配置文件读取模板列表。
258
+ * ---
259
+ * 不依赖网络。文件不存在 / 非数组 / 解析失败 → 返回 `[]` 并告警,绝不抛错阻塞。
260
+ */
261
+ export declare const readTemplateListFromFile: (configPath: string) => Promise<CreateTemplateChoiceItem[]>;
262
+
263
+ /**
264
+ * create-mcp「模板列表资源」的纯读取逻辑。
265
+ * ---
266
+ * 只调 `readTemplateListFromFile`(本地、不联网、不读家目录全局指针、不读远程默认)。
267
+ * `configPath` 缺失/为空 → 抛错(不静默联网、不回落)。供 MCP 资源回调与单测复用。
268
+ */
269
+ export declare const readTemplateListResource: (configPath: string) => Promise<CreateTemplateListResource>;
270
+
271
+ /**
272
+ * 解析"模板配置文件路径"。
273
+ * ---
274
+ * 优先级:显式传入(CLI `--template-config` / MCP `configPath`) > home 指针文件。
275
+ * 都没有 → 返回 undefined(由调用方回落到内置远端配置)。
276
+ * 不依赖网络;读取失败一律忽略,不抛错阻塞。
277
+ */
278
+ export declare const resolveTemplateConfigPath: (explicitConfigPath?: string) => Promise<string | undefined>;
279
+
218
280
  /** create 包子命令枚举 */
219
281
  export declare enum SubcommandEnum {
220
282
  /** 创建项目命令 */