create-done-coding 0.12.3-alpha.0 → 0.13.1-alpha.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/README.md +121 -2
- package/es/cli.mjs +4 -2
- package/es/index-42cea2ea.js +4887 -0
- package/es/index.mjs +20 -10
- package/package.json +10 -7
- package/types/index.d.ts +158 -10
- package/es/index-b3017a49.js +0 -4384
package/es/index.mjs
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { F as
|
|
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-42cea2ea.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
|
-
import "node:
|
|
4
|
+
import "node:os";
|
|
5
5
|
import "node:path";
|
|
6
|
+
import "node:crypto";
|
|
7
|
+
import "node:fs";
|
|
6
8
|
import "@done-coding/cli-template";
|
|
7
9
|
import "@done-coding/cli-git";
|
|
8
10
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
p as CreateTemplateSourceTypeEnum,
|
|
12
|
+
c as FormNameEnum,
|
|
13
|
+
l as GitRemoteRepoAliasNameEnum,
|
|
14
|
+
C as LOCAL_POINTER_CONFIG_RELATIVE_PATH,
|
|
11
15
|
d as SubcommandEnum,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
u as commandCliInfo,
|
|
17
|
+
T as completeCreateProject,
|
|
18
|
+
f as createAsSubcommand,
|
|
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
|
|
18
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-done-coding",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1-alpha.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.
|
|
42
|
+
"@done-coding/cli-inject": "0.6.4-alpha.0",
|
|
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.
|
|
49
|
-
"@done-coding/cli-template": "0.
|
|
50
|
-
"@done-coding/cli-utils": "0.
|
|
51
|
+
"@done-coding/cli-git": "0.7.4-alpha.0",
|
|
52
|
+
"@done-coding/cli-template": "0.10.1-alpha.0",
|
|
53
|
+
"@done-coding/cli-utils": "0.10.1-alpha.0"
|
|
51
54
|
},
|
|
52
55
|
"engines": {
|
|
53
56
|
"node": ">=18.0.0"
|
|
54
57
|
},
|
|
55
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "5a3ce40184afb4503b47b52e261eb2d3b4ee40ce"
|
|
56
59
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,30 +1,88 @@
|
|
|
1
1
|
import { CliHandlerArgv } from '@done-coding/cli-utils';
|
|
2
2
|
import { CliInfo } from '@done-coding/cli-utils';
|
|
3
3
|
import { CommandModule } from 'yargs';
|
|
4
|
+
import type { HandlerContextInit } from '@done-coding/cli-utils';
|
|
4
5
|
import type { SubCliInfo } from '@done-coding/cli-utils';
|
|
5
6
|
|
|
7
|
+
/** create 包根命令配置 */
|
|
6
8
|
export declare const commandCliInfo: Omit<CliInfo, "usage">;
|
|
7
9
|
|
|
10
|
+
/** 完成创建项目:使用 prepare 阶段草稿和模板参数完成编译、git 初始化与目录落位 */
|
|
11
|
+
export declare const completeCreateProject: (argv: CliHandlerArgv<CreateCompleteOptions>, ctxInit?: HandlerContextInit) => Promise<{
|
|
12
|
+
success: boolean;
|
|
13
|
+
projectPath: string;
|
|
14
|
+
draftId: string;
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
|
|
8
18
|
/** 作为子命令创建 */
|
|
9
19
|
export declare const createAsSubcommand: () => CommandModule<{}, {}>;
|
|
10
20
|
|
|
21
|
+
/** create 子命令配置 */
|
|
11
22
|
export declare const createCommandCliInfo: SubCliInfo;
|
|
12
23
|
|
|
24
|
+
/** create complete 入参 */
|
|
25
|
+
export declare interface CreateCompleteOptions extends CreateOptions {
|
|
26
|
+
/** prepare 阶段返回的草稿 ID */
|
|
27
|
+
draftId: string;
|
|
28
|
+
/** 模板预置问题答案 */
|
|
29
|
+
envData?: Record<string, any>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** create 包配置文件结构 */
|
|
13
33
|
export declare interface CreateConfigJson {
|
|
34
|
+
/** 可选模板列表 */
|
|
14
35
|
templateList: CreateTemplateChoiceItem[];
|
|
15
36
|
}
|
|
16
37
|
|
|
17
|
-
|
|
38
|
+
/** create 命令 handler:交互模式保持原 CLI 流程,非交互模式走 prepare/complete 协议 */
|
|
39
|
+
export declare const createHandler: (argv: CliHandlerArgv<CreateOptions>, ctxInit?: HandlerContextInit) => Promise<{
|
|
40
|
+
default?: string | undefined;
|
|
41
|
+
key: string;
|
|
42
|
+
required: boolean;
|
|
43
|
+
}[] | {
|
|
44
|
+
success: boolean;
|
|
45
|
+
projectPath: string;
|
|
46
|
+
draftId: string;
|
|
47
|
+
message: string;
|
|
48
|
+
} | undefined>;
|
|
18
49
|
|
|
50
|
+
/** 创建项目命令参数 */
|
|
19
51
|
export declare interface CreateOptions {
|
|
52
|
+
/** 创建项目的根目录 */
|
|
53
|
+
rootDir?: string;
|
|
20
54
|
/** 项目名称 */
|
|
21
55
|
[FormNameEnum.PROJECT_NAME]?: string;
|
|
22
56
|
/** 是否仅仅(从done-coding系列项目列表中)克隆远程仓库 */
|
|
23
57
|
justCloneFromDoneCoding?: boolean;
|
|
24
|
-
/**
|
|
58
|
+
/** 模板地址,远程 git 地址或本地绝对路径 */
|
|
59
|
+
[FormNameEnum.TEMPLATE_URL]?: string;
|
|
60
|
+
/** 模板仓库地址 @deprecated 使用 templateUrl */
|
|
25
61
|
[FormNameEnum.TEMPLATE_GIT_PATH]?: string;
|
|
26
62
|
/** 模板仓库分支 -- 不传则是默认分支 */
|
|
27
63
|
[FormNameEnum.TEMPLATE_GIT_BRANCH]?: string;
|
|
64
|
+
/** 仓库内模板目录 */
|
|
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;
|
|
28
86
|
/** 是否跳过模板编译(不跳过则会在克隆完成后进行模板编译)
|
|
29
87
|
* --
|
|
30
88
|
* 为MCP模式预留 设置为true则不会进行模板编译
|
|
@@ -54,6 +112,27 @@ export declare interface CreateOptions {
|
|
|
54
112
|
[FormNameEnum.GIT_COMMIT_MESSAGE]?: string;
|
|
55
113
|
}
|
|
56
114
|
|
|
115
|
+
/** create prepare 返回的模板预置问题 */
|
|
116
|
+
export declare interface CreatePrepareQuestion {
|
|
117
|
+
key: string;
|
|
118
|
+
label: string;
|
|
119
|
+
initial?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** create prepare 结果 */
|
|
123
|
+
export declare type CreatePrepareResult = {
|
|
124
|
+
status: "ready";
|
|
125
|
+
draftId: string;
|
|
126
|
+
projectPath: string;
|
|
127
|
+
draftProjectPath: string;
|
|
128
|
+
} | {
|
|
129
|
+
status: "need_input";
|
|
130
|
+
draftId: string;
|
|
131
|
+
projectPath: string;
|
|
132
|
+
draftProjectPath: string;
|
|
133
|
+
questions: CreatePrepareQuestion[];
|
|
134
|
+
};
|
|
135
|
+
|
|
57
136
|
/** 创建模板-分支信息 */
|
|
58
137
|
export declare interface CreateTemplateBranchInfo {
|
|
59
138
|
/** 分支名 */
|
|
@@ -66,8 +145,10 @@ export declare interface CreateTemplateBranchInfo {
|
|
|
66
145
|
export declare interface CreateTemplateChoiceItem {
|
|
67
146
|
/** 模板名 */
|
|
68
147
|
name: string;
|
|
69
|
-
/**
|
|
148
|
+
/** 模板 git 仓库地址,远程 git 地址或本地 git 仓库根路径 */
|
|
70
149
|
url?: string;
|
|
150
|
+
/** 仓库内模板目录 */
|
|
151
|
+
directory?: string;
|
|
71
152
|
/** 描述 */
|
|
72
153
|
description?: string;
|
|
73
154
|
/** 目标分支 */
|
|
@@ -76,6 +157,24 @@ export declare interface CreateTemplateChoiceItem {
|
|
|
76
157
|
instances?: string[];
|
|
77
158
|
}
|
|
78
159
|
|
|
160
|
+
/** create-mcp「模板列表资源」读取结果的载荷结构 */
|
|
161
|
+
export declare interface CreateTemplateListResource {
|
|
162
|
+
/** 固定为 "local":本资源只读本地、不联网、不读全局/远程 */
|
|
163
|
+
source: "local";
|
|
164
|
+
/** 解析所用的本地配置文件绝对路径 */
|
|
165
|
+
configPath: string;
|
|
166
|
+
/** 模板列表(缺失/非数组/解析失败 → 空数组) */
|
|
167
|
+
templateList: CreateTemplateChoiceItem[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** 创建模板来源类型 */
|
|
171
|
+
export declare enum CreateTemplateSourceTypeEnum {
|
|
172
|
+
/** git 仓库模板 */
|
|
173
|
+
GIT = "git",
|
|
174
|
+
/** 本地目录模板 */
|
|
175
|
+
LOCAL = "local"
|
|
176
|
+
}
|
|
177
|
+
|
|
79
178
|
/** 表单name枚举 */
|
|
80
179
|
export declare enum FormNameEnum {
|
|
81
180
|
/** 项目名称选择 */
|
|
@@ -98,16 +197,17 @@ export declare enum FormNameEnum {
|
|
|
98
197
|
CUSTOM_GIT_URL_INPUT = "customUrl",
|
|
99
198
|
/** git的提交信息 */
|
|
100
199
|
GIT_COMMIT_MESSAGE = "gitCommitMessage",
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* 为mcp拓展所加
|
|
105
|
-
*/
|
|
200
|
+
/** 模板地址 */
|
|
201
|
+
TEMPLATE_URL = "templateUrl",
|
|
202
|
+
/** 模板仓库地址 @deprecated 使用 TEMPLATE_URL */
|
|
106
203
|
TEMPLATE_GIT_PATH = "templateGitPath",
|
|
107
204
|
/** 模板仓库分支 */
|
|
108
205
|
TEMPLATE_GIT_BRANCH = "templateGitBranch"
|
|
109
206
|
}
|
|
110
207
|
|
|
208
|
+
/** 本机指针配置文件绝对路径 */
|
|
209
|
+
export declare const getLocalPointerConfigPath: () => string;
|
|
210
|
+
|
|
111
211
|
/** 远程仓库别名枚举 */
|
|
112
212
|
export declare enum GitRemoteRepoAliasNameEnum {
|
|
113
213
|
/** 默认 */
|
|
@@ -116,11 +216,21 @@ export declare enum GitRemoteRepoAliasNameEnum {
|
|
|
116
216
|
UPSTREAM = "upstream"
|
|
117
217
|
}
|
|
118
218
|
|
|
119
|
-
|
|
219
|
+
/** create 包根 handler */
|
|
220
|
+
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<{
|
|
221
|
+
default?: string | undefined;
|
|
222
|
+
key: string;
|
|
223
|
+
required: boolean;
|
|
224
|
+
}[] | {
|
|
225
|
+
success: boolean;
|
|
226
|
+
projectPath: string;
|
|
227
|
+
draftId: string;
|
|
228
|
+
message: string;
|
|
229
|
+
} | undefined>;
|
|
120
230
|
|
|
121
231
|
export declare const injectInfo: {
|
|
122
232
|
"name": "create-done-coding",
|
|
123
|
-
"version": "0.
|
|
233
|
+
"version": "0.13.1-alpha.0",
|
|
124
234
|
"description": "项目创建命令行工具",
|
|
125
235
|
"bin": {
|
|
126
236
|
"create-done-coding": "es/cli.mjs"
|
|
@@ -131,7 +241,45 @@ export declare const injectInfo: {
|
|
|
131
241
|
}
|
|
132
242
|
};
|
|
133
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
|
+
|
|
253
|
+
/** 准备创建项目:非交互模式下克隆模板、读取模板预置问题并返回草稿信息 */
|
|
254
|
+
export declare const prepareCreateProject: (argv: CliHandlerArgv<CreateOptions>, ctxInit?: HandlerContextInit) => Promise<CreatePrepareResult>;
|
|
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
|
+
|
|
280
|
+
/** create 包子命令枚举 */
|
|
134
281
|
export declare enum SubcommandEnum {
|
|
282
|
+
/** 创建项目命令 */
|
|
135
283
|
CREATE = "create"
|
|
136
284
|
}
|
|
137
285
|
|