@hcmai/cli 0.21.7 → 0.21.8
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 +26 -57
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9974,14 +9974,7 @@ async function workspaceActiveCommand(args) {
|
|
|
9974
9974
|
fallbackEnv: localContext?.profile
|
|
9975
9975
|
});
|
|
9976
9976
|
const client3 = HcmClient22.fromAuthContext(ctx);
|
|
9977
|
-
const
|
|
9978
|
-
if (response.data?.success === false) {
|
|
9979
|
-
throw new Error("\u5F00\u53D1\u6001\u72B6\u6001\u67E5\u8BE2\u5931\u8D25\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
|
|
9980
|
-
}
|
|
9981
|
-
const binding = unwrapWorkspaceActionPayload(response.data);
|
|
9982
|
-
if (!binding || typeof binding.enabled !== "boolean" || binding.enabled && !optionalText(binding.workspaceKey)) {
|
|
9983
|
-
throw new Error("\u5F00\u53D1\u6001\u67E5\u8BE2\u8FD4\u56DE\u65E0\u6548\u6570\u636E\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
|
|
9984
|
-
}
|
|
9977
|
+
const binding = await readWorkspaceDevModeBinding(client3);
|
|
9985
9978
|
const activeWorkspaceKey = binding.enabled ? optionalText(binding.workspaceKey) : null;
|
|
9986
9979
|
const bindingUpdatedAt = typeof binding.updatedAt === "number" && Number.isFinite(binding.updatedAt) && binding.updatedAt > 0 && binding.updatedAt <= 864e13 ? binding.updatedAt : null;
|
|
9987
9980
|
const view = {
|
|
@@ -10338,9 +10331,6 @@ async function workspaceValidateCommand(args) {
|
|
|
10338
10331
|
exitWorkspaceError(e);
|
|
10339
10332
|
}
|
|
10340
10333
|
}
|
|
10341
|
-
function isScriptPath(relativePath) {
|
|
10342
|
-
return relativePath.startsWith("scripts/");
|
|
10343
|
-
}
|
|
10344
10334
|
async function workspacePushCommand(args) {
|
|
10345
10335
|
try {
|
|
10346
10336
|
await withWorkspacePushProgress(async (bindHttp, assertRunning) => {
|
|
@@ -10361,25 +10351,8 @@ async function workspacePushCommand(args) {
|
|
|
10361
10351
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
10362
10352
|
);
|
|
10363
10353
|
bindHttp(client3.raw());
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
const plan = await pushWorkspaceRawFiles({
|
|
10367
|
-
http: client3.raw(),
|
|
10368
|
-
rootDir,
|
|
10369
|
-
context,
|
|
10370
|
-
dryRun: true
|
|
10371
|
-
});
|
|
10372
|
-
const scriptOps = plan.operations.filter(
|
|
10373
|
-
(op) => isScriptPath(op.remotePath ?? op.localPath)
|
|
10374
|
-
);
|
|
10375
|
-
if (scriptOps.length > 0) {
|
|
10376
|
-
throw new Error(
|
|
10377
|
-
`\u672C\u6B21\u4F1A\u5199 ${scriptOps.length} \u4E2A\u811A\u672C\uFF0C\u4F46\u5F53\u524D\u6FC0\u6D3B\u7684\u5F00\u53D1\u7A7A\u95F4\u662F ${activeWorkspaceKey ? `"${activeWorkspaceKey}"` : "\uFF08\u672A\u6FC0\u6D3B\uFF09"}\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${context.workspaceKey}"\u3002
|
|
10378
|
-
\u670D\u52A1\u7AEF\u4F1A\u62D2\u7EDD\u5199\u811A\u672C\uFF0C\u800C\u975E\u811A\u672C\u6587\u4EF6\u5DF2\u7ECF\u5199\u8FDB\u53BB\u4E86 \u2014\u2014 \u90A3\u4F1A\u7559\u4E0B\u534A\u63A8\u9001\u72B6\u6001\u3002
|
|
10379
|
-
\u4E0B\u4E00\u6B65\uFF1Ahcm workspace activate ${context.workspaceKey}
|
|
10380
|
-
\u6D89\u53CA\u811A\u672C\uFF1A${scriptOps.map((op) => op.remotePath ?? op.localPath).join(", ")}`
|
|
10381
|
-
);
|
|
10382
|
-
}
|
|
10354
|
+
if (!args.dryRun) {
|
|
10355
|
+
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
|
|
10383
10356
|
}
|
|
10384
10357
|
const rawResult = await pushWorkspaceRawFiles({
|
|
10385
10358
|
http: client3.raw(),
|
|
@@ -10396,15 +10369,11 @@ async function workspacePushCommand(args) {
|
|
|
10396
10369
|
});
|
|
10397
10370
|
results.push({ app, result });
|
|
10398
10371
|
}
|
|
10399
|
-
const hint = activationHint(
|
|
10400
|
-
activeWorkspaceKey ?? await probeActiveWorkspaceKey(client3),
|
|
10401
|
-
context.workspaceKey ?? null
|
|
10402
|
-
);
|
|
10403
10372
|
assertRunning();
|
|
10404
10373
|
writeWorkspacePushResult(rawResult, results, args.output ?? "table");
|
|
10405
|
-
if (
|
|
10406
|
-
|
|
10407
|
-
|
|
10374
|
+
if (!args.dryRun) {
|
|
10375
|
+
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey, true);
|
|
10376
|
+
}
|
|
10408
10377
|
process.exitCode = rawResult.conflicts.length || results.some((item) => item.result.conflicts.length) ? 3 : 0;
|
|
10409
10378
|
}, args.env ?? args.profile);
|
|
10410
10379
|
return;
|
|
@@ -11391,28 +11360,28 @@ function exitWorkspaceError(err, profile) {
|
|
|
11391
11360
|
}
|
|
11392
11361
|
exitWithError(translated);
|
|
11393
11362
|
}
|
|
11394
|
-
async function
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
fields: ["workspaceKey", "devModeEnabled"],
|
|
11399
|
-
limit: 1
|
|
11400
|
-
});
|
|
11401
|
-
return optionalText(result.rows[0]?.workspaceKey) ?? null;
|
|
11402
|
-
} catch {
|
|
11403
|
-
return null;
|
|
11404
|
-
}
|
|
11405
|
-
}
|
|
11406
|
-
function activationHint(activeKey, localKey) {
|
|
11407
|
-
if (localKey && activeKey === localKey) {
|
|
11408
|
-
return null;
|
|
11363
|
+
async function readWorkspaceDevModeBinding(client3) {
|
|
11364
|
+
const response = await client3.raw().get("/api/tenant-extension/dev-mode");
|
|
11365
|
+
if (response.data?.success === false) {
|
|
11366
|
+
throw new Error("\u5F00\u53D1\u6001\u72B6\u6001\u67E5\u8BE2\u5931\u8D25\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
|
|
11409
11367
|
}
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11368
|
+
const binding = unwrapWorkspaceActionPayload(response.data);
|
|
11369
|
+
if (!binding || typeof binding.enabled !== "boolean" || binding.enabled && !optionalText(binding.workspaceKey)) {
|
|
11370
|
+
throw new Error("\u5F00\u53D1\u6001\u67E5\u8BE2\u8FD4\u56DE\u65E0\u6548\u6570\u636E\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
|
|
11413
11371
|
}
|
|
11414
|
-
return
|
|
11415
|
-
|
|
11372
|
+
return binding;
|
|
11373
|
+
}
|
|
11374
|
+
async function probeActiveWorkspaceKey(client3) {
|
|
11375
|
+
const binding = await readWorkspaceDevModeBinding(client3);
|
|
11376
|
+
return binding.enabled ? optionalText(binding.workspaceKey) : null;
|
|
11377
|
+
}
|
|
11378
|
+
function requireWorkspaceActivation(activeKey, workspaceKey, afterPush = false) {
|
|
11379
|
+
if (activeKey === workspaceKey) return;
|
|
11380
|
+
throw new CliError25({
|
|
11381
|
+
code: CliErrorCode26.INVALID_ARGUMENT,
|
|
11382
|
+
message: (afterPush ? "\u63A8\u9001\u540E\u7ED1\u5B9A\u5DF2\u53D8\u5316\uFF0C\u6587\u4EF6\u53EF\u80FD\u5DF2\u4FDD\u5B58\u4E3A\u8349\u7A3F\uFF1B" : "") + (activeKey ? `\u5F53\u524D\u8EAB\u4EFD\u6FC0\u6D3B\u7684\u662F "${activeKey}"\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002` : `\u5F53\u524D\u8EAB\u4EFD\u672A\u6FC0\u6D3B\u5F00\u53D1\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002`),
|
|
11383
|
+
context: { workspaceKey, activeWorkspaceKey: activeKey, nextStep: `hcm workspace activate ${workspaceKey}` }
|
|
11384
|
+
});
|
|
11416
11385
|
}
|
|
11417
11386
|
async function setDevModeBinding(client3, workspaceKey) {
|
|
11418
11387
|
await client3.raw().put("/api/tenant-extension/dev-mode", {
|