@done-coding/cli-component 0.4.10-alpha.0 → 0.4.10-alpha.2

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-1dc6cc87.js";
2
+ import { c as m } from "./index-9c17f32d.js";
3
3
  import "node:path";
4
4
  import "node:fs";
5
5
  import "@done-coding/cli-utils";
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import p from "node:path";
3
- import l from "node:fs";
3
+ import u from "node:fs";
4
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";
@@ -8,7 +8,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 u = /* @__PURE__ */ ((e) => (e.ADD = "add", e.REMOVE = "remove", e.LIST = "list", e))(u || {});
11
+ var l = /* @__PURE__ */ ((e) => (e.ADD = "add", e.REMOVE = "remove", e.LIST = "list", e))(l || {});
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.10-alpha.0",
20
+ version: "0.4.10-alpha.2",
21
21
  description: "组件命令行工具",
22
22
  bin: {
23
23
  "dc-component": "es/cli.mjs"
@@ -30,13 +30,13 @@ const _ = (e, t) => {
30
30
  execDir: process.cwd(),
31
31
  templateDir: N()
32
32
  }), D = (e) => {
33
- const { series: t, name: n } = e, o = x(S(n)), i = T(o), a = v(o), s = t ? x(S(t)) : "", c = s ? `${s}${o}` : "", d = v(c);
33
+ const { series: t, name: n } = e, o = x(S(n)), c = T(o), a = v(o), s = t ? x(S(t)) : "", i = s ? `${s}${o}` : "", d = v(i);
34
34
  return {
35
35
  series: s,
36
36
  name: o,
37
- nameLowerFirst: i,
37
+ nameLowerFirst: c,
38
38
  nameKebab: a,
39
- fullName: c,
39
+ fullName: i,
40
40
  fullNameKebab: d,
41
41
  cls: d
42
42
  };
@@ -46,42 +46,42 @@ const _ = (e, t) => {
46
46
  ...D(e)
47
47
  }), $ = () => {
48
48
  const e = p.resolve(N(), "index.json");
49
- if (!l.existsSync(e))
49
+ if (!u.existsSync(e))
50
50
  return m.error(`模块入口文件不存在: ${e}`), process.exit(1);
51
- const n = JSON.parse(l.readFileSync(e, "utf-8")).config;
51
+ const n = JSON.parse(u.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 (!l.existsSync(o))
58
+ if (!u.existsSync(o))
59
59
  return m.error(`配置文件不存在: ${o}`), process.exit(1);
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, {
60
+ const c = F.parse(u.readFileSync(o, "utf-8")), a = I();
61
+ return c.componentDir = f(c.componentDir)(a), u.existsSync(c.componentDir) || u.mkdirSync(c.componentDir, {
62
62
  recursive: !0
63
- }), i;
63
+ }), c;
64
64
  }, R = async ({
65
65
  name: e,
66
66
  config: t,
67
67
  command: n
68
68
  }) => {
69
- if (![u.ADD, u.REMOVE].includes(n))
69
+ if (![l.ADD, l.REMOVE].includes(n))
70
70
  return m.error(`不支持组件${n}操作`), process.exit(1);
71
71
  const o = Z({
72
72
  ...t,
73
73
  name: e
74
- }), i = process.cwd(), a = JSON.stringify(o);
75
- for (const { entry: s, index: c } of t.list) {
74
+ }), c = process.cwd(), a = JSON.stringify(o);
75
+ for (const { entry: s, index: i } of t.list) {
76
76
  const d = {
77
77
  envData: a,
78
- rollback: n === u.REMOVE,
78
+ rollback: n === l.REMOVE,
79
79
  /** 回滚时可以删除空文件 */
80
80
  rollbackDelNullFile: !0,
81
81
  rollbackDelAskAsYes: !0,
82
82
  dealMarkdown: !0,
83
83
  batch: !1,
84
- rootDir: i
84
+ rootDir: c
85
85
  };
86
86
  if (s) {
87
87
  const r = s;
@@ -93,11 +93,11 @@ const _ = (e, t) => {
93
93
  };
94
94
  await C(b);
95
95
  }
96
- if (c) {
97
- const r = c;
96
+ if (i) {
97
+ const r = i;
98
98
  r != null && r.input && (r.input = f(r.input)(o)), r != null && r.output && (r.output = f(r.output)(o));
99
99
  const b = {
100
- ...c,
100
+ ...i,
101
101
  mode: E.OVERWRITE,
102
102
  ...d
103
103
  };
@@ -118,41 +118,41 @@ const _ = (e, t) => {
118
118
  }
119
119
  }), y = (e) => {
120
120
  const { componentDir: t, nameExcludes: n } = e;
121
- return l.statSync(t).isDirectory() ? l.readdirSync(t).map((s) => {
122
- const c = p.join(t, s);
123
- return l.statSync(c).isDirectory() ? (m.info("filePath:", c, p.basename(c)), p.basename(c)) : "";
121
+ return u.statSync(t).isDirectory() ? u.readdirSync(t).map((s) => {
122
+ const i = p.join(t, s);
123
+ return u.statSync(i).isDirectory() ? (m.info("filePath:", i, p.basename(i)), p.basename(i)) : "";
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 = $(), o = y(n), i = t || n.nameListJsonOutputPath, a = o.map((s) => {
131
- const { name: c, fullName: d } = D({
130
+ const n = $(), o = y(n), c = t || n.nameListJsonOutputPath, a = o.map((s) => {
131
+ const { name: i, fullName: d } = D({
132
132
  ...n,
133
133
  name: s
134
134
  });
135
135
  return {
136
- name: c,
136
+ name: i,
137
137
  nameKebab: s,
138
138
  fullName: d
139
139
  };
140
140
  });
141
- if (console.table(
142
- a.map(({ name: s, fullName: c, nameKebab: d }) => ({
141
+ if (m.table(
142
+ a.map(({ name: s, fullName: i, nameKebab: d }) => ({
143
143
  [h.success("名称")]: s,
144
- [h.success("带系列名称")]: c,
144
+ [h.success("带系列名称")]: i,
145
145
  [h.success("绝对路径")]: p.resolve(
146
146
  n.componentDir,
147
147
  d
148
148
  )
149
149
  }))
150
- ), e && i) {
151
- const s = p.resolve(i), c = p.dirname(s);
152
- l.existsSync(c) || l.mkdirSync(c, { recursive: !0 }), m.stage(`输出组件名列表到${s}`), l.writeFileSync(s, JSON.stringify(a, null, 2));
150
+ ), e && c) {
151
+ const s = p.resolve(c), i = p.dirname(s);
152
+ u.existsSync(i) || u.mkdirSync(i, { recursive: !0 }), m.stage(`输出组件名列表到${s}`), u.writeFileSync(s, JSON.stringify(a, null, 2));
153
153
  }
154
154
  }, U = {
155
- command: u.LIST,
155
+ command: l.LIST,
156
156
  describe: "展示组件列表",
157
157
  options: H(),
158
158
  handler: k
@@ -173,8 +173,8 @@ const _ = (e, t) => {
173
173
  })).name;
174
174
  const n = $();
175
175
  _(t, n);
176
- const { series: o } = n, i = await y(n);
177
- for (let a of i)
176
+ const { series: o } = n, c = await y(n);
177
+ for (let a of c)
178
178
  if (D({
179
179
  series: o,
180
180
  name: t
@@ -183,10 +183,10 @@ const _ = (e, t) => {
183
183
  return R({
184
184
  name: t,
185
185
  config: n,
186
- command: u.ADD
186
+ command: l.ADD
187
187
  });
188
188
  }, Y = {
189
- command: `${u.ADD} <name>`,
189
+ command: `${l.ADD} <name>`,
190
190
  describe: "新增一个组件",
191
191
  positionals: W(),
192
192
  handler: A
@@ -209,32 +209,32 @@ const _ = (e, t) => {
209
209
  message: "请选择要移除的组件",
210
210
  choices: n.map((a) => ({ title: a, value: a }))
211
211
  })).name;
212
- const { series: i } = t;
212
+ const { series: c } = t;
213
213
  for (let a of n)
214
214
  if (D({
215
- series: i,
215
+ series: c,
216
216
  name: o
217
217
  }).nameKebab === a) {
218
218
  await R({
219
219
  name: o,
220
220
  config: t,
221
- command: u.REMOVE
222
- }), l.rmdirSync(p.resolve(t.componentDir, a));
221
+ command: l.REMOVE
222
+ }), u.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: `${u.REMOVE} [name]`,
227
+ command: `${l.REMOVE} [name]`,
228
228
  describe: "删除一个组件",
229
229
  positionals: q(),
230
230
  handler: M
231
- }, ie = async (e, t) => {
231
+ }, ce = async (e, t) => {
232
232
  switch (e) {
233
- case u.ADD:
233
+ case l.ADD:
234
234
  return A(t);
235
- case u.REMOVE:
235
+ case l.REMOVE:
236
236
  return M(t);
237
- case u.LIST:
237
+ case l.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
- }), le = () => O({
260
+ }), ue = () => O({
261
261
  ...L,
262
262
  ...j(!0)
263
263
  });
264
264
  export {
265
- u as S,
266
- le as a,
265
+ l as S,
266
+ ue as a,
267
267
  me as c,
268
- ie as h
268
+ ce 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-1dc6cc87.js";
2
+ import { S as u, a as b, h as c } from "./index-9c17f32d.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.10-alpha.0",
3
+ "version": "0.4.10-alpha.2",
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.21-alpha.0",
44
+ "@done-coding/cli-inject": "0.5.21-alpha.2",
45
45
  "@types/lodash.camelcase": "^4.3.8",
46
46
  "@types/lodash.kebabcase": "^4.1.8",
47
47
  "@types/lodash.lowerfirst": "^4.3.8",
@@ -58,13 +58,13 @@
58
58
  "node": ">=18.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@done-coding/cli-template": "0.8.8-alpha.0",
62
- "@done-coding/cli-utils": "0.8.2-alpha.0",
61
+ "@done-coding/cli-template": "0.8.8-alpha.2",
62
+ "@done-coding/cli-utils": "0.8.2-alpha.2",
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": "b09dd794f69ba2dafe22a3519d712d059c2eb376"
69
+ "gitHead": "7683cce31678dfecc6b35014f9658ad8b59f0c97"
70
70
  }