@done-coding/cli-config 0.1.0 → 0.1.2-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-93ab2332.js → index-8f693835.js} +3 -1
- package/es/index.mjs +5 -3
- package/package.json +4 -4
- package/types/cli.d.ts +1 -2
- package/types/index.d.ts +116 -2
- package/types/handlers/add.d.ts +0 -15
- package/types/handlers/check.d.ts +0 -12
- package/types/handlers/index.d.ts +0 -10
- package/types/injectInfo.json.d.ts +0 -11
- package/types/main.d.ts +0 -9
- package/types/types/index.d.ts +0 -92
- package/types/utils/config-resolve.d.ts +0 -20
- package/types/utils/index.d.ts +0 -2
- package/types/utils/path.d.ts +0 -4
package/es/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { execSync as k } from "node:child_process";
|
|
|
6
6
|
var y = /* @__PURE__ */ ((e) => (e.CHECK = "check", e.ADD = "add", e))(y || {}), m = /* @__PURE__ */ ((e) => (e.ESLINT = "eslint", e.PRETTIER = "prettier", e.COMMITLINT = "commitlint", e.LSLINT = "ls-lint", e.MERGELINT = "merge-lint", e))(m || {});
|
|
7
7
|
const N = {
|
|
8
8
|
name: "@done-coding/cli-config",
|
|
9
|
-
version: "0.1.0",
|
|
9
|
+
version: "0.1.2-alpha.0",
|
|
10
10
|
description: "工程化配置命令行工具",
|
|
11
11
|
cliConfig: {
|
|
12
12
|
namespaceDir: ".done-coding",
|
|
@@ -398,6 +398,8 @@ ${JSON.stringify($, null, 2)}`), await ee({
|
|
|
398
398
|
...x(!0)
|
|
399
399
|
});
|
|
400
400
|
export {
|
|
401
|
+
m as C,
|
|
402
|
+
y as S,
|
|
401
403
|
Te as a,
|
|
402
404
|
Pe as c,
|
|
403
405
|
Ee as h
|
package/es/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { C as i, S as s, a as t, h as u } from "./index-8f693835.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
4
|
import "node:fs";
|
|
5
5
|
import "node:path";
|
|
6
6
|
import "node:child_process";
|
|
7
7
|
export {
|
|
8
|
-
i as
|
|
9
|
-
|
|
8
|
+
i as ConfigModuleEnum,
|
|
9
|
+
s as SubcommandEnum,
|
|
10
|
+
t as crateAsSubcommand,
|
|
11
|
+
u as handler
|
|
10
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-config",
|
|
3
|
-
"version": "0.1.0",
|
|
3
|
+
"version": "0.1.2-alpha.0",
|
|
4
4
|
"description": "工程化配置命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"sideEffects": false,
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@done-coding/cli-inject": "^0.5.
|
|
43
|
+
"@done-coding/cli-inject": "^0.5.10-alpha.0",
|
|
44
44
|
"@types/node": "^18.0.0",
|
|
45
45
|
"@types/yargs": "^17.0.28",
|
|
46
46
|
"rimraf": "^6.0.1",
|
|
@@ -52,7 +52,7 @@
|
|
|
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
|
}
|
package/types/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
export { }
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { CliHandlerArgv } from '@done-coding/cli-utils';
|
|
2
|
+
import { CommandModule } from 'yargs';
|
|
3
|
+
import { InitConfigFileOptions } from '@done-coding/cli-utils';
|
|
4
|
+
import { ReadConfigFileOptions } from '@done-coding/cli-utils';
|
|
5
|
+
|
|
6
|
+
/** 添加配置选项 */
|
|
7
|
+
export declare interface AddConfigOptions extends ReadConfigFileOptions, Partial<ConfigConfig> {
|
|
8
|
+
/** 是否直接提交git */
|
|
9
|
+
commitGit?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** 检测配置选项 */
|
|
13
|
+
export declare interface CheckConfigOptions extends ReadConfigFileOptions, Partial<ConfigConfig> {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** config命令的配置 */
|
|
17
|
+
export declare interface ConfigConfig {
|
|
18
|
+
moduleList?: ConfigModuleEnum[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 配置文件信息 */
|
|
22
|
+
export declare interface ConfigConfigFileInfo {
|
|
23
|
+
/**
|
|
24
|
+
* 待复制的配置文件路径
|
|
25
|
+
* ---
|
|
26
|
+
* 相对于当前工程化模块目录对应的版本目录
|
|
27
|
+
*/
|
|
28
|
+
sourceFile: string;
|
|
29
|
+
/**
|
|
30
|
+
* 目标配置文件路径
|
|
31
|
+
* ---
|
|
32
|
+
* 相对于命令运行目录
|
|
33
|
+
*/
|
|
34
|
+
targetFile: string;
|
|
35
|
+
/** 描述 */
|
|
36
|
+
description?: string;
|
|
37
|
+
/** 当前配置依赖的额外包 */
|
|
38
|
+
relyPackages?: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 工程化配置 */
|
|
42
|
+
export declare interface ConfigConfigJson {
|
|
43
|
+
project: ConfigProject;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** (工程化)配置模块枚举 */
|
|
47
|
+
export declare enum ConfigModuleEnum {
|
|
48
|
+
/** eslint 配置 */
|
|
49
|
+
ESLINT = "eslint",
|
|
50
|
+
/** prettier 配置 */
|
|
51
|
+
PRETTIER = "prettier",
|
|
52
|
+
/** 提交配置 */
|
|
53
|
+
COMMITLINT = "commitlint",
|
|
54
|
+
/** 文件配置 */
|
|
55
|
+
LSLINT = "ls-lint",
|
|
56
|
+
/** (git)合并检测 */
|
|
57
|
+
MERGELINT = "merge-lint"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 项目配置
|
|
62
|
+
* ---
|
|
63
|
+
* value 为 string时则是该模块对应的预置列表json文件名【相对于所属工程化模块目录】,如 reset-list.json
|
|
64
|
+
*/
|
|
65
|
+
export declare type ConfigProject = Record<string, ConfigProjectConfigItem[] | string>;
|
|
66
|
+
|
|
67
|
+
/** 项目配置单项 */
|
|
68
|
+
export declare interface ConfigProjectConfigItem {
|
|
69
|
+
version: string;
|
|
70
|
+
/** 配置文件配置列表 */
|
|
71
|
+
configFileInfoList: ConfigConfigFileInfo[];
|
|
72
|
+
/** 依赖的包 */
|
|
73
|
+
relyPackages?: string[];
|
|
74
|
+
/** package.json需要添加的配置 */
|
|
75
|
+
packageJson?: {
|
|
76
|
+
scripts?: Record<string, string>;
|
|
77
|
+
"lint-staged"?: Record<string, string[]>;
|
|
78
|
+
};
|
|
79
|
+
/** husky需要添加的配置 */
|
|
80
|
+
husky?: {
|
|
81
|
+
hooks?: Record<string, string>;
|
|
82
|
+
};
|
|
83
|
+
/** 运行脚本 */
|
|
84
|
+
runScripts?: string[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** 作为子命令创建 */
|
|
88
|
+
export declare const crateAsSubcommand: () => CommandModule<{}, {}>;
|
|
89
|
+
|
|
90
|
+
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void | {
|
|
91
|
+
config: ConfigConfig;
|
|
92
|
+
info: TypeConfigInfo;
|
|
93
|
+
}>;
|
|
94
|
+
|
|
95
|
+
/** 初始化配置选项 */
|
|
96
|
+
export declare interface initConfigOptions extends InitConfigFileOptions {
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** 子命令枚举 */
|
|
100
|
+
export declare enum SubcommandEnum {
|
|
101
|
+
/** 检测工程化配置*/
|
|
102
|
+
CHECK = "check",
|
|
103
|
+
/** 添加工程化配置 */
|
|
104
|
+
ADD = "add"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** 各类型工程化配置信息 */
|
|
108
|
+
export declare type TypeConfigInfo = {
|
|
109
|
+
[key in ConfigModuleEnum]?: {
|
|
110
|
+
version: string;
|
|
111
|
+
/** 配置文件相对路径 */
|
|
112
|
+
configFileRelativePathList: string[];
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { }
|
package/types/handlers/add.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type AddConfigOptions, type ConfigModuleEnum, type ConfigProjectConfigItem } from '../types';
|
|
2
|
-
import type { ArgumentsCamelCase } from "yargs";
|
|
3
|
-
import type { SubCliInfo } from "@done-coding/cli-utils";
|
|
4
|
-
import type yargs from "yargs";
|
|
5
|
-
export declare const getOptions: () => {
|
|
6
|
-
[key: string]: yargs.Options;
|
|
7
|
-
};
|
|
8
|
-
/** 解析模块配置列表 */
|
|
9
|
-
export declare const resolveModuleConfigList: ({ listConfig, moduleDir, moduleName, }: {
|
|
10
|
-
listConfig: ConfigProjectConfigItem[] | string;
|
|
11
|
-
moduleDir: string;
|
|
12
|
-
moduleName: ConfigModuleEnum;
|
|
13
|
-
}) => ConfigProjectConfigItem[];
|
|
14
|
-
export declare const handler: (argv: ArgumentsCamelCase<AddConfigOptions>) => Promise<void>;
|
|
15
|
-
export declare const commandCliInfo: SubCliInfo;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type CheckConfigOptions, type ConfigConfig, type TypeConfigInfo } from '../types';
|
|
2
|
-
import type { SubCliInfo } from "@done-coding/cli-utils";
|
|
3
|
-
import type { ArgumentsCamelCase } from "yargs";
|
|
4
|
-
import type yargs from "yargs";
|
|
5
|
-
export declare const getOptions: () => {
|
|
6
|
-
[key: string]: yargs.Options;
|
|
7
|
-
};
|
|
8
|
-
export declare const handler: (argv: ArgumentsCamelCase<CheckConfigOptions>) => Promise<{
|
|
9
|
-
config: ConfigConfig;
|
|
10
|
-
info: TypeConfigInfo;
|
|
11
|
-
}>;
|
|
12
|
-
export declare const commandCliInfo: SubCliInfo;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { handler as checkHandler, commandCliInfo as checkCommandCliInfo } from "./check";
|
|
2
|
-
import { handler as addHandler, commandCliInfo as addCommandCliInfo } from "./add";
|
|
3
|
-
import { SubcommandEnum } from '../types';
|
|
4
|
-
import { type CliHandlerArgv, type CliInfo } from "@done-coding/cli-utils";
|
|
5
|
-
export { checkHandler, checkCommandCliInfo, addHandler, addCommandCliInfo };
|
|
6
|
-
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void | {
|
|
7
|
-
config: import('../types').ConfigConfig;
|
|
8
|
-
info: import('../types').TypeConfigInfo;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const commandCliInfo: Omit<CliInfo, "usage">;
|
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,92 +0,0 @@
|
|
|
1
|
-
import { InitConfigFileOptions, ReadConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
|
-
/** 子命令枚举 */
|
|
3
|
-
export declare enum SubcommandEnum {
|
|
4
|
-
/** 检测工程化配置*/
|
|
5
|
-
CHECK = "check",
|
|
6
|
-
/** 添加工程化配置 */
|
|
7
|
-
ADD = "add"
|
|
8
|
-
}
|
|
9
|
-
/** (工程化)配置模块枚举 */
|
|
10
|
-
export declare enum ConfigModuleEnum {
|
|
11
|
-
/** eslint 配置 */
|
|
12
|
-
ESLINT = "eslint",
|
|
13
|
-
/** prettier 配置 */
|
|
14
|
-
PRETTIER = "prettier",
|
|
15
|
-
/** 提交配置 */
|
|
16
|
-
COMMITLINT = "commitlint",
|
|
17
|
-
/** 文件配置 */
|
|
18
|
-
LSLINT = "ls-lint",
|
|
19
|
-
/** (git)合并检测 */
|
|
20
|
-
MERGELINT = "merge-lint"
|
|
21
|
-
}
|
|
22
|
-
/** config命令的配置 */
|
|
23
|
-
export interface ConfigConfig {
|
|
24
|
-
moduleList?: ConfigModuleEnum[];
|
|
25
|
-
}
|
|
26
|
-
/** 初始化配置选项 */
|
|
27
|
-
export interface initConfigOptions extends InitConfigFileOptions {
|
|
28
|
-
}
|
|
29
|
-
/** 检测配置选项 */
|
|
30
|
-
export interface CheckConfigOptions extends ReadConfigFileOptions, Partial<ConfigConfig> {
|
|
31
|
-
}
|
|
32
|
-
/** 添加配置选项 */
|
|
33
|
-
export interface AddConfigOptions extends ReadConfigFileOptions, Partial<ConfigConfig> {
|
|
34
|
-
/** 是否直接提交git */
|
|
35
|
-
commitGit?: boolean;
|
|
36
|
-
}
|
|
37
|
-
/** 各类型工程化配置信息 */
|
|
38
|
-
export type TypeConfigInfo = {
|
|
39
|
-
[key in ConfigModuleEnum]?: {
|
|
40
|
-
version: string;
|
|
41
|
-
/** 配置文件相对路径 */
|
|
42
|
-
configFileRelativePathList: string[];
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
/** 配置文件信息 */
|
|
46
|
-
export interface ConfigConfigFileInfo {
|
|
47
|
-
/**
|
|
48
|
-
* 待复制的配置文件路径
|
|
49
|
-
* ---
|
|
50
|
-
* 相对于当前工程化模块目录对应的版本目录
|
|
51
|
-
*/
|
|
52
|
-
sourceFile: string;
|
|
53
|
-
/**
|
|
54
|
-
* 目标配置文件路径
|
|
55
|
-
* ---
|
|
56
|
-
* 相对于命令运行目录
|
|
57
|
-
*/
|
|
58
|
-
targetFile: string;
|
|
59
|
-
/** 描述 */
|
|
60
|
-
description?: string;
|
|
61
|
-
/** 当前配置依赖的额外包 */
|
|
62
|
-
relyPackages?: string[];
|
|
63
|
-
}
|
|
64
|
-
/** 项目配置单项 */
|
|
65
|
-
export interface ConfigProjectConfigItem {
|
|
66
|
-
version: string;
|
|
67
|
-
/** 配置文件配置列表 */
|
|
68
|
-
configFileInfoList: ConfigConfigFileInfo[];
|
|
69
|
-
/** 依赖的包 */
|
|
70
|
-
relyPackages?: string[];
|
|
71
|
-
/** package.json需要添加的配置 */
|
|
72
|
-
packageJson?: {
|
|
73
|
-
scripts?: Record<string, string>;
|
|
74
|
-
"lint-staged"?: Record<string, string[]>;
|
|
75
|
-
};
|
|
76
|
-
/** husky需要添加的配置 */
|
|
77
|
-
husky?: {
|
|
78
|
-
hooks?: Record<string, string>;
|
|
79
|
-
};
|
|
80
|
-
/** 运行脚本 */
|
|
81
|
-
runScripts?: string[];
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* 项目配置
|
|
85
|
-
* ---
|
|
86
|
-
* value 为 string时则是该模块对应的预置列表json文件名【相对于所属工程化模块目录】,如 reset-list.json
|
|
87
|
-
*/
|
|
88
|
-
export type ConfigProject = Record<string, ConfigProjectConfigItem[] | string>;
|
|
89
|
-
/** 工程化配置 */
|
|
90
|
-
export interface ConfigConfigJson {
|
|
91
|
-
project: ConfigProject;
|
|
92
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AddConfigOptions, CheckConfigOptions, ConfigConfig, TypeConfigInfo } from '../types';
|
|
2
|
-
import { ConfigModuleEnum } from '../types';
|
|
3
|
-
/** 允许的模块 */
|
|
4
|
-
export declare const ALLOW_MODULE_LIST: ConfigModuleEnum[];
|
|
5
|
-
export declare const getConfig: (argv: CheckConfigOptions | AddConfigOptions) => Promise<ConfigConfig>;
|
|
6
|
-
/** 配置模块与包名的映射 */
|
|
7
|
-
export declare const configModulePkgNameMap: {
|
|
8
|
-
[key in ConfigModuleEnum]: string;
|
|
9
|
-
};
|
|
10
|
-
/** 配置类型与配置文件后缀的映射 */
|
|
11
|
-
export declare const configModuleConfigFileSuffixMap: {
|
|
12
|
-
[key in ConfigModuleEnum]: string[];
|
|
13
|
-
};
|
|
14
|
-
/** 矫正配置模块列表 */
|
|
15
|
-
export declare const adjustModuleList: (list: string[]) => ConfigModuleEnum[];
|
|
16
|
-
/** 获取配置信息 */
|
|
17
|
-
export declare const getConfigInfo: ({ config, rootDir, }: {
|
|
18
|
-
config: ConfigConfig;
|
|
19
|
-
rootDir: string;
|
|
20
|
-
}) => TypeConfigInfo;
|
package/types/utils/index.d.ts
DELETED
package/types/utils/path.d.ts
DELETED