mano-coding 0.1.38 → 0.1.40

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.
Files changed (2) hide show
  1. package/dist/bin.js +28 -8
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -52750,7 +52750,11 @@ async function verifyCliVersion(binPath, expected, runner = runCommand) {
52750
52750
  }
52751
52751
  async function performUpgrade(installation, targetVersion, offline, runner = runCommand) {
52752
52752
  const args = installation.manager === "npm" ? ["install", "-g", `${CLI_PACKAGE_NAME}@${targetVersion}`] : ["add", "-g", `${CLI_PACKAGE_NAME}@${targetVersion}`];
52753
- if (offline) args.push("--offline");
52753
+ if (offline) {
52754
+ args.push("--offline");
52755
+ } else if (installation.manager === "npm") {
52756
+ args.push("--prefer-online");
52757
+ }
52754
52758
  const result = await runner(installation.managerExecutable, args);
52755
52759
  if (result.exitCode === 0 && await verifyCliVersion(installation.binPath, targetVersion, runner)) {
52756
52760
  return;
@@ -52765,7 +52769,9 @@ async function performUpgrade(installation, targetVersion, offline, runner = run
52765
52769
  "CLI_UPDATE_ROLLBACK_FAILED"
52766
52770
  );
52767
52771
  }
52768
- throw new CliError(t("selfUpgrade.upgradeFailed"), ExitCode.ExecuteFailed, "CLI_UPDATE_FAILED");
52772
+ const rawErr = (result.stderr || result.stdout || "").trim();
52773
+ const detail = rawErr ? ` (${rawErr.split("\n")[0].replace(/[\r\n]+/g, " ").slice(0, 100)})` : "";
52774
+ throw new CliError(`${t("selfUpgrade.upgradeFailed")}${detail}`, ExitCode.ExecuteFailed, "CLI_UPDATE_FAILED");
52769
52775
  }
52770
52776
  async function fetchCliMetadata(registry, request = fetch, options) {
52771
52777
  const envTimeout = process.env["AICODING_FETCH_TIMEOUT"] ? Number.parseInt(process.env["AICODING_FETCH_TIMEOUT"], 10) : void 0;
@@ -52951,6 +52957,15 @@ async function executeSelfUpgrade(options, cliVersion) {
52951
52957
  rollbackResult: "not-needed"
52952
52958
  });
52953
52959
  await cacheRepository.resetAutoUpdateFailure().catch(() => void 0);
52960
+ const previous = await cacheRepository.read().catch(() => void 0);
52961
+ const isHigher = !previous?.latestVersion || isCliUpdateAvailable(previous.latestVersion, result.plan.targetVersion);
52962
+ await cacheRepository.write({
52963
+ schemaVersion: 1,
52964
+ registryOrigin: registry,
52965
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
52966
+ latestVersion: isHigher ? result.plan.targetVersion : previous.latestVersion,
52967
+ ...previous?.lastNotifiedAt ? { lastNotifiedAt: previous.lastNotifiedAt } : {}
52968
+ }).catch(() => void 0);
52954
52969
  }
52955
52970
  if (options.json) emitSuccessJson("self-upgrade", { dryRun: result.dryRun, ...result.plan, changed: result.changed });
