done-coding-template 0.7.9-alpha.0 → 0.7.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.mjs +2 -2
- package/es/{main-cc17e60c.js → main-66386e55.js} +1 -1
- package/package.json +4 -4
- package/types/cli.d.ts +1 -2
- package/types/index.d.ts +125 -5
- package/types/handler.d.ts +0 -5
- package/types/injectInfo.json.d.ts +0 -11
- package/types/json/default.json.d.ts +0 -38
- package/types/main.d.ts +0 -9
- package/types/utils/compile.d.ts +0 -16
- package/types/utils/config.d.ts +0 -3
- package/types/utils/dealOptions.d.ts +0 -21
- package/types/utils/index.d.ts +0 -6
- package/types/utils/init.d.ts +0 -6
- package/types/utils/path.d.ts +0 -4
- package/types/utils/types.d.ts +0 -82
package/es/cli.mjs
CHANGED
package/es/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { M as r } from "./main-
|
|
3
|
-
import { O as E, S as h, T as b, b as T, c as A, a as H, h as O, i as S } from "./main-
|
|
2
|
+
import { M as r } from "./main-66386e55.js";
|
|
3
|
+
import { O as E, S as h, T as b, b as T, c as A, a as H, h as O, i as S } from "./main-66386e55.js";
|
|
4
4
|
import t from "node:path";
|
|
5
5
|
import { existsSync as n } from "node:fs";
|
|
6
6
|
import "@done-coding/cli-utils";
|
|
@@ -7,7 +7,7 @@ import B from "lodash.assign";
|
|
|
7
7
|
var h = /* @__PURE__ */ ((e) => (e.INIT = "init", e.COMPILE = "compile", e))(h || {}), J = /* @__PURE__ */ ((e) => (e.REPOSITORY_URL = "REPOSITORY_URL", e))(J || {}), b = /* @__PURE__ */ ((e) => (e.OVERWRITE = "overwrite", e.APPEND = "append", e.REPLACE = "replace", e.RETURN = "return", e))(b || {});
|
|
8
8
|
const _ = {
|
|
9
9
|
name: "@done-coding/cli-template",
|
|
10
|
-
version: "0.7.
|
|
10
|
+
version: "0.7.10-alpha.0",
|
|
11
11
|
description: "预编译命令行工具",
|
|
12
12
|
cliConfig: {
|
|
13
13
|
namespaceDir: ".done-coding",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "done-coding-template",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10-alpha.0",
|
|
4
4
|
"description": "预编译命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"sideEffects": false,
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@done-coding/cli-inject": "^0.5.
|
|
33
|
+
"@done-coding/cli-inject": "^0.5.10-alpha.0",
|
|
34
34
|
"@types/lodash.assign": "^4.2.9",
|
|
35
35
|
"@types/lodash.template": "^4.5.3",
|
|
36
36
|
"@types/node": "^18.0.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"node": ">=18.0.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@done-coding/cli-utils": "^0.7.0",
|
|
47
|
+
"@done-coding/cli-utils": "^0.7.1-alpha.0",
|
|
48
48
|
"lodash.assign": "^4.2.0",
|
|
49
49
|
"lodash.template": "^4.5.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3376f5fbbf8b87c791316e76df06028afd650e08",
|
|
52
52
|
"scripts": {}
|
|
53
53
|
}
|
package/types/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
export { }
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { CliHandlerArgv } from '@done-coding/cli-utils';
|
|
2
|
+
import { CommandModule } from 'yargs';
|
|
3
|
+
import type { InitConfigFileOptions } from '@done-coding/cli-utils';
|
|
4
|
+
import type { ReadConfigFileOptions } from '@done-coding/cli-utils';
|
|
5
|
+
|
|
6
|
+
/** 批量编译模板 */
|
|
7
|
+
export declare const batchCompileHandler: ({ rootDir, configPath, itemDefaultRollback, extraEnvData, }: {
|
|
8
|
+
/** 项目更目录 */
|
|
9
|
+
rootDir: string;
|
|
10
|
+
/** 配置文件路径 */
|
|
11
|
+
configPath?: string | undefined;
|
|
12
|
+
/** item默认回滚? */
|
|
13
|
+
itemDefaultRollback?: boolean | undefined;
|
|
14
|
+
/** 额外环境变量 */
|
|
15
|
+
extraEnvData?: object | undefined;
|
|
16
|
+
}, paramsConfig?: CompileTemplateConfig) => Promise<(string | undefined)[]>;
|
|
17
|
+
|
|
18
|
+
/** 采集环境变量配置 */
|
|
19
|
+
export declare interface CollectFormItem {
|
|
20
|
+
/** 采集环境变量的key */
|
|
21
|
+
key: string;
|
|
22
|
+
/** 采集环境变量标签 */
|
|
23
|
+
label: string;
|
|
24
|
+
/** 采集环境变量初始值 */
|
|
25
|
+
initial?: string;
|
|
26
|
+
/** 绑定的关键变量 */
|
|
27
|
+
bindKey?: TemplateBindKeyEnum;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 编译模板 */
|
|
31
|
+
export declare const compileHandler: (argv: CliHandlerArgv<CompileOptions>) => Promise<string | (string | undefined)[] | undefined>;
|
|
32
|
+
|
|
33
|
+
export declare interface CompileOptions {
|
|
34
|
+
/** 项目根目录 */
|
|
35
|
+
rootDir: string;
|
|
36
|
+
/** 配置文件路径 */
|
|
37
|
+
configPath?: string;
|
|
38
|
+
/** 环境数据(json)文件(优先级高于 envData ) */
|
|
39
|
+
env?: string;
|
|
40
|
+
/** 环境变量数据(JSON字符串) */
|
|
41
|
+
envData?: string;
|
|
42
|
+
/** 模板文件相对路径(优先级高于 inputData ) */
|
|
43
|
+
input?: string;
|
|
44
|
+
/** 模板数据 */
|
|
45
|
+
inputData?: string;
|
|
46
|
+
/** 输出文件相对路径 */
|
|
47
|
+
output?: string;
|
|
48
|
+
/** 输出模式 @default OutputModeEnum.OVERWRITE */
|
|
49
|
+
mode: OutputModeEnum;
|
|
50
|
+
/** 是否回滚 @default false */
|
|
51
|
+
rollback?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* 回滚删除空文件
|
|
54
|
+
* ---
|
|
55
|
+
* 只限 OutputModeEnum.APPEND 模式下生效
|
|
56
|
+
*/
|
|
57
|
+
rollbackDelNullFile?: boolean;
|
|
58
|
+
/** (检测是markdown)是否处理(单个)代码块包裹 */
|
|
59
|
+
dealMarkdown?: boolean;
|
|
60
|
+
/** 是否批量处理 */
|
|
61
|
+
batch?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** 编译模板配置 */
|
|
65
|
+
export declare interface CompileTemplateConfig {
|
|
66
|
+
/** 全局环境变量 */
|
|
67
|
+
globalEnvData?: Record<string, any>;
|
|
68
|
+
/** 采集环境变量表单配置 */
|
|
69
|
+
collectEnvDataForm?: (CollectFormItem | string)[];
|
|
70
|
+
/** 配置列表 */
|
|
71
|
+
list?: Omit<CompileOptions, keyof ReadConfigFileOptions>[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 编译模板配置选项
|
|
76
|
+
*/
|
|
77
|
+
export declare type CompileTemplateConfigListItem = Omit<CompileOptions, "envData" | keyof ReadConfigFileOptions> & {
|
|
78
|
+
/** 已经解析为对象的envData */
|
|
79
|
+
envData: Record<string, any>;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** 作为子命令创建 */
|
|
83
|
+
export declare const crateAsSubcommand: () => CommandModule<{}, {}>;
|
|
84
|
+
|
|
85
|
+
/** 获取配置文件路径 */
|
|
86
|
+
export declare const getConfigPath: ({ rootDir, configPath, }: ReadConfigFileOptions) => string | undefined;
|
|
87
|
+
|
|
88
|
+
/** 命令处理函数 */
|
|
89
|
+
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<InitOptions | CompileOptions>) => Promise<string | void | (string | undefined)[]>;
|
|
90
|
+
|
|
91
|
+
/** 初始化模板 */
|
|
92
|
+
export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
|
|
93
|
+
|
|
94
|
+
export declare type InitOptions = InitConfigFileOptions;
|
|
95
|
+
|
|
96
|
+
/** 模块默认配置文件相对路径 */
|
|
97
|
+
export declare const MODULE_DEFAULT_CONFIG_RELATIVE_PATH: string;
|
|
98
|
+
|
|
99
|
+
/** 输出模式 */
|
|
100
|
+
export declare enum OutputModeEnum {
|
|
101
|
+
/** 覆盖模式 */
|
|
102
|
+
OVERWRITE = "overwrite",
|
|
103
|
+
/** 追加模式 */
|
|
104
|
+
APPEND = "append",
|
|
105
|
+
/** 替换模式 */
|
|
106
|
+
REPLACE = "replace",
|
|
107
|
+
/** 返回模式--函数调用方式可用 */
|
|
108
|
+
RETURN = "return"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** 子命令枚举 */
|
|
112
|
+
export declare enum SubcommandEnum {
|
|
113
|
+
/** 初始化模板 */
|
|
114
|
+
INIT = "init",
|
|
115
|
+
/** 编译模板 */
|
|
116
|
+
COMPILE = "compile"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** 绑定的关键变量枚举 */
|
|
120
|
+
export declare enum TemplateBindKeyEnum {
|
|
121
|
+
/** 远程仓库地址 */
|
|
122
|
+
REPOSITORY_URL = "REPOSITORY_URL"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { }
|
package/types/handler.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CompileOptions, 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 | CompileOptions>) => Promise<string | void | (string | undefined)[]>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
"globalEnvData": {},
|
|
3
|
-
"collectEnvDataForm": [
|
|
4
|
-
{
|
|
5
|
-
"key": "name",
|
|
6
|
-
"label": "项目名"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"key": "chineseName",
|
|
10
|
-
"label": "项目中文名"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"key": "description",
|
|
14
|
-
"label": "描述",
|
|
15
|
-
"initial": "这是一个描述"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"key": "repositoryUrl",
|
|
19
|
-
"label": "仓库地址",
|
|
20
|
-
"initial": "",
|
|
21
|
-
"bindKey": "REPOSITORY_URL"
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"list": [
|
|
25
|
-
{
|
|
26
|
-
"input": "./package.json",
|
|
27
|
-
"output": "./package.json",
|
|
28
|
-
"mode": "replace"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"input": "./README.md",
|
|
32
|
-
"output": "./README.md",
|
|
33
|
-
"mode": "replace"
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default _default;
|
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/utils/compile.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CompileTemplateConfig } from '.';
|
|
2
|
-
import { type CompileOptions } from '.';
|
|
3
|
-
import type { CliHandlerArgv } from "@done-coding/cli-utils";
|
|
4
|
-
/** 批量编译模板 */
|
|
5
|
-
export declare const batchCompileHandler: ({ rootDir, configPath, itemDefaultRollback, extraEnvData, }: {
|
|
6
|
-
/** 项目更目录 */
|
|
7
|
-
rootDir: string;
|
|
8
|
-
/** 配置文件路径 */
|
|
9
|
-
configPath?: string | undefined;
|
|
10
|
-
/** item默认回滚? */
|
|
11
|
-
itemDefaultRollback?: boolean | undefined;
|
|
12
|
-
/** 额外环境变量 */
|
|
13
|
-
extraEnvData?: object | undefined;
|
|
14
|
-
}, paramsConfig?: CompileTemplateConfig) => Promise<(string | undefined)[]>;
|
|
15
|
-
/** 编译模板 */
|
|
16
|
-
export declare const compileHandler: (argv: CliHandlerArgv<CompileOptions>) => Promise<string | (string | undefined)[] | undefined>;
|
package/types/utils/config.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type CliInfo } from "@done-coding/cli-utils";
|
|
2
|
-
import { OutputModeEnum, type CompileOptions } from "./types";
|
|
3
|
-
/** 编译默认选项 */
|
|
4
|
-
export declare const defaultCompileOptions: Pick<CompileOptions, "rollback" | "dealMarkdown" | "mode" | "batch" | "rollbackDelNullFile">;
|
|
5
|
-
/** 设置编译默认选项 */
|
|
6
|
-
export declare const completeDefaultCompileOptions: <T extends Pick<CompileOptions, "mode" | "rollback" | "rollbackDelNullFile" | "dealMarkdown" | "batch">>(options: T) => {
|
|
7
|
-
env?: string | undefined;
|
|
8
|
-
envData?: string | undefined;
|
|
9
|
-
input?: string | undefined;
|
|
10
|
-
inputData?: string | undefined;
|
|
11
|
-
output?: string | undefined;
|
|
12
|
-
rollback: boolean | undefined;
|
|
13
|
-
rollbackDelNullFile: boolean | undefined;
|
|
14
|
-
dealMarkdown: boolean | undefined;
|
|
15
|
-
mode: OutputModeEnum;
|
|
16
|
-
batch: boolean | undefined;
|
|
17
|
-
rootDir: string;
|
|
18
|
-
configPath: string;
|
|
19
|
-
};
|
|
20
|
-
/** 获取编译选项 */
|
|
21
|
-
export declare const getCompileOptions: () => CliInfo["options"];
|
package/types/utils/index.d.ts
DELETED
package/types/utils/init.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="yargs" />
|
|
2
|
-
import { type InitOptions } from '.';
|
|
3
|
-
import { type CliHandlerArgv } from "@done-coding/cli-utils";
|
|
4
|
-
export declare const getInitOptions: () => Record<keyof import("@done-coding/cli-utils").ConfigFileCommonOptions, import("yargs").Options>;
|
|
5
|
-
/** 初始化模板 */
|
|
6
|
-
export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
|
package/types/utils/path.d.ts
DELETED
package/types/utils/types.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { InitConfigFileOptions, ReadConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
|
-
/** 子命令枚举 */
|
|
3
|
-
export declare enum SubcommandEnum {
|
|
4
|
-
/** 初始化模板 */
|
|
5
|
-
INIT = "init",
|
|
6
|
-
/** 编译模板 */
|
|
7
|
-
COMPILE = "compile"
|
|
8
|
-
}
|
|
9
|
-
export type InitOptions = InitConfigFileOptions;
|
|
10
|
-
/** 绑定的关键变量枚举 */
|
|
11
|
-
export declare enum TemplateBindKeyEnum {
|
|
12
|
-
/** 远程仓库地址 */
|
|
13
|
-
REPOSITORY_URL = "REPOSITORY_URL"
|
|
14
|
-
}
|
|
15
|
-
/** 输出模式 */
|
|
16
|
-
export declare enum OutputModeEnum {
|
|
17
|
-
/** 覆盖模式 */
|
|
18
|
-
OVERWRITE = "overwrite",
|
|
19
|
-
/** 追加模式 */
|
|
20
|
-
APPEND = "append",
|
|
21
|
-
/** 替换模式 */
|
|
22
|
-
REPLACE = "replace",
|
|
23
|
-
/** 返回模式--函数调用方式可用 */
|
|
24
|
-
RETURN = "return"
|
|
25
|
-
}
|
|
26
|
-
export interface CompileOptions {
|
|
27
|
-
/** 项目根目录 */
|
|
28
|
-
rootDir: string;
|
|
29
|
-
/** 配置文件路径 */
|
|
30
|
-
configPath?: string;
|
|
31
|
-
/** 环境数据(json)文件(优先级高于 envData ) */
|
|
32
|
-
env?: string;
|
|
33
|
-
/** 环境变量数据(JSON字符串) */
|
|
34
|
-
envData?: string;
|
|
35
|
-
/** 模板文件相对路径(优先级高于 inputData ) */
|
|
36
|
-
input?: string;
|
|
37
|
-
/** 模板数据 */
|
|
38
|
-
inputData?: string;
|
|
39
|
-
/** 输出文件相对路径 */
|
|
40
|
-
output?: string;
|
|
41
|
-
/** 输出模式 @default OutputModeEnum.OVERWRITE */
|
|
42
|
-
mode: OutputModeEnum;
|
|
43
|
-
/** 是否回滚 @default false */
|
|
44
|
-
rollback?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* 回滚删除空文件
|
|
47
|
-
* ---
|
|
48
|
-
* 只限 OutputModeEnum.APPEND 模式下生效
|
|
49
|
-
*/
|
|
50
|
-
rollbackDelNullFile?: boolean;
|
|
51
|
-
/** (检测是markdown)是否处理(单个)代码块包裹 */
|
|
52
|
-
dealMarkdown?: boolean;
|
|
53
|
-
/** 是否批量处理 */
|
|
54
|
-
batch?: boolean;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* 编译模板配置选项
|
|
58
|
-
*/
|
|
59
|
-
export type CompileTemplateConfigListItem = Omit<CompileOptions, "envData" | keyof ReadConfigFileOptions> & {
|
|
60
|
-
/** 已经解析为对象的envData */
|
|
61
|
-
envData: Record<string, any>;
|
|
62
|
-
};
|
|
63
|
-
/** 采集环境变量配置 */
|
|
64
|
-
export interface CollectFormItem {
|
|
65
|
-
/** 采集环境变量的key */
|
|
66
|
-
key: string;
|
|
67
|
-
/** 采集环境变量标签 */
|
|
68
|
-
label: string;
|
|
69
|
-
/** 采集环境变量初始值 */
|
|
70
|
-
initial?: string;
|
|
71
|
-
/** 绑定的关键变量 */
|
|
72
|
-
bindKey?: TemplateBindKeyEnum;
|
|
73
|
-
}
|
|
74
|
-
/** 编译模板配置 */
|
|
75
|
-
export interface CompileTemplateConfig {
|
|
76
|
-
/** 全局环境变量 */
|
|
77
|
-
globalEnvData?: Record<string, any>;
|
|
78
|
-
/** 采集环境变量表单配置 */
|
|
79
|
-
collectEnvDataForm?: (CollectFormItem | string)[];
|
|
80
|
-
/** 配置列表 */
|
|
81
|
-
list?: Omit<CompileOptions, keyof ReadConfigFileOptions>[];
|
|
82
|
-
}
|