@done-coding/cli-component 0.1.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/README.md +7 -0
- package/es/cli.mjs +3 -0
- package/es/handler.mjs +13 -0
- package/es/index.mjs +7 -0
- package/es/injectInfo.json.mjs +9 -0
- package/es/main.mjs +46 -0
- package/es/utils/add.mjs +35 -0
- package/es/utils/config.mjs +26 -0
- package/es/utils/const.mjs +6 -0
- package/es/utils/env-data.mjs +32 -0
- package/es/utils/list.mjs +33 -0
- package/es/utils/name.mjs +14 -0
- package/es/utils/operate.mjs +47 -0
- package/es/utils/remove.mjs +40 -0
- package/es/utils/types.mjs +5 -0
- package/package.json +78 -0
- package/types/cli.d.ts +2 -0
- package/types/handler.d.ts +6 -0
- package/types/index.d.ts +2 -0
- package/types/injectInfo.json.d.ts +7 -0
- package/types/main.d.ts +4 -0
- package/types/utils/add.d.ts +3 -0
- package/types/utils/config.d.ts +3 -0
- package/types/utils/const.d.ts +4 -0
- package/types/utils/env-data.d.ts +41 -0
- package/types/utils/index.d.ts +7 -0
- package/types/utils/list.d.ts +6 -0
- package/types/utils/name.d.ts +7 -0
- package/types/utils/operate.d.ts +8 -0
- package/types/utils/remove.d.ts +3 -0
- package/types/utils/types.d.ts +44 -0
package/README.md
ADDED
package/es/cli.mjs
ADDED
package/es/handler.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { SubcommandEnum as n } from "./utils/types.mjs";
|
|
3
|
+
import { listComponent as r } from "./utils/list.mjs";
|
|
4
|
+
import { addComponent as t } from "./utils/add.mjs";
|
|
5
|
+
import { removeComponent as m } from "./utils/remove.mjs";
|
|
6
|
+
import s from "chalk";
|
|
7
|
+
const u = async (o, e) => (console.log("com", e), o === n.ADD ? t(e) : o === n.REMOVE ? m(e) : o === n.LIST ? r() : (console.log(s.red("无效的命令")), process.exit(1))), d = async (o) => {
|
|
8
|
+
console.log("component 子命令处理函数", o);
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
d as handler,
|
|
12
|
+
u as subHandler
|
|
13
|
+
};
|
package/es/index.mjs
ADDED
package/es/main.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import l from "yargs";
|
|
3
|
+
import { hideBin as p } from "yargs/helpers";
|
|
4
|
+
import { MODULE_NAME as u } from "./utils/const.mjs";
|
|
5
|
+
import { SubcommandEnum as o } from "./utils/types.mjs";
|
|
6
|
+
import { handler as i, subHandler as r } from "./handler.mjs";
|
|
7
|
+
import a from "chalk";
|
|
8
|
+
import t from "./injectInfo.json.mjs";
|
|
9
|
+
import m from "lodash.curry";
|
|
10
|
+
const c = u, g = (e, n) => {
|
|
11
|
+
console.log(e ? a.red(e) : a.red(n.message)), process.exit(1);
|
|
12
|
+
}, f = t.description, b = `Usage: $0 ${c} <command> [options]`, h = "Usage: $0 <command> [options]", s = (e) => e.command({
|
|
13
|
+
command: `${o.ADD} <name>`,
|
|
14
|
+
describe: "新增一个组件",
|
|
15
|
+
builder: (n) => n.positional("name", {
|
|
16
|
+
describe: "组件名称",
|
|
17
|
+
type: "string"
|
|
18
|
+
}),
|
|
19
|
+
handler: m(r)(o.ADD)
|
|
20
|
+
}).command({
|
|
21
|
+
command: `${o.REMOVE} [name]`,
|
|
22
|
+
describe: "删除一个组件",
|
|
23
|
+
builder: (n) => n.positional("name", {
|
|
24
|
+
describe: "组件名称",
|
|
25
|
+
type: "string"
|
|
26
|
+
}),
|
|
27
|
+
handler: m(r)(o.REMOVE)
|
|
28
|
+
}).command({
|
|
29
|
+
command: o.LIST,
|
|
30
|
+
describe: "展示组件列表",
|
|
31
|
+
handler: m(r)(o.LIST)
|
|
32
|
+
}).demandCommand(1), d = (e, n = !1) => n ? s(e.strict().usage(b)) : s(
|
|
33
|
+
e.strict().usage(h).help("help").version(t.version).alias("v", "version").alias("h", "help")
|
|
34
|
+
).fail(g).argv, v = (e) => d(e, !0), A = {
|
|
35
|
+
command: c,
|
|
36
|
+
describe: f,
|
|
37
|
+
builder: v,
|
|
38
|
+
handler: i
|
|
39
|
+
}, I = async () => {
|
|
40
|
+
const e = l(p(process.argv)), n = await d(e);
|
|
41
|
+
return i(n);
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
A as command,
|
|
45
|
+
I as createCli
|
|
46
|
+
};
|
package/es/utils/add.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { SubcommandEnum as s } from "./types.mjs";
|
|
3
|
+
import { ensureNameLegal as i } from "./name.mjs";
|
|
4
|
+
import { getConfig as p } from "./config.mjs";
|
|
5
|
+
import n from "chalk";
|
|
6
|
+
import f from "prompts";
|
|
7
|
+
import { operateComponent as c } from "./operate.mjs";
|
|
8
|
+
import { getComponentList as l } from "./list.mjs";
|
|
9
|
+
import { getComponentEnvData as g } from "./env-data.mjs";
|
|
10
|
+
const E = async ({ name: t }) => {
|
|
11
|
+
console.log(n.blue("添加组件"));
|
|
12
|
+
let o;
|
|
13
|
+
t ? o = t : o = (await f({
|
|
14
|
+
type: "text",
|
|
15
|
+
name: "name",
|
|
16
|
+
message: "请输入组件名"
|
|
17
|
+
})).name;
|
|
18
|
+
const e = p();
|
|
19
|
+
i(o, e);
|
|
20
|
+
const { series: r } = e, a = await l(e);
|
|
21
|
+
for (let m of a)
|
|
22
|
+
if (g({
|
|
23
|
+
series: r,
|
|
24
|
+
name: o
|
|
25
|
+
}).nameKebab === m)
|
|
26
|
+
return console.log(n.red(`组件${m}已存在, 不能再次创建${o}组件`)), process.exit(1);
|
|
27
|
+
return c({
|
|
28
|
+
name: o,
|
|
29
|
+
config: e,
|
|
30
|
+
command: s.ADD
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
E as addComponent
|
|
35
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import i from "node:path";
|
|
3
|
+
import o from "node:fs";
|
|
4
|
+
import a from "json5";
|
|
5
|
+
import s from "chalk";
|
|
6
|
+
import { getTemplateDirAbsolutePath as m, getPathEnvData as p } from "./env-data.mjs";
|
|
7
|
+
import f from "lodash.template";
|
|
8
|
+
const D = () => {
|
|
9
|
+
const e = i.resolve(m(), "index.json");
|
|
10
|
+
if (!o.existsSync(e))
|
|
11
|
+
return console.log(s.red(`模块入口文件不存在: ${e}`)), process.exit(1);
|
|
12
|
+
const t = JSON.parse(o.readFileSync(e, "utf-8")).config;
|
|
13
|
+
if (!t)
|
|
14
|
+
return console.log(s.red(`配置文件相对路径不存在: ${t}`)), process.exit(1);
|
|
15
|
+
const n = i.resolve(
|
|
16
|
+
i.dirname(e),
|
|
17
|
+
t
|
|
18
|
+
);
|
|
19
|
+
if (!o.existsSync(n))
|
|
20
|
+
return console.log(s.red(`配置文件不存在: ${n}`)), process.exit(1);
|
|
21
|
+
const r = a.parse(o.readFileSync(n, "utf-8")), c = p();
|
|
22
|
+
return r.componentDir = f(r.componentDir)(c), r;
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
D as getConfig
|
|
26
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import a from "lodash.upperfirst";
|
|
3
|
+
import m from "lodash.camelcase";
|
|
4
|
+
import c from "lodash.kebabcase";
|
|
5
|
+
import u from "lodash.lowerfirst";
|
|
6
|
+
import b from "node:path";
|
|
7
|
+
import { CLI_NAMESPACE_DIR as f, MODULE_NAME as D } from "./const.mjs";
|
|
8
|
+
const E = () => b.resolve(f, D), _ = () => ({
|
|
9
|
+
execDir: process.cwd(),
|
|
10
|
+
templateDir: E()
|
|
11
|
+
}), v = (t) => {
|
|
12
|
+
const { series: r, name: i } = t, e = a(m(i)), p = u(e), l = c(e), o = r ? a(m(r)) : "", s = o ? `${o}${e}` : "", n = c(s);
|
|
13
|
+
return {
|
|
14
|
+
series: o,
|
|
15
|
+
name: e,
|
|
16
|
+
nameLowerFirst: p,
|
|
17
|
+
nameKebab: l,
|
|
18
|
+
fullName: s,
|
|
19
|
+
fullNameKebab: n,
|
|
20
|
+
cls: n
|
|
21
|
+
};
|
|
22
|
+
}, w = (t) => ({
|
|
23
|
+
$: "$",
|
|
24
|
+
..._(),
|
|
25
|
+
...v(t)
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
v as getComponentEnvData,
|
|
29
|
+
w as getEnvData,
|
|
30
|
+
_ as getPathEnvData,
|
|
31
|
+
E as getTemplateDirAbsolutePath
|
|
32
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import o from "chalk";
|
|
3
|
+
import i from "node:path";
|
|
4
|
+
import c from "node:fs";
|
|
5
|
+
import { getConfig as m } from "./config.mjs";
|
|
6
|
+
import { getComponentEnvData as f } from "./env-data.mjs";
|
|
7
|
+
const p = (t) => {
|
|
8
|
+
const { componentDir: e, nameExcludes: n } = t;
|
|
9
|
+
return c.statSync(e).isDirectory() ? c.readdirSync(e).map((s) => {
|
|
10
|
+
const r = i.join(e, s);
|
|
11
|
+
return c.statSync(r).isDirectory() ? (console.log("filePath:", r, i.basename(r)), i.basename(r)) : "";
|
|
12
|
+
}).filter((s) => !(!s || n.includes(s))) : (console.log(o.red("组件源码路径不是目录")), process.exit(1));
|
|
13
|
+
}, v = async () => {
|
|
14
|
+
console.log(o.blue("展示列表"));
|
|
15
|
+
const t = m(), e = p(t);
|
|
16
|
+
console.table(
|
|
17
|
+
e.map((n) => {
|
|
18
|
+
const { name: l, fullName: a } = f({
|
|
19
|
+
...t,
|
|
20
|
+
name: n
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
[o.green("名称")]: l,
|
|
24
|
+
[o.green("带系列名称")]: a,
|
|
25
|
+
[o.green("绝对路径")]: i.resolve(t.componentDir, n)
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
p as getComponentList,
|
|
32
|
+
v as listComponent
|
|
33
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import o from "chalk";
|
|
3
|
+
const t = (e, s) => {
|
|
4
|
+
if (!/^[a-zA-Z]+[a-zA-Z0-9-]*$/.test(e))
|
|
5
|
+
return console.log(o.red("组件名只能包含字母、数字、中划线")), process.exit(1);
|
|
6
|
+
const { nameExcludes: r } = s;
|
|
7
|
+
return r.includes(e) ? (console.log(
|
|
8
|
+
o.red(`组件名: ${e}是保留名称。
|
|
9
|
+
保留名称: ${r.join(",")}`)
|
|
10
|
+
), process.exit(1)) : !0;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
t as ensureNameLegal
|
|
14
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { getEnvData as E } from "./env-data.mjs";
|
|
3
|
+
import { SubcommandEnum as u } from "./types.mjs";
|
|
4
|
+
import { OutputModeEnum as l, handler as c } from "@done-coding/cli-template";
|
|
5
|
+
import i from "lodash.template";
|
|
6
|
+
import d from "chalk";
|
|
7
|
+
const k = async ({
|
|
8
|
+
name: m,
|
|
9
|
+
config: e,
|
|
10
|
+
command: n
|
|
11
|
+
}) => {
|
|
12
|
+
if (![u.ADD, u.REMOVE].includes(n))
|
|
13
|
+
return console.log(d.red(`不支持组件${n}操作`)), process.exit(1);
|
|
14
|
+
const o = E({
|
|
15
|
+
...e,
|
|
16
|
+
name: m
|
|
17
|
+
}), f = JSON.stringify(o);
|
|
18
|
+
for (const { entry: p, index: a } of e.list) {
|
|
19
|
+
if (p) {
|
|
20
|
+
const t = p;
|
|
21
|
+
t != null && t.input && (t.input = i(t.input)(o)), t != null && t.output && (t.output = i(t.output)(o));
|
|
22
|
+
const r = {
|
|
23
|
+
...p,
|
|
24
|
+
envData: f,
|
|
25
|
+
mode: l.APPEND,
|
|
26
|
+
rollback: n === u.REMOVE,
|
|
27
|
+
dealMarkdown: !0
|
|
28
|
+
};
|
|
29
|
+
await c(r);
|
|
30
|
+
}
|
|
31
|
+
if (a) {
|
|
32
|
+
const t = a;
|
|
33
|
+
t != null && t.input && (t.input = i(t.input)(o)), t != null && t.output && (t.output = i(t.output)(o));
|
|
34
|
+
const r = {
|
|
35
|
+
...a,
|
|
36
|
+
envData: f,
|
|
37
|
+
mode: l.OVERWRITE,
|
|
38
|
+
rollback: n === u.REMOVE,
|
|
39
|
+
dealMarkdown: !0
|
|
40
|
+
};
|
|
41
|
+
await c(r);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
k as operateComponent
|
|
47
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { SubcommandEnum as s } from "./types.mjs";
|
|
3
|
+
import { getConfig as i } from "./config.mjs";
|
|
4
|
+
import n from "chalk";
|
|
5
|
+
import p from "prompts";
|
|
6
|
+
import { operateComponent as c } from "./operate.mjs";
|
|
7
|
+
import { getComponentList as f } from "./list.mjs";
|
|
8
|
+
import { getComponentEnvData as l } from "./env-data.mjs";
|
|
9
|
+
import g from "node:fs";
|
|
10
|
+
import u from "node:path";
|
|
11
|
+
const K = async ({ name: m }) => {
|
|
12
|
+
console.log(n.blue("移除组件"));
|
|
13
|
+
const t = i(), r = await f(t);
|
|
14
|
+
if (r.length === 0)
|
|
15
|
+
return console.log(n.red("组件列表为空")), process.exit(1);
|
|
16
|
+
let o;
|
|
17
|
+
m ? o = m : o = (await p({
|
|
18
|
+
type: "select",
|
|
19
|
+
name: "name",
|
|
20
|
+
message: "请选择要移除的组件",
|
|
21
|
+
choices: r.map((e) => ({ title: e, value: e }))
|
|
22
|
+
})).name;
|
|
23
|
+
const { series: a } = t;
|
|
24
|
+
for (let e of r)
|
|
25
|
+
if (l({
|
|
26
|
+
series: a,
|
|
27
|
+
name: o
|
|
28
|
+
}).nameKebab === e) {
|
|
29
|
+
await c({
|
|
30
|
+
name: o,
|
|
31
|
+
config: t,
|
|
32
|
+
command: s.REMOVE
|
|
33
|
+
}), g.rmdirSync(u.resolve(t.componentDir, e));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
return console.log(n.red(`组件${o}不存在`)), process.exit(1);
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
K as removeComponent
|
|
40
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@done-coding/cli-component",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "组件命令行工具",
|
|
5
|
+
"private": false,
|
|
6
|
+
"module": "es/index.mjs",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"dc-component": "es/cli.mjs"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./es/index.mjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"es",
|
|
19
|
+
"lib",
|
|
20
|
+
"types",
|
|
21
|
+
"gif"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"clean": "rimraf es lib types",
|
|
25
|
+
"predev": "pnpm run clean",
|
|
26
|
+
"dev": "vite build --watch",
|
|
27
|
+
"prebuild": "pnpm run clean",
|
|
28
|
+
"build": "vite build",
|
|
29
|
+
"prepack": "pnpm build"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://gitee.com/justsosu/done-coding-cli.git",
|
|
34
|
+
"directory": "packages/component"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"author": "JustSoSu",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@done-coding/cli-inject": "^0.2.2",
|
|
44
|
+
"@types/json5": "^2.2.0",
|
|
45
|
+
"@types/lodash.camelcase": "^4.3.8",
|
|
46
|
+
"@types/lodash.curry": "^4.1.8",
|
|
47
|
+
"@types/lodash.get": "^4.4.8",
|
|
48
|
+
"@types/lodash.kebabcase": "^4.1.8",
|
|
49
|
+
"@types/lodash.lowerfirst": "^4.3.8",
|
|
50
|
+
"@types/lodash.template": "^4.5.2",
|
|
51
|
+
"@types/lodash.upperfirst": "^4.3.8",
|
|
52
|
+
"@types/node": "^16.0.0",
|
|
53
|
+
"@types/prompts": "^2.4.6",
|
|
54
|
+
"@types/yargs": "^17.0.28",
|
|
55
|
+
"rimraf": "^6.0.1",
|
|
56
|
+
"typescript": "^5.2.2",
|
|
57
|
+
"vite": "^4.4.11",
|
|
58
|
+
"vite-plugin-dts": "^3.6.0"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=16.0.0"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@done-coding/cli-template": "^0.2.1",
|
|
65
|
+
"chalk": "^5.3.0",
|
|
66
|
+
"json5": "^2.2.3",
|
|
67
|
+
"lodash.camelcase": "^4.3.0",
|
|
68
|
+
"lodash.curry": "^4.1.1",
|
|
69
|
+
"lodash.get": "^4.4.2",
|
|
70
|
+
"lodash.kebabcase": "^4.1.1",
|
|
71
|
+
"lodash.lowerfirst": "^4.3.1",
|
|
72
|
+
"lodash.template": "^4.5.0",
|
|
73
|
+
"lodash.upperfirst": "^4.3.1",
|
|
74
|
+
"prompts": "^2.4.2",
|
|
75
|
+
"yargs": "^17.7.2"
|
|
76
|
+
},
|
|
77
|
+
"gitHead": "e2dc7c4b0fa74aa83dc6173416aaffe0a0a445ad"
|
|
78
|
+
}
|
package/types/cli.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Options } from './utils';
|
|
2
|
+
import { SubcommandEnum } from './utils';
|
|
3
|
+
import type { ArgumentsCamelCase } from "yargs";
|
|
4
|
+
/** 子命令处理函数 */
|
|
5
|
+
export declare const subHandler: (command: SubcommandEnum, argv: ArgumentsCamelCase<Options>) => Promise<void>;
|
|
6
|
+
export declare const handler: (argv: ArgumentsCamelCase<Options>) => Promise<void>;
|
package/types/index.d.ts
ADDED
package/types/main.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Config, Options } from "./types";
|
|
2
|
+
/** 获取模板目录绝对路径 */
|
|
3
|
+
export declare const getTemplateDirAbsolutePath: () => string;
|
|
4
|
+
/** 路径环境变量 */
|
|
5
|
+
export interface PathEnvData {
|
|
6
|
+
/** 执行命令的目录绝对路径 */
|
|
7
|
+
execDir: string;
|
|
8
|
+
/** 模板目录绝对路径 */
|
|
9
|
+
templateDir: string;
|
|
10
|
+
}
|
|
11
|
+
/** 获取路径环境变量 */
|
|
12
|
+
export declare const getPathEnvData: () => {
|
|
13
|
+
execDir: string;
|
|
14
|
+
templateDir: string;
|
|
15
|
+
};
|
|
16
|
+
/** 组件环境变量 */
|
|
17
|
+
export interface ComponentEnvData {
|
|
18
|
+
/** 矫正后的组件系列 */
|
|
19
|
+
series: string;
|
|
20
|
+
/** 矫正后的组件名 */
|
|
21
|
+
name: string;
|
|
22
|
+
/** 矫正后的组件名小写开头 */
|
|
23
|
+
nameLowerFirst: string;
|
|
24
|
+
/** 小写连接的组件名 */
|
|
25
|
+
nameKebab: string;
|
|
26
|
+
/** 矫正后的带系列组件名 */
|
|
27
|
+
fullName: string;
|
|
28
|
+
/** 矫正后的带系列小写连接的组件名 */
|
|
29
|
+
fullNameKebab: string;
|
|
30
|
+
/** 组件类名 */
|
|
31
|
+
cls: string;
|
|
32
|
+
}
|
|
33
|
+
/** 获取环境变量 */
|
|
34
|
+
export declare const getComponentEnvData: (data: Pick<Config, "series"> & Required<Options>) => ComponentEnvData;
|
|
35
|
+
/** 环境变量 */
|
|
36
|
+
export interface EnvData extends PathEnvData, ComponentEnvData {
|
|
37
|
+
/** 转义的$ */
|
|
38
|
+
$: "$";
|
|
39
|
+
}
|
|
40
|
+
/** 获取环境变量 */
|
|
41
|
+
export declare const getEnvData: (data: Pick<Config, "series"> & Required<Options>) => EnvData;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Options as TemplateOptions } from "@done-coding/cli-template";
|
|
2
|
+
/** 子命令枚举 */
|
|
3
|
+
export declare enum SubcommandEnum {
|
|
4
|
+
/** 新增组件 */
|
|
5
|
+
ADD = "add",
|
|
6
|
+
/** 移除组件 */
|
|
7
|
+
REMOVE = "remove",
|
|
8
|
+
/** 展示列表 */
|
|
9
|
+
LIST = "list"
|
|
10
|
+
}
|
|
11
|
+
export interface Options {
|
|
12
|
+
/**
|
|
13
|
+
* 组件名
|
|
14
|
+
* ---
|
|
15
|
+
* 新增时必传
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
/** 模版配置输入路径 */
|
|
20
|
+
export type TemplateConfigInputByPath = Pick<TemplateOptions, "input" | "output">;
|
|
21
|
+
/** 模版配置输入数据 */
|
|
22
|
+
export type TemplateConfigInputByData = Pick<TemplateOptions, "inputData" | "output">;
|
|
23
|
+
/** 模版配置 */
|
|
24
|
+
export type TemplateConfig = TemplateConfigInputByPath | TemplateConfigInputByData;
|
|
25
|
+
/** 模版配置完整 */
|
|
26
|
+
export type TemplateConfigFull = Pick<TemplateOptions, "input" | "inputData" | "output">;
|
|
27
|
+
/** 列表item */
|
|
28
|
+
export interface ConfigListItem {
|
|
29
|
+
/** 组件逻辑文件 */
|
|
30
|
+
entry: TemplateConfig;
|
|
31
|
+
/** 组件逻辑文件 */
|
|
32
|
+
index?: TemplateConfig;
|
|
33
|
+
}
|
|
34
|
+
/** 组件配置 */
|
|
35
|
+
export interface Config {
|
|
36
|
+
/** 组件系列 */
|
|
37
|
+
series: string;
|
|
38
|
+
/** 组件名排除列表 */
|
|
39
|
+
nameExcludes: string[];
|
|
40
|
+
/** 组件目录 */
|
|
41
|
+
componentDir: string;
|
|
42
|
+
/** 配置列表 */
|
|
43
|
+
list: ConfigListItem[];
|
|
44
|
+
}
|