@done-coding/cli-config 0.1.13-alpha.2 → 0.1.14-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/es/cli.mjs +2 -1
- package/es/{index-0b08e6e9.js → index-c3a8e382.js} +42 -40
- package/es/index.mjs +5 -4
- package/package.json +7 -11
package/es/cli.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readConfigFile as B,
|
|
3
|
-
import
|
|
2
|
+
import { readConfigFile as B, outputConsole as i, getPackageJson as Q, getRelyPkgVersion as X, getConfigFileCommonOptions as Y, readCliModuleAssetsConfig as Z, xPrompts as w, addPackageConfig as ee, addHuskyHooks as te, createSubcommand as J, getRootScriptName as ne, createMainCommand as oe } from "@done-coding/cli-utils";
|
|
3
|
+
import k, { existsSync as C } from "node:fs";
|
|
4
4
|
import g from "node:path";
|
|
5
|
+
import { execSync as N } from "node:child_process";
|
|
5
6
|
var y = /* @__PURE__ */ ((e) => (e.CHECK = "check", e.ADD = "add", e))(y || {}), m = /* @__PURE__ */ ((e) => (e.ESLINT = "eslint", e.PRETTIER = "prettier", e.COMMITLINT = "commitlint", e.LSLINT = "ls-lint", e.MERGELINT = "merge-lint", e))(m || {});
|
|
6
|
-
const
|
|
7
|
+
const L = {
|
|
7
8
|
name: "@done-coding/cli-config",
|
|
8
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.14-alpha.0",
|
|
9
10
|
description: "工程化配置命令行工具",
|
|
10
11
|
bin: {
|
|
11
12
|
"dc-config": "es/cli.mjs"
|
|
@@ -16,7 +17,7 @@ const h = {
|
|
|
16
17
|
}
|
|
17
18
|
}, {
|
|
18
19
|
cliConfig: { namespaceDir: se, moduleName: ie }
|
|
19
|
-
} =
|
|
20
|
+
} = L, re = `./${se}/${ie}`, ce = `${re}.json`, I = Object.values(m).filter(
|
|
20
21
|
(e) => e.toUpperCase() !== e
|
|
21
22
|
), ae = async (e) => await B(e, () => {
|
|
22
23
|
const { moduleList: t = [] } = e;
|
|
@@ -138,7 +139,7 @@ ${JSON.stringify(o, null, 2)}`), {
|
|
|
138
139
|
handler: E
|
|
139
140
|
}, {
|
|
140
141
|
cliConfig: { moduleName: fe }
|
|
141
|
-
} =
|
|
142
|
+
} = L, ge = () => ({
|
|
142
143
|
...H(),
|
|
143
144
|
commitGit: {
|
|
144
145
|
type: "boolean",
|
|
@@ -205,14 +206,11 @@ ${JSON.stringify(o, null, 2)}`), {
|
|
|
205
206
|
}, ye = ({ rootDir: e, list: t }) => {
|
|
206
207
|
i.stage(`开始安装依赖包: ${JSON.stringify(t, null, 2)}`);
|
|
207
208
|
const o = g.resolve(e, "pnpm-workspace.yaml"), s = C(o);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
);
|
|
215
|
-
}, he = async ({
|
|
209
|
+
N(`pnpm add -D ${s ? "-w" : ""} ${t.join(" ")}`, {
|
|
210
|
+
cwd: e,
|
|
211
|
+
stdio: "inherit"
|
|
212
|
+
});
|
|
213
|
+
}, Le = async ({
|
|
216
214
|
hooksConfig: e,
|
|
217
215
|
argv: t
|
|
218
216
|
}) => Object.entries(e).forEach(async ([o, s]) => {
|
|
@@ -221,7 +219,7 @@ ${JSON.stringify(o, null, 2)}`), {
|
|
|
221
219
|
rootDir: t.rootDir,
|
|
222
220
|
getCode: () => s
|
|
223
221
|
});
|
|
224
|
-
}),
|
|
222
|
+
}), he = async ({
|
|
225
223
|
moduleName: e,
|
|
226
224
|
moduleConfigList: t,
|
|
227
225
|
argv: o
|
|
@@ -264,7 +262,7 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
264
262
|
/** 方法内部已经使用husky了 但是所有依赖包在最后才统一安装 */
|
|
265
263
|
addHuskyConfigFn: () => {
|
|
266
264
|
var p;
|
|
267
|
-
return
|
|
265
|
+
return Le({
|
|
268
266
|
hooksConfig: ((p = s.husky) == null ? void 0 : p.hooks) || {},
|
|
269
267
|
argv: o
|
|
270
268
|
});
|
|
@@ -281,7 +279,7 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
281
279
|
throw new Error(
|
|
282
280
|
`${o} 预设列表文件 ${s} 不存在`
|
|
283
281
|
);
|
|
284
|
-
const r =
|
|
282
|
+
const r = k.readFileSync(s, "utf-8");
|
|
285
283
|
return JSON.parse(
|
|
286
284
|
r
|
|
287
285
|
);
|
|
@@ -317,36 +315,40 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
317
315
|
i.success("预设配置拉取成功");
|
|
318
316
|
const { project: S } = c, { rootDir: $ } = e, p = [], P = [], T = [];
|
|
319
317
|
for (let d of a) {
|
|
320
|
-
const
|
|
318
|
+
const v = g.resolve(
|
|
321
319
|
u,
|
|
322
320
|
j
|
|
323
|
-
),
|
|
321
|
+
), D = ke({
|
|
324
322
|
listConfig: S[d],
|
|
325
|
-
moduleDir:
|
|
323
|
+
moduleDir: v,
|
|
326
324
|
moduleName: d
|
|
327
325
|
});
|
|
328
|
-
if (!
|
|
326
|
+
if (!D) {
|
|
329
327
|
i.error(`未找到 ${d} 预设配置`);
|
|
330
328
|
return;
|
|
331
329
|
}
|
|
332
330
|
i.stage(`开始添加 ${d} 配置`);
|
|
333
|
-
const M = await
|
|
331
|
+
const M = await he({
|
|
334
332
|
moduleName: d,
|
|
335
|
-
moduleConfigList:
|
|
333
|
+
moduleConfigList: D,
|
|
336
334
|
argv: e
|
|
337
335
|
});
|
|
338
336
|
if (M) {
|
|
339
337
|
const {
|
|
340
338
|
sourceFile: U,
|
|
341
339
|
targetFile: K,
|
|
342
|
-
version:
|
|
343
|
-
pkgList:
|
|
340
|
+
version: V,
|
|
341
|
+
pkgList: W,
|
|
344
342
|
addHuskyConfigFn: q,
|
|
345
343
|
runScripts: z
|
|
346
|
-
} = M, A = g.resolve(
|
|
347
|
-
i.stage(
|
|
348
|
-
|
|
349
|
-
|
|
344
|
+
} = M, A = g.resolve(v, V, U), h = g.resolve($, K);
|
|
345
|
+
i.stage(
|
|
346
|
+
`开始复制 ${A} -> ${h}`
|
|
347
|
+
);
|
|
348
|
+
const R = g.dirname(h);
|
|
349
|
+
k.existsSync(R) || k.mkdirSync(R, { recursive: !0 }), k.copyFileSync(A, h), i.success(
|
|
350
|
+
`添加 ${d} 配置成功, 路径: ${h}`
|
|
351
|
+
), p.push(...W), P.push(q), T.push(...z);
|
|
350
352
|
}
|
|
351
353
|
}
|
|
352
354
|
await ye({
|
|
@@ -354,7 +356,7 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
354
356
|
list: [...new Set(p)]
|
|
355
357
|
});
|
|
356
358
|
for (let d of T)
|
|
357
|
-
i.stage(`运行脚本: ${d}`),
|
|
359
|
+
i.stage(`运行脚本: ${d}`), N(d, { cwd: $, stdio: "inherit" });
|
|
358
360
|
await Promise.all(P.map((d) => d()));
|
|
359
361
|
}
|
|
360
362
|
});
|
|
@@ -366,7 +368,7 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
366
368
|
message: "请输入提交信息",
|
|
367
369
|
initial: `chore: 添加 ${a.join(", ")} 工程化配置`
|
|
368
370
|
});
|
|
369
|
-
|
|
371
|
+
N("git add .", { cwd: f, stdio: "inherit" }), N(`git commit -m "${c}"`, {
|
|
370
372
|
cwd: f,
|
|
371
373
|
stdio: "inherit"
|
|
372
374
|
});
|
|
@@ -376,7 +378,7 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
376
378
|
describe: "添加工程化配置",
|
|
377
379
|
options: ge(),
|
|
378
380
|
handler: b
|
|
379
|
-
},
|
|
381
|
+
}, Se = async (e, t) => {
|
|
380
382
|
switch (e) {
|
|
381
383
|
case y.CHECK:
|
|
382
384
|
return E(t);
|
|
@@ -385,28 +387,28 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
385
387
|
default:
|
|
386
388
|
throw new Error(`不支持的命令 ${e}`);
|
|
387
389
|
}
|
|
388
|
-
}, { version: Ie, description: je } =
|
|
390
|
+
}, { version: Ie, description: je } = L, G = {
|
|
389
391
|
describe: je,
|
|
390
392
|
version: Ie,
|
|
391
393
|
subcommands: [ue, Ne].map(J),
|
|
392
394
|
demandCommandCount: 1,
|
|
393
|
-
rootScriptName: ne({ packageJson:
|
|
395
|
+
rootScriptName: ne({ packageJson: L })
|
|
394
396
|
}, {
|
|
395
397
|
cliConfig: { moduleName: O }
|
|
396
|
-
} =
|
|
398
|
+
} = L, x = (e = !1) => {
|
|
397
399
|
const t = e ? O : void 0, o = `$0${e ? ` ${O}` : ""} <command> [options]`;
|
|
398
400
|
return { command: t, usage: o };
|
|
399
|
-
},
|
|
401
|
+
}, Pe = async () => oe({
|
|
400
402
|
...G,
|
|
401
403
|
...x()
|
|
402
|
-
}),
|
|
404
|
+
}), Te = () => J({
|
|
403
405
|
...G,
|
|
404
406
|
...x(!0)
|
|
405
407
|
});
|
|
406
408
|
export {
|
|
407
409
|
m as C,
|
|
408
410
|
y as S,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
411
|
+
Te as a,
|
|
412
|
+
Pe as c,
|
|
413
|
+
Se as h
|
|
412
414
|
};
|
package/es/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as
|
|
2
|
+
import { C as i, S as s, a as t, h as u } from "./index-c3a8e382.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
4
|
import "node:fs";
|
|
5
5
|
import "node:path";
|
|
6
|
+
import "node:child_process";
|
|
6
7
|
export {
|
|
7
|
-
|
|
8
|
+
i as ConfigModuleEnum,
|
|
8
9
|
s as SubcommandEnum,
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
t as crateAsSubcommand,
|
|
11
|
+
u as handler
|
|
11
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-config",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14-alpha.0",
|
|
4
4
|
"description": "工程化配置命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -21,10 +21,7 @@
|
|
|
21
21
|
"types"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"
|
|
25
|
-
"predev": "pnpm run clean",
|
|
26
|
-
"dev": "vite build --watch",
|
|
27
|
-
"prebuild": "pnpm run clean",
|
|
24
|
+
"dev": "vite build -w -m hotBuild",
|
|
28
25
|
"build": "vite build",
|
|
29
26
|
"prepack": "pnpm build"
|
|
30
27
|
},
|
|
@@ -41,19 +38,18 @@
|
|
|
41
38
|
"license": "MIT",
|
|
42
39
|
"sideEffects": false,
|
|
43
40
|
"devDependencies": {
|
|
44
|
-
"@done-coding/cli-inject": "0.5.
|
|
41
|
+
"@done-coding/cli-inject": "0.5.22-alpha.0",
|
|
45
42
|
"@types/node": "^18.0.0",
|
|
46
43
|
"@types/yargs": "^17.0.28",
|
|
47
|
-
"rimraf": "^6.0.1",
|
|
48
44
|
"typescript": "^5.8.3",
|
|
49
45
|
"vite": "^4.4.11",
|
|
50
46
|
"vite-plugin-dts": "^3.6.0"
|
|
51
47
|
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@done-coding/cli-utils": "0.8.3-alpha.0"
|
|
50
|
+
},
|
|
52
51
|
"engines": {
|
|
53
52
|
"node": ">=18.0.0"
|
|
54
53
|
},
|
|
55
|
-
"
|
|
56
|
-
"@done-coding/cli-utils": "0.8.2-alpha.2"
|
|
57
|
-
},
|
|
58
|
-
"gitHead": "7683cce31678dfecc6b35014f9658ad8b59f0c97"
|
|
54
|
+
"gitHead": "906b7683d9e4dc75fb07806b12e5507827122a16"
|
|
59
55
|
}
|