@hcmai/cli 0.15.11 → 0.15.13

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
@@ -2519,6 +2519,25 @@ function rejectionLine(reason) {
2519
2519
  const known = rejectionMessages[reason];
2520
2520
  return known ? `${known} (${reason})` : `\u6709\u4EBA\u6253\u5F00\u4E86\u6388\u6743\u94FE\u63A5\u4F46\u88AB\u6321\u4E0B\uFF0C\u539F\u56E0\u7801\u672C\u7248 CLI \u8FD8\u4E0D\u8BA4\u8BC6 (unknown:${reason})\uFF1B\u5347\u7EA7 hcm CLI \u53EF\u770B\u5230\u5BF9\u75C7\u8BF4\u660E\u3002`;
2521
2521
  }
2522
+ var WAIT_COUNTDOWN_INTERVAL_MS = 6e4;
2523
+ var WAIT_COUNTDOWN_FLOOR_MS = 5e3;
2524
+ function humanDuration(ms) {
2525
+ const total = Math.round(ms / 1e3);
2526
+ const minutes = Math.floor(total / 60);
2527
+ const seconds = total % 60;
2528
+ if (minutes === 0) return `${seconds} \u79D2`;
2529
+ return seconds === 0 ? `${minutes} \u5206` : `${minutes} \u5206 ${seconds} \u79D2`;
2530
+ }
2531
+ function startWaitCountdown(deadline) {
2532
+ const timer = setInterval(() => {
2533
+ const remaining = deadline - Date.now();
2534
+ if (remaining < WAIT_COUNTDOWN_FLOOR_MS) return;
2535
+ process.stderr.write(`\u8FD8\u6709 ${humanDuration(remaining)}\uFF1B\u4ECD\u5728\u7B49\u5F85\u786E\u8BA4\uFF0C\u8981\u653E\u5F03\u8BF7\u6309 Ctrl-C\u3002
2536
+ `);
2537
+ }, WAIT_COUNTDOWN_INTERVAL_MS);
2538
+ timer.unref?.();
2539
+ return () => clearInterval(timer);
2540
+ }
2522
2541
  async function beginDeviceLogin(input) {
2523
2542
  const cancel = cancellation();
2524
2543
  let session;
@@ -2540,19 +2559,24 @@ async function beginDeviceLogin(input) {
2540
2559
  \u8BBE\u5907\u7801\uFF1A${authorization.userCode}
2541
2560
  \u6388\u6743\u622A\u6B62\uFF1A${authorization.expiresAt}\uFF1B\u6B63\u5728\u7B49\u5F85\u786E\u8BA4\u3002
2542
2561
  `);
2543
- session = await pollDeviceAuthorization({
2544
- ...input,
2545
- authorization,
2546
- signal: cancel.controller.signal,
2547
- onTimeout: () => process.stderr.write("\u6388\u6743\u8F6E\u8BE2\u8BF7\u6C42\u8D85\u65F6\uFF1B\u4ECD\u5728\u539F\u6388\u6743\u671F\u9650\u5185\u7B49\u5F85\uFF0C\u4E0D\u4F1A\u53D1\u8D77\u65B0\u6388\u6743\u3002\n"),
2548
- // 🔴 印出来但**不结束等待**:授权链接里带着 requestId,谁拿到链接谁都能打开并触发一次拒绝,
2549
- // 在这里失败等于让任何链接持有人都能取消别人的登录。停不停由用户按 Ctrl-C 决定。
2550
- onRejection: (rejection) => process.stderr.write(
2551
- `${rejectionLine(rejection.reason)}
2562
+ const stopCountdown = startWaitCountdown(authorization.deadline);
2563
+ try {
2564
+ session = await pollDeviceAuthorization({
2565
+ ...input,
2566
+ authorization,
2567
+ signal: cancel.controller.signal,
2568
+ onTimeout: () => process.stderr.write("\u6388\u6743\u8F6E\u8BE2\u8BF7\u6C42\u8D85\u65F6\uFF1B\u4ECD\u5728\u539F\u6388\u6743\u671F\u9650\u5185\u7B49\u5F85\uFF0C\u4E0D\u4F1A\u53D1\u8D77\u65B0\u6388\u6743\u3002\n"),
2569
+ // 🔴 印出来但**不结束等待**:授权链接里带着 requestId,谁拿到链接谁都能打开并触发一次拒绝,
2570
+ // 在这里失败等于让任何链接持有人都能取消别人的登录。停不停由用户按 Ctrl-C 决定。
2571
+ onRejection: (rejection) => process.stderr.write(
2572
+ `${rejectionLine(rejection.reason)}
2552
2573
  \u4ECD\u5728\u7B49\u5F85\u672C\u6B21\u6388\u6743\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u53D6\u6D88\uFF1B\u8981\u653E\u5F03\u8BF7\u6309 Ctrl-C\u3002
2553
2574
  `
2554
- )
2555
- });
2575
+ )
2576
+ });
2577
+ } finally {
2578
+ stopCountdown();
2579
+ }
2556
2580
  return { session, complete: async () => {
2557
2581
  if (cancel.controller.signal.aborted) throw cancel.error(new Error("\u767B\u5F55\u5DF2\u53D6\u6D88"));
2558
2582
  session.complete();
@@ -2585,6 +2609,7 @@ async function beginBrowserLogin(input) {
2585
2609
  let timeout;
2586
2610
  let closing;
2587
2611
  let watch;
2612
+ let stopCountdown = () => void 0;
2588
2613
  let resolve3;
2589
2614
  let reject;
2590
2615
  const result = new Promise((yes, no) => {
@@ -2592,6 +2617,7 @@ async function beginBrowserLogin(input) {
2592
2617
  reject = no;
2593
2618
  });
2594
2619
  void result.catch(() => void 0);
2620
+ void result.finally(() => stopCountdown()).catch(() => void 0);
2595
2621
  const server = createServer((request, response) => {
2596
2622
  let url;
2597
2623
  try {
@@ -2706,6 +2732,7 @@ async function beginBrowserLogin(input) {
2706
2732
  () => reject(cliAuthorizationExpired(watch?.lastRejection(), watch?.probe())),
2707
2733
  Math.max(1, deadline - Date.now())
2708
2734
  );
2735
+ stopCountdown = startWaitCountdown(deadline);
2709
2736
  watch = watchBrowserAuthorization({
2710
2737
  ...input,
2711
2738
  requestId: authorization.requestId,
@@ -4585,7 +4612,8 @@ function collectYmlFiles(path19) {
4585
4612
  var DRY_RUN_CLIENT = {
4586
4613
  findIdByKey: async () => null,
4587
4614
  create: async () => ({ id: "" }),
4588
- update: async () => ({})
4615
+ update: async () => ({}),
4616
+ fieldKeys: async () => []
4589
4617
  };
4590
4618
  async function importCommand(path19, args) {
4591
4619
  try {
@@ -4608,6 +4636,23 @@ async function importCommand(path19, args) {
4608
4636
  `
4609
4637
  );
4610
4638
  process.stdout.write(formatObject7(result, { format: fmt }) + "\n");
4639
+ const unmappedRows = result.rows.filter((r) => r.unmappedFields?.length);
4640
+ if (unmappedRows.length > 0) {
4641
+ const keys = [...new Set(unmappedRows.flatMap((r) => r.unmappedFields ?? []))].sort();
4642
+ process.stderr.write(
4643
+ `\u26A0 ${unmappedRows.length} \u884C\u91CC\u6709\u76EE\u6807\u6A21\u578B\u4E0D\u8BA4\u8BC6\u7684\u5B57\u6BB5\u540D\uFF1A${keys.join(" / ")}
4644
+ \u8FD9\u4E9B\u952E\u670D\u52A1\u7AEF\u8FDE\u8BFB\u90FD\u4E0D\u8BFB\uFF0C\u503C\u4E0D\u4F1A\u843D\u5E93\uFF08\u62A5\u544A\u91CC\u8BE5\u884C\u7684 status \u4ECD\u662F\u88AB\u63A5\u53D7\u7684\u90A3\u4E2A\uFF09\u3002
4645
+ next_step=hcm describe <Model> \u6838\u5BF9\u771F\u540D\u540E\u6539\u8F7D\u8377\u91CD\u8DD1\uFF1B\u771F\u540D\u5E26\u4E0B\u5212\u7EBF\u7684\u8981\u539F\u6837\u5199\uFF0C\u522B\u8F6C\u9A7C\u5CF0\u3002
4646
+ `
4647
+ );
4648
+ }
4649
+ if (result.fieldNamesUnverified.length > 0) {
4650
+ process.stderr.write(
4651
+ `\u26A0 \u8FD9\u4E9B\u6A21\u578B\u7684\u5B57\u6BB5\u6E05\u5355\u6CA1\u8BFB\u5230\uFF0C\u5B57\u6BB5\u540D\u6309\u8001\u89C4\u5219\uFF08\u4E00\u5F8B\u8F6C\u9A7C\u5CF0\uFF09\u53D1\u51FA\u3001\u672A\u505A\u6821\u9A8C\uFF1A${result.fieldNamesUnverified.join(" / ")}
4652
+ next_step=\u771F\u540D\u5E26\u4E0B\u5212\u7EBF\u7684\u5B57\u6BB5\u53EF\u80FD\u88AB\u9759\u9ED8\u4E22\u5F03\uFF0C\u5199\u540E\u56DE\u8BFB\u4E00\u6B21\u6838\u5BF9\uFF1B\u6216\u6362\u542B /meta \u6743\u9650\u7684\u8EAB\u4EFD\u91CD\u8DD1\u3002
4653
+ `
4654
+ );
4655
+ }
4611
4656
  process.exitCode = result.failed > 0 ? 3 : 0;
4612
4657
  return;
4613
4658
  } catch (e) {