jjb-cmd 2.2.2 → 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 +4 -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/README.md
CHANGED
package/build.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
const child_process = require('child_process');
|
2
|
+
const utils = require("./src/old/util");
|
3
|
+
|
4
|
+
child_process.execSync(`npx javascript-obfuscator src --output publish/src --config obf.config.json`, (error, stdout) => {});
|
5
|
+
console.log("obf Done!");
|
6
|
+
utils.CopyFolder('./bin', './publish/bin', () => {
|
7
|
+
console.log("bin Folder Done!");
|
8
|
+
utils.CopyFile('./package.json', './publish/package.json', () => {
|
9
|
+
utils.CopyFile('./README.md', './publish/README.md', () => {
|
10
|
+
utils.CopyFile('./LICENSE', './publish/LICENSE', () => {
|
11
|
+
console.log("ALL Done !");
|
12
|
+
});
|
13
|
+
});
|
14
|
+
});
|
15
|
+
})
|
package/obf.config.json
ADDED
package/package.json
CHANGED
@@ -1 +1,26 @@
|
|
1
|
-
|
1
|
+
const axios = require("axios");
|
2
|
+
const fs = require("fs");
|
3
|
+
const path = require("path");
|
4
|
+
const { getApiHost } = require("../cmd.install/config");
|
5
|
+
|
6
|
+
module.exports = args => {
|
7
|
+
console.log(args)
|
8
|
+
const [username, password] = args;
|
9
|
+
axios.post(`${getApiHost()}/api/auth`, {
|
10
|
+
username,
|
11
|
+
password
|
12
|
+
}).then(res => {
|
13
|
+
const authPath = path.join(__dirname, '../../../.auth');
|
14
|
+
if (res.data.status) {
|
15
|
+
console.log('Auth Success!');
|
16
|
+
fs.writeFileSync(authPath, `${username}/${password}`);
|
17
|
+
} else {
|
18
|
+
console.log('Auth Fail!');
|
19
|
+
if (fs.existsSync(authPath)) {
|
20
|
+
fs.unlinkSync(authPath);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}).catch(e => {
|
24
|
+
console.log('Auth NetWork Fail!');
|
25
|
+
});
|
26
|
+
};
|
@@ -1 +1,116 @@
|
|
1
|
-
const
|
1
|
+
const fs = require('fs');
|
2
|
+
const os = require("os");
|
3
|
+
const path = require('path');
|
4
|
+
const request = require("request");
|
5
|
+
const utils = require("../../old/util");
|
6
|
+
const compressing = require("compressing");
|
7
|
+
const readline = require('readline');
|
8
|
+
const io = readline.createInterface({
|
9
|
+
input: process.stdin,
|
10
|
+
output: process.stdout
|
11
|
+
});
|
12
|
+
const child_process = require('child_process');
|
13
|
+
const { CLOUD_PROJECT, GIT_TEMP_DIR, GIT_HOST } = require('../cmd.install/config');
|
14
|
+
|
15
|
+
module.exports = stdin => {
|
16
|
+
/**
|
17
|
+
* 下发数据根路径
|
18
|
+
* @type {string}
|
19
|
+
*/
|
20
|
+
const root_path = path.resolve('./');
|
21
|
+
|
22
|
+
const cloudObj = CLOUD_PROJECT[ stdin ] || undefined;
|
23
|
+
if (cloudObj) {
|
24
|
+
const tmpDir = os.tmpdir();
|
25
|
+
const zipPath = `${tmpDir}/${GIT_TEMP_DIR}/${stdin}.zip`;
|
26
|
+
const zipFolder = `${tmpDir}/${GIT_TEMP_DIR}/unzip/`;
|
27
|
+
utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
|
28
|
+
fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
|
29
|
+
let stream = fs.createWriteStream(zipPath);
|
30
|
+
request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`).pipe(stream)
|
31
|
+
.on('close', () => {
|
32
|
+
fs.mkdirSync(zipFolder);
|
33
|
+
compressing.zip.uncompress(zipPath, zipFolder)
|
34
|
+
.then(() => {
|
35
|
+
setTimeout(() => {
|
36
|
+
fs.readdirSync(zipFolder).forEach(dirName => {
|
37
|
+
if (dirName.indexOf('-master-') !== -1) {
|
38
|
+
utils.CopyFolder(zipFolder + dirName, root_path, () => {
|
39
|
+
io.question('初始化完成?请选择安装方式![yarn/npm]:', function (answer) {
|
40
|
+
if (['yarn', 'npm'].includes(answer.trim())) {
|
41
|
+
console.log('安装中,请耐心等待...');
|
42
|
+
child_process.execSync(`jjb-cmd install.app ${answer.trim()}`, { cwd: root_path });
|
43
|
+
console.log('安装完成,祝您愉快编码!');
|
44
|
+
process.exit(0);
|
45
|
+
} else {
|
46
|
+
console.log('初始化完成!请自行使用jjb-cmd install.app yarn/npm安装项目!');
|
47
|
+
process.exit(0);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
});
|
51
|
+
}
|
52
|
+
})
|
53
|
+
}, 2000);
|
54
|
+
})
|
55
|
+
});
|
56
|
+
});
|
57
|
+
} else {
|
58
|
+
console.log('【Error】:初始化失败,'+ stdin +'不存在。');
|
59
|
+
}
|
60
|
+
|
61
|
+
// if (stdin === 'micro-app') {
|
62
|
+
// if (
|
63
|
+
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
64
|
+
// !fs.existsSync(`${root_path}\\public`) &&
|
65
|
+
// !fs.existsSync(`${root_path}\\src`) &&
|
66
|
+
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
67
|
+
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
68
|
+
// !fs.existsSync(`${root_path}\\package.json`) &&
|
69
|
+
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
70
|
+
// ) {
|
71
|
+
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app`, root_path);
|
72
|
+
// console.log('初始化完成!');
|
73
|
+
// process.exit(0);
|
74
|
+
// } else {
|
75
|
+
// console.log('初始化失败,文件已存在!');
|
76
|
+
// process.exit(0);
|
77
|
+
// }
|
78
|
+
// } else if(stdin === 'micro-app-ts') {
|
79
|
+
// if (
|
80
|
+
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
81
|
+
// !fs.existsSync(`${root_path}\\public`) &&
|
82
|
+
// !fs.existsSync(`${root_path}\\src`) &&
|
83
|
+
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
84
|
+
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
85
|
+
// !fs.existsSync(`${root_path}\\tsconfig.json`) &&
|
86
|
+
// !fs.existsSync(`${root_path}\\package.json`) &&
|
87
|
+
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
88
|
+
// ) {
|
89
|
+
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app-ts`, root_path);
|
90
|
+
// console.log('初始化完成!');
|
91
|
+
// process.exit(0);
|
92
|
+
// } else {
|
93
|
+
// console.log('初始化失败,文件已存在!');
|
94
|
+
// process.exit(0);
|
95
|
+
// }
|
96
|
+
// } else if ([
|
97
|
+
// 'lib',
|
98
|
+
// 'react-component'
|
99
|
+
// ].includes(stdin)) {
|
100
|
+
// if (
|
101
|
+
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
102
|
+
// !fs.existsSync(`${root_path}\\src`) &&
|
103
|
+
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
104
|
+
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
105
|
+
// !fs.existsSync(`${root_path}\\package.json`) &&
|
106
|
+
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
107
|
+
// ) {
|
108
|
+
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\${stdin}`, root_path);
|
109
|
+
// console.log('初始化完成!');
|
110
|
+
// process.exit(0);
|
111
|
+
// } else {
|
112
|
+
// console.log('初始化失败,文件已存在!');
|
113
|
+
// process.exit(0);
|
114
|
+
// }
|
115
|
+
// }
|
116
|
+
};
|
@@ -1 +1,70 @@
|
|
1
|
-
const
|
1
|
+
const os = require('os');
|
2
|
+
const path = require('path');
|
3
|
+
const fs = require('fs');
|
4
|
+
|
5
|
+
const API_HOST = 'http://120.26.210.58:8088';
|
6
|
+
const API_HOST_TEST = 'http://120.26.210.58:8089';
|
7
|
+
|
8
|
+
exports.CONFIG_FILE_HOST = 'https://cdn.cqjjb.cn/jjb-cloud-config';
|
9
|
+
exports.API_HOST = API_HOST;
|
10
|
+
exports.API_HOST_TEST = API_HOST_TEST;
|
11
|
+
exports.GIT_HOST = 'http://192.168.1.242:10985';
|
12
|
+
exports.GIT_TEMP_DIR = `jjb-assembly-${Date.now()}`;
|
13
|
+
exports.GIT_TEMP_JAVA = `jjb-assembly-java`;
|
14
|
+
exports.GIT_JAVA_ENV_JSON = {
|
15
|
+
"development": "dev",
|
16
|
+
"production": "prod",
|
17
|
+
"test": "test"
|
18
|
+
};
|
19
|
+
exports.CLOUD_PROJECT = {
|
20
|
+
'common': {
|
21
|
+
token: 'G4HJRsHr9D7Ssmixegw2',
|
22
|
+
projectId: 279
|
23
|
+
},
|
24
|
+
'react-admin-component': {
|
25
|
+
token: 'FT3pKzxpRynFkmddJ9Bs',
|
26
|
+
projectId: 340
|
27
|
+
},
|
28
|
+
'jjb-dva-runtime': {
|
29
|
+
token: 'hLqARY89CN6fUD3yg4NL',
|
30
|
+
projectId: 571
|
31
|
+
},
|
32
|
+
'jjb-common-lib': {
|
33
|
+
token: 'e9njpBd1nS_LREN8GFpR',
|
34
|
+
projectId: 572
|
35
|
+
},
|
36
|
+
'jjb-common-decorator': {
|
37
|
+
token: 'gPSit8aJsLVmNzuQ5Cy4',
|
38
|
+
projectId: 574
|
39
|
+
},
|
40
|
+
'vue-unisass-component': {
|
41
|
+
token: 'd4wQ7dzEjYPsgVbKnYei',
|
42
|
+
projectId: 339
|
43
|
+
},
|
44
|
+
'react-component': {
|
45
|
+
token: 'snBxJ2i5kYarGGcsojhY',
|
46
|
+
projectId: 831
|
47
|
+
},
|
48
|
+
'micro-app-ts': {
|
49
|
+
token: '7V-YUxhmh51Mdhgx4rq4',
|
50
|
+
projectId: 830
|
51
|
+
},
|
52
|
+
'micro-app': {
|
53
|
+
token: 'FqNrmFAgrxasMrbbjvq9',
|
54
|
+
projectId: 829
|
55
|
+
},
|
56
|
+
'lib': {
|
57
|
+
token: 'ywPtT3xCG6b_vAxp6sTj',
|
58
|
+
projectId: 828
|
59
|
+
}
|
60
|
+
};
|
61
|
+
exports.TEMPLATE_FOLDER = `${os.tmpdir()}\\${exports.GIT_TEMP_DIR}`;
|
62
|
+
|
63
|
+
exports.getApiHost = () => {
|
64
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../package.json')).toString());
|
65
|
+
if (packageJson.env === 'test') {
|
66
|
+
return API_HOST_TEST;
|
67
|
+
} else {
|
68
|
+
return API_HOST;
|
69
|
+
}
|
70
|
+
};
|
@@ -1 +1,262 @@
|
|
1
|
-
const
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
|
+
const request = require('request');
|
4
|
+
const compressing = require('compressing');
|
5
|
+
const {
|
6
|
+
f_rm_rf,
|
7
|
+
f_file_copy,
|
8
|
+
f_create_package_json,
|
9
|
+
f_pull_git_repository,
|
10
|
+
f_scan_jjb_config_json,
|
11
|
+
f_scan_jjb_config_json_rules,
|
12
|
+
f_update_project_package_json
|
13
|
+
} = require('./tools');
|
14
|
+
const { TEMPLATE_FOLDER } = require('./config');
|
15
|
+
const start_time = Date.now();
|
16
|
+
|
17
|
+
module.exports = () => {
|
18
|
+
/**
|
19
|
+
* 下发数据根路径
|
20
|
+
* @type {string}
|
21
|
+
*/
|
22
|
+
const root_path = path.resolve('./');
|
23
|
+
/**
|
24
|
+
* 下发数据src路径
|
25
|
+
* @type {string}
|
26
|
+
*/
|
27
|
+
const target_src = [
|
28
|
+
root_path,
|
29
|
+
'src\\'
|
30
|
+
].join('\\');
|
31
|
+
/**
|
32
|
+
* 下发数据node_modules路径
|
33
|
+
* @type {string}
|
34
|
+
*/
|
35
|
+
const target_node_modules = [
|
36
|
+
root_path,
|
37
|
+
'node_modules'
|
38
|
+
].join('\\');
|
39
|
+
/**
|
40
|
+
* 下发数据package.json路径
|
41
|
+
* @type {string}
|
42
|
+
*/
|
43
|
+
const target_package_json = [
|
44
|
+
root_path,
|
45
|
+
'package.json'
|
46
|
+
].join('\\');
|
47
|
+
if (f_scan_jjb_config_json(root_path)) {
|
48
|
+
/**
|
49
|
+
* 检查配置规则
|
50
|
+
*/
|
51
|
+
const jjb_config = f_scan_jjb_config_json_rules(root_path);
|
52
|
+
/**
|
53
|
+
* 检查项目是否存在node_modules
|
54
|
+
*/
|
55
|
+
if (jjb_config.installTarget === 'node_modules') {
|
56
|
+
if (!fs.existsSync(target_node_modules)) {
|
57
|
+
console.log('【Error】:安装失败,node_modules目录不存在。');
|
58
|
+
process.exit(0);
|
59
|
+
} else {
|
60
|
+
console.log('【Warning】:若安装在node_modules中,请确保projectType = micro-spa,并关闭webpack.config.js rules限制。');
|
61
|
+
}
|
62
|
+
} else {
|
63
|
+
if (!fs.existsSync(target_src)) {
|
64
|
+
console.log('【Error】:安装失败,src目录不存在。');
|
65
|
+
process.exit(0);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* 文件操作:定义一个临时文件夹
|
70
|
+
*/
|
71
|
+
fs.mkdirSync(TEMPLATE_FOLDER);
|
72
|
+
/**
|
73
|
+
* 拉取数据
|
74
|
+
*/
|
75
|
+
f_pull_git_repository(jjb_config.installResources).map(item => {
|
76
|
+
const stream = fs.createWriteStream(item.path);
|
77
|
+
/**
|
78
|
+
* 流操作:下载git仓库
|
79
|
+
*/
|
80
|
+
request(item.repository).pipe(stream).on('close', () => {
|
81
|
+
fs.mkdirSync(item.compress);
|
82
|
+
/**
|
83
|
+
* 流操作:解压
|
84
|
+
*/
|
85
|
+
compressing.zip.uncompress(item.path, item.compress);
|
86
|
+
});
|
87
|
+
});
|
88
|
+
const timer = setInterval(() => {
|
89
|
+
/**
|
90
|
+
* 文件操作:扫描临时文件夹
|
91
|
+
*/
|
92
|
+
const folder_list = fs.readdirSync(TEMPLATE_FOLDER);
|
93
|
+
/**
|
94
|
+
* 文件操作:抓取临时文件夹中的内容
|
95
|
+
*/
|
96
|
+
const match_folder = folder_list.filter(item => jjb_config.installResources.map(item => `${item.name}_zip`).includes(item));
|
97
|
+
/**
|
98
|
+
* 文件操作:判断是否已解压完成
|
99
|
+
*/
|
100
|
+
if (match_folder.length === jjb_config.installResources.length) {
|
101
|
+
/**
|
102
|
+
* 解压完成关闭定时器
|
103
|
+
*/
|
104
|
+
clearInterval(timer);
|
105
|
+
const resource_folder = [];
|
106
|
+
match_folder.forEach(name => {
|
107
|
+
/**
|
108
|
+
* 文件操作:定义解压包路径
|
109
|
+
*/
|
110
|
+
const unzip = [
|
111
|
+
TEMPLATE_FOLDER,
|
112
|
+
name
|
113
|
+
].join('\\');
|
114
|
+
/**
|
115
|
+
* 文件操作:抓取解压包中的文件
|
116
|
+
*/
|
117
|
+
fs.readdirSync(unzip).forEach(dir => resource_folder.push({
|
118
|
+
name: name,
|
119
|
+
path: [
|
120
|
+
unzip,
|
121
|
+
dir
|
122
|
+
].join('\\'),
|
123
|
+
pure_name: name.replace(/_zip$/, ''),
|
124
|
+
import_list: jjb_config.installResources.find(item => `${item.name}_zip` === name).importList
|
125
|
+
}));
|
126
|
+
});
|
127
|
+
resource_folder.forEach(item => {
|
128
|
+
/**
|
129
|
+
* 文件操作:依赖名称
|
130
|
+
*/
|
131
|
+
const folder_name = item.pure_name;
|
132
|
+
/**
|
133
|
+
* 文件操作:按需加载
|
134
|
+
*/
|
135
|
+
const folder_import_list = item.import_list;
|
136
|
+
/**
|
137
|
+
* 文件操作:组装路径
|
138
|
+
*/
|
139
|
+
const folder_idea_path = [
|
140
|
+
item.path,
|
141
|
+
'.idea'
|
142
|
+
].join('//');
|
143
|
+
/**
|
144
|
+
* 文件操作:组装路径
|
145
|
+
*/
|
146
|
+
const folder_git_ignore_path = [
|
147
|
+
item.path,
|
148
|
+
'.gitignore'
|
149
|
+
].join('//');
|
150
|
+
/**
|
151
|
+
* 特殊处理:删除.idea文件夹
|
152
|
+
*/
|
153
|
+
if (fs.existsSync(folder_idea_path)) {
|
154
|
+
f_rm_rf(folder_idea_path);
|
155
|
+
fs.rmdirSync(folder_idea_path);
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* 特殊处理:删除.gitignore文件
|
159
|
+
*/
|
160
|
+
if (fs.existsSync(folder_git_ignore_path)) {
|
161
|
+
fs.unlinkSync(folder_git_ignore_path);
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
* 文件操作:按需加载
|
165
|
+
*/
|
166
|
+
if (folder_import_list.length) {
|
167
|
+
/**
|
168
|
+
* 文件操作:根据jjb.config.json中的importList获取需要的文件
|
169
|
+
*/
|
170
|
+
fs.readdirSync(item.path).filter(item => !folder_import_list.includes(item) && item !== 'index.js' && item !== 'setting.json').forEach(dir => {
|
171
|
+
/**
|
172
|
+
* 文件操作:组装路径
|
173
|
+
*/
|
174
|
+
const dirPath = `${item.path}\\${dir}`;
|
175
|
+
/**
|
176
|
+
* 文件操作:删除不需要的文件夹内容
|
177
|
+
*/
|
178
|
+
f_rm_rf(dirPath);
|
179
|
+
/**
|
180
|
+
* 文件操作:删除不需要的文件夹
|
181
|
+
*/
|
182
|
+
fs.rmdirSync(dirPath);
|
183
|
+
});
|
184
|
+
}
|
185
|
+
if (jjb_config.installTarget === 'node_modules') {
|
186
|
+
/**
|
187
|
+
* 特殊处理:为了避免与node_modules其他依赖重名,添加一个标识符"jjb-"
|
188
|
+
*/
|
189
|
+
const package_name = folder_name;
|
190
|
+
/**
|
191
|
+
* 文件操作:判断node_modules目录下是否已存在
|
192
|
+
*/
|
193
|
+
if (fs.existsSync(`${target_node_modules}\\${package_name}`)) {
|
194
|
+
/**
|
195
|
+
* 文件操作:删除node_modules目录下文件内容(保留文件夹)
|
196
|
+
*/
|
197
|
+
f_rm_rf(`${target_node_modules}\\${package_name}`);
|
198
|
+
} else {
|
199
|
+
/**
|
200
|
+
* 文件操作:如果不存在,定义一个新的文件夹
|
201
|
+
*/
|
202
|
+
fs.mkdirSync(`${target_node_modules}\\${package_name}`);
|
203
|
+
}
|
204
|
+
if (package_name !== 'jjb-common-lib') {
|
205
|
+
/**
|
206
|
+
* 文件操作:复制文件到node_modules中
|
207
|
+
*/
|
208
|
+
f_file_copy(item.path, `${target_node_modules}\\${package_name}`);
|
209
|
+
/**
|
210
|
+
* 文件操作:创建package.json
|
211
|
+
*/
|
212
|
+
f_create_package_json(`${target_node_modules}\\${package_name}`, package_name, '1.0.0');
|
213
|
+
} else {
|
214
|
+
/**
|
215
|
+
* 文件操作:复制文件到node_modules中
|
216
|
+
*/
|
217
|
+
f_file_copy(`${item.path}\\types`, `${target_node_modules}\\${package_name}`);
|
218
|
+
}
|
219
|
+
/**
|
220
|
+
* 文件操作:在src/package.json中定义一个组件依赖
|
221
|
+
*/
|
222
|
+
f_update_project_package_json(target_package_json, package_name, '1.0.0');
|
223
|
+
} else if (jjb_config.installTarget === 'src') {
|
224
|
+
/**
|
225
|
+
* 文件操作:判断src目录下是否已存在
|
226
|
+
*/
|
227
|
+
if (fs.existsSync(target_src + folder_name)) {
|
228
|
+
/**
|
229
|
+
* 文件操作:删除src目录下文件内容(保留文件夹)
|
230
|
+
*/
|
231
|
+
f_rm_rf(target_src + folder_name);
|
232
|
+
} else {
|
233
|
+
/**
|
234
|
+
* 文件操作:如果不存在,定义一个新的文件夹
|
235
|
+
*/
|
236
|
+
fs.mkdirSync(target_src + folder_name);
|
237
|
+
}
|
238
|
+
/**
|
239
|
+
* 文件操作:复制文件到src中
|
240
|
+
*/
|
241
|
+
f_file_copy(item.path, target_src + folder_name);
|
242
|
+
}
|
243
|
+
});
|
244
|
+
setTimeout(() => {
|
245
|
+
/**
|
246
|
+
* 文件操作:删除临时文件夹内容
|
247
|
+
*/
|
248
|
+
f_rm_rf(TEMPLATE_FOLDER);
|
249
|
+
/**
|
250
|
+
* 文件操作:删除临时文件夹
|
251
|
+
*/
|
252
|
+
fs.rmdirSync(TEMPLATE_FOLDER);
|
253
|
+
const end_time = Date.now();
|
254
|
+
console.log(`【jjb-cmd】:install命令执行完成,用时${(end_time - start_time) / 1000}s`);
|
255
|
+
}, 1500);
|
256
|
+
}
|
257
|
+
}, 1000);
|
258
|
+
} else {
|
259
|
+
console.log('【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。');
|
260
|
+
}
|
261
|
+
};
|
262
|
+
|