@done-coding/cli-component 0.2.2 → 0.2.3-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 +1 -1
- package/es/{index-ec860b99.js → index-67f85fe7.js} +27 -27
- package/es/index.mjs +1 -1
- package/package.json +4 -4
- package/types/injectInfo.json.d.ts +1 -1
package/es/cli.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import r from "chalk";
|
|
3
3
|
import m from "node:path";
|
|
4
|
-
import
|
|
4
|
+
import p from "node:fs";
|
|
5
5
|
import I from "json5";
|
|
6
|
-
import
|
|
6
|
+
import y from "lodash.upperfirst";
|
|
7
7
|
import x from "lodash.camelcase";
|
|
8
8
|
import E from "lodash.kebabcase";
|
|
9
9
|
import L from "lodash.lowerfirst";
|
|
@@ -23,7 +23,7 @@ const _ = (e, t) => {
|
|
|
23
23
|
保留名称: ${o.join(",")}`)
|
|
24
24
|
), process.exit(1)) : !0;
|
|
25
25
|
}, f = {
|
|
26
|
-
version: "0.2.
|
|
26
|
+
version: "0.2.3-alpha.0",
|
|
27
27
|
name: "@done-coding/cli-component",
|
|
28
28
|
description: "组件命令行工具",
|
|
29
29
|
cliConfig: {
|
|
@@ -34,44 +34,44 @@ const _ = (e, t) => {
|
|
|
34
34
|
execDir: process.cwd(),
|
|
35
35
|
templateDir: M()
|
|
36
36
|
}), g = (e) => {
|
|
37
|
-
const { series: t, name: o } = e, s =
|
|
37
|
+
const { series: t, name: o } = e, s = y(x(o)), c = L(s), a = E(s), l = t ? y(x(t)) : "", n = l ? `${l}${s}` : "", u = E(n);
|
|
38
38
|
return {
|
|
39
39
|
series: l,
|
|
40
40
|
name: s,
|
|
41
41
|
nameLowerFirst: c,
|
|
42
42
|
nameKebab: a,
|
|
43
43
|
fullName: n,
|
|
44
|
-
fullNameKebab:
|
|
45
|
-
cls:
|
|
44
|
+
fullNameKebab: u,
|
|
45
|
+
cls: u
|
|
46
46
|
};
|
|
47
47
|
}, K = (e) => ({
|
|
48
48
|
$: "$",
|
|
49
49
|
...N(),
|
|
50
50
|
...g(e)
|
|
51
|
-
}),
|
|
51
|
+
}), h = () => {
|
|
52
52
|
const e = m.resolve(M(), "index.json");
|
|
53
|
-
if (!
|
|
53
|
+
if (!p.existsSync(e))
|
|
54
54
|
return console.log(r.red(`模块入口文件不存在: ${e}`)), process.exit(1);
|
|
55
|
-
const o = JSON.parse(
|
|
55
|
+
const o = JSON.parse(p.readFileSync(e, "utf-8")).config;
|
|
56
56
|
if (!o)
|
|
57
57
|
return console.log(r.red(`配置文件相对路径不存在: ${o}`)), process.exit(1);
|
|
58
58
|
const s = m.resolve(
|
|
59
59
|
m.dirname(e),
|
|
60
60
|
o
|
|
61
61
|
);
|
|
62
|
-
if (!
|
|
62
|
+
if (!p.existsSync(s))
|
|
63
63
|
return console.log(r.red(`配置文件不存在: ${s}`)), process.exit(1);
|
|
64
|
-
const c = I.parse(
|
|
64
|
+
const c = I.parse(p.readFileSync(s, "utf-8")), a = N();
|
|
65
65
|
return c.componentDir = d(c.componentDir)(a), c;
|
|
66
|
-
},
|
|
66
|
+
}, v = (e) => {
|
|
67
67
|
const { componentDir: t, nameExcludes: o } = e;
|
|
68
|
-
return
|
|
68
|
+
return p.statSync(t).isDirectory() ? p.readdirSync(t).map((l) => {
|
|
69
69
|
const n = m.join(t, l);
|
|
70
|
-
return
|
|
70
|
+
return p.statSync(n).isDirectory() ? (console.log("filePath:", n, m.basename(n)), m.basename(n)) : "";
|
|
71
71
|
}).filter((l) => !(!l || o.includes(l))) : (console.log(r.red("组件源码路径不是目录")), process.exit(1));
|
|
72
72
|
}, U = async () => {
|
|
73
73
|
console.log(r.blue("展示列表"));
|
|
74
|
-
const e =
|
|
74
|
+
const e = h(), t = v(e);
|
|
75
75
|
console.table(
|
|
76
76
|
t.map((o) => {
|
|
77
77
|
const { name: s, fullName: c } = g({
|
|
@@ -100,26 +100,26 @@ const _ = (e, t) => {
|
|
|
100
100
|
if (a) {
|
|
101
101
|
const n = a;
|
|
102
102
|
n != null && n.input && (n.input = d(n.input)(s)), n != null && n.output && (n.output = d(n.output)(s));
|
|
103
|
-
const
|
|
103
|
+
const u = {
|
|
104
104
|
...a,
|
|
105
105
|
envData: c,
|
|
106
106
|
mode: $.APPEND,
|
|
107
107
|
rollback: o === i.REMOVE,
|
|
108
108
|
dealMarkdown: !0
|
|
109
109
|
};
|
|
110
|
-
await C(
|
|
110
|
+
await C(u);
|
|
111
111
|
}
|
|
112
112
|
if (l) {
|
|
113
113
|
const n = l;
|
|
114
114
|
n != null && n.input && (n.input = d(n.input)(s)), n != null && n.output && (n.output = d(n.output)(s));
|
|
115
|
-
const
|
|
115
|
+
const u = {
|
|
116
116
|
...l,
|
|
117
117
|
envData: c,
|
|
118
118
|
mode: $.OVERWRITE,
|
|
119
119
|
rollback: o === i.REMOVE,
|
|
120
120
|
dealMarkdown: !0
|
|
121
121
|
};
|
|
122
|
-
await C(
|
|
122
|
+
await C(u);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}, z = async ({ name: e }) => {
|
|
@@ -131,9 +131,9 @@ const _ = (e, t) => {
|
|
|
131
131
|
message: "请输入组件名",
|
|
132
132
|
onState: O
|
|
133
133
|
})).name;
|
|
134
|
-
const o =
|
|
134
|
+
const o = h();
|
|
135
135
|
_(t, o);
|
|
136
|
-
const { series: s } = o, c = await
|
|
136
|
+
const { series: s } = o, c = await v(o);
|
|
137
137
|
for (let a of c)
|
|
138
138
|
if (g({
|
|
139
139
|
series: s,
|
|
@@ -147,7 +147,7 @@ const _ = (e, t) => {
|
|
|
147
147
|
});
|
|
148
148
|
}, H = async ({ name: e }) => {
|
|
149
149
|
console.log(r.blue("移除组件"));
|
|
150
|
-
const t =
|
|
150
|
+
const t = h(), o = await v(t);
|
|
151
151
|
if (o.length === 0)
|
|
152
152
|
return console.log(r.red("组件列表为空")), process.exit(1);
|
|
153
153
|
let s;
|
|
@@ -168,7 +168,7 @@ const _ = (e, t) => {
|
|
|
168
168
|
name: s,
|
|
169
169
|
config: t,
|
|
170
170
|
command: i.REMOVE
|
|
171
|
-
}),
|
|
171
|
+
}), p.rmdirSync(m.resolve(t.componentDir, a));
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
return console.log(r.red(`组件${s}不存在`)), process.exit(1);
|
|
@@ -203,17 +203,17 @@ const _ = (e, t) => {
|
|
|
203
203
|
}
|
|
204
204
|
}).demandCommand(1), F = (e, t = !1) => t ? S(e.strict().usage(B)) : S(
|
|
205
205
|
e.strict().usage(W).help("help").version(f.version).alias("v", "version").alias("h", "help")
|
|
206
|
-
).fail(J).argv, q = (e) => F(e, !0),
|
|
206
|
+
).fail(J).argv, q = (e) => F(e, !0), pe = {
|
|
207
207
|
command: V,
|
|
208
208
|
describe: Z,
|
|
209
209
|
builder: q,
|
|
210
210
|
handler: P
|
|
211
|
-
},
|
|
211
|
+
}, ue = async () => {
|
|
212
212
|
const e = k(T(process.argv));
|
|
213
213
|
return await F(e), P();
|
|
214
214
|
};
|
|
215
215
|
export {
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
pe as a,
|
|
217
|
+
ue as c,
|
|
218
218
|
P as h
|
|
219
219
|
};
|
package/es/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-component",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3-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.4.
|
|
44
|
+
"@done-coding/cli-inject": "^0.4.6-alpha.0",
|
|
45
45
|
"@types/json5": "^2.2.0",
|
|
46
46
|
"@types/lodash.camelcase": "^4.3.8",
|
|
47
47
|
"@types/lodash.curry": "^4.1.8",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"node": ">=18.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@done-coding/cli-template": "^0.6.0",
|
|
65
|
+
"@done-coding/cli-template": "^0.6.1-alpha.0",
|
|
66
66
|
"chalk": "^5.3.0",
|
|
67
67
|
"json5": "^2.2.3",
|
|
68
68
|
"lodash.camelcase": "^4.3.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"prompts": "^2.4.2",
|
|
76
76
|
"yargs": "^17.7.2"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "21eb698f64179882cfec979bd8f19920b047dacb"
|
|
79
79
|
}
|