crabatool 1.0.453 → 1.0.455
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 +11 -3
- package/package.json +1 -1
- package/tool/autoUpdate.js +11 -2
- package/tool/compress.js +9 -1
- package/tool/merge/mergeTool.js +5 -1
package/index.js
CHANGED
|
@@ -32,8 +32,12 @@ exports.run = async function(options) {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
|
|
35
|
+
// 检查是否应该在交互式模式下跳过自动更新
|
|
36
|
+
// 当用户直接输入 crabatool 命令(无参数)时,跳过自动更新
|
|
37
|
+
const isDirectCommand = process.argv.length <= 2; // 只有 node 和脚本路径
|
|
38
|
+
|
|
39
|
+
// 只有在交互式模式下且不是直接命令时才进行分离式更新
|
|
40
|
+
if (!autoUpdate.shouldSkipUpdate() && !isDirectCommand) {
|
|
37
41
|
// 执行分离式更新检查
|
|
38
42
|
const shouldContinue = await processManager.executeDetachedUpdate(
|
|
39
43
|
() => autoUpdate.checkAndUpdateDetached(false),
|
|
@@ -45,7 +49,11 @@ exports.run = async function(options) {
|
|
|
45
49
|
return;
|
|
46
50
|
}
|
|
47
51
|
} else {
|
|
48
|
-
|
|
52
|
+
if (isDirectCommand) {
|
|
53
|
+
console.log('⏭️ 直接命令模式,跳过自动更新检查');
|
|
54
|
+
} else {
|
|
55
|
+
console.log('⏭️ 跳过更新检查');
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
start.showLocalVersion(true);
|
package/package.json
CHANGED
package/tool/autoUpdate.js
CHANGED
|
@@ -111,8 +111,17 @@ class AutoUpdate {
|
|
|
111
111
|
console.log(chalk.gray(`当前版本: ${currentVersion}, 最新版本: ${latestVersion}`));
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
//
|
|
115
|
-
|
|
114
|
+
// 版本比较逻辑
|
|
115
|
+
// 如果当前版本为 unknown,跳过更新
|
|
116
|
+
if (currentVersion === 'unknown') {
|
|
117
|
+
if (!silent) {
|
|
118
|
+
console.log(chalk.yellow('⚠️ 当前版本未知,跳过更新检查'));
|
|
119
|
+
}
|
|
120
|
+
resolve(false);
|
|
121
|
+
} else {
|
|
122
|
+
// 简单的版本比较
|
|
123
|
+
resolve(latestVersion !== currentVersion);
|
|
124
|
+
}
|
|
116
125
|
} catch (e) {
|
|
117
126
|
// 如果版本比较失败,默认执行更新
|
|
118
127
|
resolve(true);
|
package/tool/compress.js
CHANGED
|
@@ -176,6 +176,11 @@ function compressFiles(inNames, outName) {
|
|
|
176
176
|
} else if (ext == '.gspx') {
|
|
177
177
|
content = compressGspx(filePath);
|
|
178
178
|
}
|
|
179
|
+
if (!content) {
|
|
180
|
+
console.log('文件不存在或为空', filePath);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
179
184
|
json[path2] = content;
|
|
180
185
|
});
|
|
181
186
|
|
|
@@ -198,7 +203,7 @@ function compressJs(inNames, targetJs, onEnd) {
|
|
|
198
203
|
onEnd();
|
|
199
204
|
}
|
|
200
205
|
|
|
201
|
-
console.log('compress完成', inNames, targetJs);
|
|
206
|
+
console.log('compress完成', inNames, targetJs ? targetJs : '');
|
|
202
207
|
console.log('\r\n');
|
|
203
208
|
|
|
204
209
|
return content;
|
|
@@ -241,6 +246,9 @@ function compressCss(inNames, targetCss) {
|
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
function compressGspx(filePath) {
|
|
249
|
+
if (!fs.existsSync(filePath)) {
|
|
250
|
+
return '';
|
|
251
|
+
}
|
|
244
252
|
const xmlMinifier = require('xml-minifier');
|
|
245
253
|
let xml = fs.readFileSync(filePath, 'utf8');
|
|
246
254
|
let minified = xmlMinifier.minify(xml);
|
package/tool/merge/mergeTool.js
CHANGED
|
@@ -257,7 +257,11 @@ function compressFile(filePath, options, filePath2, stats) {
|
|
|
257
257
|
|
|
258
258
|
if (!options.hidejspath) {
|
|
259
259
|
var p = filePath2 || filePath;
|
|
260
|
-
options.
|
|
260
|
+
if (options.ext == '.js') {
|
|
261
|
+
options.__filesContent.push('// ' + p.split(path.sep).splice(-3).join(path.sep));
|
|
262
|
+
} else {
|
|
263
|
+
options.__filesContent.push('/* ' + p.split(path.sep).splice(-3).join(path.sep) + ' */');
|
|
264
|
+
}
|
|
261
265
|
}
|
|
262
266
|
options.__filesContent.push(content);
|
|
263
267
|
utils.debug('文件打包完成:' + filePath + '\r\n');
|