@done-coding/cli-config 0.1.12 → 0.1.13-alpha.1

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