done-coding-extract 0.1.9-alpha.0 → 0.1.10
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-7899ce46.js → index-e4f5918d.js} +18 -18
- package/es/index.mjs +1 -1
- package/package.json +5 -5
- package/types/cli.d.ts +1 -2
- package/types/helpers.d.ts +70 -1
- package/types/index.d.ts +118 -3
- package/types/config/index.d.ts +0 -3
- package/types/handlers/generate.d.ts +0 -13
- package/types/handlers/index.d.ts +0 -7
- package/types/handlers/init.d.ts +0 -8
- package/types/helpers-assets/done-coding.d.ts +0 -5
- package/types/injectInfo.json.d.ts +0 -11
- package/types/main.d.ts +0 -9
- package/types/types/index.d.ts +0 -74
- package/types/utils/index.d.ts +0 -2
- package/types/utils/path.d.ts +0 -4
- package/types/utils/resolve.d.ts +0 -14
package/es/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import y from "node:fs";
|
|
|
6
6
|
import { OutputModeEnum as U, batchCompileHandler as W } from "@done-coding/cli-template";
|
|
7
7
|
const O = {
|
|
8
8
|
name: "@done-coding/cli-extract",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.10",
|
|
10
10
|
description: "信息提取命令行工具",
|
|
11
11
|
cliConfig: {
|
|
12
12
|
namespaceDir: ".done-coding",
|
|
@@ -27,7 +27,7 @@ const O = {
|
|
|
27
27
|
const { type: a = r.READ } = t;
|
|
28
28
|
switch (a) {
|
|
29
29
|
case r.REG: {
|
|
30
|
-
const { sourceKey: c, pattern:
|
|
30
|
+
const { sourceKey: c, pattern: p, replaceValue: l, flags: f } = t, d = new RegExp(p, f ?? void 0), i = b(e, c);
|
|
31
31
|
return typeof i == "string" ? i.replace(d, l) : (s.warn(
|
|
32
32
|
`${i}不是字符串类型,无法使用正则表达式进行替换,此处将直接返回原值`
|
|
33
33
|
), i);
|
|
@@ -47,7 +47,7 @@ const O = {
|
|
|
47
47
|
}
|
|
48
48
|
}, S = {
|
|
49
49
|
name: "@done-coding/cli-inject",
|
|
50
|
-
version: "0.5.
|
|
50
|
+
version: "0.5.10",
|
|
51
51
|
description: "信息(JSON)注入命令行工具",
|
|
52
52
|
cliConfig: {
|
|
53
53
|
namespaceDir: ".done-coding",
|
|
@@ -93,7 +93,7 @@ const O = {
|
|
|
93
93
|
sourceFilePath: t,
|
|
94
94
|
keyConfigMap: a,
|
|
95
95
|
injectFilePath: c
|
|
96
|
-
} = n,
|
|
96
|
+
} = n, p = {
|
|
97
97
|
...a,
|
|
98
98
|
...o
|
|
99
99
|
};
|
|
@@ -101,21 +101,21 @@ const O = {
|
|
|
101
101
|
return s.error("源文件必须是json"), process.exit(1);
|
|
102
102
|
if (!c.endsWith(".json"))
|
|
103
103
|
return s.error("注入文件必须是json"), process.exit(1);
|
|
104
|
-
const l = j.resolve(e, t), f = y.readFileSync(l, "utf-8"), d = JSON.parse(f), i = Object.entries(
|
|
104
|
+
const l = j.resolve(e, t), f = y.readFileSync(l, "utf-8"), d = JSON.parse(f), i = Object.entries(p).reduce(
|
|
105
105
|
(g, [R, P]) => {
|
|
106
106
|
const M = C({ sourceJson: d, targetKey: R, keyConfig: P });
|
|
107
107
|
return L(g, R, M), g;
|
|
108
108
|
},
|
|
109
109
|
{}
|
|
110
|
-
),
|
|
111
|
-
if (y.existsSync(
|
|
112
|
-
const g = y.readFileSync(
|
|
110
|
+
), m = j.resolve(e, c), E = JSON.stringify(i, null, 2);
|
|
111
|
+
if (y.existsSync(m)) {
|
|
112
|
+
const g = y.readFileSync(m, "utf-8");
|
|
113
113
|
if (E === g)
|
|
114
114
|
return s.skip("注入文件已存在且内容相同,无需重复注入"), i;
|
|
115
115
|
s.stage("文件内容变化,开始覆盖注入文件");
|
|
116
116
|
} else
|
|
117
117
|
s.stage("开始注入文件");
|
|
118
|
-
y.writeFileSync(
|
|
118
|
+
y.writeFileSync(m, E), s.success(`文件注入成功: ${m}`), s.info(E);
|
|
119
119
|
}, te = async (e) => {
|
|
120
120
|
const n = await F(e);
|
|
121
121
|
if (!n)
|
|
@@ -228,16 +228,16 @@ const ce = ({
|
|
|
228
228
|
}
|
|
229
229
|
]
|
|
230
230
|
}
|
|
231
|
-
},
|
|
231
|
+
}, me = () => D({
|
|
232
232
|
configPathDefault: J
|
|
233
233
|
}), G = async (e) => v(de, e, {
|
|
234
234
|
onFileGenerated: () => {
|
|
235
235
|
s.info("文件生成成功");
|
|
236
236
|
}
|
|
237
|
-
}),
|
|
237
|
+
}), pe = {
|
|
238
238
|
command: h.INIT,
|
|
239
239
|
describe: "初始化配置文件",
|
|
240
|
-
options:
|
|
240
|
+
options: me(),
|
|
241
241
|
handler: G
|
|
242
242
|
}, le = () => ({
|
|
243
243
|
...D({
|
|
@@ -255,17 +255,17 @@ const ce = ({
|
|
|
255
255
|
config: n
|
|
256
256
|
}) => {
|
|
257
257
|
const { extractInput: o, extractOutput: t } = n, a = Object.entries(o).reduce(
|
|
258
|
-
(c, [
|
|
258
|
+
(c, [p, l]) => {
|
|
259
259
|
const f = ce({
|
|
260
260
|
rootDir: e,
|
|
261
|
-
input:
|
|
261
|
+
input: p
|
|
262
262
|
});
|
|
263
263
|
return Object.entries(l).reduce(
|
|
264
|
-
(d, [i,
|
|
264
|
+
(d, [i, m]) => {
|
|
265
265
|
const E = ae({
|
|
266
266
|
content: f,
|
|
267
267
|
targetKey: i,
|
|
268
|
-
keyConfig:
|
|
268
|
+
keyConfig: m
|
|
269
269
|
});
|
|
270
270
|
return d[i] = E, d;
|
|
271
271
|
},
|
|
@@ -304,7 +304,7 @@ const ce = ({
|
|
|
304
304
|
}, { version: ye, description: ge } = O, k = {
|
|
305
305
|
describe: ge,
|
|
306
306
|
version: ye,
|
|
307
|
-
subcommands: [
|
|
307
|
+
subcommands: [pe, Ee].map(
|
|
308
308
|
N
|
|
309
309
|
),
|
|
310
310
|
demandCommandCount: 1
|
|
@@ -322,7 +322,7 @@ const ce = ({
|
|
|
322
322
|
});
|
|
323
323
|
export {
|
|
324
324
|
Re as a,
|
|
325
|
-
|
|
325
|
+
pe as b,
|
|
326
326
|
Oe as c,
|
|
327
327
|
I as d,
|
|
328
328
|
Ee as e,
|
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as t, a as i, e as s, g as d, d as l, f as p, b as f, h as u } from "./index-
|
|
2
|
+
import { i as t, a as i, e as s, g as d, d as l, f as p, b as f, h as u } from "./index-e4f5918d.js";
|
|
3
3
|
import { E as C, G as E, S as b } from "./index-a1ee6691-8c73eb4d.js";
|
|
4
4
|
import "@done-coding/cli-utils";
|
|
5
5
|
import "node:path";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "done-coding-extract",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "信息提取命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@done-coding/cli-inject": "^0.5.
|
|
45
|
+
"@done-coding/cli-inject": "^0.5.10",
|
|
46
46
|
"@types/node": "^18.0.0",
|
|
47
47
|
"@types/yargs": "^17.0.28",
|
|
48
48
|
"rimraf": "^6.0.1",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"node": ">=18.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@done-coding/cli-template": "0.7.
|
|
58
|
-
"@done-coding/cli-utils": "^0.7.
|
|
57
|
+
"@done-coding/cli-template": "0.7.10",
|
|
58
|
+
"@done-coding/cli-utils": "^0.7.1"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "299ab3991d6842c83d65816dfba6efd175aa885a",
|
|
61
61
|
"scripts": {}
|
|
62
62
|
}
|
package/types/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
export { }
|
package/types/helpers.d.ts
CHANGED
|
@@ -1 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CompileTemplateConfig } from '@done-coding/cli-template';
|
|
2
|
+
import type { InjectKeyConfig } from '@done-coding/cli-inject';
|
|
3
|
+
import type { InjectKeyConfigFixed } from '@done-coding/cli-inject';
|
|
4
|
+
import type { InjectKeyConfigReg } from '@done-coding/cli-inject';
|
|
5
|
+
|
|
6
|
+
/** done-coding 系列cli 别名发布信息 */
|
|
7
|
+
export declare const doneCodingPublishAliasInfo: ExtractConfig;
|
|
8
|
+
|
|
9
|
+
/** done-coding 系列cli 注入信息 */
|
|
10
|
+
export declare const doneCodingSeriesCliInjectInfo: ExtractConfig;
|
|
11
|
+
|
|
12
|
+
declare interface ExtractConfig {
|
|
13
|
+
/**
|
|
14
|
+
* 输入配置
|
|
15
|
+
* -- 每个源文件 对应一个配置
|
|
16
|
+
*/
|
|
17
|
+
extractInput: Record<string, ExtractInputConfig>;
|
|
18
|
+
/** 输出配置 */
|
|
19
|
+
extractOutput: CompileTemplateConfig;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 提取输入配置 */
|
|
23
|
+
declare interface ExtractInputConfig {
|
|
24
|
+
[key: string]: ExtractInputKeyConfig;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** 提取配置 */
|
|
28
|
+
declare type ExtractInputKeyConfig = ExtractInputKeyConfigReg | ExtractInputKeyConfigJsonInject | ExtractInputKeyConfigFixed;
|
|
29
|
+
|
|
30
|
+
/** 提取配置基础 */
|
|
31
|
+
declare interface ExtractInputKeyConfigBase<T extends ExtractTypeEnum> {
|
|
32
|
+
/**
|
|
33
|
+
* 提取类型
|
|
34
|
+
*/
|
|
35
|
+
type: T;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 提取配置固定值 */
|
|
39
|
+
declare type ExtractInputKeyConfigFixed = ExtractInputKeyConfigBase<ExtractTypeEnum.FIXED> & Omit<InjectKeyConfigFixed, "type">;
|
|
40
|
+
|
|
41
|
+
/** 提取配置直接读取 */
|
|
42
|
+
declare interface ExtractInputKeyConfigJsonInject extends ExtractInputKeyConfigBase<ExtractTypeEnum.JSON_INJECT> {
|
|
43
|
+
inject: InjectKeyConfig;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 提取配置正则表达式 */
|
|
47
|
+
declare interface ExtractInputKeyConfigReg extends ExtractInputKeyConfigBase<ExtractTypeEnum.REG>, Omit<InjectKeyConfigReg, "type" | "sourceKey"> {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 提取方式枚举 */
|
|
51
|
+
declare enum ExtractTypeEnum {
|
|
52
|
+
/**
|
|
53
|
+
* 正则 类型
|
|
54
|
+
* ---
|
|
55
|
+
* 通过正则匹配后 replace 替换
|
|
56
|
+
*/
|
|
57
|
+
REG = "reg",
|
|
58
|
+
/**
|
|
59
|
+
* json注入 类型
|
|
60
|
+
* ---
|
|
61
|
+
* 只限于读取json文件 input\output 均为json文件
|
|
62
|
+
* ---
|
|
63
|
+
* 内部直接调用 @done-coding/cli-inject
|
|
64
|
+
*/
|
|
65
|
+
JSON_INJECT = "json-inject",
|
|
66
|
+
/** 固定值 类型 */
|
|
67
|
+
FIXED = "fixed"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { }
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { CliHandlerArgv } from '@done-coding/cli-utils';
|
|
2
|
+
import { CliInfo } from '@done-coding/cli-utils';
|
|
3
|
+
import { CommandModule } from 'yargs';
|
|
4
|
+
import type { CompileTemplateConfig } from '@done-coding/cli-template';
|
|
5
|
+
import type { InitConfigFileOptions } from '@done-coding/cli-utils';
|
|
6
|
+
import type { InjectKeyConfig } from '@done-coding/cli-inject';
|
|
7
|
+
import type { InjectKeyConfigFixed } from '@done-coding/cli-inject';
|
|
8
|
+
import type { InjectKeyConfigReg } from '@done-coding/cli-inject';
|
|
9
|
+
import type { ReadConfigFileOptions } from '@done-coding/cli-utils';
|
|
10
|
+
import { SubCliInfo } from '@done-coding/cli-utils';
|
|
11
|
+
|
|
12
|
+
export declare const commandCliInfo: Omit<CliInfo, "usage">;
|
|
13
|
+
|
|
14
|
+
/** 作为子命令创建 */
|
|
15
|
+
export declare const crateAsSubcommand: () => CommandModule<{}, {}>;
|
|
16
|
+
|
|
17
|
+
export declare interface ExtractConfig {
|
|
18
|
+
/**
|
|
19
|
+
* 输入配置
|
|
20
|
+
* -- 每个源文件 对应一个配置
|
|
21
|
+
*/
|
|
22
|
+
extractInput: Record<string, ExtractInputConfig>;
|
|
23
|
+
/** 输出配置 */
|
|
24
|
+
extractOutput: CompileTemplateConfig;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** 提取输入配置 */
|
|
28
|
+
export declare interface ExtractInputConfig {
|
|
29
|
+
[key: string]: ExtractInputKeyConfig;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 提取配置 */
|
|
33
|
+
export declare type ExtractInputKeyConfig = ExtractInputKeyConfigReg | ExtractInputKeyConfigJsonInject | ExtractInputKeyConfigFixed;
|
|
34
|
+
|
|
35
|
+
/** 提取配置基础 */
|
|
36
|
+
export declare interface ExtractInputKeyConfigBase<T extends ExtractTypeEnum> {
|
|
37
|
+
/**
|
|
38
|
+
* 提取类型
|
|
39
|
+
*/
|
|
40
|
+
type: T;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** 提取配置固定值 */
|
|
44
|
+
export declare type ExtractInputKeyConfigFixed = ExtractInputKeyConfigBase<ExtractTypeEnum.FIXED> & Omit<InjectKeyConfigFixed, "type">;
|
|
45
|
+
|
|
46
|
+
/** 提取配置直接读取 */
|
|
47
|
+
export declare interface ExtractInputKeyConfigJsonInject extends ExtractInputKeyConfigBase<ExtractTypeEnum.JSON_INJECT> {
|
|
48
|
+
inject: InjectKeyConfig;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 提取配置正则表达式 */
|
|
52
|
+
export declare interface ExtractInputKeyConfigReg extends ExtractInputKeyConfigBase<ExtractTypeEnum.REG>, Omit<InjectKeyConfigReg, "type" | "sourceKey"> {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 提取方式枚举 */
|
|
56
|
+
export declare enum ExtractTypeEnum {
|
|
57
|
+
/**
|
|
58
|
+
* 正则 类型
|
|
59
|
+
* ---
|
|
60
|
+
* 通过正则匹配后 replace 替换
|
|
61
|
+
*/
|
|
62
|
+
REG = "reg",
|
|
63
|
+
/**
|
|
64
|
+
* json注入 类型
|
|
65
|
+
* ---
|
|
66
|
+
* 只限于读取json文件 input\output 均为json文件
|
|
67
|
+
* ---
|
|
68
|
+
* 内部直接调用 @done-coding/cli-inject
|
|
69
|
+
*/
|
|
70
|
+
JSON_INJECT = "json-inject",
|
|
71
|
+
/** 固定值 类型 */
|
|
72
|
+
FIXED = "fixed"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export declare const generateCommandCliInfo: SubCliInfo;
|
|
76
|
+
|
|
77
|
+
/** 将提取的信息生成文件 */
|
|
78
|
+
export declare const generateFile: ({ rootDir, config, }: {
|
|
79
|
+
rootDir?: string | undefined;
|
|
80
|
+
config: ExtractConfig;
|
|
81
|
+
}) => Promise<void>;
|
|
82
|
+
|
|
83
|
+
/** 提取文件命令处理器 */
|
|
84
|
+
export declare const generateHandler: (argv: CliHandlerArgv<GenerateOptions>) => Promise<undefined>;
|
|
85
|
+
|
|
86
|
+
/** 生成模式枚举 */
|
|
87
|
+
export declare enum GenerateModeEnum {
|
|
88
|
+
/** 提取出结果 */
|
|
89
|
+
RESULT = "result",
|
|
90
|
+
/** 提取出模板 */
|
|
91
|
+
TEMPLATE = "template"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** 生成选项 */
|
|
95
|
+
export declare interface GenerateOptions extends ReadConfigFileOptions {
|
|
96
|
+
/** 生成模式 */
|
|
97
|
+
mode?: GenerateModeEnum;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void>;
|
|
101
|
+
|
|
102
|
+
export declare const initCommandCliInfo: SubCliInfo;
|
|
103
|
+
|
|
104
|
+
/** 初始化命令处理器 */
|
|
105
|
+
export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
|
|
106
|
+
|
|
107
|
+
/** 初始化选项 */
|
|
108
|
+
export declare type InitOptions = InitConfigFileOptions;
|
|
109
|
+
|
|
110
|
+
/** 子命令枚举 */
|
|
111
|
+
export declare enum SubcommandEnum {
|
|
112
|
+
/** 初始化提取配置文件 */
|
|
113
|
+
INIT = "init",
|
|
114
|
+
/** 生成文件 */
|
|
115
|
+
GENERATE = "generate"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { }
|
package/types/config/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { SubCliInfo } from "@done-coding/cli-utils";
|
|
2
|
-
import { type CliHandlerArgv, type CliInfo } from "@done-coding/cli-utils";
|
|
3
|
-
import { type ExtractConfig, type GenerateOptions } from '../types';
|
|
4
|
-
/** 获取生成命令选项 */
|
|
5
|
-
export declare const getOptions: () => CliInfo["options"];
|
|
6
|
-
/** 将提取的信息生成文件 */
|
|
7
|
-
export declare const generateFile: ({ rootDir, config, }: {
|
|
8
|
-
rootDir?: string | undefined;
|
|
9
|
-
config: ExtractConfig;
|
|
10
|
-
}) => Promise<void>;
|
|
11
|
-
/** 提取文件命令处理器 */
|
|
12
|
-
export declare const handler: (argv: CliHandlerArgv<GenerateOptions>) => Promise<undefined>;
|
|
13
|
-
export declare const commandCliInfo: SubCliInfo;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { handler as initHandler, commandCliInfo as initCommandCliInfo } from "./init";
|
|
2
|
-
import { handler as generateHandler, commandCliInfo as generateCommandCliInfo, generateFile } from "./generate";
|
|
3
|
-
import { SubcommandEnum } from '../types';
|
|
4
|
-
import { type CliHandlerArgv, type CliInfo } from "@done-coding/cli-utils";
|
|
5
|
-
export { initHandler, initCommandCliInfo, generateHandler, generateCommandCliInfo, generateFile, };
|
|
6
|
-
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void>;
|
|
7
|
-
export declare const commandCliInfo: Omit<CliInfo, "usage">;
|
package/types/handlers/init.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="yargs" />
|
|
2
|
-
import type { CliHandlerArgv, SubCliInfo } from "@done-coding/cli-utils";
|
|
3
|
-
import { type InitOptions } from '../types';
|
|
4
|
-
/** 获取初始化选项 */
|
|
5
|
-
export declare const getOptions: () => Record<keyof import("@done-coding/cli-utils").ConfigFileCommonOptions, import("yargs").Options>;
|
|
6
|
-
/** 初始化命令处理器 */
|
|
7
|
-
export declare const handler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
|
|
8
|
-
export declare const commandCliInfo: SubCliInfo;
|
package/types/main.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="yargs" />
|
|
2
|
-
/** 作为主命令创建 */
|
|
3
|
-
export declare const createCommand: () => Promise<void | {
|
|
4
|
-
[x: string]: unknown;
|
|
5
|
-
_: (string | number)[];
|
|
6
|
-
$0: string;
|
|
7
|
-
}>;
|
|
8
|
-
/** 作为子命令创建 */
|
|
9
|
-
export declare const crateAsSubcommand: () => import("yargs").CommandModule<{}, {}>;
|
package/types/types/index.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { InitConfigFileOptions, ReadConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
|
-
import type { CompileTemplateConfig } from "@done-coding/cli-template";
|
|
3
|
-
import type { InjectKeyConfig, InjectKeyConfigFixed, InjectKeyConfigReg } from "@done-coding/cli-inject";
|
|
4
|
-
/** 子命令枚举 */
|
|
5
|
-
export declare enum SubcommandEnum {
|
|
6
|
-
/** 初始化提取配置文件 */
|
|
7
|
-
INIT = "init",
|
|
8
|
-
/** 生成文件 */
|
|
9
|
-
GENERATE = "generate"
|
|
10
|
-
}
|
|
11
|
-
/** 提取方式枚举 */
|
|
12
|
-
export declare enum ExtractTypeEnum {
|
|
13
|
-
/**
|
|
14
|
-
* 正则 类型
|
|
15
|
-
* ---
|
|
16
|
-
* 通过正则匹配后 replace 替换
|
|
17
|
-
*/
|
|
18
|
-
REG = "reg",
|
|
19
|
-
/**
|
|
20
|
-
* json注入 类型
|
|
21
|
-
* ---
|
|
22
|
-
* 只限于读取json文件 input\output 均为json文件
|
|
23
|
-
* ---
|
|
24
|
-
* 内部直接调用 @done-coding/cli-inject
|
|
25
|
-
*/
|
|
26
|
-
JSON_INJECT = "json-inject",
|
|
27
|
-
/** 固定值 类型 */
|
|
28
|
-
FIXED = "fixed"
|
|
29
|
-
}
|
|
30
|
-
/** 初始化选项 */
|
|
31
|
-
export type InitOptions = InitConfigFileOptions;
|
|
32
|
-
/** 提取配置基础 */
|
|
33
|
-
export interface ExtractInputKeyConfigBase<T extends ExtractTypeEnum> {
|
|
34
|
-
/**
|
|
35
|
-
* 提取类型
|
|
36
|
-
*/
|
|
37
|
-
type: T;
|
|
38
|
-
}
|
|
39
|
-
/** 提取配置正则表达式 */
|
|
40
|
-
export interface ExtractInputKeyConfigReg extends ExtractInputKeyConfigBase<ExtractTypeEnum.REG>, Omit<InjectKeyConfigReg, "type" | "sourceKey"> {
|
|
41
|
-
}
|
|
42
|
-
/** 提取配置直接读取 */
|
|
43
|
-
export interface ExtractInputKeyConfigJsonInject extends ExtractInputKeyConfigBase<ExtractTypeEnum.JSON_INJECT> {
|
|
44
|
-
inject: InjectKeyConfig;
|
|
45
|
-
}
|
|
46
|
-
/** 提取配置固定值 */
|
|
47
|
-
export type ExtractInputKeyConfigFixed = ExtractInputKeyConfigBase<ExtractTypeEnum.FIXED> & Omit<InjectKeyConfigFixed, "type">;
|
|
48
|
-
/** 提取配置 */
|
|
49
|
-
export type ExtractInputKeyConfig = ExtractInputKeyConfigReg | ExtractInputKeyConfigJsonInject | ExtractInputKeyConfigFixed;
|
|
50
|
-
/** 提取输入配置 */
|
|
51
|
-
export interface ExtractInputConfig {
|
|
52
|
-
[key: string]: ExtractInputKeyConfig;
|
|
53
|
-
}
|
|
54
|
-
export interface ExtractConfig {
|
|
55
|
-
/**
|
|
56
|
-
* 输入配置
|
|
57
|
-
* -- 每个源文件 对应一个配置
|
|
58
|
-
*/
|
|
59
|
-
extractInput: Record<string, ExtractInputConfig>;
|
|
60
|
-
/** 输出配置 */
|
|
61
|
-
extractOutput: CompileTemplateConfig;
|
|
62
|
-
}
|
|
63
|
-
/** 生成模式枚举 */
|
|
64
|
-
export declare enum GenerateModeEnum {
|
|
65
|
-
/** 提取出结果 */
|
|
66
|
-
RESULT = "result",
|
|
67
|
-
/** 提取出模板 */
|
|
68
|
-
TEMPLATE = "template"
|
|
69
|
-
}
|
|
70
|
-
/** 生成选项 */
|
|
71
|
-
export interface GenerateOptions extends ReadConfigFileOptions {
|
|
72
|
-
/** 生成模式 */
|
|
73
|
-
mode?: GenerateModeEnum;
|
|
74
|
-
}
|
package/types/utils/index.d.ts
DELETED
package/types/utils/path.d.ts
DELETED
package/types/utils/resolve.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type ExtractInputKeyConfig } from '../types';
|
|
2
|
-
/** 内容解析 */
|
|
3
|
-
export declare const contentResolve: ({ input, rootDir, }: {
|
|
4
|
-
input: string;
|
|
5
|
-
rootDir: string;
|
|
6
|
-
}) => string | Record<string, any>;
|
|
7
|
-
/** 内容是否为对象 */
|
|
8
|
-
export declare const contentIsObj: (content: ReturnType<typeof contentResolve>) => boolean;
|
|
9
|
-
/** 配置解析 */
|
|
10
|
-
export declare const keyConfigResolve: ({ content, targetKey, keyConfig, }: {
|
|
11
|
-
content: ReturnType<typeof contentResolve>;
|
|
12
|
-
targetKey: string;
|
|
13
|
-
keyConfig: ExtractInputKeyConfig;
|
|
14
|
-
}) => any;
|