@hcmai/cli 0.21.12 → 0.21.14

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 CHANGED
@@ -2236,7 +2236,7 @@ var init_readline = __esm({
2236
2236
 
2237
2237
  // src/index.ts
2238
2238
  import { Command } from "commander";
2239
- import { LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
2239
+ import { DATA_PACKAGE_FIXTURE_SCHEMA_V1, LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
2240
2240
 
2241
2241
  // src/package-version.ts
2242
2242
  import { readFileSync } from "fs";
@@ -4690,6 +4690,8 @@ async function importCommand(path21, args) {
4690
4690
  };
4691
4691
  const client3 = opts.dryRun ? DRY_RUN_CLIENT : HcmClient8.fromAuthContext(await getActiveAuthContextFromCli(args));
4692
4692
  const result = await runImport(client3, fixtures, opts);
4693
+ for (const warning of result.warnings ?? []) process.stderr.write(`\u26A0 ${warning}
4694
+ `);
4693
4695
  if (args.report) writeFileSync(args.report, JSON.stringify(result, null, 2));
4694
4696
  const fmt = args.output ?? "json";
4695
4697
  const tag = opts.dryRun ? "\u{1F50D} dry-run" : "\u{1F4E6} import";
@@ -9804,6 +9806,7 @@ import {
9804
9806
  runMiniSmokeChecks,
9805
9807
  saveWorkspaceFileContent,
9806
9808
  validateMiniProject,
9809
+ validateMetaContent as validateMetaContent2,
9807
9810
  fromAxiosError as fromAxiosError22,
9808
9811
  CliError as CliError25,
9809
9812
  CliErrorCode as CliErrorCode26
@@ -10335,9 +10338,29 @@ async function workspaceValidateCommand(args) {
10335
10338
  const rootDir = resolveRootDir(args.dir);
10336
10339
  await requireWorkspaceContext(rootDir);
10337
10340
  const miniApps = await discoverMiniApps(rootDir);
10338
- const results = await Promise.all(
10339
- miniApps.map(async (app) => ({ app, result: await validateMiniProject(app.dir) }))
10340
- );
10341
+ const metaFiles = await readWorkspaceRawLocalFiles(path9.join(rootDir, "metas"));
10342
+ const metaResults = metaFiles.filter((file) => /\.ya?ml$/i.test(file.localPath)).map((file) => {
10343
+ const artifact = `meta:metas/${file.localPath}`;
10344
+ const validation = validateMetaContent2(`metas/${file.localPath}`, file.content);
10345
+ const message = (issue) => `${issue.path}: ${issue.message}${issue.hint ? `\uFF1B${issue.hint}` : ""}`;
10346
+ return {
10347
+ artifact,
10348
+ result: {
10349
+ valid: validation.errors.length === 0,
10350
+ errors: validation.errors.map(message),
10351
+ warnings: validation.issues.filter((issue) => issue.severity === "warn").map(message)
10352
+ }
10353
+ };
10354
+ });
10355
+ const results = [
10356
+ ...metaResults,
10357
+ ...await Promise.all(
10358
+ miniApps.map(async (app) => ({
10359
+ artifact: `mini:${app.appCode}`,
10360
+ result: await validateMiniProject(app.dir)
10361
+ }))
10362
+ )
10363
+ ];
10341
10364
  writeWorkspaceValidateResult(results, args.output ?? "table");
10342
10365
  process.exitCode = results.every((item) => item.result.valid) ? 0 : 1;
10343
10366
  return;
@@ -11305,14 +11328,14 @@ function writeWorkspaceValidateResult(results, format) {
11305
11328
  if (format !== "table") {
11306
11329
  process.stdout.write(
11307
11330
  formatObject22(
11308
- results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
11331
+ results.map((item) => ({ artifact: item.artifact, ...item.result })),
11309
11332
  { format }
11310
11333
  ) + "\n"
11311
11334
  );
11312
11335
  return;
11313
11336
  }
11314
11337
  const rows2 = results.map((item) => ({
11315
- artifact: `mini:${item.app.appCode}`,
11338
+ artifact: item.artifact,
11316
11339
  valid: item.result.valid ? "yes" : "no",
11317
11340
  errors: item.result.errors.length,
11318
11341
  warnings: item.result.warnings.length
@@ -11321,7 +11344,7 @@ function writeWorkspaceValidateResult(results, format) {
11321
11344
  for (const item of results) {
11322
11345
  if (!item.result.errors.length && !item.result.warnings.length) continue;
11323
11346
  process.stdout.write(`
11324
- mini:${item.app.appCode}
11347
+ ${item.artifact}
11325
11348
  `);
11326
11349
  for (const error of item.result.errors) process.stdout.write(` error: ${error}
11327
11350
  `);
@@ -19424,7 +19447,12 @@ program.command("create <Model>").description("\u521B\u5EFA\u4E00\u6761 Model \u
19424
19447
  "\u591A\u8BED\u8A00\u5B57\u6BB5\u6309 Map \u5B8C\u6574\u66FF\u6362\uFF08\u952E\u7528 zh-CN / en-US \u8FDE\u5B57\u7B26\u5F62\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309\u5B57\u7B26\u4E32\u53EA\u6539\u5F53\u524D\u8BED\u8A00"
19425
19448
  ).action((m, opts) => createCommand(m, opts));
19426
19449
  program.command("delete <Model>").description("\u5220\u9664\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF1B\u90E8\u5206 Model \u4F1A\u6267\u884C\u4E1A\u52A1\u64A4\u9500\uFF09").option("--id <id>", "\u76EE\u6807\u5B9E\u4F53 ID\uFF08\u5FC5\u586B\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((m, opts) => deleteCommand(m, opts));
19427
- program.command("import <path>").description("\u6CE8\u5165 DataPackage YAML \u6570\u636E\u96C6\uFF08\u76EE\u5F55\u6216\u5355\u6587\u4EF6\uFF0C\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09").option("--dry-run", "\u53EA\u8DD1\u5BA2\u6237\u7AEF\u9759\u6001\u6821\u9A8C\uFF0C\u4E0D\u843D\u5E93\uFF08\u89C1 spec \xA78 \u9650\u5236\uFF09").option("--update-only", "\u5DF2\u5B58\u5728\uFF08\u6309 key_field\uFF09\u5219 PUT \u66F4\u65B0\uFF0C\u5426\u5219 create").option("--on-error <mode>", "stop | continue\uFF08\u9ED8\u8BA4 continue\uFF09", "continue").option("--report <path>", "\u5199 JSON \u6CE8\u5165\u62A5\u544A\uFF08\u9010\u884C\u7ED3\u679C + key\u2192id \u6620\u5C04\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((p, opts) => importCommand(p, opts));
19450
+ program.command("import <path>").description("\u6CE8\u5165 DataPackage fixture v1\uFF08\u76EE\u5F55\u6216\u5355\u6587\u4EF6\uFF0C\u5355\u4E00\u4E1A\u52A1\u952E\uFF09").option("--dry-run", "\u53EA\u8DD1\u5BA2\u6237\u7AEF\u9759\u6001\u6821\u9A8C\uFF0C\u4E0D\u843D\u5E93\uFF08\u89C1 spec \xA78 \u9650\u5236\uFF09").option("--update-only", "\u5DF2\u5B58\u5728\uFF08\u6309 key_field\uFF09\u5219 PUT \u66F4\u65B0\uFF0C\u5426\u5219 create").option("--on-error <mode>", "stop | continue\uFF08\u9ED8\u8BA4 continue\uFF09", "continue").option("--report <path>", "\u5199 JSON \u6CE8\u5165\u62A5\u544A\uFF08\u9010\u884C\u7ED3\u679C + key\u2192id \u6620\u5C04\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").addHelpText("after", `
19451
+ \u516C\u5171 schema\uFF1A${DATA_PACKAGE_FIXTURE_SCHEMA_V1.$id}
19452
+ ${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key_field.description}
19453
+ ${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.description}
19454
+ \u5B8C\u6574 DataPackage manifest \u7684 models[].keys \u7531 hcm datapackage install \u5904\u7406\u3002
19455
+ `).action((p, opts) => importCommand(p, opts));
19428
19456
  program.command("models [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u6709\u54EA\u4E9B Model\uFF08describe \u7684\u4E0A\u4E00\u6B65\uFF09\uFF1B\u53EF\u5E26\u5173\u952E\u5B57\u8FC7\u6EE4").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((keyword, opts) => modelsCommand(keyword, opts));
19429
19457
  program.command("describe <Model>").description("\u67E5\u770B Model \u5143\u6570\u636E\uFF08\u5B57\u6BB5\u3001\u5173\u7CFB\u3001Action \u5217\u8868\uFF09").option("-v, --verbose", "\u663E\u793A enum \u53D6\u503C\u57DF\uFF0C\u4EE5\u53CA\u81EA\u5B9A\u4E49\u5B57\u6BB5\u7684\u63CF\u8FF0").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => describeCommand(m, opts));
19430
19458
  var interactions = program.command("interactions").description("\u770B\u89C1\u5E76\u5904\u7406\u4F1A\u8BDD\u91CC\u672A\u51B3\u7684\u6682\u505C\uFF08\u786E\u8BA4 / \u8FFD\u95EE\uFF09\u2014\u2014\u4E0D\u53D1\u65B0\u6D88\u606F\uFF0C\u76F4\u63A5\u56DE\u5230\u90A3\u4E00\u6761");