jjb-cmd 2.2.1 → 2.2.3
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 +8 -0
- package/build.js +15 -0
- package/obf.config.json +3 -0
- package/package.json +1 -1
- package/src/new/cmd.auth/index.js +26 -1
- package/src/new/cmd.init/index.js +116 -1
- package/src/new/cmd.install/config.js +70 -1
- package/src/new/cmd.install/index.js +262 -1
- package/src/new/cmd.install/tools.js +230 -1
- package/src/new/cmd.install.app/index.js +27 -1
- package/src/new/cmd.jenkins/index.js +72 -1
- package/src/new/cmd.publish/index.js +197 -1
- package/src/new/cmd.push/index.js +76 -1
- package/src/new/cmd.push/java.js +148 -1
- package/src/new/cmd.push-set/index.js +205 -1
- package/src/new/cmd.refresh/index.js +65 -1
- package/src/new/cmd.reglist/index.js +23 -1
- package/src/new/cmd.rm-rf/index.js +58 -1
- package/src/new/cmd.version/index.js +35 -1
- package/src/old/cli.dva.register.saas.txt +40 -0
- package/src/old/cli.dva.register.spa.txt +22 -0
- package/src/old/cli.dva.router.saas.txt +210 -0
- package/src/old/cli.dva.router.spa.txt +119 -0
- package/src/old/cli.init.js +26 -1
- package/src/old/cli.install/config.js +206 -1
- package/src/old/cli.install/index.js +340 -1
- package/src/old/cli.install/tools.js +230 -1
- package/src/old/cli.merge.js +80 -1
- package/src/old/cli.pull.js +94 -1
- package/src/old/cli.pull2.js +377 -1
- package/src/old/cli.rm-rf.js +88 -1
- package/src/old/progress-bar.js +23 -1
- package/src/old/util.js +149 -1
package/src/new/cmd.push/java.js
CHANGED
@@ -1 +1,148 @@
|
|
1
|
-
const
|
1
|
+
const fs = require('fs');
|
2
|
+
const os = require('os');
|
3
|
+
const path = require('path');
|
4
|
+
const child_process = require('child_process');
|
5
|
+
const { CopyFolder, DeleteDirAllFile } = require('../../old/util');
|
6
|
+
const { GIT_TEMP_JAVA, GIT_JAVA_ENV_JSON, getApiHost } = require("../cmd.install/config");
|
7
|
+
const axios = require("axios");
|
8
|
+
|
9
|
+
module.exports = arguments => {
|
10
|
+
|
11
|
+
const authPath = path.join(__dirname, '../../../.auth');
|
12
|
+
if (!fs.existsSync(authPath)) {
|
13
|
+
console.log(`【Error】:no auth login`);
|
14
|
+
process.exit(0);
|
15
|
+
}
|
16
|
+
|
17
|
+
/**
|
18
|
+
* 环境
|
19
|
+
*/
|
20
|
+
const environment = arguments[1];
|
21
|
+
|
22
|
+
/**
|
23
|
+
* 描述
|
24
|
+
*/
|
25
|
+
const describe = arguments[2] || '"no message"';
|
26
|
+
|
27
|
+
/**
|
28
|
+
* 当前根路径
|
29
|
+
* @type {Promise<void> | Promise<string>}
|
30
|
+
*/
|
31
|
+
const root_path = path.resolve('./');
|
32
|
+
|
33
|
+
/**
|
34
|
+
* jjb配置文件路径
|
35
|
+
* @type {string}
|
36
|
+
*/
|
37
|
+
const config_json_path = `${root_path}\\jjb.config.js`;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* 打包输出目录
|
41
|
+
* @type {string}
|
42
|
+
*/
|
43
|
+
const build_output_dir = `${root_path}\\dist`;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* 临时目录
|
47
|
+
*/
|
48
|
+
const tmpdir = os.tmpdir();
|
49
|
+
|
50
|
+
const [username , password] = fs.readFileSync(authPath).toString().split('/');
|
51
|
+
axios.post(`${getApiHost()}/api/auth`, {
|
52
|
+
username,
|
53
|
+
password
|
54
|
+
}).then(res => {
|
55
|
+
if (res.data.status) {
|
56
|
+
if (fs.existsSync(config_json_path)) {
|
57
|
+
const jjbConfig = require(config_json_path);
|
58
|
+
// const config_json_file = JSON.parse(fs.readFileSync(config_json_path).toString());
|
59
|
+
if (jjbConfig.javaGit) {
|
60
|
+
const tempGit = tmpdir + '/' + GIT_TEMP_JAVA;
|
61
|
+
if (!fs.existsSync(tempGit)) {
|
62
|
+
fs.mkdirSync(tempGit);
|
63
|
+
}
|
64
|
+
const projectDir = `${tempGit}/${jjbConfig.javaGitName}`;
|
65
|
+
if (!fs.existsSync(projectDir)) {
|
66
|
+
child_process.execSync(`git clone ${jjbConfig.javaGit}`, {cwd: tempGit});
|
67
|
+
} else {
|
68
|
+
if (arguments[3] && "force" === arguments[3]) {
|
69
|
+
DeleteDirAllFile(projectDir, () => child_process.execSync(`git clone ${jjbConfig.javaGit}`, {cwd: tempGit}));
|
70
|
+
}
|
71
|
+
}
|
72
|
+
project_sync(tempGit, jjbConfig);
|
73
|
+
} else {
|
74
|
+
console.log('【Error】:no setting git');
|
75
|
+
}
|
76
|
+
}
|
77
|
+
} else {
|
78
|
+
console.log('Auth Fail!');
|
79
|
+
}
|
80
|
+
}).catch(e => {
|
81
|
+
console.log(e)
|
82
|
+
console.log('Auth NetWork Fail!');
|
83
|
+
});
|
84
|
+
|
85
|
+
if (arguments.length < 2) {
|
86
|
+
console.log('【Error】:参数传递错误');
|
87
|
+
process.exit(0);
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* 项目git同步
|
92
|
+
*/
|
93
|
+
function project_sync (tempGit, jjbConfig) {
|
94
|
+
const envData = jjbConfig.environment[environment];
|
95
|
+
const projectDir = `${tempGit}/${jjbConfig.javaGitName}`;
|
96
|
+
if (!fs.existsSync(projectDir)) {
|
97
|
+
console.log('【Error】:no setting javaGitName');
|
98
|
+
process.exit(0);
|
99
|
+
}
|
100
|
+
child_process.execSync(`git pull`, { cwd: projectDir });
|
101
|
+
if (!fs.existsSync(root_path + '/node_modules')) {
|
102
|
+
console.log('【warning】:Git Pull Done,yarn install project,please wait...');
|
103
|
+
child_process.execSync(`yarn`, { cwd: root_path });
|
104
|
+
console.log('yarn install Done!');
|
105
|
+
} else {
|
106
|
+
console.log(`Git Pull Done,yarn build:${environment},please wait...`);
|
107
|
+
}
|
108
|
+
child_process.execSync(`yarn build:${environment}`, { cwd: root_path, maxBuffer: 1000000000 });
|
109
|
+
console.log('Project build Done,copy project,please wait...');
|
110
|
+
if (fs.existsSync(build_output_dir)) {
|
111
|
+
const appIdentifier = jjbConfig.appIdentifier;
|
112
|
+
const indexContent = fs.readFileSync(build_output_dir + '/index.html');
|
113
|
+
fs.writeFileSync(build_output_dir + '/' + appIdentifier + '.html', indexContent, 'utf-8');
|
114
|
+
if (arguments[4] && arguments[4] === 'index') {
|
115
|
+
fs.writeFileSync(build_output_dir + '/index.html', indexContent, 'utf-8');
|
116
|
+
}
|
117
|
+
// const tempJavaPath = `${projectDir}/src/main/resources/templates/${GIT_JAVA_ENV_JSON[environment]}`;
|
118
|
+
const tempJavaPath = `${projectDir}/start/src/main/resources/templates`;
|
119
|
+
if (!fs.existsSync(tempJavaPath)) {
|
120
|
+
fs.mkdirSync(tempJavaPath);
|
121
|
+
}
|
122
|
+
child_process.execSync(`git checkout ${envData.javaGitBranch ? envData.javaGitBranch : 'master'}`, { cwd: projectDir });
|
123
|
+
const projectJavaPath = tempJavaPath + '/' + jjbConfig.appIdentifier;
|
124
|
+
DeleteDirAllFile(projectJavaPath, () => {
|
125
|
+
fs.mkdirSync(projectJavaPath);
|
126
|
+
fs.writeFileSync(projectJavaPath+'.html', indexContent, 'utf-8');
|
127
|
+
CopyFolder(build_output_dir + '\\' +jjbConfig.appIdentifier, projectJavaPath, () => {
|
128
|
+
console.log('Dist output copy Done,git add,please wait...', `git checkout ${jjbConfig.javaGitBranch ? jjbConfig.javaGitBranch : 'master'}`);
|
129
|
+
setTimeout(() => {
|
130
|
+
child_process.execSync(`git add .`, { cwd: projectDir });
|
131
|
+
console.log('Git Add Done,git commit,please wait...');
|
132
|
+
try {
|
133
|
+
child_process.execSync(`git commit -m ${describe} --no-verify`, { cwd: projectDir });
|
134
|
+
console.log('Git Commit Done,git push,please wait...');
|
135
|
+
} catch (e) {
|
136
|
+
console.log('【warning】:no commit,git push,please wait...');
|
137
|
+
}
|
138
|
+
child_process.execSync(`git push --force`, { cwd: projectDir });
|
139
|
+
console.log('Git Push Done!');
|
140
|
+
}, 1000);
|
141
|
+
});
|
142
|
+
});
|
143
|
+
} else {
|
144
|
+
console.log('【Error】:打包失败,没有dist目录!');
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
};
|
@@ -1 +1,205 @@
|
|
1
|
-
const
|
1
|
+
const path = require('path');
|
2
|
+
const fs = require('fs');
|
3
|
+
const os = require('os');
|
4
|
+
const axios = require('axios');
|
5
|
+
const readline = require('readline');
|
6
|
+
const io = readline.createInterface({
|
7
|
+
input: process.stdin,
|
8
|
+
output: process.stdout
|
9
|
+
});
|
10
|
+
const child_process = require('child_process');
|
11
|
+
|
12
|
+
module.exports = args => {
|
13
|
+
|
14
|
+
const [apiHost, version] = args;
|
15
|
+
|
16
|
+
const authPath = path.join(__dirname, '../../../.auth');
|
17
|
+
if (!fs.existsSync(authPath)) {
|
18
|
+
console.log(`【Error】:no auth login`);
|
19
|
+
process.exit(0);
|
20
|
+
}
|
21
|
+
|
22
|
+
if (!apiHost || apiHost.indexOf('http') === -1) {
|
23
|
+
console.log(`【Error】:host non-existent`);
|
24
|
+
process.exit(0);
|
25
|
+
}
|
26
|
+
|
27
|
+
if (!version) {
|
28
|
+
console.log(`【Error】:version non-existent`);
|
29
|
+
process.exit(0);
|
30
|
+
}
|
31
|
+
|
32
|
+
const [ username, password ] = fs.readFileSync(authPath).toString().split('/');
|
33
|
+
axios.post(`${apiHost}/api/auth`, {
|
34
|
+
username,
|
35
|
+
password
|
36
|
+
}).then(res => {
|
37
|
+
if (res.data.status) {
|
38
|
+
|
39
|
+
/**
|
40
|
+
* 下发数据根路径
|
41
|
+
* @type {string}
|
42
|
+
*/
|
43
|
+
const root_path = path.resolve('./');
|
44
|
+
|
45
|
+
console.log('Please wait, build ...');
|
46
|
+
if (fs.existsSync(root_path + '/yarn.lock')) {
|
47
|
+
child_process.execSync('yarn build:production', { cwd: root_path });
|
48
|
+
} else {
|
49
|
+
child_process.execSync('npm run build:production', { cwd: root_path });
|
50
|
+
}
|
51
|
+
|
52
|
+
const dist_folder_path = `${root_path}\\dist\\index.js`;
|
53
|
+
const package_json_path = `${root_path}\\package.json`;
|
54
|
+
const readme_path = `${root_path}\\README.md`;
|
55
|
+
const thumbnail_png_path = `${root_path}\\thumbnail.png`;
|
56
|
+
const log_text = [
|
57
|
+
os.hostname(),
|
58
|
+
os.platform(),
|
59
|
+
os.arch(),
|
60
|
+
new Date().toString()
|
61
|
+
];
|
62
|
+
|
63
|
+
const package_json_file = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../package.json')).toString());
|
64
|
+
const {
|
65
|
+
version: cmd_version
|
66
|
+
} = package_json_file;
|
67
|
+
|
68
|
+
const pushData = {
|
69
|
+
username,
|
70
|
+
cmd_version,
|
71
|
+
hostname: os.hostname(),
|
72
|
+
platform: os.platform()
|
73
|
+
};
|
74
|
+
|
75
|
+
if (fs.existsSync(package_json_path)) {
|
76
|
+
if (fs.existsSync(dist_folder_path)) {
|
77
|
+
pushData.package_version = version
|
78
|
+
? version
|
79
|
+
: 0;
|
80
|
+
pushData.package_content = fs.readFileSync(dist_folder_path).toString();
|
81
|
+
|
82
|
+
const dist_content = fs.readFileSync(dist_folder_path).toString();
|
83
|
+
const matches = dist_content.match(/(window\[).+?(\.componentKey|.+]={)/img);
|
84
|
+
if (matches && matches.length){
|
85
|
+
|
86
|
+
const infoMatches = dist_content.match(/componentKey.+(info:\s{0,}{)/img);
|
87
|
+
if (infoMatches && infoMatches.length) {
|
88
|
+
let infoStr = '{';
|
89
|
+
const infoStr1 = dist_content.split(infoMatches[0])[1];
|
90
|
+
for (let i = 0; i < infoStr1.length; i++){
|
91
|
+
infoStr += infoStr1[i];
|
92
|
+
if (infoStr1[i] === '}') {
|
93
|
+
try {
|
94
|
+
const currJson = new Function('return '+infoStr)();
|
95
|
+
pushData.component_config_content = {
|
96
|
+
...currJson,
|
97
|
+
defaultSetting: {}
|
98
|
+
};
|
99
|
+
} catch (e) {
|
100
|
+
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
} else {
|
105
|
+
console.log('【Error】:window暴露配置缺少info基础信息');
|
106
|
+
process.exit(0);
|
107
|
+
}
|
108
|
+
|
109
|
+
const settingsMatches = dist_content.match(/componentKey.+(settings:\s{0,}{)/img);
|
110
|
+
if (settingsMatches && settingsMatches.length) {
|
111
|
+
let settingsStr = '{';
|
112
|
+
const settingsStr1 = dist_content.split(settingsMatches[0])[1];
|
113
|
+
for (let i = 0; i < settingsStr1.length; i++){
|
114
|
+
settingsStr += settingsStr1[i];
|
115
|
+
if (settingsStr1[i] === '}') {
|
116
|
+
try {
|
117
|
+
const currJson = new Function('return '+settingsStr)();
|
118
|
+
pushData.component_config_content.defaultSetting = currJson;
|
119
|
+
} catch (e) {
|
120
|
+
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
pushData.component_config_content = JSON.stringify(pushData.component_config_content);
|
126
|
+
} else {
|
127
|
+
console.log('【Error】:window暴露配置缺少info基础信息');
|
128
|
+
process.exit(0);
|
129
|
+
}
|
130
|
+
|
131
|
+
// let currStr = matches[0].split('=')[1];
|
132
|
+
// const str= dist_content.split(matches[0])[1];
|
133
|
+
// for (let i = 0; i< str.length; i++){
|
134
|
+
// currStr += str[i]
|
135
|
+
// if (str[i] === '}'){
|
136
|
+
// try {
|
137
|
+
// const currJson = new Function('return '+currStr)();
|
138
|
+
// if (!currJson.info) {
|
139
|
+
// console.log('【Error】:window暴露配置缺少info基础信息');
|
140
|
+
// process.exit(0);
|
141
|
+
// }
|
142
|
+
// if (!currJson.settings) {
|
143
|
+
// console.log('【Error】:window暴露配置缺少settings基础信息');
|
144
|
+
// process.exit(0);
|
145
|
+
// }
|
146
|
+
// pushData.component_config_content = JSON.stringify({
|
147
|
+
// ...currJson.info,
|
148
|
+
// defaultSetting: currJson.settings
|
149
|
+
// });
|
150
|
+
// break;
|
151
|
+
// }
|
152
|
+
// catch (e) {
|
153
|
+
//
|
154
|
+
// }
|
155
|
+
// }
|
156
|
+
//
|
157
|
+
// }
|
158
|
+
} else {
|
159
|
+
console.log('【Error】:请在window下暴露配置信息');
|
160
|
+
process.exit(0);
|
161
|
+
}
|
162
|
+
|
163
|
+
if (fs.existsSync(readme_path)) {
|
164
|
+
pushData.readme_content = fs.readFileSync(readme_path).toString();
|
165
|
+
} else {
|
166
|
+
console.log('【Error】:请必须包含README.md说明文件');
|
167
|
+
process.exit(0);
|
168
|
+
}
|
169
|
+
|
170
|
+
if (!fs.existsSync(thumbnail_png_path)) {
|
171
|
+
console.log('【Error】:组件根目录必须包含thumbnail.png缩略图片');
|
172
|
+
process.exit(0);
|
173
|
+
} else {
|
174
|
+
const thumbnailData = fs.readFileSync(thumbnail_png_path);
|
175
|
+
const thumbnail_base64 = Buffer.from(thumbnailData).toString('base64');
|
176
|
+
pushData.thumbnail_base64 = thumbnail_base64;
|
177
|
+
}
|
178
|
+
|
179
|
+
io.question('请输入此次提交信息,按Enter确认:', function (message) {
|
180
|
+
pushData.message = message || 'no message';
|
181
|
+
axios.post(`${apiHost}/api/file/publish`, pushData).then(res => {
|
182
|
+
console.log(res.data.message);
|
183
|
+
process.exit(0);
|
184
|
+
}).catch(e => {
|
185
|
+
console.log(e);
|
186
|
+
console.log('网络异常。');
|
187
|
+
process.exit(0);
|
188
|
+
});
|
189
|
+
});
|
190
|
+
} else {
|
191
|
+
console.log('发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。');
|
192
|
+
process.exit(0);
|
193
|
+
}
|
194
|
+
} else {
|
195
|
+
console.log('发布失败!根目录缺少‘package.json’文件,无法完成发布。');
|
196
|
+
process.exit(0);
|
197
|
+
}
|
198
|
+
} else {
|
199
|
+
console.log('Auth Fail!');
|
200
|
+
}
|
201
|
+
}).catch(e => {
|
202
|
+
console.log(e);
|
203
|
+
console.log('Auth NetWork Fail!');
|
204
|
+
});
|
205
|
+
};
|
@@ -1 +1,65 @@
|
|
1
|
-
|
1
|
+
const https = require('https');
|
2
|
+
const fs = require('fs');
|
3
|
+
const path = require('path');
|
4
|
+
const { CONFIG_FILE_HOST } = require("../cmd.install/config");
|
5
|
+
|
6
|
+
const REGISTRY = {
|
7
|
+
eslint: {
|
8
|
+
remoteDir: 'eslint',
|
9
|
+
files: ['.eslintrc.js', '.eslintignore']
|
10
|
+
},
|
11
|
+
prettier: {
|
12
|
+
remoteDir: 'prettier',
|
13
|
+
files: ['.prettierrc.js', '.prettierignore']
|
14
|
+
},
|
15
|
+
jjb_script: {
|
16
|
+
remoteDir: 'jjb.script',
|
17
|
+
localDir: 'jjb.script',
|
18
|
+
files: ['build.js', 'config.js', 'proxy.js', 'server.js', 'utils.js']
|
19
|
+
},
|
20
|
+
babel: {
|
21
|
+
remoteDir: 'babel',
|
22
|
+
files: ['.babelrc']
|
23
|
+
},
|
24
|
+
microAppPackage: {
|
25
|
+
remoteDir: 'micro.app.package.json',
|
26
|
+
files: ['package.json']
|
27
|
+
}
|
28
|
+
};
|
29
|
+
|
30
|
+
const root_path = path.resolve('./');
|
31
|
+
|
32
|
+
function recursion (regObj, index, cb) {
|
33
|
+
const file = regObj.files[index];
|
34
|
+
https.get(`${CONFIG_FILE_HOST}/${regObj.remoteDir ? `${regObj.remoteDir}/` : ''}${file}?v=${new Date().getTime()}`, resp => {
|
35
|
+
let data = '';
|
36
|
+
resp.on('data', chunk => {
|
37
|
+
data += chunk;
|
38
|
+
});
|
39
|
+
resp.on('end', () => {
|
40
|
+
if (data) {
|
41
|
+
fs.writeFileSync(`${root_path}/${regObj.localDir ? `${regObj.localDir}/` : ''}${file}`, data);
|
42
|
+
console.log(file + ' file Success!');
|
43
|
+
if (index < regObj.files.length - 1) {
|
44
|
+
index++;
|
45
|
+
recursion(regObj, index, cb);
|
46
|
+
} else {
|
47
|
+
console.log('All Finish!')
|
48
|
+
cb && cb();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}).on('error', err => {
|
52
|
+
console.log('http error ', err);
|
53
|
+
});
|
54
|
+
});
|
55
|
+
}
|
56
|
+
|
57
|
+
module.exports = stdin => {
|
58
|
+
|
59
|
+
if (!Object.keys(REGISTRY).includes(stdin)) {
|
60
|
+
console.log(`【Error】:no ${stdin} file, available:[${Object.keys(REGISTRY).join('/')}]`);
|
61
|
+
process.exit(0);
|
62
|
+
}
|
63
|
+
|
64
|
+
recursion(REGISTRY[stdin], 0);
|
65
|
+
};
|
@@ -1 +1,23 @@
|
|
1
|
-
const
|
1
|
+
const axios = require('axios');
|
2
|
+
const { getApiHost } = require('../cmd.install/config');
|
3
|
+
|
4
|
+
module.exports = type => {
|
5
|
+
axios.post(`${getApiHost()}/api/file/config`).then(res => {
|
6
|
+
if (res.data.status) {
|
7
|
+
const data = res.data.data;
|
8
|
+
if (type === 'server') {
|
9
|
+
console.log(data.host);
|
10
|
+
console.log(data.port);
|
11
|
+
}
|
12
|
+
if (type === 'components') {
|
13
|
+
console.log(data.components);
|
14
|
+
}
|
15
|
+
} else {
|
16
|
+
console.log(res.data.message);
|
17
|
+
}
|
18
|
+
process.exit(0);
|
19
|
+
}).catch(() => {
|
20
|
+
console.log('网络异常。');
|
21
|
+
process.exit(0);
|
22
|
+
});
|
23
|
+
};
|
@@ -1 +1,58 @@
|
|
1
|
-
const
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
|
+
const readline = require('readline');
|
4
|
+
const io = readline.createInterface({
|
5
|
+
input: process.stdin,
|
6
|
+
output: process.stdout
|
7
|
+
});
|
8
|
+
|
9
|
+
let f_total = 0;
|
10
|
+
|
11
|
+
module.exports = function () {
|
12
|
+
const root_path = path.resolve('./');
|
13
|
+
|
14
|
+
io.question('是否确认删除?删除后不可恢复![y/n]:', function (answer) {
|
15
|
+
if (answer.trim() === 'y') {
|
16
|
+
console.log('正在计算项目数,请稍等...');
|
17
|
+
setTimeout(() => {
|
18
|
+
setTimeout(() => {
|
19
|
+
console.clear();
|
20
|
+
exec(root_path);
|
21
|
+
setTimeout(() => {
|
22
|
+
console.log('删除完成。');
|
23
|
+
console.clear();
|
24
|
+
process.exit(0);
|
25
|
+
}, 500);
|
26
|
+
}, 500);
|
27
|
+
}, 500);
|
28
|
+
} else if (answer.trim() === 'n') {
|
29
|
+
console.log('取消删除。');
|
30
|
+
process.exit(0);
|
31
|
+
} else {
|
32
|
+
console.log('无效操作。');
|
33
|
+
process.exit(0);
|
34
|
+
}
|
35
|
+
});
|
36
|
+
};
|
37
|
+
|
38
|
+
function exec (path) {
|
39
|
+
if (fs.existsSync(path)) {
|
40
|
+
const list = fs.readdirSync(path);
|
41
|
+
for (let i = 0; i < list.length; i++) {
|
42
|
+
const item = list[ i ];
|
43
|
+
const vPath = `${path}/${item}`;
|
44
|
+
try {
|
45
|
+
if (fs.statSync(vPath).isDirectory()) {
|
46
|
+
exec(vPath);
|
47
|
+
fs.rmdirSync(vPath, { recursive: true });
|
48
|
+
console.log('删除文件夹:' + vPath);
|
49
|
+
} else {
|
50
|
+
fs.unlinkSync(vPath);
|
51
|
+
console.log('删除文件:' + vPath);
|
52
|
+
}
|
53
|
+
} catch (e) {
|
54
|
+
console.log('删除异常:' + vPath);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
@@ -1 +1,35 @@
|
|
1
|
-
const
|
1
|
+
const path = require('path');
|
2
|
+
const fs = require('fs');
|
3
|
+
const axios = require('axios');
|
4
|
+
const { getApiHost } = require("../cmd.install/config");
|
5
|
+
|
6
|
+
module.exports = () => {
|
7
|
+
/**
|
8
|
+
* 下发数据根路径
|
9
|
+
* @type {string}
|
10
|
+
*/
|
11
|
+
const root_path = path.resolve('./');
|
12
|
+
const package_json_path = `${root_path}\\package.json`;
|
13
|
+
|
14
|
+
if (fs.existsSync(package_json_path)) {
|
15
|
+
const package_json_file = JSON.parse(fs.readFileSync(package_json_path).toString());
|
16
|
+
const {
|
17
|
+
name: package_name
|
18
|
+
} = package_json_file;
|
19
|
+
|
20
|
+
axios.post(`${getApiHost()}/api/file/version`, { package_name }).then(res => {
|
21
|
+
if (res.data.status) {
|
22
|
+
console.log(res.data.data);
|
23
|
+
} else {
|
24
|
+
console.log(res.data.message);
|
25
|
+
}
|
26
|
+
process.exit(0);
|
27
|
+
}).catch(() => {
|
28
|
+
console.log('网络异常。');
|
29
|
+
process.exit(0);
|
30
|
+
});
|
31
|
+
} else {
|
32
|
+
console.log('查询失败!根目录缺少‘package.json’文件,无法完成查询。');
|
33
|
+
process.exit(0);
|
34
|
+
}
|
35
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/**
|
2
|
+
* @author XiWell
|
3
|
+
* @version 2.0.1
|
4
|
+
* @description 基于QianKun框架的APP注册文件,请勿修改!
|
5
|
+
*/
|
6
|
+
|
7
|
+
import 'moment/locale/zh-cn';
|
8
|
+
import dva from 'dva';
|
9
|
+
import { createBrowserHistory } from 'history';
|
10
|
+
import { unmountComponentAtNode } from 'react-dom';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @description 注册app
|
14
|
+
* @param selector {string}
|
15
|
+
* @returns {{unmount: Function, mount: Function, bootstrap: Function}}
|
16
|
+
*/
|
17
|
+
export const registerApplication = (selector = '#root') => {
|
18
|
+
try {
|
19
|
+
const app = dva({ history: createBrowserHistory() });
|
20
|
+
require('./models').automaticModels(app);
|
21
|
+
app.router(config => require('./router').AutomaticRouter(config));
|
22
|
+
|
23
|
+
const render = () => app.start(selector);
|
24
|
+
if (!window.__POWERED_BY_QIANKUN__) render();
|
25
|
+
|
26
|
+
return {
|
27
|
+
mount: () => render(),
|
28
|
+
unmount: props => {
|
29
|
+
const { container } = props;
|
30
|
+
const element = container
|
31
|
+
? container.querySelector(selector)
|
32
|
+
: document.querySelector(selector);
|
33
|
+
unmountComponentAtNode(element);
|
34
|
+
},
|
35
|
+
bootstrap: props => props
|
36
|
+
};
|
37
|
+
} catch (e) {
|
38
|
+
console.error('注册APP失败,原因:', e.message);
|
39
|
+
}
|
40
|
+
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* @author XiWell
|
3
|
+
* @version 1.0.1
|
4
|
+
* @description 基于QianKun框架的APP注册文件,请勿修改!
|
5
|
+
*/
|
6
|
+
|
7
|
+
import dva from 'dva';
|
8
|
+
import ReactDOM from 'react-dom';
|
9
|
+
import { createBrowserHistory } from 'history';
|
10
|
+
import 'antd/dist/antd.less';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @description 注册app
|
14
|
+
* @param selector {string}
|
15
|
+
* @returns {{unmount: Function, mount: Function, bootstrap: Function}}
|
16
|
+
*/
|
17
|
+
export const registerApplication = (selector = '#app-root') => {
|
18
|
+
const app = dva({ history: createBrowserHistory() });
|
19
|
+
require('./models').automaticModels(app);
|
20
|
+
app.router(config => require('./router').AutomaticRouter(config));
|
21
|
+
app.start(selector);
|
22
|
+
};
|