@workclaw/cli 1.0.23 → 1.0.26
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.
|
@@ -32,7 +32,9 @@ const ERROR_CODES$1 = {
|
|
|
32
32
|
NODE_NOT_FOUND: "NODE_NOT_FOUND",
|
|
33
33
|
NPM_NOT_FOUND: "NPM_NOT_FOUND",
|
|
34
34
|
NPM_INSTALL_FAILED: "NPM_INSTALL_FAILED",
|
|
35
|
-
CONFIG_WRITE_FAILED: "CONFIG_WRITE_FAILED"
|
|
35
|
+
CONFIG_WRITE_FAILED: "CONFIG_WRITE_FAILED",
|
|
36
|
+
HTTP_ERROR: "HTTP_ERROR",
|
|
37
|
+
NETWORK_ERROR: "NETWORK_ERROR"
|
|
36
38
|
};
|
|
37
39
|
let AppError$1 = class AppError extends Error {
|
|
38
40
|
constructor(code, message) {
|
|
@@ -111,20 +113,20 @@ async function httpPost(url, data, config) {
|
|
|
111
113
|
debugLog(`[HTTP POST] 响应状态文本: ${axiosError.response.statusText}`);
|
|
112
114
|
debugLog(`[HTTP POST] 响应数据: ${JSON.stringify(responseData)}`);
|
|
113
115
|
if (typeof responseData === "string") {
|
|
114
|
-
throw new
|
|
116
|
+
throw new AppError$1(ERROR_CODES$1.HTTP_ERROR, `请求失败 (${axiosError.response.status}): ${responseData}`);
|
|
115
117
|
} else if (responseData && typeof responseData === "object" && "message" in responseData) {
|
|
116
|
-
throw new
|
|
118
|
+
throw new AppError$1(ERROR_CODES$1.HTTP_ERROR, `请求失败 (${axiosError.response.status}): ${responseData.message}`);
|
|
117
119
|
} else {
|
|
118
|
-
throw new
|
|
120
|
+
throw new AppError$1(ERROR_CODES$1.HTTP_ERROR, `请求失败 (${axiosError.response.status}): ${axiosError.response.statusText}`);
|
|
119
121
|
}
|
|
120
122
|
} else if (axiosError.request) {
|
|
121
123
|
debugLog(`[HTTP POST] 未收到响应`);
|
|
122
124
|
debugLog(`[HTTP POST] 错误信息: ${axiosError.message}`);
|
|
123
|
-
throw new
|
|
125
|
+
throw new AppError$1(ERROR_CODES$1.NETWORK_ERROR, `网络错误: ${axiosError.message}`);
|
|
124
126
|
} else {
|
|
125
127
|
debugLog(`[HTTP POST] 请求配置错误`);
|
|
126
128
|
debugLog(`[HTTP POST] 错误信息: ${axiosError.message}`);
|
|
127
|
-
throw new
|
|
129
|
+
throw new AppError$1(ERROR_CODES$1.HTTP_ERROR, `请求配置错误: ${axiosError.message}`);
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
}
|
|
@@ -4155,8 +4157,8 @@ class LocalInstaller {
|
|
|
4155
4157
|
debugLog(`[路径配置] target=${paths.target}`);
|
|
4156
4158
|
debugLog(`[路径配置] config=${paths.config}`);
|
|
4157
4159
|
debugLog(`[路径配置] workspace=${paths.workspace}`);
|
|
4158
|
-
await this.doLogin(env);
|
|
4159
|
-
const boundConfig = await this.doFetchBoundConfig(env);
|
|
4160
|
+
const token = await this.doLogin(env);
|
|
4161
|
+
const boundConfig = await this.doFetchBoundConfig(env, token);
|
|
4160
4162
|
await this.doCleanOldFiles(paths.target);
|
|
4161
4163
|
await this.doDownloadFromNpm(paths);
|
|
4162
4164
|
await this.doUpdateConfig(paths, boundConfig, env);
|
|
@@ -4180,16 +4182,15 @@ class LocalInstaller {
|
|
|
4180
4182
|
}
|
|
4181
4183
|
debugLog("[用户登录] 密码加密成功");
|
|
4182
4184
|
debugLog("[用户登录] 调用登录接口...");
|
|
4183
|
-
await login(this.config.phone, encryptedPassword, env);
|
|
4185
|
+
const token = await login(this.config.phone, encryptedPassword, env);
|
|
4184
4186
|
this.prefixText += chalk.green(`✓ 用户登录成功
|
|
4185
4187
|
`);
|
|
4186
4188
|
debugLog("[用户登录] 登录成功");
|
|
4189
|
+
return token;
|
|
4187
4190
|
}
|
|
4188
|
-
async doFetchBoundConfig(env) {
|
|
4191
|
+
async doFetchBoundConfig(env, token) {
|
|
4189
4192
|
this.spinner.prefixText = this.prefixText;
|
|
4190
4193
|
this.spinner.text = `${chalk.cyan("获取配置")} ${chalk.dim("→")} ${chalk.yellow("正在获取绑定配置...")}`;
|
|
4191
|
-
debugLog("[获取配置] 获取 token...");
|
|
4192
|
-
const token = await login(this.config.phone, rsaEncrypt(this.config.userPass), env);
|
|
4193
4194
|
debugLog("[获取配置] 调用绑定配置接口...");
|
|
4194
4195
|
const boundConfig = await fetchBoundConfig(token, this.config.phone, env);
|
|
4195
4196
|
debugLog(`[获取配置] agentId=${boundConfig.agentId}, appKey=${boundConfig.appKey?.slice(0, 8)}...`);
|
|
@@ -4283,15 +4284,21 @@ class LocalInstaller {
|
|
|
4283
4284
|
this.spinner.text = `${chalk.cyan("下载插件")} ${chalk.dim("→")} ${chalk.yellow("安装依赖")}`;
|
|
4284
4285
|
debugLog("[下载插件] 执行 npm install 安装生产环境依赖");
|
|
4285
4286
|
try {
|
|
4286
|
-
execSync("npm install --
|
|
4287
|
+
execSync("npm install --omit=dev --ignore-scripts", {
|
|
4287
4288
|
cwd: paths.target,
|
|
4288
4289
|
stdio: "pipe",
|
|
4289
4290
|
timeout: 12e4
|
|
4290
4291
|
});
|
|
4291
4292
|
debugLog("[下载插件] npm install 执行成功");
|
|
4292
4293
|
} catch (error) {
|
|
4293
|
-
const
|
|
4294
|
-
|
|
4294
|
+
const stderr = error.stderr?.toString() || "";
|
|
4295
|
+
const stdout = error.stdout?.toString() || "";
|
|
4296
|
+
const combinedOutput = stderr + stdout;
|
|
4297
|
+
if (combinedOutput.includes("npm warn") || combinedOutput.includes("deprecated")) {
|
|
4298
|
+
debugLog("[下载插件] npm install 有警告但可能成功,继续流程");
|
|
4299
|
+
} else {
|
|
4300
|
+
debugLog(`[下载插件] npm install 失败: ${combinedOutput}`);
|
|
4301
|
+
}
|
|
4295
4302
|
}
|
|
4296
4303
|
this.prefixText += chalk.green(`✓ 插件下载完成
|
|
4297
4304
|
`);
|
|
@@ -4546,7 +4553,6 @@ class LocalInstaller {
|
|
|
4546
4553
|
installPath: paths.target
|
|
4547
4554
|
}
|
|
4548
4555
|
},
|
|
4549
|
-
// 插件加载路径(本地开发或自定义安装位置)
|
|
4550
4556
|
load: {
|
|
4551
4557
|
paths: [paths.target]
|
|
4552
4558
|
},
|
|
@@ -4716,8 +4722,11 @@ const ERROR_CODES = {
|
|
|
4716
4722
|
APP_KEY_REQUIRED: "APP_KEY_REQUIRED",
|
|
4717
4723
|
APP_SECRET_REQUIRED: "APP_SECRET_REQUIRED",
|
|
4718
4724
|
NODE_VERSION_LOW: "NODE_VERSION_LOW",
|
|
4725
|
+
NODE_NOT_FOUND: "NODE_NOT_FOUND",
|
|
4719
4726
|
NPM_NOT_FOUND: "NPM_NOT_FOUND",
|
|
4720
|
-
NPM_INSTALL_FAILED: "NPM_INSTALL_FAILED"
|
|
4727
|
+
NPM_INSTALL_FAILED: "NPM_INSTALL_FAILED",
|
|
4728
|
+
CONFIG_WRITE_FAILED: "CONFIG_WRITE_FAILED",
|
|
4729
|
+
PLUGIN_EXTRACT_FAILED: "PLUGIN_EXTRACT_FAILED"
|
|
4721
4730
|
};
|
|
4722
4731
|
class AppError2 extends Error {
|
|
4723
4732
|
constructor(code, message) {
|
|
@@ -4893,7 +4902,7 @@ class BoxInstaller {
|
|
|
4893
4902
|
this.spinner.text = `${chalk.cyan("安装依赖")} ${chalk.dim("→")} ${chalk.yellow("正在安装...")}`;
|
|
4894
4903
|
debugLog("[安装依赖] 执行 npm install 安装生产环境依赖");
|
|
4895
4904
|
try {
|
|
4896
|
-
execSync("npm install --
|
|
4905
|
+
execSync("npm install --omit=dev --ignore-scripts", {
|
|
4897
4906
|
cwd: paths.target,
|
|
4898
4907
|
stdio: "pipe",
|
|
4899
4908
|
timeout: 12e4
|
|
@@ -4902,15 +4911,23 @@ class BoxInstaller {
|
|
|
4902
4911
|
this.prefixText += chalk.green(`✓ 依赖安装成功
|
|
4903
4912
|
`);
|
|
4904
4913
|
} catch (error) {
|
|
4905
|
-
const
|
|
4906
|
-
|
|
4914
|
+
const stderr = error.stderr?.toString() || "";
|
|
4915
|
+
const stdout = error.stdout?.toString() || "";
|
|
4916
|
+
const combinedOutput = stderr + stdout;
|
|
4917
|
+
if (combinedOutput.includes("npm warn") || combinedOutput.includes("deprecated")) {
|
|
4918
|
+
debugLog("[安装依赖] npm install 有警告但可能成功,继续流程");
|
|
4919
|
+
this.prefixText += chalk.green(`✓ 依赖安装完成
|
|
4920
|
+
`);
|
|
4921
|
+
} else {
|
|
4922
|
+
debugLog(`[安装依赖] npm install 失败: ${combinedOutput}`);
|
|
4923
|
+
}
|
|
4907
4924
|
}
|
|
4908
4925
|
await fs.rm(paths.temp, { recursive: true, force: true });
|
|
4909
4926
|
debugLog(`[解压插件] 清理临时文件成功`);
|
|
4910
4927
|
this.prefixText += chalk.green(`✓ 清理临时文件成功
|
|
4911
4928
|
`);
|
|
4912
4929
|
} else {
|
|
4913
|
-
throw new
|
|
4930
|
+
throw new AppError2(ERROR_CODES.PLUGIN_EXTRACT_FAILED, "解压失败:package 目录不存在");
|
|
4914
4931
|
}
|
|
4915
4932
|
} catch (error) {
|
|
4916
4933
|
debugLog(`[解压插件] 解压失败: ${error.message}`);
|
|
@@ -5082,6 +5099,8 @@ class BoxInstaller {
|
|
|
5082
5099
|
allowInsecureTls: true,
|
|
5083
5100
|
// 允许原始 JSON 载荷
|
|
5084
5101
|
allowRawJsonPayload: true,
|
|
5102
|
+
// 用户 ID
|
|
5103
|
+
userId: "",
|
|
5085
5104
|
accounts: {
|
|
5086
5105
|
// 账户配置(agentId 为空表示待分配)
|
|
5087
5106
|
default: { enabled: true, agentId: "" }
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workclaw/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.26",
|
|
5
5
|
"description": "WorkClaw CLI 工具 - 用于初始化和配置 WorkClaw 插件",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -38,4 +38,4 @@
|
|
|
38
38
|
"semver": "^7.7.1",
|
|
39
39
|
"tar": "^7.4.0"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|