momo-ai 1.0.0 → 1.0.1
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 +116 -0
- package/package.json +2 -1
- package/src/_template/LAIN/.momo/advanced/actor.md +42 -0
- package/src/_template/LAIN/.momo/scripts/submodule-clean.sh +56 -0
- package/src/_template/LAIN/AGENTS.md +103 -0
- package/src/_template/LAIN/changes/proposal.md +39 -0
- package/src/_template/LAIN/changes/tasks/task-detail.md +45 -0
- package/src/_template/LAIN/changes/tasks.md +49 -0
- package/src/_template/LAIN/execute/admin-n-f-dashboard.md +53 -0
- package/src/_template/LAIN/execute/admin-n-f-form.md +51 -0
- package/src/_template/LAIN/execute/admin-n-f-home.md +49 -0
- package/src/_template/LAIN/execute/admin-n-f-list.md +52 -0
- package/src/_template/LAIN/execute/admin-n-f-login.md +56 -0
- package/src/_template/LAIN/specification/project-model.md +13 -0
- package/src/_template/LAIN/specification/project.md +73 -0
- package/src/_template/LAIN/specification/requirement.md +25 -0
- package/src/_template/PROMPT/add.md.ejs +5 -0
- package/src/_template/PROMPT/plan.md.ejs +5 -0
- package/src/_template/PROMPT/run.md.ejs +9 -0
- package/src/_template/PROMPT/tasks.md.ejs +5 -0
- package/src/commander/actor.json +12 -0
- package/src/commander/actors.json +6 -0
- package/src/commander/add.json +12 -0
- package/src/commander/archive.json +12 -0
- package/src/commander/env.json +7 -0
- package/src/commander/help.json +7 -0
- package/src/commander/init.json +13 -0
- package/src/commander/list.json +7 -0
- package/src/commander/open.json +7 -0
- package/src/commander/plan.json +12 -0
- package/src/commander/repo.json +18 -0
- package/src/commander/run.json +18 -0
- package/src/commander/show.json +12 -0
- package/src/commander/tasks.json +18 -0
- package/src/commander/unlock.json +6 -0
- package/src/commander/validate.json +12 -0
- package/src/epic/history/ai.economy.impl.fn.excel.js +148 -0
- package/src/epic/history/ai.economy.impl.fn.execute.js +117 -0
- package/src/epic/history/ai.economy.impl.fn.java.js +140 -0
- package/src/epic/history/ai.economy.impl.fn.json.js +23 -0
- package/src/epic/history/ai.economy.impl.fn.plugin.js +160 -0
- package/src/epic/history/ai.economy.impl.fn.react.js +219 -0
- package/src/epic/history/ai.export.impl.fn.parse.js +345 -0
- package/src/epic/history/ai.export.impl.fn.seek.js +42 -0
- package/src/epic/history/ai.export.interface.fn.string.js +5 -0
- package/src/epic/history/ai.export.interface.io.js +69 -0
- package/src/epic/history/ai.export.interface.util.js +17 -0
- package/src/epic/history/ai.parse.metadata.js +94 -0
- package/src/epic/history/ai.path.fn.dir.operation.js +87 -0
- package/src/epic/history/ai.path.fn.io.command.js +43 -0
- package/src/epic/history/ai.path.fn.io.specification.js +59 -0
- package/src/epic/history/ai.path.fn.io.typed.js +63 -0
- package/src/epic/history/ai.path.fn.out.content.js +47 -0
- package/src/epic/history/ai.string.fn.str.util.js +63 -0
- package/src/epic/history/ai.uncork.fn.element.feature.js +52 -0
- package/src/epic/history/ai.uncork.fn.it.feature.js +118 -0
- package/src/epic/history/ai.uncork.fn.to.typed.js +74 -0
- package/src/epic/history/ai.under.fn.cx.evaluate.js +81 -0
- package/src/epic/history/ai.under.fn.fx.terminal.js +143 -0
- package/src/epic/history/ai.unified.fn.fn.error.code.js +108 -0
- package/src/epic/history/ai.unified.fn.is.decision.js +20 -0
- package/src/epic/history/ai.unified.fn.sorter.element.js +26 -0
- package/src/epic/history/zero.__.fn.find.util.js +37 -0
- package/src/epic/history/zero.__.v.constant.js +5 -0
- package/src/epic/index.js +50 -0
- package/src/epic/lain.fn.execute.js +116 -0
- package/src/epic/lain.fn.parse.js +94 -0
- package/src/epic/momo.fn.cx.js +81 -0
- package/src/epic/momo.fn.dir.js +87 -0
- package/src/epic/momo.fn.element.js +52 -0
- package/src/epic/momo.fn.find.js +37 -0
- package/src/epic/momo.fn.fx.js +143 -0
- package/src/epic/momo.fn.io.js +157 -0
- package/src/epic/momo.fn.is.js +20 -0
- package/src/epic/momo.fn.it.js +118 -0
- package/src/epic/momo.fn.log.js +50 -0
- package/src/epic/momo.fn.out.js +47 -0
- package/src/epic/momo.fn.sorter.js +26 -0
- package/src/epic/momo.fn.str.js +63 -0
- package/src/epic/momo.fn.to.js +74 -0
- package/src/epic/momo.v.constant.js +5 -0
- package/src/epic/momo.v.errorcode.js +108 -0
- package/src/executor/executeActor.js +113 -0
- package/src/executor/executeActors.js +58 -0
- package/src/executor/executeAdd.js +248 -0
- package/src/executor/executeArchive.js +124 -0
- package/src/executor/executeEnv.js +158 -0
- package/src/executor/executeHelp.js +23 -0
- package/src/executor/executeInit.js +321 -0
- package/src/executor/executeList.js +111 -0
- package/src/executor/executeOpen.js +130 -0
- package/src/executor/executePlan.js +134 -0
- package/src/executor/executeRepo.js +234 -0
- package/src/executor/executeRun.js +321 -0
- package/src/executor/executeShow.js +164 -0
- package/src/executor/executeTasks.js +260 -0
- package/src/executor/executeUnlock.js +110 -0
- package/src/executor/executeValidate.js +210 -0
- package/src/executor/index.js +35 -0
- package/src/momo.js +39 -1
- package/.idea/copilot.data.migration.agent.xml +0 -6
- package/.idea/copilot.data.migration.ask.xml +0 -6
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/copilot.data.migration.edit.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/r2mo-lain.iml +0 -12
- package/.idea/vcs.xml +0 -6
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const __IO = require('./ai.export.interface.io');
|
|
2
|
+
const __FX = require('./ai.under.fn.fx.terminal');
|
|
3
|
+
const __LOG = require('../momo.fn.log');
|
|
4
|
+
const __STR = require('./ai.export.interface.fn.string');
|
|
5
|
+
const __SK = require('./ai.export.impl.fn.seek');
|
|
6
|
+
const U = require('underscore');
|
|
7
|
+
const {config} = require("exceljs");
|
|
8
|
+
|
|
9
|
+
const ensureMaven = (path, module) => {
|
|
10
|
+
if (!__IO.isFile(path)) {
|
|
11
|
+
__FX.fxError(10017, module);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const ensureZero = (path, module) => {
|
|
15
|
+
if (!__IO.isDirectory(path)) {
|
|
16
|
+
__FX.fxError(10033, module);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const ensureOx = (path, module) => {
|
|
20
|
+
if (!__IO.isDirectory(path)) {
|
|
21
|
+
__FX.fxError(10034, module);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const detectMaven = (modulePath) => {
|
|
25
|
+
const configuration = {};
|
|
26
|
+
// pom.xml 文件检查
|
|
27
|
+
const pom = modulePath + `/pom.xml`;
|
|
28
|
+
ensureMaven(pom, modulePath);
|
|
29
|
+
configuration.pathPom = pom;
|
|
30
|
+
// 「Zero」src/main/java 检查
|
|
31
|
+
const source = modulePath + '/src/main/java';
|
|
32
|
+
ensureZero(source, modulePath);
|
|
33
|
+
configuration.pathSource = source;
|
|
34
|
+
// 「Zero」src/main/resources 检查
|
|
35
|
+
const resource = modulePath + '/src/main/resources';
|
|
36
|
+
ensureZero(resource, modulePath);
|
|
37
|
+
configuration.pathResource = resource;
|
|
38
|
+
return configuration;
|
|
39
|
+
}
|
|
40
|
+
const detectOx = (modulePath, configuration = {}) => {
|
|
41
|
+
const resource = configuration.pathResource;
|
|
42
|
+
// 「Ox」src/main/resources/cab
|
|
43
|
+
const cab = resource + '/cab';
|
|
44
|
+
ensureOx(cab, modulePath);
|
|
45
|
+
configuration.pathOxCab = cab;
|
|
46
|
+
// 「Ox」src/main/resources/init/oob
|
|
47
|
+
const oob = resource + '/init/oob';
|
|
48
|
+
ensureOx(oob, modulePath);
|
|
49
|
+
configuration.pathOxOOB = oob;
|
|
50
|
+
// 「Ox」src/main/resources/runtime
|
|
51
|
+
const runtime = resource + '/runtime';
|
|
52
|
+
ensureOx(runtime, modulePath);
|
|
53
|
+
configuration.pathOxRuntime = runtime;
|
|
54
|
+
return configuration;
|
|
55
|
+
}
|
|
56
|
+
const detectPlugin = (modulePath, configuration = {}) => {
|
|
57
|
+
const module = configuration.module;
|
|
58
|
+
const source = configuration.pathSource;
|
|
59
|
+
const resource = configuration.pathResource;
|
|
60
|
+
const packagePath = `/cn/originx/${module}/`;
|
|
61
|
+
configuration.modulePackage = `cn.originx.${module}`;
|
|
62
|
+
configuration.moduleAlias = __STR.strFirstUpper(module).substring(0, 2);
|
|
63
|
+
configuration.moduleLog = module.toUpperCase();
|
|
64
|
+
// 源代码
|
|
65
|
+
configuration.sourceComponent = source + packagePath + 'component';
|
|
66
|
+
configuration.sourceCv = source + packagePath + 'cv';
|
|
67
|
+
configuration.sourceError = source + packagePath + 'error';
|
|
68
|
+
configuration.sourceInput = source + packagePath + 'input';
|
|
69
|
+
configuration.sourceOutput = source + packagePath + 'output';
|
|
70
|
+
configuration.sourceRefine = source + packagePath + 'refine';
|
|
71
|
+
configuration.sourcePlugin = source + packagePath + 'plugin';
|
|
72
|
+
// 资源文件目录
|
|
73
|
+
configuration.resourcePlugin = resource + `/plugin/${module}`;
|
|
74
|
+
configuration.resourceLog = resource + `/plugin/${module}/annal`;
|
|
75
|
+
|
|
76
|
+
return configuration;
|
|
77
|
+
}
|
|
78
|
+
const detectWith = (modulePath, module, ...fnPlugin) => {
|
|
79
|
+
let configuration = detectMaven(modulePath);
|
|
80
|
+
if (module) {
|
|
81
|
+
configuration.module = module;
|
|
82
|
+
}
|
|
83
|
+
for (let idx = 0; idx < fnPlugin.length; idx++) {
|
|
84
|
+
const detectFn = fnPlugin[idx];
|
|
85
|
+
if (U.isFunction(detectFn)) {
|
|
86
|
+
// 会被改掉
|
|
87
|
+
configuration = detectFn(modulePath, configuration);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return configuration;
|
|
91
|
+
}
|
|
92
|
+
const javaConfig = (config = {}, path, ...fnPlugins) => {
|
|
93
|
+
const {
|
|
94
|
+
filename,
|
|
95
|
+
module,
|
|
96
|
+
tpl,
|
|
97
|
+
} = config;
|
|
98
|
+
let modulePath = path;
|
|
99
|
+
const inputConfig = __IO.ioJObject(filename);
|
|
100
|
+
const {ZF, ...prepared} = inputConfig;
|
|
101
|
+
if (!modulePath) {
|
|
102
|
+
modulePath = ZF;
|
|
103
|
+
}
|
|
104
|
+
__FX.fxError(!modulePath, 10029, modulePath, 'ZF');
|
|
105
|
+
if (modulePath) {
|
|
106
|
+
__LOG.info(`「Java环境」,后端工作路径:${modulePath.red}。`);
|
|
107
|
+
const configuration = detectWith.apply(this, [modulePath, module].concat(fnPlugins));
|
|
108
|
+
if (configuration) {
|
|
109
|
+
__LOG.info(`Zero AI `.cyan + ` 0. 基础环境......`.rainbow);
|
|
110
|
+
__LOG.info(`Zero AI `.cyan + ` 工作目录:${modulePath.blue}`);
|
|
111
|
+
configuration.input = prepared;
|
|
112
|
+
configuration.tpl = tpl;
|
|
113
|
+
return configuration;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const javaSmartMod = (path = ".") => {
|
|
118
|
+
// 目录基础检查
|
|
119
|
+
const pathStart = __IO.ioSwitch(path);
|
|
120
|
+
const pathFile = `${pathStart}/initialize.json`;
|
|
121
|
+
__FX.fxError(!__IO.isExist(pathFile), 10035, path);
|
|
122
|
+
// 查找带有 pom.xml 的根路径
|
|
123
|
+
__LOG.info(`Zero AI `.cyan + ` 检索模块目录构造配置信息。`);
|
|
124
|
+
const modulePath = __SK.seekResource(path);
|
|
125
|
+
// 构造模块规范,查找目录设置
|
|
126
|
+
const configuration = {};
|
|
127
|
+
configuration.pathBase = modulePath;
|
|
128
|
+
configuration.path = pathStart;
|
|
129
|
+
configuration.out = pathFile;
|
|
130
|
+
configuration.prefix = pathStart.replace(`${modulePath}/`, "");
|
|
131
|
+
return configuration;
|
|
132
|
+
}
|
|
133
|
+
module.exports = {
|
|
134
|
+
Cfg: {
|
|
135
|
+
detectOx,
|
|
136
|
+
detectPlugin,
|
|
137
|
+
},
|
|
138
|
+
javaConfig,
|
|
139
|
+
javaSmartMod,
|
|
140
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const __UT = require("./ai.export.interface.util");
|
|
2
|
+
const jsonCombine = (contentJ = [], normalized = [], mode = "REPLACE") => {
|
|
3
|
+
|
|
4
|
+
let contentT = [];
|
|
5
|
+
if ("REPLACE" === mode) {
|
|
6
|
+
// 替换模式
|
|
7
|
+
contentT = normalized.sort(__UT.sorterSAsc);
|
|
8
|
+
} else {
|
|
9
|
+
const result = [].concat(__UT.clone(contentJ));
|
|
10
|
+
// 非替换模式 APPEND
|
|
11
|
+
normalized.forEach(item => {
|
|
12
|
+
if (!contentJ.includes(item)) {
|
|
13
|
+
result.push(item);
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
contentT = result.sort(__UT.sorterSAsc);
|
|
17
|
+
}
|
|
18
|
+
return contentT;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
jsonCombine,
|
|
23
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
const __IO = require('./ai.export.interface.io');
|
|
2
|
+
const __STR = require('./ai.export.interface.fn.string');
|
|
3
|
+
const __LOG = require('../momo.fn.log');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const writeFile = (config, params = {}) => {
|
|
7
|
+
const {source, target} = config;
|
|
8
|
+
if (fs.existsSync(source) && target) {
|
|
9
|
+
const content = __IO.ioString(source);
|
|
10
|
+
const normalized = __STR.strExpr(content, params);
|
|
11
|
+
__IO.outString(target, normalized, true);
|
|
12
|
+
} else {
|
|
13
|
+
__LOG.warn(`Zero AI 对不起,文件不存在`.yellow + `:${source}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const writeDir = (config = {}) => {
|
|
17
|
+
__LOG.info(`Zero AI `.cyan + ` \t1.1. 初始化源代码目录......`);
|
|
18
|
+
Object.keys(config)
|
|
19
|
+
.filter(key => key.startsWith("source"))
|
|
20
|
+
.map(field => config[field])
|
|
21
|
+
.forEach(__IO.dirCreate);
|
|
22
|
+
|
|
23
|
+
__LOG.info(`Zero AI `.cyan + ` \t1.2. 初始化资源目录......`);
|
|
24
|
+
Object.keys(config)
|
|
25
|
+
.filter(key => key.startsWith("resource"))
|
|
26
|
+
.map(field => config[field])
|
|
27
|
+
.forEach(__IO.dirCreate);
|
|
28
|
+
}
|
|
29
|
+
const fileRaw = (targetFile, tplFile, filename, filenameTpl) => {
|
|
30
|
+
const file = {};
|
|
31
|
+
file.target = `${targetFile}/${filename}`;
|
|
32
|
+
const fileTpl = filenameTpl ? filenameTpl : `${filename}.tpl`;
|
|
33
|
+
file.source = `${tplFile}/${fileTpl}`;
|
|
34
|
+
return file;
|
|
35
|
+
}
|
|
36
|
+
const fileInfix = (targetFile, tplFile, input = {}) => {
|
|
37
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.1. backlog日志配置......`);
|
|
38
|
+
const content = fileRaw(targetFile, tplFile, 'infix.xml');
|
|
39
|
+
const {params = {}} = input;
|
|
40
|
+
writeFile(content, params);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const fileConfiguration = (resourcePath, tplFile, input = {}) => {
|
|
44
|
+
const {params = {}} = input;
|
|
45
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.2.1. 「默认」集成配置......`);
|
|
46
|
+
let json = fileRaw(resourcePath, tplFile,
|
|
47
|
+
"integration.json");
|
|
48
|
+
writeFile(json, params);
|
|
49
|
+
|
|
50
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.2.2. 「开发」集成配置......`);
|
|
51
|
+
json = fileRaw(resourcePath, tplFile,
|
|
52
|
+
"integration-dev.json", "integration.json.tpl");
|
|
53
|
+
writeFile(json, params);
|
|
54
|
+
|
|
55
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.2.3. 「生产」集成配置......`);
|
|
56
|
+
json = fileRaw(resourcePath, tplFile,
|
|
57
|
+
"integration-prod.json", "integration.json.tpl");
|
|
58
|
+
writeFile(json, params);
|
|
59
|
+
|
|
60
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.2.4. 基础配置......`);
|
|
61
|
+
json = fileRaw(resourcePath, tplFile,
|
|
62
|
+
"configuration.json");
|
|
63
|
+
writeFile(json, params);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const fileJava = (tplFile, input = {}) => {
|
|
67
|
+
const {params = {}, config = {}} = input;
|
|
68
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.3.1. 常量处理......`);
|
|
69
|
+
let java = fileRaw(config.sourceCv, tplFile,
|
|
70
|
+
`${config.moduleAlias}Cv.java`, `Cv.java.tpl`);
|
|
71
|
+
writeFile(java, params);
|
|
72
|
+
|
|
73
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.3.2. Before/After 插件处理......`);
|
|
74
|
+
java = fileRaw(config.sourcePlugin, tplFile,
|
|
75
|
+
`Abstract${config.moduleAlias}Before.java`, `Plugin.Before.java.tpl`);
|
|
76
|
+
writeFile(java, params);
|
|
77
|
+
java = fileRaw(config.sourcePlugin, tplFile,
|
|
78
|
+
`Abstract${config.moduleAlias}After.java`, `Plugin.After.java.tpl`);
|
|
79
|
+
writeFile(java, params);
|
|
80
|
+
|
|
81
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.3.3. Refine 工具处理......`);
|
|
82
|
+
java = fileRaw(config.sourceRefine, tplFile,
|
|
83
|
+
`${config.moduleAlias}Log.java`, `Refine.Log.java.tpl`);
|
|
84
|
+
writeFile(java, params);
|
|
85
|
+
java = fileRaw(config.sourceRefine, tplFile,
|
|
86
|
+
`${config.moduleAlias}Pin.java`, `Refine.Pin.java.tpl`);
|
|
87
|
+
writeFile(java, params);
|
|
88
|
+
java = fileRaw(config.sourceRefine, tplFile,
|
|
89
|
+
`${config.moduleAlias}.java`, 'Refine.java.tpl');
|
|
90
|
+
writeFile(java, params);
|
|
91
|
+
|
|
92
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.3.4. Error 异常类处理......`);
|
|
93
|
+
java = fileRaw(config.sourceError, tplFile,
|
|
94
|
+
`_501${config.moduleAlias}IoNullException.java`, `ErrorIo.java.tpl`);
|
|
95
|
+
writeFile(java, params);
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.3.5. Component 通道组件......`);
|
|
99
|
+
java = fileRaw(config.sourceComponent, tplFile,
|
|
100
|
+
`Abstract${config.moduleAlias}Component.java`, `Component.java.tpl`);
|
|
101
|
+
writeFile(java, params);
|
|
102
|
+
|
|
103
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.3.6. In 组件处理......`);
|
|
104
|
+
java = fileRaw(config.sourceInput, tplFile,
|
|
105
|
+
`${config.moduleAlias}In.java`, `In.java.tpl`);
|
|
106
|
+
writeFile(java, params);
|
|
107
|
+
|
|
108
|
+
java = fileRaw(config.sourceInput, tplFile,
|
|
109
|
+
`Abstract${config.moduleAlias}In.java`, `In.Abstract.java.tpl`);
|
|
110
|
+
writeFile(java, params);
|
|
111
|
+
|
|
112
|
+
__LOG.info(`Zero AI `.cyan + ` \t2.3.7. Out 组件处理......`);
|
|
113
|
+
java = fileRaw(config.sourceOutput, tplFile,
|
|
114
|
+
`${config.moduleAlias}Io.java`, `Io.java.tpl`);
|
|
115
|
+
writeFile(java, params);
|
|
116
|
+
|
|
117
|
+
java = fileRaw(config.sourceOutput, tplFile,
|
|
118
|
+
`Abstract${config.moduleAlias}Io.java`, `Io.Abstract.java.tpl`);
|
|
119
|
+
writeFile(java, params);
|
|
120
|
+
|
|
121
|
+
java = fileRaw(config.sourceOutput, tplFile,
|
|
122
|
+
`${config.moduleAlias}IoAdd.java`, `Io.Impl.java.tpl`);
|
|
123
|
+
writeFile(java, {OP: "Add", ...params});
|
|
124
|
+
java = fileRaw(config.sourceOutput, tplFile,
|
|
125
|
+
`${config.moduleAlias}IoUpdate.java`, `Io.Impl.java.tpl`);
|
|
126
|
+
writeFile(java, {OP: "Update", ...params});
|
|
127
|
+
java = fileRaw(config.sourceOutput, tplFile,
|
|
128
|
+
`${config.moduleAlias}IoDelete.java`, `Io.Impl.java.tpl`);
|
|
129
|
+
writeFile(java, {OP: "Delete", ...params});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const pluginRun = (config = {}) => {
|
|
133
|
+
__LOG.info(`Zero AI `.cyan + ` 1. 执行Plugin命令......`.rainbow);
|
|
134
|
+
const {tpl = {}} = config;
|
|
135
|
+
const tplPath = path.join(__dirname, `../cab/${tpl.type}`);
|
|
136
|
+
writeDir(config);
|
|
137
|
+
|
|
138
|
+
const params = {};
|
|
139
|
+
__LOG.info(`Zero AI `.cyan + ` 2. 生成代码......`.rainbow);
|
|
140
|
+
params.LOG_L = config.module;
|
|
141
|
+
params.LOG_UP = config.module.toUpperCase();
|
|
142
|
+
params.ALIAS = config.moduleAlias;
|
|
143
|
+
params.PACKAGE = config.modulePackage;
|
|
144
|
+
params.MODULE = config.module;
|
|
145
|
+
|
|
146
|
+
const input = {};
|
|
147
|
+
input.config = config;
|
|
148
|
+
input.params = params;
|
|
149
|
+
|
|
150
|
+
// src/main/resources/plugin/xxx/annal/infix.xml
|
|
151
|
+
fileInfix(config.resourceLog, tplPath, input);
|
|
152
|
+
// src/main/resources/plugin/xxx/configuration.json
|
|
153
|
+
fileConfiguration(config.resourcePlugin, tplPath, input);
|
|
154
|
+
// src/main/java 源代码
|
|
155
|
+
fileJava(tplPath, input);
|
|
156
|
+
__LOG.info(`Zero AI `.cyan + ` 3. 执行完成......`.rainbow);
|
|
157
|
+
}
|
|
158
|
+
module.exports = {
|
|
159
|
+
pluginRun
|
|
160
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const __IO = require('./ai.export.interface.io');
|
|
2
|
+
const __FX = require('./ai.under.fn.fx.terminal');
|
|
3
|
+
const __LOG = require('../momo.fn.log');
|
|
4
|
+
const __STR = require('./ai.export.interface.fn.string');
|
|
5
|
+
const __CX = require('./ai.under.fn.cx.evaluate');
|
|
6
|
+
const __V = require("./zero.__.v.constant");
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const reactRoot = (path) => {
|
|
11
|
+
const current = path ? `${process.cwd()}${__V.FILE_DELIMITER}${path}` : process.cwd();
|
|
12
|
+
let root = __IO.dirParent(current, true);
|
|
13
|
+
// 检查哪个目录中包含了package.json来判断根路径
|
|
14
|
+
root = root.filter(item => fs.existsSync(`${item}${__V.FILE_DELIMITER}package.json`));
|
|
15
|
+
__FX.fxError(1 < root.length, 10010, root);
|
|
16
|
+
root = root[0];
|
|
17
|
+
return __IO.dirResolve(root);
|
|
18
|
+
};
|
|
19
|
+
const reactLanguage = () => {
|
|
20
|
+
const root = reactRoot();
|
|
21
|
+
// 生产环境无效
|
|
22
|
+
const env = __IO.ioProp(root + __V.FILE_DELIMITER + '.env.development');
|
|
23
|
+
return env['Z_LANGUAGE'] ? env['Z_LANGUAGE'] : 'cn';
|
|
24
|
+
};
|
|
25
|
+
const reactDetect = (module, component) => {
|
|
26
|
+
// 路径分析专用
|
|
27
|
+
const slash = __STR.strSlashCount(module);
|
|
28
|
+
// 10027:检查ZT环境的格式
|
|
29
|
+
__FX.fxError(1 !== slash, 10027, module);
|
|
30
|
+
if (1 === slash) {
|
|
31
|
+
// 配置
|
|
32
|
+
const configuration = {};
|
|
33
|
+
const language = reactLanguage();
|
|
34
|
+
configuration.module = module;
|
|
35
|
+
configuration.language = language;
|
|
36
|
+
|
|
37
|
+
configuration.pathRoot = reactRoot();
|
|
38
|
+
{
|
|
39
|
+
// 资源路径,组件路径
|
|
40
|
+
configuration.pathResource = `src/cab/${language}/${component}/${module}`;
|
|
41
|
+
configuration.pathUi = `src/${component}/${module}`;
|
|
42
|
+
configuration.namespace = `${component}/${module}`;
|
|
43
|
+
}
|
|
44
|
+
return configuration;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const reactEnsure = (category = 'components') => {
|
|
48
|
+
const module = process.env.ZT;
|
|
49
|
+
// 10029: 检查ZT环境变量
|
|
50
|
+
__FX.fxError(!module, 10029, module, 'ZT');
|
|
51
|
+
if (module) {
|
|
52
|
+
__LOG.info(`「启用ZT环境」,当前模块:${module.red},特殊命令只能在${`ZT`.red}环境使用。`)
|
|
53
|
+
const moduleConfig = reactDetect(module, category);
|
|
54
|
+
if (moduleConfig) {
|
|
55
|
+
__LOG.info(`Zero AI `.cyan + ` 0. 基础环境......`.rainbow);
|
|
56
|
+
__LOG.info(`环境变量:` + `ZT = ${module}`.red);
|
|
57
|
+
__LOG.info(`模块信息:${moduleConfig.module.blue}`);
|
|
58
|
+
__LOG.info(`语言信息:${moduleConfig.language.blue}`);
|
|
59
|
+
__LOG.info(`项目目录:${moduleConfig.pathRoot.blue}`);
|
|
60
|
+
return moduleConfig;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/*
|
|
65
|
+
* 目录创建专用
|
|
66
|
+
*/
|
|
67
|
+
const reactReady = (config = {}, files = {}) => {
|
|
68
|
+
__LOG.info(`Zero AI `.cyan + ` 1. 目录检查......`.rainbow);
|
|
69
|
+
// 资源目录
|
|
70
|
+
const runtime = {};
|
|
71
|
+
runtime.resource = config.pathRoot + '/' + config.pathResource;
|
|
72
|
+
runtime.resourceFiles = {};
|
|
73
|
+
__IO.dirCreate(runtime.resource);
|
|
74
|
+
// 组件目录
|
|
75
|
+
runtime.ui = config.pathRoot + '/' + config.pathUi;
|
|
76
|
+
runtime.uiFiles = {};
|
|
77
|
+
__IO.dirCreate(runtime.ui);
|
|
78
|
+
|
|
79
|
+
// 其他目录专用计算
|
|
80
|
+
__LOG.info(`Zero AI `.cyan + ` 2. 文件表:`.rainbow);
|
|
81
|
+
runtime.namespaceFile = runtime.ui + '/Cab.json';
|
|
82
|
+
|
|
83
|
+
// 资源文件/脚本文件
|
|
84
|
+
const {
|
|
85
|
+
resource = [],
|
|
86
|
+
ui = [],
|
|
87
|
+
} = files;
|
|
88
|
+
const tpl = config.tpl;
|
|
89
|
+
/*
|
|
90
|
+
* 如果配置了 tpl.target 则是单文件拷贝
|
|
91
|
+
*/
|
|
92
|
+
if (tpl.target) {
|
|
93
|
+
/*
|
|
94
|
+
* fileJs模式
|
|
95
|
+
*/
|
|
96
|
+
const filename = tpl.target;
|
|
97
|
+
runtime.resourceFiles[filename] = runtime.resource + '/' + filename + ".json";
|
|
98
|
+
runtime.uiFiles[filename] = runtime.ui + '/' + filename + ".js";
|
|
99
|
+
} else {
|
|
100
|
+
/*
|
|
101
|
+
* 非fileJs模式
|
|
102
|
+
*/
|
|
103
|
+
resource.filter(each => undefined !== each).forEach(each => {
|
|
104
|
+
const file = runtime.resource + '/' + each + ".json";
|
|
105
|
+
runtime.resourceFiles[each] = file;
|
|
106
|
+
__LOG.info(`${__STR.strWidth(each)} = ${file.blue}`);
|
|
107
|
+
});
|
|
108
|
+
ui.filter(each => undefined !== each).forEach(each => {
|
|
109
|
+
const file = runtime.ui + '/' + each + ".js";
|
|
110
|
+
runtime.uiFiles[each] = file;
|
|
111
|
+
__LOG.info(`${__STR.strWidth(each)} = ${file.yellow}`);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
config.runtime = __FX.fxSorter(runtime);
|
|
115
|
+
}
|
|
116
|
+
const reactTpl = (name, config = {}) => {
|
|
117
|
+
const {input = {}, tpl = {}} = config;
|
|
118
|
+
// 读取模板
|
|
119
|
+
let tplFile;
|
|
120
|
+
if (tpl.source) {
|
|
121
|
+
const extension = config.extension;
|
|
122
|
+
// 特殊参数注入`#NAME#`
|
|
123
|
+
input.params.NAME = tpl.target;
|
|
124
|
+
tplFile = path.join(__dirname, `../cab/${tpl.type}/${tpl.source}.${extension}.tpl`);
|
|
125
|
+
} else {
|
|
126
|
+
tplFile = path.join(__dirname, `../cab/${tpl.type}/${name}.tpl`);
|
|
127
|
+
}
|
|
128
|
+
if (fs.existsSync(tplFile)) {
|
|
129
|
+
// 读取文件内容
|
|
130
|
+
const content = __IO.ioString(tplFile);
|
|
131
|
+
return __STR.strExpr(content, input.params);
|
|
132
|
+
} else {
|
|
133
|
+
__LOG.warn(`Zero AI 对不起,文件不存在`.yellow + `:${tplFile.red}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// ==========================================================
|
|
137
|
+
// 名空间文件 Cab.json
|
|
138
|
+
// ==========================================================
|
|
139
|
+
const reactTplNamespace = (config) => {
|
|
140
|
+
const runtime = config.runtime;
|
|
141
|
+
__LOG.info(`Zero AI `.cyan + ` \t3.1. 创建名空间文件......`.rainbow);
|
|
142
|
+
if (!fs.existsSync(runtime.namespaceFile)) {
|
|
143
|
+
const namespace = {};
|
|
144
|
+
namespace.ns = config.namespace;
|
|
145
|
+
__IO.outJson(runtime.namespaceFile, namespace, true);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// ==========================================================
|
|
149
|
+
// 资源文件
|
|
150
|
+
// ==========================================================
|
|
151
|
+
const reactTplResource = (config) => {
|
|
152
|
+
const runtime = config.runtime;
|
|
153
|
+
__LOG.info(`Zero AI `.cyan + ` \t3.2. 构造资源文件......`.rainbow);
|
|
154
|
+
const resourceFiles = runtime.resourceFiles;
|
|
155
|
+
Object.keys(resourceFiles).forEach(filename => {
|
|
156
|
+
const fullName = `${filename}.json`;
|
|
157
|
+
const content = reactTpl(fullName, {
|
|
158
|
+
...config,
|
|
159
|
+
extension: 'json'
|
|
160
|
+
});
|
|
161
|
+
if (content) {
|
|
162
|
+
const contentJson = JSON.parse(content);
|
|
163
|
+
__IO.outJson(resourceFiles[filename], contentJson, true);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// ==========================================================
|
|
168
|
+
// 脚本文件
|
|
169
|
+
// ==========================================================
|
|
170
|
+
const reactTplUi = (config) => {
|
|
171
|
+
const runtime = config.runtime;
|
|
172
|
+
__LOG.info(`Zero AI `.cyan + ` \t3.3. 构造界面文件......`.rainbow);
|
|
173
|
+
const uiFiles = runtime.uiFiles;
|
|
174
|
+
Object.keys(uiFiles).forEach(filename => {
|
|
175
|
+
const fullName = `${filename}.js`;
|
|
176
|
+
const content = reactTpl(fullName, {
|
|
177
|
+
...config,
|
|
178
|
+
extension: 'js'
|
|
179
|
+
});
|
|
180
|
+
if (content) {
|
|
181
|
+
__IO.outString(uiFiles[filename], content, true);
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
const reactRun = (config) => {
|
|
186
|
+
__LOG.info(`Zero AI `.cyan + ` 3. 执行React命令......`.rainbow);
|
|
187
|
+
// 1. 创建名空间文件
|
|
188
|
+
reactTplNamespace(config);
|
|
189
|
+
// 2. 资源文件
|
|
190
|
+
reactTplResource(config);
|
|
191
|
+
// 3. 构造代码文件
|
|
192
|
+
reactTplUi(config);
|
|
193
|
+
__LOG.info(`Zero AI `.cyan + ` 4. 命令执行完成!!!`.rainbow);
|
|
194
|
+
}
|
|
195
|
+
const reactConfig = (config = {}) => {
|
|
196
|
+
const {
|
|
197
|
+
filename,
|
|
198
|
+
tpl,
|
|
199
|
+
resource = [],
|
|
200
|
+
ui = []
|
|
201
|
+
} = config;
|
|
202
|
+
const configuration = reactEnsure();
|
|
203
|
+
if (configuration) {
|
|
204
|
+
__CX.cxExist(filename);
|
|
205
|
+
const inputConfig = __IO.ioJObject(filename);
|
|
206
|
+
configuration.tpl = tpl;
|
|
207
|
+
configuration.input = inputConfig;
|
|
208
|
+
// 构造和准备
|
|
209
|
+
reactReady(configuration, {
|
|
210
|
+
resource,
|
|
211
|
+
ui
|
|
212
|
+
});
|
|
213
|
+
return configuration;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
module.exports = {
|
|
217
|
+
reactConfig,
|
|
218
|
+
reactRun,
|
|
219
|
+
};
|