zero-ai 0.3.35 → 0.3.36
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 +16 -1
- package/package.json +1 -1
- package/src/_template/MODULE/database/database-reinit.sh +1 -1
- package/src/_template/SPRING/database/init-db.sh +2 -2
- package/src/_template/SPRING/mvn-build.sh +1 -1
- package/src/_template/SPRING/pom.xml.ejs +4 -21
- package/src/_template/SPRING/source-api/pom.xml.ejs +1 -2
- package/src/_template/SPRING/source-domain/pom.xml.ejs +0 -1
- package/src/_template/ZERO/.placeholder +0 -0
- package/src/_template/ZERO/app.env.ejs +96 -0
- package/src/_template/ZERO/database/database-account.sql.ejs +3 -0
- package/src/_template/ZERO/database/database-reinit-history.sql.ejs +5 -0
- package/src/_template/ZERO/database/database-reinit-workflow.sql.ejs +5 -0
- package/src/_template/ZERO/database/database-reinit.sql.ejs +5 -0
- package/src/_template/ZERO/database/init-db.sh +49 -0
- package/src/_template/ZERO/mvn-build.sh +3 -0
- package/src/_template/ZERO/pom.xml.ejs +24 -0
- package/src/_template/ZERO/source-api/AppDev.java.ejs +13 -0
- package/src/_template/ZERO/source-api/Application.java.ejs +11 -0
- package/src/_template/ZERO/source-api/env.properties.ejs +18 -0
- package/src/_template/ZERO/source-api/flyway.conf +6 -0
- package/src/_template/ZERO/source-api/pom.xml.ejs +24 -0
- package/src/_template/ZERO/source-api/vertx.yml.ejs +70 -0
- package/src/_template/ZERO/source-domain/ModuleGeneration.java.ejs +8 -0
- package/src/_template/ZERO/source-domain/pom.xml.ejs +20 -0
- package/src/_template/ZERO/source-provider/ModuleSource.java.ejs +14 -0
- package/src/_template/ZERO/source-provider/pom.xml.ejs +21 -0
- package/src/_template/ZERO/source-test/pom.xml.ejs +28 -0
- package/src/_template/version +5 -0
- package/src/commander/zero.json +24 -0
- package/src/commander-ai/fn.source.spring.js +11 -7
- package/src/commander-ai/fn.source.zero.js +24 -0
- package/src/commander-ai/index.js +5 -4
- package/src/commander-shared/ai.fn.initialize.__.io.util.js +42 -37
- package/src/commander-shared/ai.fn.initialize.__.module.directory.js +63 -0
- package/src/commander-shared/ai.fn.initialize.__.module.file.js +81 -0
- package/src/commander-shared/ai.fn.initialize.__.spring.file.js +0 -1
- package/src/commander-shared/ai.fn.initialize.__.zero.directory.js +21 -9
- package/src/commander-shared/ai.fn.initialize.__.zero.file.js +88 -52
- package/src/commander-shared/ai.fn.initialize.module.js +1 -1
- package/src/commander-shared/ai.fn.initialize.spring.js +8 -3
- package/src/commander-shared/ai.fn.initialize.zero.js +84 -0
- package/src/commander-shared/ai.fn.parse.argument.js +9 -1
- package/src/commander-shared/index.js +2 -0
- /package/src/{commander → cab/removed}/app.json +0 -0
- /package/src/{commander → cab/removed}/mod.json +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const Ec = require("../epic");
|
|
2
|
+
const Ut = require("../commander-shared");
|
|
3
|
+
const request = require("superagent");
|
|
4
|
+
|
|
5
|
+
module.exports = async (options) => {
|
|
6
|
+
/*
|
|
7
|
+
* 参数解析,解析完成后直接加载基础版本,由于 parseArgument 的通用性,版本解析
|
|
8
|
+
* 只会在 ai zero 等项目初始化命令中完成,所以这里需要单独调用 parseVersion 方法
|
|
9
|
+
* 进行版本解析。
|
|
10
|
+
*/
|
|
11
|
+
let parsed = Ut.parseArgument(options);
|
|
12
|
+
parsed = await Ut.parseVersion(parsed);
|
|
13
|
+
/*
|
|
14
|
+
* 基本信息验证
|
|
15
|
+
*/
|
|
16
|
+
if (!Ut.nameValid(parsed.name)) {
|
|
17
|
+
Ec.error("应用名称只能包含字母、数字、点(.)和短横线(-),且不能以数字、点(.)或短横线(-)开头!");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const configuration = await Ut.initZeroConfiguration(parsed);
|
|
21
|
+
Ec.execute(`准备生成 Zero App 应用:${configuration.artifactId}`);
|
|
22
|
+
await Ut.initZero(configuration);
|
|
23
|
+
Ec.info(`应用生成完成!`);
|
|
24
|
+
}
|
|
@@ -2,21 +2,22 @@ const executeUuid = require('./fn.random.uuid');
|
|
|
2
2
|
const executeString = require('./fn.random.string');
|
|
3
3
|
const executeMD5 = require('./fn.random.md5');
|
|
4
4
|
const executeFrontendSync = require('./fn.source.sync');
|
|
5
|
-
const executeApp = require('./fn.source.app');
|
|
6
|
-
const executeMod = require('./fn.source.mod');
|
|
7
5
|
const executeHelp = require('./fn.help.metadata');
|
|
8
6
|
const executeWeb = require('./fn.source.front');
|
|
7
|
+
|
|
9
8
|
const executeSpring = require('./fn.source.spring');
|
|
9
|
+
const executeZero = require('./fn.source.zero');
|
|
10
10
|
const exported = {
|
|
11
11
|
executeUuid, // ai uuid
|
|
12
12
|
executeString, // ai str
|
|
13
13
|
executeMD5, // ai md5
|
|
14
14
|
executeFrontendSync, // ai sync
|
|
15
|
-
executeApp, // ai app
|
|
16
|
-
executeMod, // ai mod
|
|
17
15
|
executeHelp, // ai help
|
|
18
16
|
executeWeb, // ai web
|
|
17
|
+
// Spring 脚手架
|
|
19
18
|
executeSpring, // ai spring
|
|
19
|
+
// Zero 基础脚手架
|
|
20
|
+
executeZero, // ai zero
|
|
20
21
|
};
|
|
21
22
|
module.exports = exported;
|
|
22
23
|
/**
|
|
@@ -5,40 +5,13 @@ const ejs = require("ejs");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
|
|
7
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
8
|
Ec.execute(`读取 EJS 模版:${source.blue}`)
|
|
36
9
|
fs.readFile(source, "utf8", (err, data) => {
|
|
37
10
|
if (err) {
|
|
38
11
|
reject(err);
|
|
39
12
|
}
|
|
40
13
|
// 渲染模板
|
|
41
|
-
const renderContent = ejs.render(data,
|
|
14
|
+
const renderContent = ejs.render(data, configuration);
|
|
42
15
|
resolve(renderContent);
|
|
43
16
|
});
|
|
44
17
|
})
|
|
@@ -72,17 +45,48 @@ const ioConfiguration = (parsed = {}, name) => {
|
|
|
72
45
|
configMap.srcConfig = parsed.config;
|
|
73
46
|
configMap.dbType = "MYSQL";
|
|
74
47
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
48
|
+
return configMap;
|
|
49
|
+
}
|
|
50
|
+
const ioApp = async (configuration = {}) => {
|
|
51
|
+
let configFile = process.cwd() + `\`/${configuration.srcConfig}`;
|
|
52
|
+
const configDefault = process.cwd() + `/app.json`;
|
|
53
|
+
if (!fs.existsSync(configFile)) {
|
|
54
|
+
Ec.warn(`配置文件不存在,使用默认配置!路径 = ` + configDefault.blue);
|
|
55
|
+
configFile = configDefault;
|
|
78
56
|
}
|
|
79
57
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
58
|
+
// 加载配置文件
|
|
59
|
+
if (fs.existsSync(configFile)) {
|
|
60
|
+
// 配置加载
|
|
61
|
+
const configData = Ec.ioJObject(configFile);
|
|
62
|
+
[
|
|
63
|
+
"framework", // 框架版本
|
|
64
|
+
"dbHost", // 数据库主机
|
|
65
|
+
"dbPort", // 数据库端口
|
|
66
|
+
"dbUser", // 数据库用户
|
|
67
|
+
"dbPassword", // 数据库密码
|
|
68
|
+
"dbName", // 数据库名称
|
|
69
|
+
"groupId", // Maven Group ID
|
|
70
|
+
"artifactId", // Maven Artifact ID
|
|
71
|
+
"srcPackage" // Java 包名称
|
|
72
|
+
].forEach(field => {
|
|
73
|
+
if (configData.hasOwnProperty(field)) {
|
|
74
|
+
configuration[field] = configData[field];
|
|
75
|
+
Ec.execute("\t配置项覆盖:" + field + " = " + configData[field]);
|
|
76
|
+
}
|
|
77
|
+
})
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
/*
|
|
80
|
+
* - group / Maven 对应的 groupId
|
|
81
|
+
* - id / Maven 对应的 artifactId
|
|
82
|
+
* - name / 模块名称,大写形式
|
|
83
|
+
* - packageName / Java 包名称
|
|
84
|
+
*/
|
|
85
|
+
configuration.id = configuration?.artifactId;
|
|
86
|
+
configuration.name = configuration?.srcId.toUpperCase();
|
|
87
|
+
configuration.packageName = configuration?.srcPackage;
|
|
88
|
+
configuration.group = configuration?.groupId;
|
|
89
|
+
return configuration;
|
|
86
90
|
}
|
|
87
91
|
const ioAppName = (name) => {
|
|
88
92
|
let appName;
|
|
@@ -140,7 +144,7 @@ const ioChmod = async (directory) => {
|
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
const ioPackage = async (suffix, configuration, baseFn) => {
|
|
143
|
-
const packageName = !!suffix ? configuration.srcPackage + `.${suffix}
|
|
147
|
+
const packageName = !!suffix ? configuration.srcPackage + `.${suffix}` : configuration.srcPackage;
|
|
144
148
|
const pathPackage = packageName.replace(/\./g, "/");
|
|
145
149
|
let dirPackage = baseFn(configuration, `src/main/java/${pathPackage}`);
|
|
146
150
|
await fsAsync.mkdir(dirPackage, {recursive: true});
|
|
@@ -153,6 +157,7 @@ module.exports = {
|
|
|
153
157
|
ioConfiguration,
|
|
154
158
|
ioEJS,
|
|
155
159
|
ioAppName,
|
|
160
|
+
ioApp,
|
|
156
161
|
withTest,
|
|
157
162
|
withDomain,
|
|
158
163
|
withProvider,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const Ec = require('../epic');
|
|
3
|
+
const IoZero = require('./ai.fn.initialize.__.module.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
|
+
}
|
|
@@ -3,7 +3,6 @@ const Ec = require("../epic");
|
|
|
3
3
|
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
4
4
|
|
|
5
5
|
const ioSpringDatabase = async (source, configuration = {}) => {
|
|
6
|
-
|
|
7
6
|
let fileSrc = `${source}/database/database-reinit.sql.ejs`;
|
|
8
7
|
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
9
8
|
let fileDest = IoUt.withDPA(configuration, `database/database-reinit.sql`);
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
|
-
|
|
3
|
-
const
|
|
2
|
+
|
|
3
|
+
const Ec = require("../epic");
|
|
4
4
|
const IoUt = require('./ai.fn.initialize.__.io.util');
|
|
5
|
-
const
|
|
5
|
+
const IoZero = require("./ai.fn.initialize.__.zero.file");
|
|
6
|
+
|
|
7
|
+
const ioDPAZeroStructure = async (baseDir, configuration) => {
|
|
6
8
|
const name = configuration.artifactId;
|
|
7
9
|
const folders = [
|
|
8
10
|
`${baseDir}/${name}`,
|
|
9
|
-
`${baseDir}/${name}/${
|
|
11
|
+
`${baseDir}/${name}/.r2mo/database/${configuration.dbType}/`,
|
|
12
|
+
`${baseDir}/${name}/.r2mo/monitor/`,
|
|
10
13
|
`${baseDir}/${name}/${name}-domain/src/main/java`,
|
|
11
14
|
`${baseDir}/${name}/${name}-domain/src/main/resources/plugins/${name}`,
|
|
12
15
|
`${baseDir}/${name}/${name}-domain/src/main/resources/plugins/${name}/database/${configuration.dbType}/`,
|
|
@@ -20,6 +23,10 @@ const ioDPAStructure = async (baseDir, configuration) => {
|
|
|
20
23
|
`${baseDir}/${name}/${name}-provider/src/main/resources`,
|
|
21
24
|
`${baseDir}/${name}/${name}-provider/src/test/java`,
|
|
22
25
|
`${baseDir}/${name}/${name}-provider/src/test/resources`,
|
|
26
|
+
`${baseDir}/${name}/${name}-test/src/main/java`,
|
|
27
|
+
`${baseDir}/${name}/${name}-test/src/main/resources`,
|
|
28
|
+
`${baseDir}/${name}/${name}-test/src/test/java`,
|
|
29
|
+
`${baseDir}/${name}/${name}-test/src/test/resources`,
|
|
23
30
|
];
|
|
24
31
|
const results = [];
|
|
25
32
|
folders.map(async (folder) => {
|
|
@@ -29,8 +36,7 @@ const ioDPAStructure = async (baseDir, configuration) => {
|
|
|
29
36
|
})
|
|
30
37
|
return results;
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
const ioDPAPom = async (source, configuration = {}) => {
|
|
39
|
+
const ioDPAZeroPom = async (source, configuration = {}) => {
|
|
34
40
|
let fileSrc = `${source}/pom.xml.ejs`;
|
|
35
41
|
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
36
42
|
let fileDest = IoUt.withDPA(configuration, `pom.xml`);
|
|
@@ -54,10 +60,16 @@ const ioDPAPom = async (source, configuration = {}) => {
|
|
|
54
60
|
fileDest = IoUt.withDomain(configuration, `pom.xml`);
|
|
55
61
|
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
56
62
|
Ec.execute("生成文件:" + fileDest.green);
|
|
63
|
+
|
|
64
|
+
fileSrc = `${source}/source-test/pom.xml.ejs`;
|
|
65
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
66
|
+
fileDest = IoUt.withTest(configuration, `pom.xml`);
|
|
67
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
68
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
57
69
|
return true;
|
|
58
70
|
}
|
|
59
71
|
module.exports = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
...IoZero
|
|
72
|
+
ioDPAZeroStructure,
|
|
73
|
+
ioDPAZeroPom,
|
|
74
|
+
...IoZero
|
|
63
75
|
}
|
|
@@ -1,81 +1,117 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
let
|
|
7
|
-
await
|
|
8
|
-
|
|
4
|
+
const Ec = require("../epic");
|
|
5
|
+
const ioZeroDatabase = async (source, configuration = {}) => {
|
|
6
|
+
let fileSrc = `${source}/database/database-account.sql.ejs`;
|
|
7
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
8
|
+
let fileDest = IoUt.withDPA(configuration, `.r2mo/database/${configuration.dbType}/database-account.sql`);
|
|
9
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
10
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
9
11
|
|
|
10
|
-
fileSrc = `${source}/database/database-reinit.sql`;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
fileSrc = `${source}/database/database-reinit.sql.ejs`;
|
|
13
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
14
|
+
fileDest = IoUt.withDPA(configuration, `.r2mo/database/${configuration.dbType}/database-reinit.sql`);
|
|
15
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
16
|
+
Ec.execute("生成文件/DB:" + fileDest.green);
|
|
17
|
+
|
|
18
|
+
fileSrc = `${source}/database/database-reinit-workflow.sql.ejs`;
|
|
19
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
20
|
+
fileDest = IoUt.withDPA(configuration, `.r2mo/database/${configuration.dbType}/database-reinit-workflow.sql`);
|
|
21
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
22
|
+
Ec.execute("生成文件/WF:" + fileDest.green);
|
|
23
|
+
|
|
24
|
+
fileSrc = `${source}/database/database-reinit-history.sql.ejs`;
|
|
25
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
26
|
+
fileDest = IoUt.withDPA(configuration, `.r2mo/database/${configuration.dbType}/database-reinit-history.sql`);
|
|
27
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
28
|
+
Ec.execute("生成文件/HIS:" + fileDest.green);
|
|
14
29
|
|
|
15
30
|
fileSrc = `${source}/database/init-db.sh`;
|
|
16
|
-
fileDest = IoUt.
|
|
31
|
+
fileDest = IoUt.withDPA(configuration, "init-db.sh");
|
|
17
32
|
await fs.copyFile(fileSrc, fileDest);
|
|
18
33
|
Ec.execute("拷贝文件:" + fileDest.green);
|
|
19
34
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const ioZeroConfiguration = async (source, configuration = {}) => {
|
|
38
|
+
let fileSrc = `${source}/mvn-build.sh`;
|
|
39
|
+
let fileDest = IoUt.withDPA(configuration, "mvn-build.sh");
|
|
23
40
|
await fs.copyFile(fileSrc, fileDest);
|
|
24
41
|
Ec.execute("拷贝文件:" + fileDest.green);
|
|
25
42
|
|
|
26
|
-
fileSrc = `${source}/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
fileSrc = `${source}/app.env.ejs`;
|
|
44
|
+
let fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
45
|
+
fileDest = IoUt.withDPA(configuration, `.r2mo/app.env`);
|
|
46
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
47
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
30
48
|
|
|
31
|
-
fileSrc = `${source}
|
|
32
|
-
|
|
49
|
+
fileSrc = `${source}/source-api/vertx.yml.ejs`;
|
|
50
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
51
|
+
fileDest = IoUt.withApi(configuration, "src/main/resources/vertx.yml");
|
|
52
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
53
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
54
|
+
|
|
55
|
+
fileSrc = `${source}/source-api/env.properties.ejs`;
|
|
56
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
57
|
+
fileDest = IoUt.withApi(configuration, "src/main/resources/env.properties");
|
|
58
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
59
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
60
|
+
|
|
61
|
+
fileSrc = `${source}/source-api/flyway.conf`;
|
|
62
|
+
fileDest = IoUt.withApi(configuration, "src/main/resources/flyway.conf");
|
|
33
63
|
await fs.copyFile(fileSrc, fileDest);
|
|
34
64
|
Ec.execute("拷贝文件:" + fileDest.green);
|
|
35
65
|
return true;
|
|
36
66
|
}
|
|
67
|
+
const ioZeroSource = async (source, configuration = {}) => {
|
|
68
|
+
let pathPackage = await IoUt.ioPackage("test", configuration, IoUt.withTest)
|
|
37
69
|
|
|
38
|
-
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
await fs.writeFile(fileDest, fileContent, null);
|
|
43
|
-
Ec.execute("生成文件:" + fileDest.green);
|
|
70
|
+
let fileSrc = `${source}/.placeholder`;
|
|
71
|
+
let fileDest = IoUt.withTest(configuration, `src/main/java/${pathPackage}/.placeholder`);
|
|
72
|
+
await fs.copyFile(fileSrc, fileDest);
|
|
73
|
+
Ec.execute("拷贝文件:" + fileDest.green);
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
fileDest = IoUt.withDomain(configuration,
|
|
75
|
+
// 数据库脚本文件占位符
|
|
76
|
+
fileDest = IoUt.withDomain(configuration,
|
|
77
|
+
`src/main/resources/plugins/${configuration.artifactId}/database/.placeholder`);
|
|
47
78
|
await fs.copyFile(fileSrc, fileDest);
|
|
48
79
|
Ec.execute("拷贝文件:" + fileDest.green);
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
80
|
|
|
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
81
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withDomain);
|
|
83
|
+
fileSrc = `${source}/source-domain/ModuleGeneration.java.ejs`;
|
|
84
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
85
|
+
fileDest = IoUt.withDomain(configuration, `src/main/java/${pathPackage}/Module${configuration.srcId.toUpperCase()}Generation.java`);
|
|
86
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
87
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
88
|
+
|
|
89
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withProvider);
|
|
90
|
+
fileSrc = `${source}/source-provider/ModuleSource.java.ejs`;
|
|
91
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
92
|
+
fileDest = IoUt.withProvider(configuration, `src/main/java/${pathPackage}/Module${configuration.srcId.toUpperCase()}Source.java`);
|
|
93
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
94
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
68
95
|
|
|
69
|
-
|
|
96
|
+
// AppDev
|
|
97
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withApi);
|
|
98
|
+
fileSrc = `${source}/source-api/AppDev.java.ejs`;
|
|
70
99
|
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
71
|
-
fileDest = IoUt.
|
|
72
|
-
await fs.writeFile(fileDest, fileContent);
|
|
73
|
-
Ec.execute("
|
|
100
|
+
fileDest = IoUt.withApi(configuration, `src/main/java/${pathPackage}/${configuration.srcId.toUpperCase()}Dev.java`);
|
|
101
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
102
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
74
103
|
|
|
104
|
+
// Application
|
|
105
|
+
pathPackage = await IoUt.ioPackage(null, configuration, IoUt.withApi);
|
|
106
|
+
fileSrc = `${source}/source-api/Application.java.ejs`;
|
|
107
|
+
fileContent = await IoUt.ioEJS(fileSrc, configuration);
|
|
108
|
+
fileDest = IoUt.withApi(configuration, `src/main/java/${pathPackage}/${configuration.srcId.toUpperCase()}App.java`);
|
|
109
|
+
await fs.writeFile(fileDest, fileContent.toString(), null);
|
|
110
|
+
Ec.execute("生成文件:" + fileDest.green);
|
|
75
111
|
return true;
|
|
76
112
|
}
|
|
77
113
|
module.exports = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
114
|
+
ioZeroDatabase,
|
|
115
|
+
ioZeroConfiguration,
|
|
116
|
+
ioZeroSource,
|
|
81
117
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const Ec = require('../epic');
|
|
2
2
|
const fs = require("fs");
|
|
3
|
-
const Io = require("./ai.fn.initialize.__.
|
|
3
|
+
const Io = require("./ai.fn.initialize.__.module.directory");
|
|
4
4
|
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
5
5
|
|
|
6
6
|
const initModuleConfiguration = (parsed = {}) => {
|
|
@@ -2,7 +2,8 @@ const fs = require("fs");
|
|
|
2
2
|
const Ec = require("../epic");
|
|
3
3
|
const IoUt = require("./ai.fn.initialize.__.io.util");
|
|
4
4
|
const Io = require("./ai.fn.initialize.__.spring.directory");
|
|
5
|
-
const initSpringConfiguration = (parsed = {}) => {
|
|
5
|
+
const initSpringConfiguration = async (parsed = {}) => {
|
|
6
|
+
Ec.execute(`初始化 Spring 项目,${`r2mo-rapid`.green} 版本:${parsed.versionR2mo.red}`);
|
|
6
7
|
const name = parsed.name;
|
|
7
8
|
const configuration = IoUt.ioConfiguration(parsed, name);
|
|
8
9
|
configuration.groupId = "io.zerows.apps";
|
|
@@ -14,8 +15,12 @@ const initSpringConfiguration = (parsed = {}) => {
|
|
|
14
15
|
configuration.dbName = "DB_SPRING_" + appName.toUpperCase();
|
|
15
16
|
configuration.dbUser = appName;
|
|
16
17
|
configuration.dbPassword = appName;
|
|
17
|
-
configuration.dbHost = "
|
|
18
|
+
configuration.dbHost = "localhost";
|
|
18
19
|
configuration.dbPort = 3306;
|
|
20
|
+
|
|
21
|
+
// Spring 的基础是 r2mo-rapid 核心框架
|
|
22
|
+
configuration.framework = parsed.versionR2mo || "1.0.0";
|
|
23
|
+
await IoUt.ioApp(configuration);
|
|
19
24
|
return configuration;
|
|
20
25
|
}
|
|
21
26
|
const initSpring = async (configuration = {}) => {
|
|
@@ -57,7 +62,7 @@ const initSpring = async (configuration = {}) => {
|
|
|
57
62
|
Ec.error(`源代码文件生成异常:${configuration.srcOut}`)
|
|
58
63
|
}
|
|
59
64
|
// 5. 权限变更
|
|
60
|
-
const genChmod = await IoUt.ioChmod(configuration.srcOut);
|
|
65
|
+
const genChmod = await IoUt.ioChmod(configuration.srcOut + `/` + configuration.artifactId);
|
|
61
66
|
if (!genChmod) {
|
|
62
67
|
Ec.error(`权限变更异常:${configuration.srcOut}`)
|
|
63
68
|
}
|