@hcmai/cli 0.21.9 → 0.21.11
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/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -10346,11 +10346,15 @@ async function workspaceValidateCommand(args) {
|
|
|
10346
10346
|
}
|
|
10347
10347
|
}
|
|
10348
10348
|
async function workspacePushCommand(args) {
|
|
10349
|
+
let recovery2;
|
|
10350
|
+
let profile = args.env ?? args.profile;
|
|
10349
10351
|
try {
|
|
10350
10352
|
await withWorkspacePushProgress(async (bindHttp, assertRunning) => {
|
|
10351
10353
|
const rootDir = resolveRootDir(args.dir);
|
|
10352
10354
|
await assertWorkspacePushRoot(rootDir);
|
|
10353
10355
|
const context = await requireWorkspaceContext(rootDir);
|
|
10356
|
+
profile ??= context.profile;
|
|
10357
|
+
recovery2 = { command: "push", workspaceKey: context.workspaceKey, dir: rootDir, as: args.as };
|
|
10354
10358
|
const miniApps = await discoverMiniApps(rootDir);
|
|
10355
10359
|
for (const app of miniApps) {
|
|
10356
10360
|
const validation = await validateMiniProject(app.dir);
|
|
@@ -10364,6 +10368,7 @@ async function workspacePushCommand(args) {
|
|
|
10364
10368
|
const client3 = HcmClient22.fromAuthContext(
|
|
10365
10369
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
10366
10370
|
);
|
|
10371
|
+
profile = client3.profile ?? profile;
|
|
10367
10372
|
bindHttp(client3.raw());
|
|
10368
10373
|
if (!args.dryRun) {
|
|
10369
10374
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
|
|
@@ -10392,7 +10397,7 @@ async function workspacePushCommand(args) {
|
|
|
10392
10397
|
}, args.env ?? args.profile);
|
|
10393
10398
|
return;
|
|
10394
10399
|
} catch (e) {
|
|
10395
|
-
exitWorkspaceError(e,
|
|
10400
|
+
exitWorkspaceError(e, profile, recovery2);
|
|
10396
10401
|
}
|
|
10397
10402
|
}
|
|
10398
10403
|
async function workspacePreviewCommand(args) {
|
|
@@ -10558,7 +10563,7 @@ async function assertWorkspacePushRoot(rootDir) {
|
|
|
10558
10563
|
dir = parent;
|
|
10559
10564
|
}
|
|
10560
10565
|
if (!insideMiniApp && (!workspaceRoot || workspaceRoot === realRoot)) return;
|
|
10561
|
-
const target = workspaceRoot ?
|
|
10566
|
+
const target = workspaceRoot ? quoteWorkspaceArg(workspaceRoot) : "<workspace-root>";
|
|
10562
10567
|
throw new CliError25({
|
|
10563
10568
|
code: CliErrorCode26.INVALID_ARGUMENT,
|
|
10564
10569
|
message: `workspace push \u5FC5\u987B\u4ECE workspace \u6839\u76EE\u5F55\u6267\u884C\uFF0C\u5F53\u524D\u76EE\u5F55 ${rootDir} \u662F${insideMiniApp ? "\u8F7B\u5E94\u7528\u76EE\u5F55\u6216\u5176\u5B50\u76EE\u5F55" : "\u5DE5\u4F5C\u533A\u5B50\u76EE\u5F55"}\uFF1B\u7EE7\u7EED\u4F1A\u8DF3\u8FC7\u8F7B\u5E94\u7528\u90E8\u7F72\u3002`,
|
|
@@ -11359,9 +11364,30 @@ function summarizeStatus(status) {
|
|
|
11359
11364
|
function formatStatusSummary(summary) {
|
|
11360
11365
|
return `added=${summary.added}, modified=${summary.modified}, deleted=${summary.deleted}, unchanged=${summary.unchanged}`;
|
|
11361
11366
|
}
|
|
11362
|
-
function
|
|
11367
|
+
function quoteWorkspaceArg(value) {
|
|
11368
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
11369
|
+
}
|
|
11370
|
+
function exitWorkspaceError(err, profile, operation) {
|
|
11363
11371
|
const maybeAxios = err;
|
|
11364
11372
|
const translated = maybeAxios?.isAxiosError ? fromAxiosError22(err, profile) : err;
|
|
11373
|
+
if (translated instanceof CliError25 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
|
|
11374
|
+
const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
|
|
11375
|
+
const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
|
|
11376
|
+
const deployment = translated.context.responseCode === "DEPLOY_IN_PROGRESS" ? `\u6709\u53D1\u5E03\u67E5\u8BE2\u6743\u9650\u65F6\uFF0C\u6267\u884C hcm query TenantExtensionRelease --fields id,workspaceKey,deploymentStatus --limit 20${scope} \u67E5\u770B\u53EF\u89C1\u90E8\u7F72\u8BB0\u5F55\uFF1B\u7A7A\u7ED3\u679C\u4E0D\u80FD\u8BC1\u660E\u9501\u5DF2\u91CA\u653E\u3002` : void 0;
|
|
11377
|
+
const retry = operation.command === "activate" ? `\u6309\u670D\u52A1\u7AEF\u8BE6\u60C5\u5B8C\u6210\u5904\u7406\u5E76\u786E\u8BA4\u76EE\u6807\u5DE5\u4F5C\u533A\u540E\uFF0C\u518D\u6267\u884C hcm workspace activate ${quoteWorkspaceArg(operation.workspaceKey)}${scope}\u3002` : `\u4FDD\u7559\u672C\u5730\u76EE\u5F55 ${operation.dir}\uFF1B\u6267\u884C hcm workspace pull --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>'${scope}\uFF0C\u6BD4\u5BF9\u540E\u628A\u5F85\u4FDD\u7559\u4FEE\u6539\uFF08\u542B\u5220\u9664\u610F\u56FE\uFF09\u5408\u5E76\u5230\u65B0\u76EE\u5F55\uFF0C\u518D\u6267\u884C hcm workspace push --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>' --dry-run${scope}\uFF0C\u6838\u5BF9\u8BA1\u5212\u540E\u5728\u65B0\u76EE\u5F55\u53BB\u6389 --dry-run \u63A8\u9001\u3002\u539F\u76EE\u5F55\u4FDD\u7559\u5907\u4EFD\uFF0C\u4E0D\u8981\u8986\u76D6\u6216\u7EE7\u7EED\u4F7F\u7528\u65E7\u57FA\u7EBF\u63A8\u9001\u3002`;
|
|
11378
|
+
exitWithError(new CliError25({
|
|
11379
|
+
code: translated.code,
|
|
11380
|
+
message: translated.message,
|
|
11381
|
+
traceId: translated.traceId,
|
|
11382
|
+
profile: translated.profile ?? profile,
|
|
11383
|
+
cause: translated,
|
|
11384
|
+
context: {
|
|
11385
|
+
...translated.context,
|
|
11386
|
+
workspaceKey: operation.workspaceKey,
|
|
11387
|
+
nextStep: [translated.context.nextStep, `\u5148\u6267\u884C ${active} \u6838\u5BF9\u5F53\u524D\u8EAB\u4EFD\u7684\u5F00\u53D1\u6001\u7ED1\u5B9A\uFF08\u8BE5\u547D\u4EE4\u4E0D\u67E5\u8BE2\u90E8\u7F72\u8FDB\u5EA6\uFF09\u3002`, deployment, retry].filter(Boolean).join(" ")
|
|
11388
|
+
}
|
|
11389
|
+
}));
|
|
11390
|
+
}
|
|
11365
11391
|
if (translated instanceof CliError25 && translated.code === CliErrorCode26.AUTH_FAILED) {
|
|
11366
11392
|
exitWithError(new CliError25({
|
|
11367
11393
|
code: translated.code,
|
|
@@ -11426,9 +11452,13 @@ async function requestWorkspaceDeactivation(client3) {
|
|
|
11426
11452
|
return binding;
|
|
11427
11453
|
}
|
|
11428
11454
|
async function workspaceActivateCommand(workspaceKey, args) {
|
|
11455
|
+
let recovery2;
|
|
11456
|
+
let profile = args.env ?? args.profile;
|
|
11429
11457
|
try {
|
|
11430
11458
|
const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11459
|
+
profile = client3.profile ?? profile;
|
|
11431
11460
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
11461
|
+
recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
|
|
11432
11462
|
await setDevModeBinding(client3, key2);
|
|
11433
11463
|
const fmt = args.output ?? "table";
|
|
11434
11464
|
if (fmt === "table") {
|
|
@@ -11443,7 +11473,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11443
11473
|
process.exitCode = 0;
|
|
11444
11474
|
return;
|
|
11445
11475
|
} catch (e) {
|
|
11446
|
-
exitWorkspaceError(e,
|
|
11476
|
+
exitWorkspaceError(e, profile, recovery2);
|
|
11447
11477
|
}
|
|
11448
11478
|
}
|
|
11449
11479
|
async function workspaceDeactivateCommand(args) {
|