@hcmai/cli 0.14.3 → 0.14.4
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 +29 -15
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6018,6 +6018,7 @@ import {
|
|
|
6018
6018
|
formatObject as formatObject17,
|
|
6019
6019
|
fromAxiosError as fromAxiosError16,
|
|
6020
6020
|
loadGlobalConfig as loadGlobalConfig6,
|
|
6021
|
+
discoverProjectEnv as discoverProjectEnv3,
|
|
6021
6022
|
resolveEnvContext as resolveEnvContext5,
|
|
6022
6023
|
printResolvedEnvironment as printResolvedEnvironment4,
|
|
6023
6024
|
CliError as CliError20,
|
|
@@ -6803,16 +6804,29 @@ async function resolveEndpoint(args) {
|
|
|
6803
6804
|
return args.endpoint.replace(/\/+$/, "");
|
|
6804
6805
|
}
|
|
6805
6806
|
const g = await loadGlobalConfig6();
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6807
|
+
try {
|
|
6808
|
+
const resolved = await resolveEnvContext5({ envFlag: args.env }, process.env, g);
|
|
6809
|
+
printResolvedEnvironment4(resolved);
|
|
6810
|
+
const env2 = resolved.config;
|
|
6811
|
+
if (env2?.endpoint) return env2.endpoint.replace(/\/+$/, "");
|
|
6812
|
+
} catch (e) {
|
|
6813
|
+
if (e?.code !== CliErrorCode19.ENV_NOT_FOUND) throw e;
|
|
6814
|
+
const project = await discoverProjectEnv3();
|
|
6815
|
+
const name = args.env ?? project?.config.default;
|
|
6816
|
+
const fromProject = name ? project?.config.environments[name] : void 0;
|
|
6817
|
+
if (fromProject?.endpoint) {
|
|
6818
|
+
process.stderr.write(
|
|
6819
|
+
`\u2192 ${fromProject.endpoint} \xB7 \u79DF\u6237 ${fromProject.tenant} \xB7 \u8EAB\u4EFD \u672A\u767B\u5F55\uFF08\u6765\u81EA ${project.path} \u7684 '${name}'\uFF1B\u672C\u673A\u6CA1\u6709\u5339\u914D\u7684\u69FD\uFF0C\u4F46\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u53D6\u76EE\u5F55\u4E0D\u9700\u8981\u5B83\uFF09
|
|
6820
|
+
`
|
|
6821
|
+
);
|
|
6822
|
+
return fromProject.endpoint.replace(/\/+$/, "");
|
|
6823
|
+
}
|
|
6824
|
+
throw e;
|
|
6814
6825
|
}
|
|
6815
|
-
|
|
6826
|
+
throw new CliError20({
|
|
6827
|
+
code: CliErrorCode19.MISSING_FLAG,
|
|
6828
|
+
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\uFF08\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u5148 login\uFF09"
|
|
6829
|
+
});
|
|
6816
6830
|
}
|
|
6817
6831
|
function normalizeEndpoint(endpoint) {
|
|
6818
6832
|
return endpoint.replace(/\/+$/, "");
|
|
@@ -8241,7 +8255,7 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
|
|
|
8241
8255
|
// src/commands/tenant.ts
|
|
8242
8256
|
import {
|
|
8243
8257
|
bootstrapTenant,
|
|
8244
|
-
discoverProjectEnv as
|
|
8258
|
+
discoverProjectEnv as discoverProjectEnv4,
|
|
8245
8259
|
assertDangerWrite as assertDangerWrite3,
|
|
8246
8260
|
normalizeOrigin as normalizeOrigin4,
|
|
8247
8261
|
createHttpClient as createHttpClient3,
|
|
@@ -8307,7 +8321,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
8307
8321
|
});
|
|
8308
8322
|
}
|
|
8309
8323
|
const endpoint = await resolveEndpoint2(args);
|
|
8310
|
-
const project = await
|
|
8324
|
+
const project = await discoverProjectEnv4();
|
|
8311
8325
|
const protectedNames = project ? Object.entries(project.config.environments).filter(([, candidate]) => candidate.danger && candidate.endpoint === normalizeOrigin4(endpoint)).map(([name]) => name) : [];
|
|
8312
8326
|
assertDangerWrite3({ name: protectedNames.join(", "), danger: protectedNames.length > 0, allowDanger: args.allowDanger }, "\u5F00\u901A\u79DF\u6237");
|
|
8313
8327
|
if (args.endpoint) process.stderr.write(`\u2192 ${endpoint} \xB7 \u79DF\u6237 ${args.tenantId} \xB7 \u8EAB\u4EFD bootstrap key\uFF08\u6765\u81EA --endpoint\uFF09
|
|
@@ -10385,7 +10399,7 @@ import {
|
|
|
10385
10399
|
isTempEnv as isTempEnv3,
|
|
10386
10400
|
listIdentities as listIdentities5,
|
|
10387
10401
|
loadEnv as loadEnv5,
|
|
10388
|
-
discoverProjectEnv as
|
|
10402
|
+
discoverProjectEnv as discoverProjectEnv5,
|
|
10389
10403
|
findEnvByEndpoint as findEnvByEndpoint4,
|
|
10390
10404
|
normalizeOrigin as normalizeOrigin5,
|
|
10391
10405
|
loadGlobalConfig as loadGlobalConfig9
|
|
@@ -10436,7 +10450,7 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
10436
10450
|
identity: args.env ? await identityOf(args.env) : null
|
|
10437
10451
|
};
|
|
10438
10452
|
}
|
|
10439
|
-
const existing = await
|
|
10453
|
+
const existing = await discoverProjectEnv5(root);
|
|
10440
10454
|
if (existing && path10.dirname(existing.path) === path10.resolve(root)) {
|
|
10441
10455
|
const name2 = args.env ?? existing.config.default;
|
|
10442
10456
|
const env2 = existing.config.environments[name2];
|
|
@@ -11124,7 +11138,7 @@ import {
|
|
|
11124
11138
|
AUTH_INFO_PATH as AUTH_INFO_PATH2,
|
|
11125
11139
|
CliError as CliError26,
|
|
11126
11140
|
CliErrorCode as CliErrorCode24,
|
|
11127
|
-
discoverProjectEnv as
|
|
11141
|
+
discoverProjectEnv as discoverProjectEnv6,
|
|
11128
11142
|
ENV_FILE as ENV_FILE2,
|
|
11129
11143
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
11130
11144
|
formatObject as formatObject25,
|
|
@@ -11265,7 +11279,7 @@ async function runChironEnv(action, args = {}) {
|
|
|
11265
11279
|
invalid2(`\u672A\u77E5\u8F93\u51FA\u683C\u5F0F '${args.output}'\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u4F7F\u7528 --output table\u3001json \u6216 yaml");
|
|
11266
11280
|
}
|
|
11267
11281
|
const root = path12.resolve(args.project ?? ".");
|
|
11268
|
-
const discovered = await
|
|
11282
|
+
const discovered = await discoverProjectEnv6(root);
|
|
11269
11283
|
const file = discovered?.path ?? path12.join(root, ENV_FILE2);
|
|
11270
11284
|
if (!discovered && action !== "add") invalid2(`\u6CA1\u6709\u627E\u5230 ${file}\u3002`, "\u8FDB\u5165\u987E\u95EE\u9879\u76EE\uFF0C\u6216\u8FD0\u884C hcm chiron env add <\u540D\u5B57> --endpoint <URL> --frontend <URL> --tenant <\u79DF\u6237>");
|
|
11271
11285
|
const original = discovered ? await fs11.readFile(file, "utf8") : null;
|