done-coding-inject 0.5.9-alpha.0 → 0.5.10-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-334ebd43.js → index-ec13d757.js} +36 -36
- package/es/index.mjs +1 -1
- package/package.json +3 -3
- package/types/cli.d.ts +1 -2
- package/types/helpers.d.ts +77 -1
- package/types/index.d.ts +136 -4
- package/types/config/index.d.ts +0 -6
- package/types/handlers/generate.d.ts +0 -17
- 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 -6
- package/types/injectInfo.json.d.ts +0 -11
- package/types/main.d.ts +0 -9
- package/types/types/index.d.ts +0 -87
- package/types/utils/index.d.ts +0 -2
- package/types/utils/path.d.ts +0 -7
- package/types/utils/resolve.d.ts +0 -10
package/es/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { I as r, S as d } from "./index-a1ee6691.js";
|
|
3
|
-
import { log as o, _get as I, initHandlerCommon as b, getConfigFileCommonOptions as
|
|
3
|
+
import { log as o, _get as I, initHandlerCommon as b, getConfigFileCommonOptions as $, _set as w, readConfigFile as _, createSubcommand as A, createMainCommand as k } from "@done-coding/cli-utils";
|
|
4
4
|
import j from "node:path";
|
|
5
|
-
import
|
|
5
|
+
import m from "node:fs";
|
|
6
6
|
const M = ({
|
|
7
7
|
sourceJson: e,
|
|
8
8
|
targetKey: n,
|
|
@@ -36,7 +36,7 @@ const M = ({
|
|
|
36
36
|
}
|
|
37
37
|
}, h = {
|
|
38
38
|
name: "@done-coding/cli-inject",
|
|
39
|
-
version: "0.5.
|
|
39
|
+
version: "0.5.10-alpha.0",
|
|
40
40
|
description: "信息(JSON)注入命令行工具",
|
|
41
41
|
cliConfig: {
|
|
42
42
|
namespaceDir: ".done-coding",
|
|
@@ -44,7 +44,7 @@ const M = ({
|
|
|
44
44
|
}
|
|
45
45
|
}, {
|
|
46
46
|
cliConfig: { namespaceDir: x, moduleName: G }
|
|
47
|
-
} = h, L = `./${x}/${G}`, N = `${L}.json`,
|
|
47
|
+
} = h, L = `./${x}/${G}`, N = `${L}.json`, J = {
|
|
48
48
|
sourceFilePath: "./package.json",
|
|
49
49
|
keyConfigMap: {
|
|
50
50
|
name: {
|
|
@@ -58,22 +58,22 @@ const M = ({
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
injectFilePath: "./src/injectInfo.json"
|
|
61
|
-
}, J = () =>
|
|
61
|
+
}, R = J, U = () => $({
|
|
62
62
|
configPathDefault: N
|
|
63
63
|
}), O = async (e) => b(R, e, {
|
|
64
64
|
onFileGenerated: () => {
|
|
65
65
|
o.info("文件生成成功");
|
|
66
66
|
}
|
|
67
|
-
}),
|
|
67
|
+
}), V = {
|
|
68
68
|
command: d.INIT,
|
|
69
69
|
describe: "初始化配置文件",
|
|
70
|
-
options:
|
|
70
|
+
options: U(),
|
|
71
71
|
handler: O
|
|
72
|
-
},
|
|
73
|
-
|
|
72
|
+
}, H = () => ({
|
|
73
|
+
...$({
|
|
74
74
|
configPathDefault: N
|
|
75
75
|
})
|
|
76
|
-
}),
|
|
76
|
+
}), K = async ({
|
|
77
77
|
rootDir: e = process.cwd(),
|
|
78
78
|
config: n = R,
|
|
79
79
|
keyConfigMap: t = {}
|
|
@@ -90,33 +90,33 @@ const M = ({
|
|
|
90
90
|
return o.error("源文件必须是json"), process.exit(1);
|
|
91
91
|
if (!c.endsWith(".json"))
|
|
92
92
|
return o.error("注入文件必须是json"), process.exit(1);
|
|
93
|
-
const p = j.resolve(e, s), g =
|
|
94
|
-
(
|
|
93
|
+
const p = j.resolve(e, s), g = m.readFileSync(p, "utf-8"), y = JSON.parse(g), a = Object.entries(f).reduce(
|
|
94
|
+
(u, [F, P]) => {
|
|
95
95
|
const T = M({ sourceJson: y, targetKey: F, keyConfig: P });
|
|
96
|
-
return w(
|
|
96
|
+
return w(u, F, T), u;
|
|
97
97
|
},
|
|
98
98
|
{}
|
|
99
99
|
), l = j.resolve(e, c), E = JSON.stringify(a, null, 2);
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
if (E ===
|
|
100
|
+
if (m.existsSync(l)) {
|
|
101
|
+
const u = m.readFileSync(l, "utf-8");
|
|
102
|
+
if (E === u)
|
|
103
103
|
return o.skip("注入文件已存在且内容相同,无需重复注入"), a;
|
|
104
104
|
o.stage("文件内容变化,开始覆盖注入文件");
|
|
105
105
|
} else
|
|
106
106
|
o.stage("开始注入文件");
|
|
107
|
-
|
|
107
|
+
m.writeFileSync(l, E), o.success(`文件注入成功: ${l}`), o.info(E);
|
|
108
108
|
}, C = async (e) => {
|
|
109
109
|
const n = await _(e);
|
|
110
110
|
if (!n)
|
|
111
111
|
return o.error("配置文件为空"), process.exit(1);
|
|
112
112
|
const { rootDir: t } = e;
|
|
113
|
-
await
|
|
114
|
-
},
|
|
113
|
+
await K({ rootDir: t, config: n });
|
|
114
|
+
}, W = {
|
|
115
115
|
command: d.GENERATE,
|
|
116
116
|
describe: "生成文件",
|
|
117
|
-
options:
|
|
117
|
+
options: H(),
|
|
118
118
|
handler: C
|
|
119
|
-
},
|
|
119
|
+
}, Z = async (e, n) => {
|
|
120
120
|
switch (e) {
|
|
121
121
|
case d.INIT:
|
|
122
122
|
return O(n);
|
|
@@ -125,33 +125,33 @@ const M = ({
|
|
|
125
125
|
default:
|
|
126
126
|
return C(n);
|
|
127
127
|
}
|
|
128
|
-
}, { version:
|
|
129
|
-
describe:
|
|
130
|
-
version:
|
|
131
|
-
subcommands: [
|
|
132
|
-
|
|
128
|
+
}, { version: X, description: q } = h, S = {
|
|
129
|
+
describe: q,
|
|
130
|
+
version: X,
|
|
131
|
+
subcommands: [V, W].map(
|
|
132
|
+
A
|
|
133
133
|
),
|
|
134
134
|
demandCommandCount: 1
|
|
135
135
|
}, {
|
|
136
|
-
cliConfig: { moduleName:
|
|
136
|
+
cliConfig: { moduleName: D }
|
|
137
137
|
} = h, v = (e = !1) => {
|
|
138
|
-
const n = e ?
|
|
138
|
+
const n = e ? D : void 0, t = `$0${e ? ` ${D}` : ""} <command> [options]`;
|
|
139
139
|
return { command: n, usage: t };
|
|
140
|
-
},
|
|
140
|
+
}, ee = async () => k({
|
|
141
141
|
...S,
|
|
142
142
|
...v()
|
|
143
|
-
}),
|
|
143
|
+
}), ne = () => A({
|
|
144
144
|
...S,
|
|
145
145
|
...v(!0)
|
|
146
146
|
});
|
|
147
147
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
ne as a,
|
|
149
|
+
V as b,
|
|
150
|
+
ee as c,
|
|
151
151
|
C as d,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
W as e,
|
|
153
|
+
Z as f,
|
|
154
|
+
K as g,
|
|
155
155
|
O as h,
|
|
156
156
|
S as i,
|
|
157
157
|
M as k
|
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as r, a as i, e as s, g as t, d, f as l, b as f, h as p, k as C } from "./index-
|
|
2
|
+
import { i as r, a as i, e as s, g as t, d, f as l, b as f, h as p, k as C } from "./index-ec13d757.js";
|
|
3
3
|
import { I as g, S as u } from "./index-a1ee6691.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-inject",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10-alpha.0",
|
|
4
4
|
"description": "信息(JSON)注入命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"node": ">=18.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@done-coding/cli-utils": "^0.7.0"
|
|
55
|
+
"@done-coding/cli-utils": "^0.7.1-alpha.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "3376f5fbbf8b87c791316e76df06028afd650e08",
|
|
58
58
|
"scripts": {}
|
|
59
59
|
}
|
package/types/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
export { }
|
package/types/helpers.d.ts
CHANGED
|
@@ -1 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
/** done-coding-cli 注入配置 */
|
|
2
|
+
export declare const doneCodingCliConfig: InjectConfig;
|
|
3
|
+
|
|
4
|
+
/** 注入配置 */
|
|
5
|
+
declare interface InjectConfig {
|
|
6
|
+
/** json文件相对路径 */
|
|
7
|
+
sourceFilePath: string;
|
|
8
|
+
/** 注入的key路径 */
|
|
9
|
+
keyConfigMap: Record<string, InjectKeyConfig>;
|
|
10
|
+
/** 注入信息文件路径 */
|
|
11
|
+
injectFilePath: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 注入配置
|
|
16
|
+
* ---
|
|
17
|
+
* 为 string 时 解析为 InjectKeyConfigFixed, 其中InjectKeyConfigFixed.value = string
|
|
18
|
+
*/
|
|
19
|
+
declare type InjectKeyConfig = InjectKeyConfigReg | (InjectKeyConfigFixed | string) | InjectKeyConfigRead;
|
|
20
|
+
|
|
21
|
+
/** 注入配置基础 */
|
|
22
|
+
declare interface InjectKeyConfigBase<T extends InjectTypeEnum> {
|
|
23
|
+
/**
|
|
24
|
+
* 提取类型
|
|
25
|
+
*/
|
|
26
|
+
type: T;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 注入配置-固定值类型 */
|
|
30
|
+
declare interface InjectKeyConfigFixed extends InjectKeyConfigBase<InjectTypeEnum.FIXED> {
|
|
31
|
+
/** 值 */
|
|
32
|
+
value: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 注入配置-读取类型 */
|
|
36
|
+
declare interface InjectKeyConfigRead extends InjectKeyConfigBase<InjectTypeEnum.READ> {
|
|
37
|
+
/** 源key */
|
|
38
|
+
sourceKey?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 注入配置-正则类型 */
|
|
42
|
+
declare interface InjectKeyConfigReg extends InjectKeyConfigBase<InjectTypeEnum.REG> {
|
|
43
|
+
/**
|
|
44
|
+
* 正则表达式字符串
|
|
45
|
+
* ----
|
|
46
|
+
* 不带flags
|
|
47
|
+
*/
|
|
48
|
+
pattern: string;
|
|
49
|
+
/** 正则匹配的 flags */
|
|
50
|
+
flags?: string;
|
|
51
|
+
/**
|
|
52
|
+
* 替换值
|
|
53
|
+
* ---
|
|
54
|
+
* replace 第二个参数
|
|
55
|
+
*/
|
|
56
|
+
replaceValue: string;
|
|
57
|
+
/** 源key */
|
|
58
|
+
sourceKey: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 配置类型枚举 */
|
|
62
|
+
declare enum InjectTypeEnum {
|
|
63
|
+
/**
|
|
64
|
+
* 正则表达式 类型
|
|
65
|
+
*/
|
|
66
|
+
REG = "reg",
|
|
67
|
+
/**
|
|
68
|
+
* 固定值 类型
|
|
69
|
+
*/
|
|
70
|
+
FIXED = "fixed",
|
|
71
|
+
/**
|
|
72
|
+
* 读取 类型
|
|
73
|
+
*/
|
|
74
|
+
READ = "read"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { }
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { CliHandlerArgv } from '@done-coding/cli-utils';
|
|
2
|
+
import { CliInfo } from '@done-coding/cli-utils';
|
|
3
|
+
import { CommandModule } from 'yargs';
|
|
4
|
+
import type { InitConfigFileOptions } from '@done-coding/cli-utils';
|
|
5
|
+
import type { ReadConfigFileOptions } from '@done-coding/cli-utils';
|
|
6
|
+
import { SubCliInfo } from '@done-coding/cli-utils';
|
|
7
|
+
|
|
8
|
+
export declare const commandCliInfo: Omit<CliInfo, "usage">;
|
|
9
|
+
|
|
10
|
+
/** 作为子命令创建 */
|
|
11
|
+
export declare const crateAsSubcommand: () => CommandModule<{}, {}>;
|
|
12
|
+
|
|
13
|
+
export declare const generateCommandCliInfo: SubCliInfo;
|
|
14
|
+
|
|
15
|
+
/** 生成注入信息文件 */
|
|
16
|
+
export declare const generateFile: ({ rootDir, config, keyConfigMap: extractKeyConfigMap, }?: {
|
|
17
|
+
rootDir?: string | undefined;
|
|
18
|
+
config?: InjectConfig | undefined;
|
|
19
|
+
keyConfigMap?: Record<string, InjectKeyConfig> | undefined;
|
|
20
|
+
}) => Promise<{} | undefined>;
|
|
21
|
+
|
|
22
|
+
/** 提取文件命令处理器 */
|
|
23
|
+
export declare const generateHandler: (argv: CliHandlerArgv<GenerateOptions>) => Promise<undefined>;
|
|
24
|
+
|
|
25
|
+
/** 生成选项 */
|
|
26
|
+
export declare type GenerateOptions = ReadConfigFileOptions;
|
|
27
|
+
|
|
28
|
+
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void>;
|
|
29
|
+
|
|
30
|
+
export declare const initCommandCliInfo: SubCliInfo;
|
|
31
|
+
|
|
32
|
+
/** 初始化命令处理器 */
|
|
33
|
+
export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
|
|
34
|
+
|
|
35
|
+
/** 初始化选项 */
|
|
36
|
+
export declare type InitOptions = InitConfigFileOptions;
|
|
37
|
+
|
|
38
|
+
/** 注入配置 */
|
|
39
|
+
export declare interface InjectConfig {
|
|
40
|
+
/** json文件相对路径 */
|
|
41
|
+
sourceFilePath: string;
|
|
42
|
+
/** 注入的key路径 */
|
|
43
|
+
keyConfigMap: Record<string, InjectKeyConfig>;
|
|
44
|
+
/** 注入信息文件路径 */
|
|
45
|
+
injectFilePath: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 注入配置
|
|
50
|
+
* ---
|
|
51
|
+
* 为 string 时 解析为 InjectKeyConfigFixed, 其中InjectKeyConfigFixed.value = string
|
|
52
|
+
*/
|
|
53
|
+
export declare type InjectKeyConfig = InjectKeyConfigReg | (InjectKeyConfigFixed | string) | InjectKeyConfigRead;
|
|
54
|
+
|
|
55
|
+
/** 注入配置基础 */
|
|
56
|
+
export declare interface InjectKeyConfigBase<T extends InjectTypeEnum> {
|
|
57
|
+
/**
|
|
58
|
+
* 提取类型
|
|
59
|
+
*/
|
|
60
|
+
type: T;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 注入配置-固定值类型 */
|
|
64
|
+
export declare interface InjectKeyConfigFixed extends InjectKeyConfigBase<InjectTypeEnum.FIXED> {
|
|
65
|
+
/** 值 */
|
|
66
|
+
value: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 注入配置-读取类型 */
|
|
70
|
+
export declare interface InjectKeyConfigRead extends InjectKeyConfigBase<InjectTypeEnum.READ> {
|
|
71
|
+
/** 源key */
|
|
72
|
+
sourceKey?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 注入配置-正则类型 */
|
|
76
|
+
export declare interface InjectKeyConfigReg extends InjectKeyConfigBase<InjectTypeEnum.REG> {
|
|
77
|
+
/**
|
|
78
|
+
* 正则表达式字符串
|
|
79
|
+
* ----
|
|
80
|
+
* 不带flags
|
|
81
|
+
*/
|
|
82
|
+
pattern: string;
|
|
83
|
+
/** 正则匹配的 flags */
|
|
84
|
+
flags?: string;
|
|
85
|
+
/**
|
|
86
|
+
* 替换值
|
|
87
|
+
* ---
|
|
88
|
+
* replace 第二个参数
|
|
89
|
+
*/
|
|
90
|
+
replaceValue: string;
|
|
91
|
+
/** 源key */
|
|
92
|
+
sourceKey: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 配置类型枚举 */
|
|
96
|
+
export declare enum InjectTypeEnum {
|
|
97
|
+
/**
|
|
98
|
+
* 正则表达式 类型
|
|
99
|
+
*/
|
|
100
|
+
REG = "reg",
|
|
101
|
+
/**
|
|
102
|
+
* 固定值 类型
|
|
103
|
+
*/
|
|
104
|
+
FIXED = "fixed",
|
|
105
|
+
/**
|
|
106
|
+
* 读取 类型
|
|
107
|
+
*/
|
|
108
|
+
READ = "read"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** key配置解析-获取最终值 */
|
|
112
|
+
export declare const keyConfigResolve: ({ sourceJson, targetKey, keyConfig: keyConfigInit, }: {
|
|
113
|
+
sourceJson: Record<string, any>;
|
|
114
|
+
targetKey: string;
|
|
115
|
+
keyConfig: InjectKeyConfig;
|
|
116
|
+
}) => any;
|
|
117
|
+
|
|
118
|
+
/** @deprecated */
|
|
119
|
+
export declare interface Options {
|
|
120
|
+
/** json文件相对路径 */
|
|
121
|
+
sourceJsonFilePath: string;
|
|
122
|
+
/** 注入的key路径 */
|
|
123
|
+
injectKeyPath: string[];
|
|
124
|
+
/** 注入信息文件路径 */
|
|
125
|
+
injectInfoFilePath: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** 子命令枚举 */
|
|
129
|
+
export declare enum SubcommandEnum {
|
|
130
|
+
/** 初始化提取配置文件 */
|
|
131
|
+
INIT = "init",
|
|
132
|
+
/** 生成文件 */
|
|
133
|
+
GENERATE = "generate"
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { }
|
package/types/config/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
2
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
3
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
4
|
-
import type { SubCliInfo } from "@done-coding/cli-utils";
|
|
5
|
-
import { type CliHandlerArgv, type CliInfo } from "@done-coding/cli-utils";
|
|
6
|
-
import type { GenerateOptions, InjectConfig } from "../types";
|
|
7
|
-
/** 获取生成命令选项 */
|
|
8
|
-
export declare const getOptions: () => CliInfo["options"];
|
|
9
|
-
/** 生成注入信息文件 */
|
|
10
|
-
export declare const generateFile: ({ rootDir, config, keyConfigMap: extractKeyConfigMap, }?: {
|
|
11
|
-
rootDir?: string | undefined;
|
|
12
|
-
config?: InjectConfig | undefined;
|
|
13
|
-
keyConfigMap?: Record<string, import("../types").InjectKeyConfig> | undefined;
|
|
14
|
-
}) => Promise<{} | undefined>;
|
|
15
|
-
/** 提取文件命令处理器 */
|
|
16
|
-
export declare const handler: (argv: CliHandlerArgv<GenerateOptions>) => Promise<undefined>;
|
|
17
|
-
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,87 +0,0 @@
|
|
|
1
|
-
import type { InitConfigFileOptions, ReadConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
|
-
/** 子命令枚举 */
|
|
3
|
-
export declare enum SubcommandEnum {
|
|
4
|
-
/** 初始化提取配置文件 */
|
|
5
|
-
INIT = "init",
|
|
6
|
-
/** 生成文件 */
|
|
7
|
-
GENERATE = "generate"
|
|
8
|
-
}
|
|
9
|
-
/** 配置类型枚举 */
|
|
10
|
-
export declare enum InjectTypeEnum {
|
|
11
|
-
/**
|
|
12
|
-
* 正则表达式 类型
|
|
13
|
-
*/
|
|
14
|
-
REG = "reg",
|
|
15
|
-
/**
|
|
16
|
-
* 固定值 类型
|
|
17
|
-
*/
|
|
18
|
-
FIXED = "fixed",
|
|
19
|
-
/**
|
|
20
|
-
* 读取 类型
|
|
21
|
-
*/
|
|
22
|
-
READ = "read"
|
|
23
|
-
}
|
|
24
|
-
/** 初始化选项 */
|
|
25
|
-
export type InitOptions = InitConfigFileOptions;
|
|
26
|
-
/** 注入配置基础 */
|
|
27
|
-
export interface InjectKeyConfigBase<T extends InjectTypeEnum> {
|
|
28
|
-
/**
|
|
29
|
-
* 提取类型
|
|
30
|
-
*/
|
|
31
|
-
type: T;
|
|
32
|
-
}
|
|
33
|
-
/** 注入配置-正则类型 */
|
|
34
|
-
export interface InjectKeyConfigReg extends InjectKeyConfigBase<InjectTypeEnum.REG> {
|
|
35
|
-
/**
|
|
36
|
-
* 正则表达式字符串
|
|
37
|
-
* ----
|
|
38
|
-
* 不带flags
|
|
39
|
-
*/
|
|
40
|
-
pattern: string;
|
|
41
|
-
/** 正则匹配的 flags */
|
|
42
|
-
flags?: string;
|
|
43
|
-
/**
|
|
44
|
-
* 替换值
|
|
45
|
-
* ---
|
|
46
|
-
* replace 第二个参数
|
|
47
|
-
*/
|
|
48
|
-
replaceValue: string;
|
|
49
|
-
/** 源key */
|
|
50
|
-
sourceKey: string;
|
|
51
|
-
}
|
|
52
|
-
/** 注入配置-固定值类型 */
|
|
53
|
-
export interface InjectKeyConfigFixed extends InjectKeyConfigBase<InjectTypeEnum.FIXED> {
|
|
54
|
-
/** 值 */
|
|
55
|
-
value: string;
|
|
56
|
-
}
|
|
57
|
-
/** 注入配置-读取类型 */
|
|
58
|
-
export interface InjectKeyConfigRead extends InjectKeyConfigBase<InjectTypeEnum.READ> {
|
|
59
|
-
/** 源key */
|
|
60
|
-
sourceKey?: string;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* 注入配置
|
|
64
|
-
* ---
|
|
65
|
-
* 为 string 时 解析为 InjectKeyConfigFixed, 其中InjectKeyConfigFixed.value = string
|
|
66
|
-
*/
|
|
67
|
-
export type InjectKeyConfig = InjectKeyConfigReg | (InjectKeyConfigFixed | string) | InjectKeyConfigRead;
|
|
68
|
-
/** @deprecated */
|
|
69
|
-
export interface Options {
|
|
70
|
-
/** json文件相对路径 */
|
|
71
|
-
sourceJsonFilePath: string;
|
|
72
|
-
/** 注入的key路径 */
|
|
73
|
-
injectKeyPath: string[];
|
|
74
|
-
/** 注入信息文件路径 */
|
|
75
|
-
injectInfoFilePath: string;
|
|
76
|
-
}
|
|
77
|
-
/** 注入配置 */
|
|
78
|
-
export interface InjectConfig {
|
|
79
|
-
/** json文件相对路径 */
|
|
80
|
-
sourceFilePath: string;
|
|
81
|
-
/** 注入的key路径 */
|
|
82
|
-
keyConfigMap: Record<string, InjectKeyConfig>;
|
|
83
|
-
/** 注入信息文件路径 */
|
|
84
|
-
injectFilePath: string;
|
|
85
|
-
}
|
|
86
|
-
/** 生成选项 */
|
|
87
|
-
export type GenerateOptions = ReadConfigFileOptions;
|
package/types/utils/index.d.ts
DELETED
package/types/utils/path.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
2
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
3
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
4
|
-
/** 模块配置相对路径 */
|
|
5
|
-
export declare const MODULE_CONFIG_RELATIVE_PATH: string;
|
|
6
|
-
/** 模块默认配置文件相对路径 */
|
|
7
|
-
export declare const MODULE_DEFAULT_CONFIG_RELATIVE_PATH: string;
|
package/types/utils/resolve.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
2
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
3
|
-
/** 考虑本包会使用当前文件源码 避免不识别@ 此处用相对路径 */
|
|
4
|
-
import type { InjectKeyConfig } from "../types";
|
|
5
|
-
/** key配置解析-获取最终值 */
|
|
6
|
-
export declare const keyConfigResolve: ({ sourceJson, targetKey, keyConfig: keyConfigInit, }: {
|
|
7
|
-
sourceJson: Record<string, any>;
|
|
8
|
-
targetKey: string;
|
|
9
|
-
keyConfig: InjectKeyConfig;
|
|
10
|
-
}) => any;
|