zero-ai 0.3.33 → 0.3.35
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 +3 -20
- package/package.json +3 -4
- package/src/_template/APP/.placeholder +0 -0
- package/src/_template/MODULE/.placeholder +0 -0
- package/src/_template/MODULE/database/MYSQL.properties +4 -0
- package/src/_template/MODULE/database/MYSQL.yml +2 -0
- package/src/_template/MODULE/database/database-reinit.sh +3 -0
- package/src/_template/MODULE/database/database-reinit.sql +5 -0
- package/src/_template/MODULE/database/init-db.sh +5 -0
- package/src/_template/MODULE/pom.xml.ejs +20 -0
- package/src/_template/MODULE/source-api/pom.xml.ejs +21 -0
- package/src/_template/MODULE/source-domain/ExtensionGeneration.ejs +7 -0
- package/src/_template/MODULE/source-domain/configuration.yml.ejs +3 -0
- package/src/_template/MODULE/source-domain/pom.xml.ejs +37 -0
- package/src/_template/MODULE/source-provider/ExtensionSource.ejs +14 -0
- package/src/_template/MODULE/source-provider/pom.xml.ejs +21 -0
- package/src/_template/SPRING/.placeholder +0 -0
- package/src/_template/SPRING/database/database-account.sql.ejs +3 -0
- package/src/_template/SPRING/database/database-reinit.sql.ejs +5 -0
- package/src/_template/SPRING/database/init-db.sh +4 -0
- package/src/_template/SPRING/mvn-build.sh +3 -0
- package/src/_template/SPRING/mvn-env.sh.ejs +7 -0
- package/src/_template/SPRING/pom.xml.ejs +46 -0
- package/src/_template/SPRING/source-api/AppDev.java.ejs +13 -0
- package/src/_template/SPRING/source-api/Application.java.ejs +12 -0
- package/src/_template/SPRING/source-api/application.yml.ejs +64 -0
- package/src/_template/SPRING/source-api/env.properties.ejs +7 -0
- package/src/_template/SPRING/source-api/pom.xml.ejs +65 -0
- package/src/_template/SPRING/source-domain/ActOperationCommon.ejs +17 -0
- package/src/_template/SPRING/source-domain/GenConfigApp.ejs +22 -0
- package/src/_template/SPRING/source-domain/pom.xml.ejs +21 -0
- package/src/_template/SPRING/source-provider/GenAppModule.ejs +12 -0
- package/src/_template/SPRING/source-provider/pom.xml.ejs +21 -0
- package/src/_template/SPRING/source-test/pom.xml.ejs +28 -0
- package/src/ai.js +11 -5
- package/src/commander/ai.zero +7 -11
- package/src/commander/app.json +24 -0
- package/src/commander/help.json +7 -0
- package/src/commander/md5.json +12 -0
- package/src/commander/mod.json +24 -0
- package/src/commander/spring.json +24 -0
- package/src/commander/str.json +25 -0
- package/src/commander/sync.json +19 -0
- package/src/commander/uuid.json +13 -0
- package/src/commander/web.json +12 -0
- package/src/commander-ai/fn.help.metadata.js +20 -0
- package/src/commander-ai/{fn.md5.js → fn.random.md5.js} +6 -12
- package/src/commander-ai/{fn.random.js → fn.random.string.js} +7 -13
- package/src/commander-ai/{fn.uuid.js → fn.random.uuid.js} +5 -9
- package/src/commander-ai/fn.source.app.js +20 -0
- package/src/commander-ai/fn.source.front.js +106 -0
- package/src/commander-ai/fn.source.mod.js +15 -0
- package/src/commander-ai/fn.source.spring.js +20 -0
- package/src/commander-ai/{fn.sync.js → fn.source.sync.js} +12 -17
- package/src/commander-ai/index.js +20 -23
- package/src/commander-shared/ai.fn.initialize.__.io.util.js +161 -0
- package/src/commander-shared/ai.fn.initialize.__.spring.directory.js +73 -0
- package/src/commander-shared/ai.fn.initialize.__.spring.file.js +112 -0
- package/src/commander-shared/ai.fn.initialize.__.zero.directory.js +63 -0
- package/src/commander-shared/ai.fn.initialize.__.zero.file.js +81 -0
- package/src/commander-shared/ai.fn.initialize.app.js +26 -0
- package/src/commander-shared/ai.fn.initialize.module.js +63 -0
- package/src/commander-shared/ai.fn.initialize.spring.js +68 -0
- package/src/commander-shared/ai.fn.parse.argument.js +92 -0
- package/src/commander-shared/index.js +26 -0
- package/src/epic/ai.economy.impl.fn.execute.js +11 -56
- package/src/epic/ai.unified.fn._.logging.js +4 -25
- package/src/epic/ai.unified.fn.fn.error.code.js +1 -1
- package/src/epic/index.js +2 -2
- package/src/{aj.js → previous/aj.js} +1 -1
- package/src/{art.js → previous/art.js} +1 -1
- package/src/{commander-aj → previous/commander-aj}/fn.i.mod.js +1 -1
- package/src/{commander-aj → previous/commander-aj}/fn.i.resource.js +1 -1
- package/src/{commander-aj → previous/commander-aj}/fn.j.bundle.js +1 -1
- package/src/{commander-aj → previous/commander-aj}/fn.j.init.js +2 -2
- package/src/{commander-aj → previous/commander-aj}/fn.j.permission.js +1 -1
- package/src/{commander-aj → previous/commander-aj}/fn.j.plugin.js +1 -1
- package/src/{commander-ar → previous/commander-ar}/fn.i.complex.js +1 -1
- package/src/{commander-ar → previous/commander-ar}/fn.i.form.js +1 -1
- /package/src/{commander → previous}/aj.zero +0 -0
- /package/src/{commander → previous}/ar.zero +0 -0
- /package/src/{commander-aj → previous/commander-aj}/bundle/specification.txt +0 -0
- /package/src/{commander-aj → previous/commander-aj}/index.js +0 -0
- /package/src/{commander-ar → previous/commander-ar}/index.js +0 -0
- /package/src/{commander-ai → previous}/fn.csv.js +0 -0
- /package/src/{commander-ai → previous}/fn.data.js +0 -0
- /package/src/{commander-ai → previous}/fn.init.js +0 -0
- /package/src/{commander-ai → previous}/fn.key.js +0 -0
- /package/src/{commander-ai → previous}/fn.uk.js +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const Ec = require("../epic");
|
|
2
|
+
const parseArgument = (options = []) => {
|
|
3
|
+
const args = process.argv.splice(3);
|
|
4
|
+
const result = {};
|
|
5
|
+
const argsLength = args.length;
|
|
6
|
+
|
|
7
|
+
// 将 options 转换为 map 以便快速查找
|
|
8
|
+
const optionsMap = new Map();
|
|
9
|
+
const aliasesMap = new Map();
|
|
10
|
+
|
|
11
|
+
options.forEach(option => {
|
|
12
|
+
optionsMap.set(option.name, option);
|
|
13
|
+
if (option.alias) {
|
|
14
|
+
aliasesMap.set(option.alias, option);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// 解析参数
|
|
19
|
+
for (let i = 0; i < argsLength; i += 2) {
|
|
20
|
+
const key = args[i];
|
|
21
|
+
const value = args[i + 1];
|
|
22
|
+
|
|
23
|
+
if (!key || !value) {
|
|
24
|
+
// 如果参数不成对,报错
|
|
25
|
+
if (key && !value) {
|
|
26
|
+
throw new Error(`[ ZERO ] 缺少参数 ${key} 的值`);
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 移除前缀(- 或 --)
|
|
32
|
+
let cleanKey = key;
|
|
33
|
+
if (key.startsWith('--')) {
|
|
34
|
+
cleanKey = key.substring(2);
|
|
35
|
+
} else if (key.startsWith('-')) {
|
|
36
|
+
cleanKey = key.substring(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 查找对应的选项
|
|
40
|
+
const option = optionsMap.get(cleanKey) || aliasesMap.get(cleanKey);
|
|
41
|
+
|
|
42
|
+
if (!option) {
|
|
43
|
+
throw new Error(`[ ZERO ] 未知的参数: ${key}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 转换值的类型
|
|
47
|
+
let parsedValue = value;
|
|
48
|
+
if (option.type === 'number') {
|
|
49
|
+
parsedValue = Number(value);
|
|
50
|
+
if (isNaN(parsedValue)) {
|
|
51
|
+
throw new Error(`[ ZERO ] 参数 ${key} 的值 ${value} 不是有效的数字`);
|
|
52
|
+
}
|
|
53
|
+
} else if (option.type === 'boolean') {
|
|
54
|
+
parsedValue = value.toLowerCase() === 'true';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
result[option.name] = parsedValue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 处理默认值和必需参数
|
|
61
|
+
options.forEach(option => {
|
|
62
|
+
const key = option.name;
|
|
63
|
+
if (!(key in result)) {
|
|
64
|
+
if ('default' in option) {
|
|
65
|
+
result[key] = option.default;
|
|
66
|
+
} else if (option.required) {
|
|
67
|
+
throw new Error(`[ ZERO ] 必需的参数缺失: ${key}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
const parseMetadata = () => {
|
|
75
|
+
const commandMeta = Ec.ioRoot() + "/commander";
|
|
76
|
+
const commandFiles = Ec.ioFiles(commandMeta);
|
|
77
|
+
const commandList = [];
|
|
78
|
+
commandFiles.forEach(fileObj => {
|
|
79
|
+
const filename = fileObj.file.toString();
|
|
80
|
+
if (filename.endsWith(".json")) {
|
|
81
|
+
const command = filename.substring(0, filename.indexOf("."));
|
|
82
|
+
const commandPath = Ec.ioRoot() + "/commander/" + command + ".json";
|
|
83
|
+
const commandJ = Ec.ioJObject(commandPath);
|
|
84
|
+
commandList.push(commandJ);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return commandList;
|
|
88
|
+
}
|
|
89
|
+
module.exports = {
|
|
90
|
+
parseArgument,
|
|
91
|
+
parseMetadata
|
|
92
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const _ARGS = require("./ai.fn.parse.argument");
|
|
2
|
+
const _MODS = require("./ai.fn.initialize.module");
|
|
3
|
+
const _APPS = require("./ai.fn.initialize.app");
|
|
4
|
+
const _SPRING = require("./ai.fn.initialize.spring");
|
|
5
|
+
module.exports = {
|
|
6
|
+
..._ARGS,
|
|
7
|
+
..._MODS,
|
|
8
|
+
..._APPS,
|
|
9
|
+
..._SPRING,
|
|
10
|
+
nameValid: (str) => {
|
|
11
|
+
if (typeof str !== 'string' || str.length === 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 检查是否以数字、. 或 - 开头
|
|
16
|
+
if (/^[0-9.\-]/.test(str)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 检查是否只包含字母、数字、. 和 -
|
|
21
|
+
if (!/^[a-zA-Z0-9.\-]+$/.test(str)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -61,11 +61,12 @@ const executeHeader = (app) => {
|
|
|
61
61
|
const appInfo = require('../../package.json');
|
|
62
62
|
program.allowUnknownOption();
|
|
63
63
|
program.version(appInfo.version);
|
|
64
|
-
__LOG.info(
|
|
65
|
-
__LOG.info('
|
|
66
|
-
__LOG.info('
|
|
67
|
-
__LOG.info(
|
|
68
|
-
__LOG.info(
|
|
64
|
+
__LOG.info(`----------------- Rachel Momo / AI工具项 ------------------`.rainbow);
|
|
65
|
+
__LOG.info('应用名称: '.bold + app);
|
|
66
|
+
__LOG.info('工具主页: '.bold + appInfo.homepage.blue);
|
|
67
|
+
__LOG.info(`工具版本: ` + `${appInfo.version}`.red + ' ' + `( Node >= 22.x )`.yellow);
|
|
68
|
+
__LOG.info();
|
|
69
|
+
__LOG.info("----------------- AI 系统启动…… ----------------------------".rainbow);
|
|
69
70
|
if (3 > process.argv.length) {
|
|
70
71
|
__LOG.error("命令缺失,请输入正确的命令!");
|
|
71
72
|
}
|
|
@@ -90,14 +91,13 @@ const executeBody = (commanders = [], Executor = {}) => {
|
|
|
90
91
|
.description(commander.description)
|
|
91
92
|
.usage(`[options] [${option.usage}]`);
|
|
92
93
|
__FX.fxContinue(0 < commander.options.length, () => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
94
|
+
// 设置选项
|
|
95
|
+
commander.options.forEach(option => {
|
|
96
|
+
cmd.option(`-${option.alias}`, option.description);
|
|
97
|
+
cmd.option(`--${option.name}`, option.description);
|
|
98
98
|
})
|
|
99
99
|
});
|
|
100
|
-
cmd.action(() => co(executor));
|
|
100
|
+
cmd.action(() => co(() => executor(commander.options)));
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
};
|
|
@@ -110,53 +110,8 @@ const executeBody = (commanders = [], Executor = {}) => {
|
|
|
110
110
|
const executeEnd = () => {
|
|
111
111
|
program.parse(process.argv);
|
|
112
112
|
};
|
|
113
|
-
/**
|
|
114
|
-
* ## `Ec.executeInput`
|
|
115
|
-
*
|
|
116
|
-
* ### 1. 基本介绍
|
|
117
|
-
*
|
|
118
|
-
* ```js
|
|
119
|
-
* const actual = Ec.executeInput(
|
|
120
|
-
* [],
|
|
121
|
-
* [
|
|
122
|
-
* ['-n', '--number', 20]
|
|
123
|
-
* ]
|
|
124
|
-
* );
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* ### 2. 参数列表
|
|
128
|
-
*
|
|
129
|
-
* #### 2.1. required 参数格式:
|
|
130
|
-
*
|
|
131
|
-
* ```js
|
|
132
|
-
* // 索引1:短参数
|
|
133
|
-
* // 索引2:长参数
|
|
134
|
-
* ["-h", "--help"]
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* #### 2.2. optional 参数格式:
|
|
138
|
-
*
|
|
139
|
-
* ```js
|
|
140
|
-
* // 索引1:短参数
|
|
141
|
-
* // 索引2:长参数
|
|
142
|
-
* // 索引3:参数的默认值
|
|
143
|
-
* ['-n', '--number', 20]
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* @memberOf module:_epic
|
|
147
|
-
* @param {Array} required 必须参数设置
|
|
148
|
-
* @param {Array} optional 可选参数设置
|
|
149
|
-
* @returns {Object} 生成最终的参数集
|
|
150
|
-
*/
|
|
151
|
-
const executeInput = (required = [], optional = []) => {
|
|
152
|
-
const elementArray = required.filter(item => U.isArray(item));
|
|
153
|
-
const isMatrix = 1 <= elementArray.length;
|
|
154
|
-
const args = isMatrix ? __PR.parseInput(required) : __PR.parseInput([required]);
|
|
155
|
-
return __PR.parseFormat(args, optional)
|
|
156
|
-
};
|
|
157
113
|
module.exports = {
|
|
158
114
|
executeHeader,
|
|
159
115
|
executeBody,
|
|
160
116
|
executeEnd,
|
|
161
|
-
executeInput,
|
|
162
117
|
};
|
|
@@ -11,34 +11,13 @@ colors.setTheme({
|
|
|
11
11
|
debug: 'magenta',
|
|
12
12
|
error: 'red'
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
* ## `Ec.error`
|
|
16
|
-
*
|
|
17
|
-
* 工具专用日志,`ERROR`级别,(黄色),消息前缀包含`[Zero AI]`前缀。
|
|
18
|
-
*
|
|
19
|
-
* @memberOf module:_debug
|
|
20
|
-
* @param {String} message 打印的日志信息。
|
|
21
|
-
*/
|
|
14
|
+
|
|
22
15
|
const error = (message) => console.error(`[Zero AI Error] `.red.bold + `${message}`.red);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* 工具专用日志,`INFO`级别,(普通日志),消息前缀包含`[Zero AI]`前缀。
|
|
27
|
-
*
|
|
28
|
-
* @memberOf module:_debug
|
|
29
|
-
* @param {String} message 打印的日志信息。
|
|
30
|
-
*/
|
|
31
|
-
const info = (message) => console.info(`[Zero AI]`.green.bold + ` ${message}`);
|
|
32
|
-
/**
|
|
33
|
-
* ## `Ec.warn`
|
|
34
|
-
*
|
|
35
|
-
* 工具专用日志,`INFO`级别,(警告日志),消息前缀包含`[Zero AI]`前缀。
|
|
36
|
-
*
|
|
37
|
-
* @memberOf module:_debug
|
|
38
|
-
* @param {String} message 打印的日志信息。
|
|
39
|
-
*/
|
|
16
|
+
const info = (message) => console.info(`[Zero AI]`.green.bold + ` ${message ? message : ''}`);
|
|
17
|
+
const execute = (message) => console.info(`[Zero AI]`.blue.bold + ` ${message ? message : ''}`);
|
|
40
18
|
const warn = (message) => console.warn(`[Zero AI]`.yellow.bold + ` ${message}`.yellow);
|
|
41
19
|
module.exports = {
|
|
20
|
+
execute,
|
|
42
21
|
info,
|
|
43
22
|
warn,
|
|
44
23
|
error,
|
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
|
66
66
|
|
|
67
67
|
// 命令
|
|
68
68
|
fn10003: (fileType) => `[AI-10003] The fileType='${fileType}' is unknown and could not found parser`,
|
|
69
|
-
fn10004: (command) => `[AI-10004] The executor of command '${command}' could not be found
|
|
69
|
+
fn10004: (command) => `[AI-10004] The executor of command '${command}' could not be found(执行器丢失)`,
|
|
70
70
|
fn10005: (command = "未输入", expected) => `[AI-10005] The command '${command}' could not be found, expected '${expected}'`,
|
|
71
71
|
fn10006: (arg) => `[AI-10006] The command missed required arguments: '${arg}'`,
|
|
72
72
|
|
package/src/epic/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const func_interface_io = require('./ai.export.interface.io');
|
|
|
2
2
|
const func_interface_util = require("./ai.export.interface.util");
|
|
3
3
|
const func_interface_string = require('./ai.export.interface.fn.string');
|
|
4
4
|
|
|
5
|
-
const func_impl_parse = require('./ai.export.impl.fn.parse');
|
|
5
|
+
// const func_impl_parse = require('./ai.export.impl.fn.parse');
|
|
6
6
|
const func_impl_seek = require("./ai.export.impl.fn.seek");
|
|
7
7
|
|
|
8
8
|
const func_impl_excel = require('./ai.economy.impl.fn.excel');
|
|
@@ -17,7 +17,7 @@ const exported = {
|
|
|
17
17
|
...func_interface_util,
|
|
18
18
|
...func_interface_string,
|
|
19
19
|
|
|
20
|
-
...func_impl_parse,
|
|
20
|
+
// ...func_impl_parse,
|
|
21
21
|
...func_impl_seek,
|
|
22
22
|
|
|
23
23
|
...func_impl_execute,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const Ec = require("
|
|
1
|
+
const Ec = require("../../epic");
|
|
2
2
|
const child = require('child_process');
|
|
3
3
|
module.exports = () => {
|
|
4
4
|
const actual = Ec.executeInput(
|
|
@@ -53,7 +53,7 @@ module.exports = () => {
|
|
|
53
53
|
* [Zero AI] Zero AI 系统启动......
|
|
54
54
|
* [Zero AI] Zero AI 加载输入参数:
|
|
55
55
|
* {
|
|
56
|
-
|
|
56
|
+
"name": "test-demo-api"
|
|
57
57
|
* }
|
|
58
58
|
* [Zero AI] 工程构建目录:test-demo-api
|
|
59
59
|
* Cloning into 'test-demo-api'...
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|