52956
52971
  else if (result.dryRun) writeHumanOutput(
@@ -53082,9 +53097,11 @@ async function scheduleAutoUpdateWorker(argv, currentVersion, options) {
53082
53097
  const cacheRepository = new CliUpdateCacheRepository(userDataDir);
53083
53098
  const cache = await cacheRepository.read();
53084
53099
  if (cache?.autoUpdatePaused) return;
53100
+ const forceCheck = Boolean(process.env["AICODING_FORCE_UPDATE_CHECK"]) && process.env["AICODING_FORCE_UPDATE_CHECK"] !== "0" && process.env["AICODING_FORCE_UPDATE_CHECK"] !== "false";
53085
53101
  const checkedAt = cache?.checkedAt ? Date.parse(cache.checkedAt) : Number.NaN;
53086
- const within24h = Number.isFinite(checkedAt) && Date.now() - checkedAt < 24 * 60 * 60 * 1e3;
53087
- if (within24h && (!cache?.latestVersion || !isCliUpdateAvailable(currentVersion, cache.latestVersion))) {
53102
+ const isFresh = Number.isFinite(checkedAt) && Date.now() - checkedAt < AUTO_UPDATE_CHECK_INTERVAL_MS;
53103
+ const isCacheStale = Boolean(cache?.latestVersion && isCliUpdateAvailable(cache.latestVersion, currentVersion));
53104
+ if (!forceCheck && isFresh && !isCacheStale && (!cache?.latestVersion || !isCliUpdateAvailable(currentVersion, cache.latestVersion))) {
53088
53105
  return;
53089
53106
  }
53090
53107
  if (options?.spawner) {
@@ -53118,11 +53135,13 @@ async function executeAutoUpdateWorker(options) {
53118
53135
  if (cache?.autoUpdatePaused) return;
53119
53136
  const registry = getRegistryUrl2();
53120
53137
  if (!registry) return;
53138
+ const forceCheck = Boolean(process.env["AICODING_FORCE_UPDATE_CHECK"]) && process.env["AICODING_FORCE_UPDATE_CHECK"] !== "0" && process.env["AICODING_FORCE_UPDATE_CHECK"] !== "false";
53121
53139
  const checkedAt = cache?.checkedAt ? Date.parse(cache.checkedAt) : Number.NaN;
53122
- const within24h = Number.isFinite(checkedAt) && Date.now() - checkedAt < 24 * 60 * 60 * 1e3;
53140
+ const isFresh = Number.isFinite(checkedAt) && Date.now() - checkedAt < AUTO_UPDATE_CHECK_INTERVAL_MS;
53141
+ const isCacheStale = Boolean(cache?.latestVersion && isCliUpdateAvailable(cache.latestVersion, options.cliVersion));
53123
53142
  let targetVersion = cache?.latestVersion;
53124
53143
  let enginesNode = cache?.latestEnginesNode;
53125
- if (!within24h || !targetVersion || !isCliUpdateAvailable(options.cliVersion, targetVersion)) {
53144
+ if (forceCheck || !isFresh || isCacheStale || !targetVersion || !isCliUpdateAvailable(options.cliVersion, targetVersion)) {
53126
53145
  const metadata = await fetchCliMetadata(registry, options.fetcher, { timeoutMs: 3e3, retries: 0 }).catch(() => void 0);
53127
53146
  if (!metadata) return;
53128
53147
  const latest = parseLatestCliVersion(metadata);
@@ -53237,7 +53256,7 @@ function getRegistryUrl2() {
53237
53256
  return "";
53238
53257
  }
53239
53258
  }
53240
- var DEFAULT_NPM_REGISTRY2;
53259
+ var DEFAULT_NPM_REGISTRY2, AUTO_UPDATE_CHECK_INTERVAL_MS;
53241
53260
  var init_auto_update = __esm({
53242
53261
  "packages/cli/src/commands/auto-update.ts"() {
53243
53262
  "use strict";
@@ -53246,6 +53265,7 @@ var init_auto_update = __esm({
53246
53265
  init_self_upgrade_pipeline();
53247
53266
  init_cli_output();
53248
53267
  DEFAULT_NPM_REGISTRY2 = "https://registry.npmjs.org";
53268
+ AUTO_UPDATE_CHECK_INTERVAL_MS = 60 * 60 * 1e3;
53249
53269
  }
53250
53270
  });
53251
53271
 
@@ -53287,7 +53307,7 @@ import { createRequire as createRequire2 } from "node:module";
53287
53307
  import { readFileSync as readFileSync4 } from "node:fs";
53288
53308
  import { fileURLToPath as fileURLToPath5 } from "node:url";
53289
53309
  function resolveVersion() {
53290
- if (true) return "0.1.38";
53310
+ if (true) return "0.1.40";
53291
53311
  const candidates = [
53292
53312
  new URL("../package.json", import.meta.url),
53293
53313
  new URL("../../package.json", import.meta.url),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mano-coding",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Mano Coding CLI and toolchain",
5
5
  "type": "module",
6
6
  "main": "index.js",