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,161 @@
|
|
|
1
|
+
const Ec = require("../epic");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const fsAsync = require("fs").promises;
|
|
4
|
+
const ejs = require("ejs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
const ioEJS = async (source, configuration = {}) => new Promise((resolve, reject) => {
|
|
8
|
+
const params = {};
|
|
9
|
+
/*
|
|
10
|
+
* - group / Maven 对应的 groupId
|
|
11
|
+
* - id / Maven 对应的 artifactId
|
|
12
|
+
* - name / 模块名称,大写形式
|
|
13
|
+
* - packageName / Java 包名称
|
|
14
|
+
*/
|
|
15
|
+
params.id = configuration?.artifactId;
|
|
16
|
+
params.name = configuration?.srcId.toUpperCase();
|
|
17
|
+
params.packageName = configuration?.srcPackage;
|
|
18
|
+
params.group = configuration?.groupId;
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* 数据库部分
|
|
22
|
+
* - dbName / 数据库实例名
|
|
23
|
+
* - dbUser / 数据库用户名
|
|
24
|
+
* - dbHost / 数据库域名
|
|
25
|
+
* - dbPort / 数据库端口
|
|
26
|
+
* - dbPassword / 数据库密码
|
|
27
|
+
*/
|
|
28
|
+
params.dbType = configuration?.dbType;
|
|
29
|
+
params.dbName = configuration?.dbName;
|
|
30
|
+
params.dbUser = configuration?.dbUser;
|
|
31
|
+
params.dbHost = configuration?.dbHost;
|
|
32
|
+
params.dbPort = configuration?.dbPort;
|
|
33
|
+
params.dbPassword = configuration?.dbPassword;
|
|
34
|
+
|
|
35
|
+
Ec.execute(`读取 EJS 模版:${source.blue}`)
|
|
36
|
+
fs.readFile(source, "utf8", (err, data) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
reject(err);
|
|
39
|
+
}
|
|
40
|
+
// 渲染模板
|
|
41
|
+
const renderContent = ejs.render(data, params);
|
|
42
|
+
resolve(renderContent);
|
|
43
|
+
});
|
|
44
|
+
})
|
|
45
|
+
const withDomain = (configuration = {}, path) => {
|
|
46
|
+
return `${configuration.srcOut}/${configuration.artifactId}/${configuration.artifactId}-domain/${path}`;
|
|
47
|
+
}
|
|
48
|
+
const withProvider = (configuration = {}, path) => {
|
|
49
|
+
return `${configuration.srcOut}/${configuration.artifactId}/${configuration.artifactId}-provider/${path}`;
|
|
50
|
+
}
|
|
51
|
+
const withApi = (configuration = {}, path) => {
|
|
52
|
+
return `${configuration.srcOut}/${configuration.artifactId}/${configuration.artifactId}-api/${path}`;
|
|
53
|
+
}
|
|
54
|
+
const withTest = (configuration = {}, path) => {
|
|
55
|
+
return `${configuration.srcOut}/${configuration.artifactId}/${configuration.artifactId}-test/${path}`;
|
|
56
|
+
}
|
|
57
|
+
const withDPA = (configuration = {}, path) => {
|
|
58
|
+
return `${configuration.srcOut}/${configuration.artifactId}/${path}`;
|
|
59
|
+
}
|
|
60
|
+
const ioConfiguration = (parsed = {}, name) => {
|
|
61
|
+
const configMap = {};
|
|
62
|
+
configMap.groupId = "io.zerows";
|
|
63
|
+
configMap.artifactId = name;
|
|
64
|
+
configMap.srcPackage = `io.zerows.extension.${name}`;
|
|
65
|
+
|
|
66
|
+
let output = parsed.output;
|
|
67
|
+
if ('.' === output) {
|
|
68
|
+
output = process.cwd();
|
|
69
|
+
}
|
|
70
|
+
configMap.srcId = name;
|
|
71
|
+
configMap.srcOut = output;
|
|
72
|
+
configMap.srcConfig = parsed.config;
|
|
73
|
+
configMap.dbType = "MYSQL";
|
|
74
|
+
|
|
75
|
+
const configInput = process.cwd() + `/${parsed.config}`;
|
|
76
|
+
if (!fs.existsSync(configInput)) {
|
|
77
|
+
Ec.warn(`配置文件不存在,使用默认配置!路径 = ` + configInput.blue);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (fs.existsSync(configInput)) {
|
|
81
|
+
// 有配置的情况要合并配置
|
|
82
|
+
const data = Ec.ioJObject(configInput);
|
|
83
|
+
Object.assign(configMap, data);
|
|
84
|
+
}
|
|
85
|
+
return configMap;
|
|
86
|
+
}
|
|
87
|
+
const ioAppName = (name) => {
|
|
88
|
+
let appName;
|
|
89
|
+
if (0 < name.indexOf("-")) {
|
|
90
|
+
appName = name.substring(name.lastIndexOf("-") + 1);
|
|
91
|
+
} else if (0 < name.indexOf(".")) {
|
|
92
|
+
appName = name.substring(name.lastIndexOf(".") + 1);
|
|
93
|
+
} else {
|
|
94
|
+
appName = name;
|
|
95
|
+
}
|
|
96
|
+
return appName;
|
|
97
|
+
}
|
|
98
|
+
const ioChmod = async (directory) => {
|
|
99
|
+
try {
|
|
100
|
+
// Ec.execute(`正在扫描目录:${directory}`);
|
|
101
|
+
// 1. 目录读取
|
|
102
|
+
const files = await fsAsync.readdir(directory, {withFileTypes: true});
|
|
103
|
+
// 2. 筛选所有的 .sh 文件
|
|
104
|
+
const chmodPromise = [];
|
|
105
|
+
for (const file of files) {
|
|
106
|
+
const fullPath = path.join(directory, file.name);
|
|
107
|
+
if (file.isDirectory()) {
|
|
108
|
+
// 递归处理子目录
|
|
109
|
+
const subPromises = await ioChmod(fullPath);
|
|
110
|
+
chmodPromise.push(...subPromises);
|
|
111
|
+
} else if (file.isFile() && path.extname(file.name) === '.sh') {
|
|
112
|
+
// 处理 .sh 文件
|
|
113
|
+
const chmodPromiseItem = fsAsync.stat(fullPath)
|
|
114
|
+
.then(stat => {
|
|
115
|
+
const currentMode = stat.mode;
|
|
116
|
+
const newMode = currentMode
|
|
117
|
+
| fsAsync.constants.S_IXUSR
|
|
118
|
+
| fsAsync.constants.S_IXGRP
|
|
119
|
+
| fsAsync.constants.S_IXOTH;
|
|
120
|
+
return fsAsync.chmod(fullPath, newMode);
|
|
121
|
+
})
|
|
122
|
+
.then(() => {
|
|
123
|
+
Ec.execute(`${fullPath} 的执行权限已添加。`);
|
|
124
|
+
})
|
|
125
|
+
.catch(chmodErr => {
|
|
126
|
+
Ec.error(`修改 ${fullPath} 权限时发生错误: ${chmodErr.message}`);
|
|
127
|
+
});
|
|
128
|
+
chmodPromise.push(chmodPromiseItem);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 等待所有 chmod 操作完成
|
|
133
|
+
await Promise.all(chmodPromise);
|
|
134
|
+
|
|
135
|
+
return chmodPromise;
|
|
136
|
+
|
|
137
|
+
} catch (error) {
|
|
138
|
+
Ec.error(`处理目录发生错误:${directory}`);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const ioPackage = async (suffix, configuration, baseFn) => {
|
|
143
|
+
const packageName = !!suffix ? configuration.srcPackage + `.${suffix}`: configuration.srcPackage;
|
|
144
|
+
const pathPackage = packageName.replace(/\./g, "/");
|
|
145
|
+
let dirPackage = baseFn(configuration, `src/main/java/${pathPackage}`);
|
|
146
|
+
await fsAsync.mkdir(dirPackage, {recursive: true});
|
|
147
|
+
await fsAsync.access(dirPackage, fsAsync.constants.F_OK);
|
|
148
|
+
return pathPackage;
|
|
149
|
+
}
|
|
150
|
+
module.exports = {
|
|
151
|
+
ioPackage,
|
|
152
|
+
ioChmod,
|
|
153
|
+
ioConfiguration,
|
|
154
|
+
ioEJS,
|
|
155
|
+
ioAppName,
|
|
156
|
+
withTest,
|
|
157
|
+
withDomain,
|
|
158
|
+
withProvider,
|
|
159
|
+
withApi,
|
|
160
|
+
withDPA,
|
|
161
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const Ec = require('../epic');
|
|
3
|
+
const IoSpring = require('./ai.fn.initialize.__.spring.file');
|
|
4
|
+
const IoUt = require('./ai.fn.initialize.__.io.util');
|
|
5
|
+
const ioDPASpringStructure = async (baseDir, configuration) => {
|
|
6
|
+
const name = configuration.artifactId;
|
|
7
|
+
const folders = [
|
|
8
|
+
`${baseDir}/${name}`,
|
|
9
|
+
`${baseDir}/${name}/generated`,
|
|
10
|
+
`${baseDir}/${name}/database`,
|
|
11
|
+
`${baseDir}/${name}/${name}-domain/src/main/java`,
|
|
12
|
+
`${baseDir}/${name}/${name}-domain/src/main/resources/${configuration.artifactId}/database/schema/`,
|
|
13
|
+
`${baseDir}/${name}/${name}-domain/src/test/java`,
|
|
14
|
+
`${baseDir}/${name}/${name}-domain/src/test/resources`,
|
|
15
|
+
`${baseDir}/${name}/${name}-api/src/main/java`,
|
|
16
|
+
`${baseDir}/${name}/${name}-api/src/main/resources`,
|
|
17
|
+
`${baseDir}/${name}/${name}-api/src/test/java`,
|
|
18
|
+
`${baseDir}/${name}/${name}-api/src/test/resources`,
|
|
19
|
+
`${baseDir}/${name}/${name}-provider/src/main/java`,
|
|
20
|
+
`${baseDir}/${name}/${name}-provider/src/main/resources`,
|
|
21
|
+
`${baseDir}/${name}/${name}-provider/src/test/java`,
|
|
22
|
+
`${baseDir}/${name}/${name}-provider/src/test/resources`,
|
|
23
|
+
`${baseDir}/${name}/${name}-test/src/main/java`,
|
|
24
|
+
`${baseDir}/${name}/${name}-test/src/main/resources`,
|
|
25
|
+
`${baseDir}/${name}/${name}-test/src/test/java`,
|
|
26
|
+
`${baseDir}/${name}/${name}-test/src/test/resources`,
|
|
27
|
+
];
|
|
28
|
+
const results = [];
|
|
29
|
+
folders.map(async (folder) => {
|
|
30
|
+
Ec.execute("创建目录:" + folder);
|
|
31
|
+
await fs.mkdir(folder, {recursive: true});
|
|
32
|
+
results.push(true);
|
|
33
|
+
})
|
|
34
|
+
return results;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ioDPASpringPom = async (source, configuration = {}) => {
|
|
38
|
+
let fileSrc = `${source}/pom.xml.ejs`;
|
|
39
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
40
|
+
let fileDest = IoUt.withDPA(configuration, `pom.xml`);
|
|
41
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
42
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
43
|
+
|
|
44
|
+
fileSrc = `${source}/source-api/pom.xml.ejs`;
|
|
45
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
46
|
+
fileDest = IoUt.withApi(configuration, `pom.xml`);
|
|
47
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
48
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
49
|
+
|
|
50
|
+
fileSrc = `${source}/source-provider/pom.xml.ejs`;
|
|
51
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
52
|
+
fileDest = IoUt.withProvider(configuration, `pom.xml`);
|
|
53
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
54
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
55
|
+
|
|
56
|
+
fileSrc = `${source}/source-domain/pom.xml.ejs`;
|
|
57
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
58
|
+
fileDest = IoUt.withDomain(configuration, `pom.xml`);
|
|
59
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
60
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
61
|
+
|
|
62
|
+
fileSrc = `${source}/source-test/pom.xml.ejs`;
|
|
63
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
64
|
+
fileDest = IoUt.withTest(configuration, `pom.xml`);
|
|
65
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
66
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
module.exports = {
|
|
70
|
+
ioDPASpringStructure,
|
|
71
|
+
ioDPASpringPom,
|
|
72
|
+
...IoSpring,
|
|
73
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const Ec = require("../epic");
|
|
3
|
+
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
4
|
+
|
|
5
|
+
const ioSpringDatabase = async (source, configuration = {}) => {
|
|
6
|
+
|
|
7
|
+
let fileSrc = `${source}/database/database-reinit.sql.ejs`;
|
|
8
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
9
|
+
let fileDest = IoUt.withDPA(configuration, `database/database-reinit.sql`);
|
|
10
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
11
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
12
|
+
|
|
13
|
+
fileSrc = `${source}/database/database-account.sql.ejs`;
|
|
14
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
15
|
+
fileDest = IoUt.withDPA(configuration, `database/database-account.sql`);
|
|
16
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
17
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
18
|
+
|
|
19
|
+
fileSrc = `${source}/database/init-db.sh`;
|
|
20
|
+
fileDest = IoUt.withDPA(configuration, "init-db.sh");
|
|
21
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
22
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
23
|
+
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
const ioSpringConfiguration = async (source, configuration = {}) => {
|
|
27
|
+
let fileSrc = `${source}/mvn-build.sh`;
|
|
28
|
+
let fileDest = IoUt.withDPA(configuration, "mvn-build.sh");
|
|
29
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
30
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
31
|
+
|
|
32
|
+
fileSrc = `${source}/mvn-env.sh.ejs`;
|
|
33
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
34
|
+
fileDest = IoUt.withDPA(configuration, `mvn-env.sh`);
|
|
35
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
36
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
37
|
+
|
|
38
|
+
fileSrc = `${source}/source-api/env.properties.ejs`;
|
|
39
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
40
|
+
fileDest = IoUt.withApi(configuration, `src/main/resources/env.properties`);
|
|
41
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
42
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
43
|
+
|
|
44
|
+
fileSrc = `${source}/source-api/application.yml.ejs`;
|
|
45
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
46
|
+
fileDest = IoUt.withApi(configuration, "src/main/resources/application.yml");
|
|
47
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
48
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
49
|
+
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
const ioSpringSource = async (source, configuration = {}) => {
|
|
53
|
+
let pathPackage = await IoUt.ioPackage("test", configuration, IoUt.withTest)
|
|
54
|
+
|
|
55
|
+
let fileSrc = `${source}/.placeholder`;
|
|
56
|
+
let fileDest = IoUt.withTest(configuration, `src/main/java/${pathPackage}/.placeholder`);
|
|
57
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
58
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
59
|
+
|
|
60
|
+
// 数据库脚本文件占位符
|
|
61
|
+
fileDest = IoUt.withDomain(configuration,
|
|
62
|
+
`src/main/resources/${configuration.artifactId}/database/schema/.placeholder`);
|
|
63
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
64
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
65
|
+
|
|
66
|
+
// ActOperationCommon
|
|
67
|
+
pathPackage = await IoUt.ioPackage("base", configuration, IoUt.withDomain);
|
|
68
|
+
fileSrc = `${source}/source-domain/ActOperationCommon.ejs`;
|
|
69
|
+
fileDest = IoUt.withDomain(configuration, `src/main/java/${pathPackage}/ActOperationCommon.java`);
|
|
70
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
71
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
72
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
73
|
+
|
|
74
|
+
// GenConfigAppXXXX
|
|
75
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withDomain);
|
|
76
|
+
fileSrc = `${source}/source-domain/GenConfigApp.ejs`;
|
|
77
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
78
|
+
fileDest = IoUt.withDomain(configuration, `src/main/java/${pathPackage}/GenConfigApp${configuration.srcId.toUpperCase()}.java`);
|
|
79
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
80
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
81
|
+
|
|
82
|
+
// GenAppModule
|
|
83
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withProvider);
|
|
84
|
+
fileSrc = `${source}/source-provider/GenAppModule.ejs`;
|
|
85
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
86
|
+
fileDest = IoUt.withProvider(configuration, `src/main/java/${pathPackage}/GenApp${configuration.srcId.toUpperCase()}Module.java`);
|
|
87
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
88
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
89
|
+
|
|
90
|
+
// AppDev
|
|
91
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withApi);
|
|
92
|
+
fileSrc = `${source}/source-api/AppDev.java.ejs`;
|
|
93
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
94
|
+
fileDest = IoUt.withApi(configuration, `src/main/java/${pathPackage}/${configuration.srcId.toUpperCase()}AppDev.java`);
|
|
95
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
96
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
97
|
+
|
|
98
|
+
// Application
|
|
99
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withApi);
|
|
100
|
+
fileSrc = `${source}/source-api/Application.java.ejs`;
|
|
101
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
102
|
+
fileDest = IoUt.withApi(configuration, `src/main/java/${pathPackage}/${configuration.srcId.toUpperCase()}Application.java`);
|
|
103
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
104
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
105
|
+
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
module.exports = {
|
|
109
|
+
ioSpringDatabase,
|
|
110
|
+
ioSpringConfiguration,
|
|
111
|
+
ioSpringSource,
|
|
112
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const Ec = require('../epic');
|
|
3
|
+
const IoZero = require('./ai.fn.initialize.__.zero.file');
|
|
4
|
+
const IoUt = require('./ai.fn.initialize.__.io.util');
|
|
5
|
+
const ioDPAStructure = async (baseDir, configuration) => {
|
|
6
|
+
const name = configuration.artifactId;
|
|
7
|
+
const folders = [
|
|
8
|
+
`${baseDir}/${name}`,
|
|
9
|
+
`${baseDir}/${name}/${name}-domain/database`,
|
|
10
|
+
`${baseDir}/${name}/${name}-domain/src/main/java`,
|
|
11
|
+
`${baseDir}/${name}/${name}-domain/src/main/resources/plugins/${name}`,
|
|
12
|
+
`${baseDir}/${name}/${name}-domain/src/main/resources/plugins/${name}/database/${configuration.dbType}/`,
|
|
13
|
+
`${baseDir}/${name}/${name}-domain/src/test/java`,
|
|
14
|
+
`${baseDir}/${name}/${name}-domain/src/test/resources`,
|
|
15
|
+
`${baseDir}/${name}/${name}-api/src/main/java`,
|
|
16
|
+
`${baseDir}/${name}/${name}-api/src/main/resources`,
|
|
17
|
+
`${baseDir}/${name}/${name}-api/src/test/java`,
|
|
18
|
+
`${baseDir}/${name}/${name}-api/src/test/resources`,
|
|
19
|
+
`${baseDir}/${name}/${name}-provider/src/main/java`,
|
|
20
|
+
`${baseDir}/${name}/${name}-provider/src/main/resources`,
|
|
21
|
+
`${baseDir}/${name}/${name}-provider/src/test/java`,
|
|
22
|
+
`${baseDir}/${name}/${name}-provider/src/test/resources`,
|
|
23
|
+
];
|
|
24
|
+
const results = [];
|
|
25
|
+
folders.map(async (folder) => {
|
|
26
|
+
Ec.execute("创建目录:" + folder);
|
|
27
|
+
await fs.mkdir(folder, {recursive: true});
|
|
28
|
+
results.push(true);
|
|
29
|
+
})
|
|
30
|
+
return results;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const ioDPAPom = async (source, configuration = {}) => {
|
|
34
|
+
let fileSrc = `${source}/pom.xml.ejs`;
|
|
35
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
36
|
+
let fileDest = IoUt.withDPA(configuration, `pom.xml`);
|
|
37
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
38
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
39
|
+
|
|
40
|
+
fileSrc = `${source}/source-api/pom.xml.ejs`;
|
|
41
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
42
|
+
fileDest = IoUt.withApi(configuration, `pom.xml`);
|
|
43
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
44
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
45
|
+
|
|
46
|
+
fileSrc = `${source}/source-provider/pom.xml.ejs`;
|
|
47
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
48
|
+
fileDest = IoUt.withProvider(configuration, `pom.xml`);
|
|
49
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
50
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
51
|
+
|
|
52
|
+
fileSrc = `${source}/source-domain/pom.xml.ejs`;
|
|
53
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
54
|
+
fileDest = IoUt.withDomain(configuration, `pom.xml`);
|
|
55
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
56
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
module.exports = {
|
|
60
|
+
ioDPAStructure,
|
|
61
|
+
ioDPAPom,
|
|
62
|
+
...IoZero,
|
|
63
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const Ec = require("../epic");
|
|
3
|
+
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
4
|
+
const ioModuleDatabase = async (source, configuration = {}) => {
|
|
5
|
+
let fileSrc = `${source}/database/database-reinit.sh`;
|
|
6
|
+
let fileDest = IoUt.withDomain(configuration, `database/database-reinit.sh`);
|
|
7
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
8
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
9
|
+
|
|
10
|
+
fileSrc = `${source}/database/database-reinit.sql`;
|
|
11
|
+
fileDest = IoUt.withDomain(configuration, `database/database-reinit.sql`);
|
|
12
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
13
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
14
|
+
|
|
15
|
+
fileSrc = `${source}/database/init-db.sh`;
|
|
16
|
+
fileDest = IoUt.withDomain(configuration, `init-db.sh`);
|
|
17
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
18
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
19
|
+
|
|
20
|
+
const databaseType = configuration.dbType;
|
|
21
|
+
fileSrc = `${source}/database/${databaseType}.properties`;
|
|
22
|
+
fileDest = IoUt.withDomain(configuration, `src/main/resources/plugins/${configuration.artifactId}/database/${databaseType}.properties`);
|
|
23
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
24
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
25
|
+
|
|
26
|
+
fileSrc = `${source}/database/${databaseType}.yml`;
|
|
27
|
+
fileDest = IoUt.withDomain(configuration, `src/main/resources/plugins/${configuration.artifactId}/database/${databaseType}.yml`);
|
|
28
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
29
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
30
|
+
|
|
31
|
+
fileSrc = `${source}/.placeholder`;
|
|
32
|
+
fileDest = IoUt.withDomain(configuration, `src/main/resources/plugins/${configuration.artifactId}/database/${databaseType}/.placeholder`);
|
|
33
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
34
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ioModuleConfiguration = async (source, configuration = {}) => {
|
|
39
|
+
let fileSrc = `${source}/source-domain/configuration.yml.ejs`;
|
|
40
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
41
|
+
let fileDest = IoUt.withDomain(configuration, `src/main/resources/plugins/${configuration.artifactId}.yml`);
|
|
42
|
+
await fs.writeFile(fileDest, fileContent, null);
|
|
43
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
44
|
+
|
|
45
|
+
fileSrc = `${source}/.placeholder`;
|
|
46
|
+
fileDest = IoUt.withDomain(configuration, `src/main/resources/plugins/${configuration.artifactId}/.placeholder`);
|
|
47
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
48
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const ioModuleSource = async (source, configuration = {}) => {
|
|
53
|
+
const pathPackage = configuration.srcPackage.replace(/\./g, "/");
|
|
54
|
+
let dirPackage = IoUt.withDomain(configuration, `src/main/java/${pathPackage}`);
|
|
55
|
+
await fs.mkdir(dirPackage, {recursive: true});
|
|
56
|
+
// 确保目录确实存在
|
|
57
|
+
await fs.access(dirPackage, fs.constants.F_OK);
|
|
58
|
+
let fileSrc = `${source}/source-domain/ExtensionGeneration.ejs`;
|
|
59
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
60
|
+
let fileDest = IoUt.withDomain(configuration, `src/main/java/${pathPackage}/Extension${configuration.srcId.toUpperCase()}Generation.java`);
|
|
61
|
+
await fs.writeFile(fileDest, fileContent, null);
|
|
62
|
+
Ec.execute("配置代码:" + fileDest.green);
|
|
63
|
+
|
|
64
|
+
dirPackage = IoUt.withProvider(configuration, `src/main/java/${pathPackage}`);
|
|
65
|
+
await fs.mkdir(dirPackage, {recursive: true});
|
|
66
|
+
// 确保目录确实存在
|
|
67
|
+
await fs.access(dirPackage, fs.constants.F_OK);
|
|
68
|
+
|
|
69
|
+
fileSrc = `${source}/source-provider/ExtensionSource.ejs`;
|
|
70
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
71
|
+
fileDest = IoUt.withProvider(configuration, `src/main/java/${pathPackage}/Extension${configuration.srcId.toUpperCase()}Source.java`);
|
|
72
|
+
await fs.writeFile(fileDest, fileContent);
|
|
73
|
+
Ec.execute("生成器代码:" + fileDest.green);
|
|
74
|
+
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
module.exports = {
|
|
78
|
+
ioModuleDatabase,
|
|
79
|
+
ioModuleConfiguration,
|
|
80
|
+
ioModuleSource,
|
|
81
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const Ec = require("../epic");
|
|
3
|
+
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
4
|
+
const {config} = require("exceljs");
|
|
5
|
+
|
|
6
|
+
const initAppConfiguration = (parsed = {}) => {
|
|
7
|
+
const name = parsed.name;
|
|
8
|
+
const configuration = IoUt.ioConfiguration(parsed, name);
|
|
9
|
+
const appName = IoUt.ioAppName(name);
|
|
10
|
+
configuration.srcPackage = `io.zerows.apps.zero.${appName}`;
|
|
11
|
+
configuration.srcId = appName;
|
|
12
|
+
configuration.srcType = Symbol("APP");
|
|
13
|
+
|
|
14
|
+
configuration.dbName = "DB_ZERO_" + appName.toUpperCase();
|
|
15
|
+
configuration.dbUser = appName;
|
|
16
|
+
configuration.dbPassword = appName;
|
|
17
|
+
return configuration;
|
|
18
|
+
}
|
|
19
|
+
const initApp = async (configuration = {}) => {
|
|
20
|
+
console.log(configuration);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
module.exports = {
|
|
24
|
+
initApp,
|
|
25
|
+
initAppConfiguration
|
|
26
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const Ec = require('../epic');
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const Io = require("./ai.fn.initialize.__.zero.directory");
|
|
4
|
+
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
5
|
+
|
|
6
|
+
const initModuleConfiguration = (parsed = {}) => {
|
|
7
|
+
const module = parsed.module;
|
|
8
|
+
const configuration = IoUt.ioConfiguration(parsed, module);
|
|
9
|
+
configuration.artifactId = `zero-extension-${module}`;
|
|
10
|
+
configuration.srcType = Symbol("MODULE");
|
|
11
|
+
return configuration;
|
|
12
|
+
}
|
|
13
|
+
const initMod = async (configuration = {}) => {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// 1. 先创建基本目录
|
|
17
|
+
Ec.execute("----------- 目录创建 -----------");
|
|
18
|
+
const baseDir = configuration.srcOut;
|
|
19
|
+
const created = await Io.ioDPAStructure(baseDir, configuration);
|
|
20
|
+
if (!(created.every(item => true === item))) {
|
|
21
|
+
Ec.error(`目录初始化异常:${configuration.srcOut}`)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Ec.execute("----------- 文件生成 -----------");
|
|
25
|
+
// 2. 每个项目的 pom.xml 文件初始化
|
|
26
|
+
const type = configuration.srcType;
|
|
27
|
+
const sourceTpl = Ec.ioRoot() + "/_template/" + type.description;
|
|
28
|
+
const genPom = await Io.ioDPAPom(sourceTpl, configuration);
|
|
29
|
+
if (!genPom) {
|
|
30
|
+
Ec.error(`pom.xml 文件生成异常:${configuration.srcOut}`)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// 3. 数据库文件初始化
|
|
35
|
+
Ec.execute("----------- 数据库初始化 -----------");
|
|
36
|
+
const genDatabase = await Io.ioModuleDatabase(sourceTpl, configuration);
|
|
37
|
+
if (!genDatabase) {
|
|
38
|
+
Ec.error(`数据库文件生成异常:${configuration.srcOut}`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// 4. 代码生成文件初始化
|
|
43
|
+
Ec.execute("----------- 代码生成 -----------");
|
|
44
|
+
const genModule = await Io.ioModuleConfiguration(sourceTpl, configuration);
|
|
45
|
+
if (!genModule) {
|
|
46
|
+
Ec.error(`配置文件生成异常:${configuration.srcOut}`)
|
|
47
|
+
}
|
|
48
|
+
const genSource = await Io.ioModuleSource(sourceTpl, configuration);
|
|
49
|
+
if (!genSource) {
|
|
50
|
+
Ec.error(`源代码文件生成异常:${configuration.srcOut}`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 5. 权限变更
|
|
54
|
+
const genChmod = await IoUt.ioChmod(configuration.srcOut);
|
|
55
|
+
if (!genChmod) {
|
|
56
|
+
Ec.error(`权限变更异常:${configuration.srcOut}`)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
initMod,
|
|
62
|
+
initModuleConfiguration,
|
|
63
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const Ec = require("../epic");
|
|
3
|
+
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
4
|
+
const Io = require("./ai.fn.initialize.__.spring.directory");
|
|
5
|
+
const initSpringConfiguration = (parsed = {}) => {
|
|
6
|
+
const name = parsed.name;
|
|
7
|
+
const configuration = IoUt.ioConfiguration(parsed, name);
|
|
8
|
+
configuration.groupId = "io.zerows.apps";
|
|
9
|
+
const appName = IoUt.ioAppName(name);
|
|
10
|
+
configuration.srcPackage = `io.zerows.apps.spring.${appName}`;
|
|
11
|
+
configuration.srcId = appName;
|
|
12
|
+
configuration.srcType = Symbol("SPRING");
|
|
13
|
+
|
|
14
|
+
configuration.dbName = "DB_SPRING_" + appName.toUpperCase();
|
|
15
|
+
configuration.dbUser = appName;
|
|
16
|
+
configuration.dbPassword = appName;
|
|
17
|
+
configuration.dbHost = "ox.engine.cn";
|
|
18
|
+
configuration.dbPort = 3306;
|
|
19
|
+
return configuration;
|
|
20
|
+
}
|
|
21
|
+
const initSpring = async (configuration = {}) => {
|
|
22
|
+
// 1. 先创建基本目录
|
|
23
|
+
Ec.execute("----------- 目录创建 -----------");
|
|
24
|
+
const baseDir = configuration.srcOut;
|
|
25
|
+
const created = await Io.ioDPASpringStructure(baseDir, configuration);
|
|
26
|
+
if (!(created.every(item => true === item))) {
|
|
27
|
+
Ec.error(`目录初始化异常:${configuration.srcOut}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Ec.execute("----------- 文件生成 -----------");
|
|
32
|
+
// 2. 每个项目的 pom.xml 文件初始化
|
|
33
|
+
const type = configuration.srcType;
|
|
34
|
+
const sourceTpl = Ec.ioRoot() + "/_template/" + type.description;
|
|
35
|
+
const genPom = await Io.ioDPASpringPom(sourceTpl, configuration);
|
|
36
|
+
if (!genPom) {
|
|
37
|
+
Ec.error(`pom.xml 文件生成异常:${configuration.srcOut}`)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// 3. 数据库文件初始化
|
|
42
|
+
Ec.execute("----------- 数据库初始化 -----------");
|
|
43
|
+
const genDatabase = await Io.ioSpringDatabase(sourceTpl, configuration);
|
|
44
|
+
if (!genDatabase) {
|
|
45
|
+
Ec.error(`数据库文件生成异常:${configuration.srcOut}`)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// 4. 代码生成文件初始化
|
|
50
|
+
Ec.execute("----------- 代码生成 -----------");
|
|
51
|
+
const genModule = await Io.ioSpringConfiguration(sourceTpl, configuration);
|
|
52
|
+
if (!genModule) {
|
|
53
|
+
Ec.error(`配置文件生成异常:${configuration.srcOut}`)
|
|
54
|
+
}
|
|
55
|
+
const genSource = await Io.ioSpringSource(sourceTpl, configuration);
|
|
56
|
+
if (!genSource) {
|
|
57
|
+
Ec.error(`源代码文件生成异常:${configuration.srcOut}`)
|
|
58
|
+
}
|
|
59
|
+
// 5. 权限变更
|
|
60
|
+
const genChmod = await IoUt.ioChmod(configuration.srcOut);
|
|
61
|
+
if (!genChmod) {
|
|
62
|
+
Ec.error(`权限变更异常:${configuration.srcOut}`)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
module.exports = {
|
|
66
|
+
initSpringConfiguration,
|
|
67
|
+
initSpring,
|
|
68
|
+
}
|