crabatool 1.0.39 → 1.0.42
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/index.js +25 -23
- package/package.json +1 -1
- package/tool/ngptool.js +12 -5
package/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var upgrade = require('./tool/upgrade.js');
|
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var readline = require('readline');
|
|
7
|
-
const { memoryUsage } = require('process');
|
|
8
7
|
|
|
9
8
|
module.exports.run = function(options) {
|
|
10
9
|
//console.log(process.argv);
|
|
@@ -82,21 +81,36 @@ function checkConfig() {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
|
|
84
|
+
async function waitFolder() {
|
|
85
|
+
const projectPath = await question('请输入项目生成路径(必须为空路径):');
|
|
86
|
+
if (!path.isAbsolute(projectPath)) {
|
|
87
|
+
console.log('路径不合法,请输入绝对路径,如:f:\\craba_web');
|
|
88
|
+
return waitFolder();
|
|
89
|
+
}
|
|
90
|
+
if (fs.existsSync(projectPath)) {
|
|
91
|
+
if (fs.readdirSync(projectPath).length > 0) {
|
|
92
|
+
console.log(':::输入的项目路径不为空,避免文件覆盖或冲突,请重新输入一个空路径或不存在的路径:::');
|
|
93
|
+
return waitFolder();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return projectPath;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function rlPromisify(fn) {
|
|
100
|
+
return async function(t) {
|
|
101
|
+
return new Promise(function(resolve) { fn(t, resolve) });
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
85
105
|
function waitInput() {
|
|
86
106
|
const rl = readline.createInterface({
|
|
87
107
|
input: process.stdin,
|
|
88
108
|
output: process.stdout
|
|
89
109
|
});
|
|
90
110
|
|
|
91
|
-
function rlPromisify(fn) {
|
|
92
|
-
return async (t) => {
|
|
93
|
-
return new Promise(resolve => fn(t, resolve));
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
111
|
const question = rlPromisify(rl.question.bind(rl));
|
|
98
112
|
|
|
99
|
-
(async ()
|
|
113
|
+
(async function() {
|
|
100
114
|
var ques = [
|
|
101
115
|
"1. 启动服务。\t\t\t\t主要包含:自动合并打包init.js和biz.js,查看本地平台的版本",
|
|
102
116
|
"2. 更新当前项目的平台,然后启动服务。\t主要包含:从<内网>拉取环境相关资源,再拷贝到webPath路径下覆盖老文件,替代手工操作,同时解决npm不稳定问题",
|
|
@@ -147,21 +161,6 @@ function waitInput() {
|
|
|
147
161
|
console.error('无效输入,请继续。\r\n\r\n');
|
|
148
162
|
waitInput(); // 重复
|
|
149
163
|
}
|
|
150
|
-
|
|
151
|
-
async function waitFolder() {
|
|
152
|
-
const projectPath = await question('请输入项目生成路径(必须为空路径):');
|
|
153
|
-
if (!path.isAbsolute(projectPath)) {
|
|
154
|
-
console.log('路径不合法,请输入绝对路径,如:f:\\craba_web');
|
|
155
|
-
return waitFolder();
|
|
156
|
-
}
|
|
157
|
-
if (fs.existsSync(projectPath)) {
|
|
158
|
-
if (fs.readdirSync(projectPath).length > 0) {
|
|
159
|
-
console.log(':::输入的项目路径不为空,避免文件覆盖或冲突,请重新输入一个空路径或不存在的路径:::');
|
|
160
|
-
return waitFolder();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return projectPath;
|
|
164
|
-
}
|
|
165
164
|
})();
|
|
166
165
|
}
|
|
167
166
|
|
|
@@ -201,7 +200,10 @@ function installvscode() {
|
|
|
201
200
|
|
|
202
201
|
function mergeInit() {
|
|
203
202
|
if (config.modName && config.childModList && config.childModList.length > 0) {
|
|
203
|
+
config.mergeinitjs = true; // 标记仅打包,不监视文件变动
|
|
204
204
|
require('../tool/ngptool.js');
|
|
205
|
+
} else {
|
|
206
|
+
console.log('mergeinitjs缺少其他相关参数配置,因此不会执行打包init.js操作')
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
|
package/package.json
CHANGED
package/tool/ngptool.js
CHANGED
|
@@ -28,12 +28,15 @@ function mergeBiz() {
|
|
|
28
28
|
utils.debug('打包完成');
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
watcher
|
|
32
|
-
.on('ready', () => utils.debug(`${bizPath},Initial scan complete. Ready for changes.`))
|
|
33
|
-
//.on('add', path => log(`File ${path} has been added`))
|
|
34
|
-
.on('change', path => watchAction({ event: 'change', eventPath: path }))
|
|
35
|
-
.on('unlink', path => watchAction({ event: 'remove', eventPath: path }));
|
|
36
31
|
|
|
32
|
+
// 只打包的情况就不监视文件
|
|
33
|
+
if (!config.mergeinitjs) {
|
|
34
|
+
watcher
|
|
35
|
+
.on('ready', () => utils.debug(`${bizPath},Initial scan complete. Ready for changes.`))
|
|
36
|
+
//.on('add', path => log(`File ${path} has been added`))
|
|
37
|
+
.on('change', path => watchAction({ event: 'change', eventPath: path }))
|
|
38
|
+
.on('unlink', path => watchAction({ event: 'remove', eventPath: path }));
|
|
39
|
+
}
|
|
37
40
|
watchAction();// 启动就打包一次
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -57,10 +60,14 @@ function mergeInit() {
|
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
var watchJs = function(jsPath) {
|
|
63
|
+
// 只打包的情况就不监视文件
|
|
64
|
+
if (config.mergeinitjs) return;
|
|
65
|
+
|
|
60
66
|
var watcher = chokidar.watch([jsPath], {
|
|
61
67
|
persistent: true,
|
|
62
68
|
usePolling: true
|
|
63
69
|
});
|
|
70
|
+
|
|
64
71
|
watcher
|
|
65
72
|
.on('ready', () => utils.debug(`${jsPath},Initial scan complete. Ready for changes.`))
|
|
66
73
|
//.on('add', path => log(`File ${path} has been added`))
|