@done-coding/cli-component 0.4.9 → 0.4.10-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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-578b8ec1.js";
2
+ import { c as m } from "./index-1dc6cc87.js";
3
3
  import "node:path";
4
4
  import "node:fs";
5
5
  import "@done-coding/cli-utils";
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import p from "node:path";
3
- import u from "node:fs";
4
- import { log as m, json5 as F, getLogText as $, xPrompts as w, createSubcommand as O, getRootScriptName as V, createMainCommand as J } from "@done-coding/cli-utils";
3
+ import l from "node:fs";
4
+ import { log as m, json5 as F, getLogText as h, xPrompts as w, createSubcommand as O, getRootScriptName as V, createMainCommand as J } from "@done-coding/cli-utils";
5
5
  import x from "lodash.upperfirst";
6
6
  import S from "lodash.camelcase";
7
7
  import v from "lodash.kebabcase";
8
8
  import T from "lodash.lowerfirst";
9
9
  import f from "lodash.template";
10
10
  import { OutputModeEnum as E, compileHandler as C } from "@done-coding/cli-template";
11
- var l = /* @__PURE__ */ ((e) => (e.ADD = "add", e.REMOVE = "remove", e.LIST = "list", e))(l || {});
11
+ var u = /* @__PURE__ */ ((e) => (e.ADD = "add", e.REMOVE = "remove", e.LIST = "list", e))(u || {});
12
12
  const _ = (e, t) => {
13
13
  if (!/^[a-zA-Z]+[a-zA-Z0-9-]*$/.test(e))
14
14
  return m.error("组件名只能包含字母、数字、中划线"), process.exit(1);
@@ -17,7 +17,7 @@ const _ = (e, t) => {
17
17
  保留名称: ${n.join(",")}`), process.exit(1)) : !0;
18
18
  }, g = {
19
19
  name: "@done-coding/cli-component",
20
- version: "0.4.9",
20
+ version: "0.4.10-alpha.0",
21
21
  description: "组件命令行工具",
22
22
  bin: {
23
23
  "dc-component": "es/cli.mjs"
@@ -44,21 +44,21 @@ const _ = (e, t) => {
44
44
  $: "$",
45
45
  ...I(),
46
46
  ...D(e)
47
- }), h = () => {
47
+ }), $ = () => {
48
48
  const e = p.resolve(N(), "index.json");
49
- if (!u.existsSync(e))
49
+ if (!l.existsSync(e))
50
50
  return m.error(`模块入口文件不存在: ${e}`), process.exit(1);
51
- const n = JSON.parse(u.readFileSync(e, "utf-8")).config;
51
+ const n = JSON.parse(l.readFileSync(e, "utf-8")).config;
52
52
  if (!n)
53
53
  return m.error(`配置文件相对路径不存在: ${n}`), process.exit(1);
54
54
  const o = p.resolve(
55
55
  p.dirname(e),
56
56
  n
57
57
  );
58
- if (!u.existsSync(o))
58
+ if (!l.existsSync(o))
59
59
  return m.error(`配置文件不存在: ${o}`), process.exit(1);
60
- const i = F.parse(u.readFileSync(o, "utf-8")), a = I();
61
- return i.componentDir = f(i.componentDir)(a), u.existsSync(i.componentDir) || u.mkdirSync(i.componentDir, {
60
+ const i = F.parse(l.readFileSync(o, "utf-8")), a = I();
61
+ return i.componentDir = f(i.componentDir)(a), l.existsSync(i.componentDir) || l.mkdirSync(i.componentDir, {
62
62
  recursive: !0
63
63
  }), i;
64
64
  }, R = async ({
@@ -66,7 +66,7 @@ const _ = (e, t) => {
66
66
  config: t,
67
67
  command: n
68
68
  }) => {
69
- if (![l.ADD, l.REMOVE].includes(n))
69
+ if (![u.ADD, u.REMOVE].includes(n))
70
70
  return m.error(`不支持组件${n}操作`), process.exit(1);
71
71
  const o = Z({
72
72
  ...t,
@@ -75,7 +75,7 @@ const _ = (e, t) => {
75
75
  for (const { entry: s, index: c } of t.list) {
76
76
  const d = {
77
77
  envData: a,
78
- rollback: n === l.REMOVE,
78
+ rollback: n === u.REMOVE,
79
79
  /** 回滚时可以删除空文件 */
80
80
  rollbackDelNullFile: !0,
81
81
  rollbackDelAskAsYes: !0,
@@ -118,16 +118,16 @@ const _ = (e, t) => {
118
118
  }
119
119
  }), y = (e) => {
120
120
  const { componentDir: t, nameExcludes: n } = e;
121
- return u.statSync(t).isDirectory() ? u.readdirSync(t).map((s) => {
121
+ return l.statSync(t).isDirectory() ? l.readdirSync(t).map((s) => {
122
122
  const c = p.join(t, s);
123
- return u.statSync(c).isDirectory() ? (m.info("filePath:", c, p.basename(c)), p.basename(c)) : "";
123
+ return l.statSync(c).isDirectory() ? (m.info("filePath:", c, p.basename(c)), p.basename(c)) : "";
124
124
  }).filter((s) => !(!s || n.includes(s))) : (m.error("组件源码路径不是目录"), process.exit(1));
125
125
  }, k = async ({
126
126
  outputJson: e,
127
127
  outputPath: t
128
128
  }) => {
129
129
  m.stage("展示列表");
130
- const n = h(), o = y(n), i = t || n.nameListJsonOutputPath, a = o.map((s) => {
130
+ const n = $(), o = y(n), i = t || n.nameListJsonOutputPath, a = o.map((s) => {
131
131
  const { name: c, fullName: d } = D({
132
132
  ...n,
133
133
  name: s
@@ -140,19 +140,19 @@ const _ = (e, t) => {
140
140
  });
141
141
  if (console.table(
142
142
  a.map(({ name: s, fullName: c, nameKebab: d }) => ({
143
- [$.success("名称")]: s,
144
- [$.success("带系列名称")]: c,
145
- [$.success("绝对路径")]: p.resolve(
143
+ [h.success("名称")]: s,
144
+ [h.success("带系列名称")]: c,
145
+ [h.success("绝对路径")]: p.resolve(
146
146
  n.componentDir,
147
147
  d
148
148
  )
149
149
  }))
150
150
  ), e && i) {
151
151
  const s = p.resolve(i), c = p.dirname(s);
152
- u.existsSync(c) || u.mkdirSync(c, { recursive: !0 }), m.stage(`输出组件名列表到${s}`), u.writeFileSync(s, JSON.stringify(a, null, 2));
152
+ l.existsSync(c) || l.mkdirSync(c, { recursive: !0 }), m.stage(`输出组件名列表到${s}`), l.writeFileSync(s, JSON.stringify(a, null, 2));
153
153
  }
154
154
  }, U = {
155
- command: l.LIST,
155
+ command: u.LIST,
156
156
  describe: "展示组件列表",
157
157
  options: H(),
158
158
  handler: k
@@ -171,7 +171,7 @@ const _ = (e, t) => {
171
171
  name: "name",
172
172
  message: "请输入组件名"
173
173
  })).name;
174
- const n = h();
174
+ const n = $();
175
175
  _(t, n);
176
176
  const { series: o } = n, i = await y(n);
177
177
  for (let a of i)
@@ -183,10 +183,10 @@ const _ = (e, t) => {
183
183
  return R({
184
184
  name: t,
185
185
  config: n,
186
- command: l.ADD
186
+ command: u.ADD
187
187
  });
188
188
  }, Y = {
189
- command: `${l.ADD} <name>`,
189
+ command: `${u.ADD} <name>`,
190
190
  describe: "新增一个组件",
191
191
  positionals: W(),
192
192
  handler: A
@@ -199,7 +199,7 @@ const _ = (e, t) => {
199
199
  name: e
200
200
  }) => {
201
201
  m.stage("移除组件");
202
- const t = h(), n = await y(t);
202
+ const t = $(), n = await y(t);
203
203
  if (n.length === 0)
204
204
  return m.error("组件列表为空"), process.exit(1);
205
205
  let o;
@@ -218,23 +218,23 @@ const _ = (e, t) => {
218
218
  await R({
219
219
  name: o,
220
220
  config: t,
221
- command: l.REMOVE
222
- }), u.rmdirSync(p.resolve(t.componentDir, a));
221
+ command: u.REMOVE
222
+ }), l.rmdirSync(p.resolve(t.componentDir, a));
223
223
  return;
224
224
  }
225
225
  return m.error(`组件${o}不存在`), process.exit(1);
226
226
  }, B = {
227
- command: `${l.REMOVE} [name]`,
227
+ command: `${u.REMOVE} [name]`,
228
228
  describe: "删除一个组件",
229
229
  positionals: q(),
230
230
  handler: M
231
231
  }, ie = async (e, t) => {
232
232
  switch (e) {
233
- case l.ADD:
233
+ case u.ADD:
234
234
  return A(t);
235
- case l.REMOVE:
235
+ case u.REMOVE:
236
236
  return M(t);
237
- case l.LIST:
237
+ case u.LIST:
238
238
  return k(t);
239
239
  default:
240
240
  throw new Error(`不支持的命令 ${e}`);
@@ -257,13 +257,13 @@ const _ = (e, t) => {
257
257
  }, me = async () => J({
258
258
  ...L,
259
259
  ...j()
260
- }), ue = () => O({
260
+ }), le = () => O({
261
261
  ...L,
262
262
  ...j(!0)
263
263
  });
264
264
  export {
265
- l as S,
266
- ue as a,
265
+ u as S,
266
+ le as a,
267
267
  me as c,
268
268
  ie as h
269
269
  };
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { S as u, a as b, h as c } from "./index-578b8ec1.js";
2
+ import { S as u, a as b, h as c } from "./index-1dc6cc87.js";
3
3
  import "node:path";
4
4
  import "node:fs";
5
5
  import "@done-coding/cli-utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-component",
3
- "version": "0.4.9",
3
+ "version": "0.4.10-alpha.0",
4
4
  "description": "组件命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -41,7 +41,7 @@
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.0",
45
45
  "@types/lodash.camelcase": "^4.3.8",
46
46
  "@types/lodash.kebabcase": "^4.1.8",
47
47
  "@types/lodash.lowerfirst": "^4.3.8",
@@ -50,7 +50,7 @@
50
50
  "@types/node": "^18.0.0",
51
51
  "@types/yargs": "^17.0.28",
52
52
  "rimraf": "^6.0.1",
53
- "typescript": "^5.2.2",
53
+ "typescript": "^5.8.3",
54
54
  "vite": "^4.4.11",
55
55
  "vite-plugin-dts": "^3.6.0"
56
56
  },
@@ -58,13 +58,13 @@
58
58
  "node": ">=18.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@done-coding/cli-template": "0.8.7",
62
- "@done-coding/cli-utils": "0.8.1",
61
+ "@done-coding/cli-template": "0.8.8-alpha.0",
62
+ "@done-coding/cli-utils": "0.8.2-alpha.0",
63
63
  "lodash.camelcase": "^4.3.0",
64
64
  "lodash.kebabcase": "^4.1.1",
65
65
  "lodash.lowerfirst": "^4.3.1",
66
66
  "lodash.template": "^4.5.0",
67
67
  "lodash.upperfirst": "^4.3.1"
68
68
  },
69
- "gitHead": "0930f800167c04a86b56eae9741872dd51bec0c6"
69
+ "gitHead": "b09dd794f69ba2dafe22a3519d712d059c2eb376"
70
70
  }