done-coding-extract 0.1.8

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 ADDED
@@ -0,0 +1,11 @@
1
+ # @done-coding/cli-extract
2
+
3
+ ```
4
+ 信息提取命令行工具
5
+ ```
6
+
7
+ ## 使用
8
+
9
+ ``` bash
10
+ npm install @done-coding/cli-extract
11
+ ```
package/es/cli.mjs ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { c as m } from "./index-2f3f403a.js";
3
+ import "@done-coding/cli-utils";
4
+ import "./types-a1ee6691-9629699d.js";
5
+ import "node:path";
6
+ import "node:fs";
7
+ import "@done-coding/cli-template";
8
+ m();
package/es/helpers.mjs ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ import { E as e, a as n } from "./types-a1ee6691-9629699d.js";
3
+ import "@done-coding/cli-utils";
4
+ import "node:path";
5
+ import "node:fs";
6
+ import { OutputModeEnum as t } from "@done-coding/cli-template";
7
+ const i = {
8
+ name: "${name}",
9
+ version: "${version}",
10
+ description: "${description}",
11
+ cliConfig: {
12
+ namespaceDir: "${cliConfig.namespaceDir}",
13
+ moduleName: "${cliConfig.moduleName}"
14
+ }
15
+ }, u = {
16
+ extractInput: {
17
+ "./package.json": {
18
+ name: {
19
+ type: e.JSON_INJECT,
20
+ inject: {
21
+ type: n.READ
22
+ }
23
+ },
24
+ description: {
25
+ type: e.JSON_INJECT,
26
+ inject: {
27
+ type: n.READ
28
+ }
29
+ },
30
+ version: {
31
+ type: e.JSON_INJECT,
32
+ inject: {
33
+ type: n.READ
34
+ }
35
+ },
36
+ "cliConfig.namespaceDir": {
37
+ type: e.JSON_INJECT,
38
+ inject: {
39
+ type: n.FIXED,
40
+ value: ".done-coding"
41
+ }
42
+ },
43
+ "cliConfig.moduleName": {
44
+ type: e.JSON_INJECT,
45
+ inject: {
46
+ sourceKey: "name",
47
+ type: n.REG,
48
+ pattern: /@done-coding\/cli-([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)/.source,
49
+ replaceValue: "$1"
50
+ }
51
+ }
52
+ }
53
+ },
54
+ extractOutput: {
55
+ list: [
56
+ {
57
+ mode: t.OVERWRITE,
58
+ inputData: JSON.stringify(i, null, 2),
59
+ output: "./src/extractInfo.json"
60
+ }
61
+ ]
62
+ }
63
+ }, o = {
64
+ npm: {
65
+ aliasInfo: [
66
+ {
67
+ packageJson: {
68
+ name: "${organizationAbbr}-${moduleName}",
69
+ bin: "${binEntry}",
70
+ scripts: {}
71
+ }
72
+ }
73
+ ]
74
+ }
75
+ }, l = {
76
+ extractInput: {
77
+ "./package.json": {
78
+ name: {
79
+ type: e.JSON_INJECT,
80
+ inject: {
81
+ type: n.READ
82
+ }
83
+ },
84
+ bin: {
85
+ type: e.JSON_INJECT,
86
+ inject: {
87
+ type: n.READ
88
+ }
89
+ },
90
+ organization: {
91
+ type: e.FIXED,
92
+ value: "done-coding"
93
+ },
94
+ /** 组织名缩写 */
95
+ organizationAbbr: {
96
+ type: e.FIXED,
97
+ value: "dc"
98
+ },
99
+ binEntry: {
100
+ type: e.FIXED,
101
+ value: "es/cli.mjs"
102
+ },
103
+ moduleName: {
104
+ type: e.JSON_INJECT,
105
+ inject: {
106
+ sourceKey: "name",
107
+ type: n.REG,
108
+ pattern: /@done-coding\/cli-([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)/.source,
109
+ replaceValue: "$1"
110
+ }
111
+ }
112
+ }
113
+ },
114
+ extractOutput: {
115
+ list: [
116
+ {
117
+ mode: t.OVERWRITE,
118
+ inputData: JSON.stringify(o, null, 2),
119
+ output: "./.done-coding/publish.json"
120
+ }
121
+ ]
122
+ }
123
+ };
124
+ export {
125
+ l as doneCodingPublishAliasInfo,
126
+ u as doneCodingSeriesCliInjectInfo
127
+ };
@@ -0,0 +1,326 @@
1
+ #!/usr/bin/env node
2
+ import { log as r, _get as O, _curry as D, createSubcommand as h, getConfigFileCommonOptions as j, initHandlerCommon as F, readConfigFile as v, _set as H, createMainCommand as V } from "@done-coding/cli-utils";
3
+ import { a as s, e as m, E as u, S as l } from "./types-a1ee6691-9629699d.js";
4
+ import R from "node:path";
5
+ import C from "node:fs";
6
+ import { OutputModeEnum as L, batchCompileHandler as W } from "@done-coding/cli-template";
7
+ const N = ({
8
+ sourceJson: e,
9
+ targetKey: n,
10
+ keyConfig: o
11
+ }) => {
12
+ let t;
13
+ typeof o == "string" ? t = {
14
+ type: s.FIXED,
15
+ value: o
16
+ } : t = o;
17
+ const { type: a = s.READ } = t;
18
+ switch (a) {
19
+ case s.REG: {
20
+ const { sourceKey: c, pattern: f, replaceValue: E, flags: g } = t, d = new RegExp(f, g ?? void 0), i = O(e, c);
21
+ return typeof i == "string" ? i.replace(d, E) : (r.warn(
22
+ `${i}不是字符串类型,无法使用正则表达式进行替换,此处将直接返回原值`
23
+ ), i);
24
+ }
25
+ case s.FIXED: {
26
+ const { value: c } = t;
27
+ return c;
28
+ }
29
+ case s.READ: {
30
+ const { sourceKey: c = n } = t;
31
+ return O(e, c);
32
+ }
33
+ default: {
34
+ r.warn(`未知的配置类型${a}`);
35
+ return;
36
+ }
37
+ }
38
+ }, $ = {
39
+ sourceFilePath: "./package.json",
40
+ keyConfigMap: {
41
+ name: {
42
+ type: s.READ
43
+ },
44
+ version: {
45
+ type: s.READ
46
+ },
47
+ description: {
48
+ type: s.READ
49
+ }
50
+ },
51
+ injectFilePath: "./src/injectInfo.json"
52
+ }, w = {
53
+ name: "@done-coding/cli-inject",
54
+ version: "0.5.8",
55
+ description: "信息(JSON)注入命令行工具",
56
+ cliConfig: {
57
+ namespaceDir: ".done-coding",
58
+ moduleName: "inject"
59
+ }
60
+ }, {
61
+ cliConfig: { namespaceDir: U, moduleName: X }
62
+ } = w, K = `./${U}/${X}`, x = `${K}.json`, q = () => j({
63
+ configPathDefault: x
64
+ }), z = async (e) => F($, e, {
65
+ onFileGenerated: () => {
66
+ r.info("文件生成成功");
67
+ }
68
+ }), B = () => ({
69
+ ...j({
70
+ configPathDefault: x
71
+ })
72
+ }), Q = async ({
73
+ rootDir: e = process.cwd(),
74
+ config: n = $,
75
+ keyConfigMap: o = {}
76
+ } = {}) => {
77
+ const {
78
+ sourceFilePath: t,
79
+ keyConfigMap: a,
80
+ injectFilePath: c
81
+ } = n, f = {
82
+ ...a,
83
+ ...o
84
+ };
85
+ if (!t.endsWith(".json"))
86
+ return r.error("源文件必须是json"), process.exit(1);
87
+ if (!c.endsWith(".json"))
88
+ return r.error("注入文件必须是json"), process.exit(1);
89
+ const E = R.resolve(e, t), g = C.readFileSync(E, "utf-8"), d = JSON.parse(g), i = Object.entries(f).reduce(
90
+ (I, [T, P]) => {
91
+ const M = N({ sourceJson: d, targetKey: T, keyConfig: P });
92
+ return H(I, T, M), I;
93
+ },
94
+ {}
95
+ ), p = R.resolve(e, c), y = JSON.stringify(i, null, 2);
96
+ if (C.existsSync(p)) {
97
+ const I = C.readFileSync(p, "utf-8");
98
+ if (y === I)
99
+ return r.skip("注入文件已存在且内容相同,无需重复注入"), i;
100
+ r.stage("文件内容变化,开始覆盖注入文件");
101
+ } else
102
+ r.stage("开始注入文件");
103
+ C.writeFileSync(p, y), r.success(`文件注入成功: ${p}`), r.info(y);
104
+ }, Y = async (e) => {
105
+ const n = await v(e);
106
+ if (!n)
107
+ return r.error("配置文件为空"), process.exit(1);
108
+ const { rootDir: o } = e;
109
+ await Q({ rootDir: o, config: n });
110
+ }, J = async (e, n) => e === m.INIT ? z(n) : e === m.GENERATE ? Y(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
111
+ version: Z,
112
+ description: ee,
113
+ cliConfig: { moduleName: Te }
114
+ } = w, ne = {
115
+ command: m.INIT,
116
+ describe: "初始化提取配置文件",
117
+ options: q(),
118
+ handler: D(J)(
119
+ m.INIT
120
+ )
121
+ }, te = {
122
+ command: m.GENERATE,
123
+ describe: "提取信息",
124
+ options: B(),
125
+ handler: D(J)(
126
+ m.GENERATE
127
+ )
128
+ };
129
+ [ne, te].map(
130
+ h
131
+ );
132
+ const oe = {
133
+ name: "${name}",
134
+ version: "${version}",
135
+ description: "${description}"
136
+ }, re = {
137
+ extractInput: {
138
+ "./package.json": {
139
+ name: {
140
+ type: u.JSON_INJECT,
141
+ inject: {
142
+ type: s.READ
143
+ }
144
+ },
145
+ description: {
146
+ type: u.JSON_INJECT,
147
+ inject: {
148
+ type: s.READ
149
+ }
150
+ },
151
+ version: {
152
+ type: u.JSON_INJECT,
153
+ inject: {
154
+ type: s.READ
155
+ }
156
+ }
157
+ },
158
+ "./README.md": {
159
+ docDescription: {
160
+ type: u.REG,
161
+ pattern: /#\s*([^`])+```([^`]+)```/.source,
162
+ replaceValue: ""
163
+ },
164
+ usage: {
165
+ type: u.REG,
166
+ pattern: /##\s*使用\s*```([^`]+)```/.source,
167
+ replaceValue: "$1"
168
+ }
169
+ }
170
+ },
171
+ extractOutput: {
172
+ list: [
173
+ {
174
+ mode: L.OVERWRITE,
175
+ inputData: JSON.stringify(oe, null, 2),
176
+ output: "./src/extractInfo.json"
177
+ }
178
+ ]
179
+ }
180
+ }, S = {
181
+ name: "@done-coding/cli-extract",
182
+ version: "0.1.8",
183
+ description: "信息提取命令行工具",
184
+ cliConfig: {
185
+ namespaceDir: ".done-coding",
186
+ moduleName: "extract"
187
+ }
188
+ }, {
189
+ cliConfig: { namespaceDir: se, moduleName: ce }
190
+ } = S, ie = `./${se}/${ce}`, b = `${ie}.json5`, ae = () => j({
191
+ configPathDefault: b
192
+ }), ue = async (e) => F(re, e, {
193
+ onFileGenerated: () => {
194
+ r.info("文件生成成功");
195
+ }
196
+ }), de = ({
197
+ input: e,
198
+ rootDir: n
199
+ }) => {
200
+ const o = R.resolve(n, e), t = C.readFileSync(o, "utf-8");
201
+ return e.endsWith(".json") || e.endsWith(".json5") ? JSON.parse(t) : t;
202
+ }, pe = (e) => typeof e == "object" && !!e, me = ({
203
+ content: e,
204
+ targetKey: n,
205
+ keyConfig: o
206
+ }) => {
207
+ const { type: t, ...a } = o;
208
+ switch (t) {
209
+ case u.REG: {
210
+ if (typeof e != "string")
211
+ throw new Error(`${t} 类型的keyConfig需要content为字符串`);
212
+ return N({
213
+ sourceJson: {
214
+ [n]: e
215
+ },
216
+ targetKey: n,
217
+ keyConfig: {
218
+ ...a,
219
+ type: s.REG,
220
+ sourceKey: n
221
+ }
222
+ });
223
+ }
224
+ case u.JSON_INJECT: {
225
+ if (!pe(e))
226
+ throw new Error(`${t} 类型的keyConfig需要content为json`);
227
+ return N({
228
+ sourceJson: e,
229
+ targetKey: n,
230
+ keyConfig: o.inject
231
+ });
232
+ }
233
+ case u.FIXED:
234
+ return N({
235
+ sourceJson: {},
236
+ targetKey: n,
237
+ keyConfig: {
238
+ ...a,
239
+ type: s.FIXED
240
+ }
241
+ });
242
+ default:
243
+ throw new Error(`不支持的类型${t}`);
244
+ }
245
+ }, le = () => ({
246
+ ...j({
247
+ configPathDefault: b
248
+ })
249
+ }), fe = async ({
250
+ rootDir: e = process.cwd(),
251
+ config: n
252
+ }) => {
253
+ const { extractInput: o, extractOutput: t } = n, a = Object.entries(o).reduce(
254
+ (c, [f, E]) => {
255
+ const g = de({
256
+ rootDir: e,
257
+ input: f
258
+ });
259
+ return Object.entries(E).reduce(
260
+ (d, [i, p]) => {
261
+ const y = me({
262
+ content: g,
263
+ targetKey: i,
264
+ keyConfig: p
265
+ });
266
+ return d[i] = y, d;
267
+ },
268
+ c
269
+ );
270
+ },
271
+ {}
272
+ );
273
+ await W(
274
+ {
275
+ rootDir: e,
276
+ extraEnvData: a
277
+ },
278
+ t
279
+ );
280
+ }, Ee = async (e) => {
281
+ const n = await v(e);
282
+ if (!n)
283
+ return r.error("配置文件为空"), process.exit(1);
284
+ const { rootDir: o } = e;
285
+ await fe({ rootDir: o, config: n });
286
+ }, G = async (e, n) => e === l.INIT ? ue(n) : e === l.GENERATE ? Ee(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
287
+ version: ge,
288
+ description: ye,
289
+ cliConfig: { moduleName: A }
290
+ } = S, Ce = {
291
+ command: l.INIT,
292
+ describe: "初始化提取配置文件",
293
+ options: ae(),
294
+ handler: D(G)(
295
+ l.INIT
296
+ )
297
+ }, Ie = {
298
+ command: l.GENERATE,
299
+ describe: "提取信息",
300
+ options: le(),
301
+ handler: D(G)(
302
+ l.GENERATE
303
+ )
304
+ }, _ = {
305
+ describe: ye,
306
+ version: ge,
307
+ subcommands: [Ce, Ie].map(
308
+ h
309
+ ),
310
+ demandCommandCount: 1
311
+ }, k = (e = !1) => {
312
+ const n = e ? A : void 0, o = `$0${e ? ` ${A}` : ""} <command> [options]`;
313
+ return { command: n, usage: o };
314
+ }, Oe = async () => V({
315
+ ..._,
316
+ ...k()
317
+ }), Ae = () => h({
318
+ ..._,
319
+ ...k(!0)
320
+ });
321
+ export {
322
+ Ae as a,
323
+ Oe as c,
324
+ fe as g,
325
+ G as h
326
+ };
package/es/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { a as n, g as p, h as s } from "./index-2f3f403a.js";
3
+ import { E as u, S as c } from "./types-a1ee6691-9629699d.js";
4
+ import "@done-coding/cli-utils";
5
+ import "node:path";
6
+ import "node:fs";
7
+ import "@done-coding/cli-template";
8
+ export {
9
+ u as ExtractTypeEnum,
10
+ c as SubcommandEnum,
11
+ n as crateAsSubcommand,
12
+ p as generateFile,
13
+ s as handler
14
+ };
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ var i = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(i || {}), E = /* @__PURE__ */ ((e) => (e.REG = "reg", e.JSON_INJECT = "json-inject", e.FIXED = "fixed", e))(E || {}), n = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(n || {}), r = /* @__PURE__ */ ((e) => (e.REG = "reg", e.FIXED = "fixed", e.READ = "read", e))(r || {});
3
+ export {
4
+ E,
5
+ i as S,
6
+ r as a,
7
+ n as e
8
+ };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "done-coding-extract",
3
+ "version": "0.1.8",
4
+ "description": "信息提取命令行工具",
5
+ "private": false,
6
+ "module": "es/index.mjs",
7
+ "type": "module",
8
+ "types": "types/index.d.ts",
9
+ "bin": "es/cli.mjs",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./es/index.mjs",
13
+ "types": "./types/index.d.ts"
14
+ },
15
+ "./helpers": {
16
+ "import": "./es/helpers.mjs",
17
+ "types": "./types/helpers.d.ts"
18
+ }
19
+ },
20
+ "typesVersions": {
21
+ "*": {
22
+ "helpers": [
23
+ "./types/helpers.d.ts"
24
+ ]
25
+ }
26
+ },
27
+ "files": [
28
+ "es",
29
+ "lib",
30
+ "types"
31
+ ],
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://gitee.com/justsosu/done-coding-cli.git",
35
+ "directory": "packages/extract"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/"
40
+ },
41
+ "author": "JustSoSu",
42
+ "license": "MIT",
43
+ "sideEffects": false,
44
+ "devDependencies": {
45
+ "@done-coding/cli-inject": "^0.5.8",
46
+ "@types/node": "^18.0.0",
47
+ "@types/yargs": "^17.0.28",
48
+ "rimraf": "^6.0.1",
49
+ "typescript": "^5.2.2",
50
+ "vite": "^4.4.11",
51
+ "vite-plugin-dts": "^3.6.0"
52
+ },
53
+ "engines": {
54
+ "node": ">=18.0.0"
55
+ },
56
+ "dependencies": {
57
+ "@done-coding/cli-template": "0.7.8",
58
+ "@done-coding/cli-utils": "^0.7.0"
59
+ },
60
+ "gitHead": "b4fb4f2380a14f72597a1dbfd1bbce22287ef02f",
61
+ "scripts": {}
62
+ }
package/types/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { GenerateOptions, InitOptions } from './utils';
2
+ import { SubcommandEnum } from './utils';
3
+ import type { CliHandlerArgv } from "@done-coding/cli-utils";
4
+ /** 命令处理函数 */
5
+ export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<InitOptions | GenerateOptions>) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { type ExtractConfig } from "../utils";
2
+ /** done-coding 系列cli 注入信息 */
3
+ export declare const doneCodingSeriesCliInjectInfo: ExtractConfig;
4
+ /** done-coding 系列cli 别名发布信息 */
5
+ export declare const doneCodingPublishAliasInfo: ExtractConfig;
@@ -0,0 +1 @@
1
+ export * from './helpers-assets/done-coding';
@@ -0,0 +1,4 @@
1
+ export { handler } from "./handler";
2
+ export { generateFile } from "./utils";
3
+ export { crateAsSubcommand } from "./main";
4
+ export * from './utils/types';
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ "name": "@done-coding/cli-extract",
3
+ "version": "0.1.8",
4
+ "description": "信息提取命令行工具",
5
+ "cliConfig": {
6
+ "namespaceDir": ".done-coding",
7
+ "moduleName": "extract"
8
+ }
9
+ };
10
+
11
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { type ExtractConfig } from '../utils';
2
+ export declare const config: ExtractConfig;
@@ -0,0 +1,9 @@
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<{}, {}>;
@@ -0,0 +1,11 @@
1
+ import { type CliHandlerArgv, type CliInfo } from "@done-coding/cli-utils";
2
+ import type { ExtractConfig, GenerateOptions } from "./types";
3
+ /** 获取生成命令选项 */
4
+ export declare const getGenerateOptions: () => CliInfo["options"];
5
+ /** 将提取的信息生成文件 */
6
+ export declare const generateFile: ({ rootDir, config, }: {
7
+ rootDir?: string | undefined;
8
+ config: ExtractConfig;
9
+ }) => Promise<void>;
10
+ /** 提取文件命令处理器 */
11
+ export declare const generateHandler: (argv: CliHandlerArgv<GenerateOptions>) => Promise<undefined>;
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./init";
3
+ export * from "./generate";
4
+ export * from "./path";
@@ -0,0 +1,7 @@
1
+ /// <reference types="yargs" />
2
+ import type { CliHandlerArgv } from "@done-coding/cli-utils";
3
+ import type { InitOptions } from "./types";
4
+ /** 获取初始化选项 */
5
+ export declare const getInitOptions: () => Record<keyof import("@done-coding/cli-utils").ConfigFileCommonOptions, import("yargs").Options>;
6
+ /** 初始化命令处理器 */
7
+ export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ /** 模块配置相对路径 */
2
+ export declare const MODULE_CONFIG_RELATIVE_PATH: string;
3
+ /** 模块默认配置文件相对路径 */
4
+ export declare const MODULE_DEFAULT_CONFIG_RELATIVE_PATH: string;
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,64 @@
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 type GenerateOptions = ReadConfigFileOptions;