@donotdev/cli 0.0.30 → 0.0.31

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.
@@ -165,6 +165,7 @@ var require_picocolors = __commonJS({
165
165
 
166
166
  // node_modules/.bun/@clack+prompts@0.11.0/node_modules/@clack/prompts/node_modules/@clack/core/dist/index.mjs
167
167
  import { stdin as j, stdout as M } from "node:process";
168
+ import * as g from "node:readline";
168
169
  import O from "node:readline";
169
170
  import { Writable as X } from "node:stream";
170
171
  function DD({ onlyFirst: e2 = false } = {}) {
@@ -255,6 +256,27 @@ function m(e2, u2) {
255
256
  const t = e2;
256
257
  t.isTTY && t.setRawMode(u2);
257
258
  }
259
+ function fD({ input: e2 = j, output: u2 = M, overwrite: t = true, hideCursor: F2 = true } = {}) {
260
+ const s = g.createInterface({ input: e2, output: u2, prompt: "", tabSize: 1 });
261
+ g.emitKeypressEvents(e2, s), e2.isTTY && e2.setRawMode(true);
262
+ const i = (D2, { name: C2, sequence: n }) => {
263
+ const E = String(D2);
264
+ if ($([E, C2, n], "cancel")) {
265
+ F2 && u2.write(import_sisteransi.cursor.show), process.exit(0);
266
+ return;
267
+ }
268
+ if (!t) return;
269
+ const a = C2 === "return" ? 0 : -1, o2 = C2 === "return" ? -1 : 0;
270
+ g.moveCursor(u2, a, o2, () => {
271
+ g.clearLine(u2, 1, () => {
272
+ e2.once("keypress", i);
273
+ });
274
+ });
275
+ };
276
+ return F2 && u2.write(import_sisteransi.cursor.hide), e2.once("keypress", i), () => {
277
+ e2.off("keypress", i), F2 && u2.write(import_sisteransi.cursor.show), e2.isTTY && !AD && e2.setRawMode(false), s.terminal = false, s.close();
278
+ };
279
+ }
258
280
  var import_sisteransi, uD, W, tD, eD, FD, sD, w, N, I, R, r, iD, CD, ED, d, oD, y, V, nD, G, _, z, K, aD, k, hD, lD, xD, B, AD, S, gD, vD, h, x, dD, A, kD, $D, H, SD;
259
281
  var init_dist = __esm({
260
282
  "node_modules/.bun/@clack+prompts@0.11.0/node_modules/@clack/prompts/node_modules/@clack/core/dist/index.mjs"() {
@@ -536,7 +558,7 @@ import y2 from "node:process";
536
558
  function ce() {
537
559
  return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
538
560
  }
539
- var import_picocolors, import_sisteransi2, V2, u, le, L2, W2, C, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U, K2, b2, G2, ye, fe, xe, Ie, Se, M2, J;
561
+ var import_picocolors, import_sisteransi2, V2, u, le, L2, W2, C, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U, K2, b2, G2, ye, fe, Me, xe, Ie, Se, M2, J, Y2;
540
562
  var init_dist2 = __esm({
541
563
  "node_modules/.bun/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs"() {
542
564
  init_utils();
@@ -584,9 +606,9 @@ var init_dist2 = __esm({
584
606
  const { cursor: n, options: r2, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
585
607
  let l2 = 0;
586
608
  n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
587
- const $2 = a < r2.length && l2 > 0, g = a < r2.length && l2 + a < r2.length;
609
+ const $2 = a < r2.length && l2 > 0, g2 = a < r2.length && l2 + a < r2.length;
588
610
  return r2.slice(l2, l2 + a).map((p2, v, f) => {
589
- const j2 = v === 0 && $2, E = v === f.length - 1 && g;
611
+ const j2 = v === 0 && $2, E = v === f.length - 1 && g2;
590
612
  return j2 || E ? import_picocolors.default.dim("...") : i(p2, v + l2 === n);
591
613
  });
592
614
  };
@@ -649,6 +671,21 @@ ${import_picocolors.default.cyan(d2)}
649
671
  }
650
672
  } }).prompt();
651
673
  };
674
+ Me = (t = "", n = "") => {
675
+ const r2 = `
676
+ ${t}
677
+ `.split(`
678
+ `), i = S2(n).length, s = Math.max(r2.reduce((a, l2) => {
679
+ const $2 = S2(l2);
680
+ return $2.length > a ? $2.length : a;
681
+ }, 0), i) + 2, c = r2.map((a) => `${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(a)}${" ".repeat(s - S2(a).length)}${import_picocolors.default.gray(o)}`).join(`
682
+ `);
683
+ process.stdout.write(`${import_picocolors.default.gray(o)}
684
+ ${import_picocolors.default.green(C)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(_2.repeat(Math.max(s - i - 1, 1)) + me)}
685
+ ${c}
686
+ ${import_picocolors.default.gray(de + _2.repeat(s + 2) + pe)}
687
+ `);
688
+ };
652
689
  xe = (t = "") => {
653
690
  process.stdout.write(`${import_picocolors.default.gray(d2)} ${import_picocolors.default.red(t)}
654
691
 
@@ -688,6 +725,53 @@ ${import_picocolors.default.gray(d2)} ${t}
688
725
  M2.message(t, { symbol: import_picocolors.default.red(K2) });
689
726
  } };
690
727
  J = `${import_picocolors.default.gray(o)} `;
728
+ Y2 = ({ indicator: t = "dots" } = {}) => {
729
+ const n = V2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], r2 = V2 ? 80 : 120, i = process.env.CI === "true";
730
+ let s, c, a = false, l2 = "", $2, g2 = performance.now();
731
+ const p2 = (m2) => {
732
+ const h2 = m2 > 1 ? "Something went wrong" : "Canceled";
733
+ a && N2(h2, m2);
734
+ }, v = () => p2(2), f = () => p2(1), j2 = () => {
735
+ process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p2);
736
+ }, E = () => {
737
+ process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p2);
738
+ }, B2 = () => {
739
+ if ($2 === void 0) return;
740
+ i && process.stdout.write(`
741
+ `);
742
+ const m2 = $2.split(`
743
+ `);
744
+ process.stdout.write(import_sisteransi2.cursor.move(-999, m2.length - 1)), process.stdout.write(import_sisteransi2.erase.down(m2.length));
745
+ }, R2 = (m2) => m2.replace(/\.+$/, ""), O2 = (m2) => {
746
+ const h2 = (performance.now() - m2) / 1e3, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
747
+ return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
748
+ }, H2 = (m2 = "") => {
749
+ a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
750
+ `);
751
+ let h2 = 0, w2 = 0;
752
+ j2(), c = setInterval(() => {
753
+ if (i && l2 === $2) return;
754
+ B2(), $2 = l2;
755
+ const I2 = import_picocolors.default.magenta(n[h2]);
756
+ if (i) process.stdout.write(`${I2} ${l2}...`);
757
+ else if (t === "timer") process.stdout.write(`${I2} ${l2} ${O2(g2)}`);
758
+ else {
759
+ const z2 = ".".repeat(Math.floor(w2)).slice(0, 3);
760
+ process.stdout.write(`${I2} ${l2}${z2}`);
761
+ }
762
+ h2 = h2 + 1 < n.length ? h2 + 1 : 0, w2 = w2 < n.length ? w2 + 0.125 : 0;
763
+ }, r2);
764
+ }, N2 = (m2 = "", h2 = 0) => {
765
+ a = false, clearInterval(c), B2();
766
+ const w2 = h2 === 0 ? import_picocolors.default.green(C) : h2 === 1 ? import_picocolors.default.red(L2) : import_picocolors.default.red(W2);
767
+ l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
768
+ `) : process.stdout.write(`${w2} ${l2}
769
+ `), E(), s();
770
+ };
771
+ return { start: H2, stop: N2, message: (m2 = "") => {
772
+ l2 = R2(m2 ?? l2);
773
+ } };
774
+ };
691
775
  }
692
776
  });
693
777
 
@@ -6735,7 +6819,7 @@ import {
6735
6819
  sep,
6736
6820
  extname
6737
6821
  } from "node:path";
6738
- import { fileURLToPath } from "node:url";
6822
+ import "node:url";
6739
6823
  function safeExecuteAsync(fn, message) {
6740
6824
  return fn().catch((error2) => {
6741
6825
  throw new Error(
@@ -7662,19 +7746,24 @@ var init_PathResolver = __esm({
7662
7746
  return resolved;
7663
7747
  }
7664
7748
  /**
7665
- * Get path to empty.js module for optional dependency aliasing
7666
- * Used by Vite and Turbopack to alias missing optional deps
7667
- * @param returnPackageSpecifier - If true, returns package specifier '@donotdev/core/empty' for Turbopack. If false, returns absolute path for Vite.
7668
- * @returns Package specifier or absolute path to empty.js
7749
+ * Get absolute path to empty ESM module for optional dependency aliasing.
7750
+ * Used by Vite resolveId — served directly to the browser in dev mode.
7751
+ * Note: resolvePackage uses require.resolve (CJS) which picks the "default"
7752
+ * condition (.cjs), so we derive the ESM path from it.
7669
7753
  */
7670
- getEmptyModulePath(returnPackageSpecifier = false) {
7671
- if (returnPackageSpecifier) {
7672
- return "@donotdev/core/empty";
7673
- }
7754
+ getEmptyModulePath() {
7755
+ const cjsPath = this.getEmptyCjsModulePath();
7756
+ return cjsPath.replace(/\.cjs$/, ".js");
7757
+ }
7758
+ /**
7759
+ * Get absolute path to empty CJS module for esbuild pre-bundling.
7760
+ * CJS because esbuild statically analyzes ESM exports — CJS has dynamic
7761
+ * exports, so any named import resolves.
7762
+ */
7763
+ getEmptyCjsModulePath() {
7674
7764
  const resolved = this.resolvePackage("@donotdev/core/empty");
7675
- if (resolved) return resolved;
7676
- const thisDir = dirname(fileURLToPath(import.meta.url));
7677
- return this.normalizePath(join(thisDir, "../empty.js"));
7765
+ if (!resolved) throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");
7766
+ return resolved;
7678
7767
  }
7679
7768
  // === PRIVATE METHODS ===
7680
7769
  /**
@@ -7875,7 +7964,7 @@ function globSync(pattern, options = {}) {
7875
7964
  });
7876
7965
  return results.map((p2) => pathResolverInstance.normalizePath(p2));
7877
7966
  }
7878
- var pathResolverInstance, getRepoRoot, getAppRoot, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, write, writeSync, ensureDir, getRelativePathBetween, getDirname, joinPath;
7967
+ var pathResolverInstance, getRepoRoot, getAppRoot, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, write, writeSync, removeSync, ensureDir, getRelativePathBetween, getDirname, joinPath;
7879
7968
  var init_pathResolver = __esm({
7880
7969
  "packages/tooling/src/utils/pathResolver.ts"() {
7881
7970
  "use strict";
@@ -7893,6 +7982,7 @@ var init_pathResolver = __esm({
7893
7982
  readSync = (filePath, options) => pathResolverInstance.readSync(filePath, options);
7894
7983
  write = async (filePath, content, options) => pathResolverInstance.write(filePath, content, options);
7895
7984
  writeSync = (filePath, content, options) => pathResolverInstance.writeSync(filePath, content, options);
7985
+ removeSync = (path) => pathResolverInstance.removeSync(path);
7896
7986
  ensureDir = async (dirPath) => pathResolverInstance.ensureDir(dirPath);
7897
7987
  getRelativePathBetween = (from, to) => {
7898
7988
  return normalizePath(relative2(from, to));
@@ -8099,6 +8189,7 @@ function writePackageJson(filePath, pkg) {
8099
8189
  if (pkg.peerDependencies)
8100
8190
  sorted.peerDependencies = sortObj(pkg.peerDependencies);
8101
8191
  if (pkg.overrides) sorted.overrides = sortObj(pkg.overrides);
8192
+ if (pkg.resolutions) sorted.resolutions = sortObj(pkg.resolutions);
8102
8193
  if (pkg.peerDependenciesMeta)
8103
8194
  sorted.peerDependenciesMeta = sortObj(pkg.peerDependenciesMeta);
8104
8195
  writeSync(filePath, JSON.stringify(sorted, null, 2) + "\n", {
@@ -8398,6 +8489,7 @@ function generatePackageJson(templateName, mode, options = {}) {
8398
8489
 
8399
8490
  // packages/tooling/src/maintenance/bump.ts
8400
8491
  init_utils();
8492
+ import { execSync as execSync2 } from "node:child_process";
8401
8493
 
8402
8494
  // packages/tooling/src/maintenance/sync-apps.ts
8403
8495
  init_utils();
@@ -8805,23 +8897,27 @@ async function syncDocumentation(options = {}) {
8805
8897
  init_cli_input();
8806
8898
  init_cli_output();
8807
8899
  init_pathResolver();
8808
- async function queryNpmLatest(packageName) {
8900
+ async function queryNpmPackage(packageName) {
8809
8901
  try {
8810
- const res = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
8902
+ const res = await fetch(
8903
+ `https://registry.npmjs.org/${packageName}/latest`
8904
+ );
8811
8905
  if (!res.ok) return null;
8812
- const data = await res.json();
8813
- return data.version || null;
8906
+ return await res.json();
8814
8907
  } catch {
8815
8908
  return null;
8816
8909
  }
8817
8910
  }
8818
- async function queryNpmVersions(packages) {
8911
+ async function queryNpmAll(packages) {
8819
8912
  const versions = {};
8913
+ const deprecated = {};
8820
8914
  for (const pkg of packages) {
8821
- const v = await queryNpmLatest(pkg);
8822
- if (v) versions[pkg] = v;
8915
+ const data = await queryNpmPackage(pkg);
8916
+ if (!data) continue;
8917
+ if (data.version) versions[pkg] = data.version;
8918
+ if (data.deprecated) deprecated[pkg] = data.deprecated;
8823
8919
  }
8824
- return versions;
8920
+ return { versions, deprecated };
8825
8921
  }
8826
8922
  function detectProjectDeps(files) {
8827
8923
  const frameworkPkgs = /* @__PURE__ */ new Set();
@@ -8834,10 +8930,12 @@ function detectProjectDeps(files) {
8834
8930
  ["dependencies", pkg.dependencies],
8835
8931
  ["devDependencies", pkg.devDependencies],
8836
8932
  ["peerDependencies", pkg.peerDependencies],
8837
- ["overrides", pkg.overrides]
8933
+ ["overrides", pkg.overrides],
8934
+ ["resolutions", pkg.resolutions]
8838
8935
  ]) {
8839
8936
  if (!deps) continue;
8840
- for (const [name, version] of Object.entries(deps)) {
8937
+ for (const [name, rawVersion] of Object.entries(deps)) {
8938
+ const version = String(rawVersion);
8841
8939
  const key = `${name}:${field}`;
8842
8940
  if (!packageOccurrences.has(key)) {
8843
8941
  packageOccurrences.set(key, []);
@@ -8853,10 +8951,142 @@ function detectProjectDeps(files) {
8853
8951
  }
8854
8952
  return { frameworkPkgs, externalDeps, packageOccurrences };
8855
8953
  }
8954
+ function padEnd(str, len) {
8955
+ return str + " ".repeat(Math.max(0, len - str.length));
8956
+ }
8957
+ function formatUpdateTable(updates, appRoot) {
8958
+ const seen = /* @__PURE__ */ new Map();
8959
+ for (const u2 of updates) {
8960
+ if (!seen.has(u2.pkg) || u2.isMajor) seen.set(u2.pkg, u2);
8961
+ }
8962
+ const unique = Array.from(seen.values());
8963
+ const maxName = Math.max(...unique.map((u2) => u2.pkg.length));
8964
+ const maxCurrent = Math.max(...unique.map((u2) => u2.current.length));
8965
+ const lines = unique.map((u2) => {
8966
+ const normalizedLatest = normalizeVersion(u2.latest);
8967
+ const displayLatest = ensureCaretPrefix(normalizedLatest);
8968
+ const major = u2.isMajor ? " MAJOR" : "";
8969
+ return ` ${padEnd(u2.pkg, maxName)} ${padEnd(u2.current, maxCurrent)} -> ${displayLatest}${major}`;
8970
+ });
8971
+ const affectedFiles = /* @__PURE__ */ new Set();
8972
+ for (const u2 of updates) {
8973
+ affectedFiles.add(
8974
+ appRoot ? getRelativePathBetween(appRoot, u2.file) : u2.file
8975
+ );
8976
+ }
8977
+ lines.push(` Affects: ${Array.from(affectedFiles).join(", ")}`);
8978
+ return lines.join("\n");
8979
+ }
8980
+ function formatDeprecatedList(deprecated, appRoot) {
8981
+ const lines = [];
8982
+ for (const d3 of deprecated) {
8983
+ lines.push(` ${d3.name} \u2014 ${d3.message}`);
8984
+ const locs = d3.locations.map((l2) => {
8985
+ const rel = appRoot ? getRelativePathBetween(appRoot, l2.file) : l2.file;
8986
+ return `${rel} (${l2.field})`;
8987
+ });
8988
+ lines.push(` Found in: ${locs.join(", ")}`);
8989
+ }
8990
+ return lines.join("\n");
8991
+ }
8992
+ function applyUpdates(updates, appRoot) {
8993
+ const updatedFiles = /* @__PURE__ */ new Map();
8994
+ let syncedPins = 0;
8995
+ for (const u2 of updates) {
8996
+ if (!updatedFiles.has(u2.file)) {
8997
+ updatedFiles.set(u2.file, /* @__PURE__ */ new Set());
8998
+ }
8999
+ updatedFiles.get(u2.file).add(`${u2.pkg}:${u2.field}`);
9000
+ }
9001
+ for (const [file, packageKeys] of updatedFiles) {
9002
+ const pkg = parsePackageJson(file);
9003
+ if (!pkg) {
9004
+ log.warn(`Could not parse ${file} \u2014 skipping`);
9005
+ continue;
9006
+ }
9007
+ let changed = false;
9008
+ for (const packageKey of packageKeys) {
9009
+ const [pkgName, field] = packageKey.split(":");
9010
+ const update = updates.find(
9011
+ (u2) => u2.file === file && u2.pkg === pkgName && u2.field === field
9012
+ );
9013
+ if (!update) continue;
9014
+ const deps = pkg[field];
9015
+ if (deps?.[pkgName]) {
9016
+ const normalizedLatest = normalizeVersion(update.latest);
9017
+ deps[pkgName] = field === "overrides" || field === "resolutions" ? normalizedLatest : ensureCaretPrefix(normalizedLatest);
9018
+ changed = true;
9019
+ }
9020
+ }
9021
+ for (const pinField of ["overrides", "resolutions"]) {
9022
+ const pinDeps = pkg[pinField];
9023
+ if (!pinDeps) continue;
9024
+ for (const u2 of updates) {
9025
+ if (u2.file === file && u2.pkg.startsWith("@donotdev/") && u2.field !== pinField && pinDeps[u2.pkg]) {
9026
+ const normalizedLatest = normalizeVersion(u2.latest);
9027
+ pinDeps[u2.pkg] = normalizedLatest;
9028
+ changed = true;
9029
+ syncedPins++;
9030
+ }
9031
+ }
9032
+ }
9033
+ if (changed) {
9034
+ writePackageJson(file, pkg);
9035
+ }
9036
+ }
9037
+ return { updatedCount: updatedFiles.size, syncedPins };
9038
+ }
9039
+ function removeDeprecated(deprecated) {
9040
+ const byFile = /* @__PURE__ */ new Map();
9041
+ for (const d3 of deprecated) {
9042
+ for (const loc of d3.locations) {
9043
+ if (!byFile.has(loc.file)) byFile.set(loc.file, []);
9044
+ byFile.get(loc.file).push({ name: d3.name, field: loc.field });
9045
+ }
9046
+ }
9047
+ let removed = 0;
9048
+ for (const [file, entries] of byFile) {
9049
+ const pkg = parsePackageJson(file);
9050
+ if (!pkg) continue;
9051
+ let changed = false;
9052
+ for (const { name, field } of entries) {
9053
+ const deps = pkg[field];
9054
+ if (deps?.[name]) {
9055
+ delete deps[name];
9056
+ changed = true;
9057
+ removed++;
9058
+ }
9059
+ }
9060
+ if (changed) writePackageJson(file, pkg);
9061
+ }
9062
+ return removed;
9063
+ }
9064
+ function deleteLockfile(appRoot) {
9065
+ const lockfilePath = joinPath(appRoot, "bun.lock");
9066
+ if (!pathExists(lockfilePath)) return false;
9067
+ try {
9068
+ removeSync(lockfilePath);
9069
+ return true;
9070
+ } catch {
9071
+ return false;
9072
+ }
9073
+ }
9074
+ function runBunInstall(appRoot) {
9075
+ try {
9076
+ execSync2("bun install", {
9077
+ cwd: appRoot,
9078
+ stdio: "pipe",
9079
+ timeout: 12e4
9080
+ });
9081
+ return true;
9082
+ } catch {
9083
+ return false;
9084
+ }
9085
+ }
8856
9086
  async function main(options = {}) {
8857
9087
  const { dryRun } = options;
8858
- Ie("\u{1F504} Bump - Update framework packages and documentation");
8859
- if (dryRun) log.info("DRY RUN MODE");
9088
+ Ie("Bump \u2014 Update packages and sync project");
9089
+ if (dryRun) log.info("DRY RUN MODE \u2014 no files will be modified");
8860
9090
  const appRoot = getAppRoot();
8861
9091
  if (!appRoot) {
8862
9092
  log.error("Could not determine project root");
@@ -8897,7 +9127,6 @@ async function main(options = {}) {
8897
9127
  }
8898
9128
  ],
8899
9129
  [0, 1]
8900
- // Default: packages + docs
8901
9130
  );
8902
9131
  updatePackages = selections.includes("packages");
8903
9132
  updateDocs = selections.includes("docs");
@@ -8913,27 +9142,44 @@ async function main(options = {}) {
8913
9142
  if (files.length === 0) {
8914
9143
  log.warn("No package.json files found");
8915
9144
  } else {
8916
- log.info(`Found ${files.length} package.json file(s)`);
9145
+ const s = Y2();
9146
+ s.start(`Scanning ${files.length} package.json file(s)...`);
8917
9147
  const { frameworkPkgs, externalDeps, packageOccurrences } = detectProjectDeps(files);
8918
- log.info(`Found ${frameworkPkgs.size} @donotdev/* package(s)`);
8919
- log.info(`Found ${externalDeps.size} external dep(s)`);
8920
- log.info("Querying npm...");
8921
- const npmVersions = await queryNpmVersions(Array.from(frameworkPkgs));
9148
+ s.message("Querying npm registry...");
9149
+ const npm = await queryNpmAll(Array.from(frameworkPkgs));
8922
9150
  const matrixResult = loadMatrix();
8923
9151
  const matrixVersions = matrixResult ? flattenGroups(matrixResult.matrix.groups) : {};
9152
+ s.stop(
9153
+ `Found ${frameworkPkgs.size} framework + ${externalDeps.size} external package(s)`
9154
+ );
8924
9155
  if (!matrixResult && externalDeps.size > 0) {
8925
9156
  log.info(
8926
- "Matrix not found - only updating @donotdev/* packages (external deps skipped)"
9157
+ "Matrix not found \u2014 only @donotdev/* packages will be checked"
8927
9158
  );
8928
9159
  }
8929
- const updates = [];
9160
+ const frameworkUpdates = [];
9161
+ const externalMinorUpdates = [];
8930
9162
  const majorUpdates = [];
9163
+ const deprecatedPkgs = [];
9164
+ for (const [pkgName, message] of Object.entries(npm.deprecated)) {
9165
+ const locations = [];
9166
+ for (const [key, occurrences] of packageOccurrences) {
9167
+ const [name] = key.split(":");
9168
+ if (name !== pkgName) continue;
9169
+ for (const occ of occurrences) {
9170
+ locations.push({ file: occ.file, field: occ.field });
9171
+ }
9172
+ }
9173
+ if (locations.length > 0) {
9174
+ deprecatedPkgs.push({ name: pkgName, message, locations });
9175
+ }
9176
+ }
8931
9177
  for (const [key, occurrences] of packageOccurrences) {
8932
9178
  const [name, field] = key.split(":");
8933
- if (name === "@donotdev/templates") continue;
9179
+ if (npm.deprecated[name]) continue;
8934
9180
  let latest;
8935
9181
  if (name.startsWith("@donotdev/")) {
8936
- latest = npmVersions[name];
9182
+ latest = npm.versions[name];
8937
9183
  } else {
8938
9184
  latest = matrixVersions[name];
8939
9185
  }
@@ -8962,32 +9208,159 @@ async function main(options = {}) {
8962
9208
  }
8963
9209
  }
8964
9210
  majorUpdates.push(update);
9211
+ } else if (name.startsWith("@donotdev/")) {
9212
+ frameworkUpdates.push(update);
8965
9213
  } else {
8966
- updates.push(update);
9214
+ externalMinorUpdates.push(update);
8967
9215
  }
8968
9216
  }
8969
9217
  }
8970
- if (updates.length === 0 && majorUpdates.length === 0) {
9218
+ const hasAnything = frameworkUpdates.length > 0 || externalMinorUpdates.length > 0 || majorUpdates.length > 0 || deprecatedPkgs.length > 0;
9219
+ if (!hasAnything) {
8971
9220
  log.success("All packages up to date!");
8972
9221
  } else {
8973
- await handlePackageUpdates(
8974
- updates,
8975
- majorUpdates,
8976
- appRoot,
8977
- dryRun || false
8978
- );
9222
+ if (frameworkUpdates.length > 0) {
9223
+ Me(
9224
+ formatUpdateTable(frameworkUpdates, appRoot),
9225
+ `@donotdev/* updates (${new Set(frameworkUpdates.map((u2) => u2.pkg)).size})`
9226
+ );
9227
+ }
9228
+ if (deprecatedPkgs.length > 0) {
9229
+ Me(
9230
+ formatDeprecatedList(deprecatedPkgs, appRoot),
9231
+ `Deprecated packages (${deprecatedPkgs.length})`
9232
+ );
9233
+ }
9234
+ if (externalMinorUpdates.length > 0) {
9235
+ Me(
9236
+ formatUpdateTable(externalMinorUpdates, appRoot),
9237
+ `External dep updates (${new Set(externalMinorUpdates.map((u2) => u2.pkg)).size})`
9238
+ );
9239
+ }
9240
+ if (majorUpdates.length > 0) {
9241
+ Me(
9242
+ formatUpdateTable(majorUpdates, appRoot),
9243
+ `MAJOR updates (${new Set(majorUpdates.map((u2) => u2.pkg)).size})`
9244
+ );
9245
+ }
9246
+ if (dryRun) {
9247
+ log.info("[DRY RUN] No files modified");
9248
+ } else {
9249
+ const allUpdates = [];
9250
+ const summary = [];
9251
+ if (frameworkUpdates.length > 0) {
9252
+ const apply = await askForConfirmation(
9253
+ "Apply @donotdev/* updates?",
9254
+ true
9255
+ );
9256
+ if (apply) allUpdates.push(...frameworkUpdates);
9257
+ }
9258
+ let shouldRemoveDeprecated = false;
9259
+ if (deprecatedPkgs.length > 0) {
9260
+ shouldRemoveDeprecated = await askForConfirmation(
9261
+ "Remove deprecated packages?",
9262
+ true
9263
+ );
9264
+ }
9265
+ if (externalMinorUpdates.length > 0) {
9266
+ const apply = await askForConfirmation(
9267
+ "Apply external dependency updates?",
9268
+ true
9269
+ );
9270
+ if (apply) allUpdates.push(...externalMinorUpdates);
9271
+ }
9272
+ if (majorUpdates.length > 0) {
9273
+ for (const u2 of majorUpdates) {
9274
+ if (u2.migrationPath) {
9275
+ log.info(`Migration guide for ${u2.pkg}: ${u2.migrationPath}`);
9276
+ }
9277
+ if (u2.breakingChanges?.length) {
9278
+ for (const bc of u2.breakingChanges) {
9279
+ log.warn(`Breaking: ${bc}`);
9280
+ }
9281
+ }
9282
+ }
9283
+ const apply = await askForConfirmation(
9284
+ "Apply MAJOR updates? (breaking changes possible)",
9285
+ false
9286
+ );
9287
+ if (apply) allUpdates.push(...majorUpdates);
9288
+ }
9289
+ if (allUpdates.length > 0) {
9290
+ const { updatedCount, syncedPins } = applyUpdates(
9291
+ allUpdates,
9292
+ appRoot
9293
+ );
9294
+ summary.push(`Updated ${updatedCount} package.json file(s)`);
9295
+ if (syncedPins > 0) {
9296
+ summary.push(
9297
+ `Synced ${syncedPins} override/resolution pin(s)`
9298
+ );
9299
+ }
9300
+ }
9301
+ if (shouldRemoveDeprecated) {
9302
+ const removed = removeDeprecated(deprecatedPkgs);
9303
+ if (removed > 0) {
9304
+ summary.push(
9305
+ `Removed ${removed} deprecated package reference(s)`
9306
+ );
9307
+ }
9308
+ }
9309
+ if (summary.length > 0) {
9310
+ if (deleteLockfile(appRoot)) {
9311
+ summary.push("Deleted bun.lock (prevents stale version pinning)");
9312
+ }
9313
+ if (detectExecutionMode() === "development") {
9314
+ clearMatrixCache();
9315
+ const freshMatrix = loadMatrix();
9316
+ if (freshMatrix) {
9317
+ const freshVersions = buildDonotdevVersions();
9318
+ const sync = syncDonotdevToMatrix(
9319
+ freshMatrix.matrix,
9320
+ freshVersions,
9321
+ false
9322
+ );
9323
+ if (sync.changes.length > 0) {
9324
+ summary.push(
9325
+ `Synced ${sync.changes.length} matrix template version(s)`
9326
+ );
9327
+ }
9328
+ }
9329
+ }
9330
+ Me(summary.map((s2) => ` ${s2}`).join("\n"), "Done");
9331
+ const shouldInstall = await askForConfirmation(
9332
+ "Run bun install now?",
9333
+ true
9334
+ );
9335
+ if (shouldInstall) {
9336
+ const installSpinner = Y2();
9337
+ installSpinner.start("Running bun install...");
9338
+ const ok = runBunInstall(appRoot);
9339
+ if (ok) {
9340
+ installSpinner.stop("bun install completed");
9341
+ } else {
9342
+ installSpinner.stop("bun install failed");
9343
+ log.warn(
9344
+ "bun install failed \u2014 run it manually to see the error"
9345
+ );
9346
+ }
9347
+ }
9348
+ } else {
9349
+ log.info("No changes applied");
9350
+ }
9351
+ }
8979
9352
  }
8980
9353
  }
8981
9354
  }
8982
9355
  if (updateDocs) {
8983
- log.info("\n\u{1F4DA} Syncing framework documentation...");
9356
+ log.info("Syncing framework documentation...");
8984
9357
  const syncResult = await syncDocumentation({ dryRun });
8985
9358
  if (syncResult !== 0 && !dryRun) {
8986
9359
  log.warn("Some documentation files could not be synced");
8987
9360
  }
8988
9361
  }
8989
9362
  if (updateDemoApp) {
8990
- log.info("\n\u{1F3A8} Syncing demo app...");
9363
+ log.info("Syncing demo app...");
8991
9364
  const result = await syncApp("demo", { dryRun });
8992
9365
  if (result.synced > 0) {
8993
9366
  log.success(`Synced ${result.synced} file(s) in apps/demo`);
@@ -8999,7 +9372,7 @@ async function main(options = {}) {
8999
9372
  }
9000
9373
  }
9001
9374
  if (updateCockpitApp) {
9002
- log.info("\n\u{1F6F8} Syncing cockpit app...");
9375
+ log.info("Syncing cockpit app...");
9003
9376
  const result = await syncApp("dndev", { dryRun });
9004
9377
  if (result.synced > 0) {
9005
9378
  log.success(`Synced ${result.synced} file(s) in apps/dndev`);
@@ -9013,142 +9386,6 @@ async function main(options = {}) {
9013
9386
  Se("");
9014
9387
  return 0;
9015
9388
  }
9016
- async function handlePackageUpdates(updates, majorUpdates, appRoot, dryRun) {
9017
- if (updates.length > 0) {
9018
- log.info(`
9019
- ${updates.length} update(s) available:`);
9020
- for (const u2 of updates) {
9021
- const relativeFile = appRoot ? getRelativePathBetween(appRoot, u2.file) : u2.file;
9022
- const normalizedLatest = normalizeVersion(u2.latest);
9023
- const displayLatest = ensureCaretPrefix(normalizedLatest);
9024
- log.info(` \u2022 ${u2.pkg}: ${u2.current} \u2192 ${displayLatest}`);
9025
- log.info(` ${relativeFile} (${u2.field})`);
9026
- }
9027
- }
9028
- if (majorUpdates.length > 0 && !dryRun) {
9029
- log.info(`
9030
- ${majorUpdates.length} major update(s) available:`);
9031
- for (const u2 of majorUpdates) {
9032
- const relativeFile = appRoot ? getRelativePathBetween(appRoot, u2.file) : u2.file;
9033
- const normalizedLatest = normalizeVersion(u2.latest);
9034
- const displayLatest = ensureCaretPrefix(normalizedLatest);
9035
- log.info(` \u26A0 ${u2.pkg}: ${u2.current} \u2192 ${displayLatest}`);
9036
- log.info(` ${relativeFile} (${u2.field})`);
9037
- if (u2.migrationPath) log.info(` migration guide: ${u2.migrationPath}`);
9038
- if (u2.breakingChanges?.length) {
9039
- for (const bc of u2.breakingChanges) log.info(` breaking: ${bc}`);
9040
- }
9041
- const apply = await askForConfirmation(
9042
- `Apply major bump for ${u2.pkg}?`,
9043
- false
9044
- );
9045
- if (apply) {
9046
- updates.push(u2);
9047
- }
9048
- }
9049
- } else if (majorUpdates.length > 0 && dryRun) {
9050
- log.info(`
9051
- ${majorUpdates.length} major update(s) available:`);
9052
- for (const u2 of majorUpdates) {
9053
- const normalizedLatest = normalizeVersion(u2.latest);
9054
- const displayLatest = ensureCaretPrefix(normalizedLatest);
9055
- log.info(` \u26A0 ${u2.pkg}: ${u2.current} \u2192 ${displayLatest}`);
9056
- if (u2.migrationPath) log.info(` migration guide: ${u2.migrationPath}`);
9057
- }
9058
- updates.push(...majorUpdates);
9059
- }
9060
- if (updates.length > 0) {
9061
- let shouldApply = false;
9062
- if (dryRun) {
9063
- log.info("\n[DRY RUN] Would update package.json files:");
9064
- for (const u2 of updates) {
9065
- const relativeFile = appRoot ? getRelativePathBetween(appRoot, u2.file) : u2.file;
9066
- const normalizedLatest = normalizeVersion(u2.latest);
9067
- const displayLatest = ensureCaretPrefix(normalizedLatest);
9068
- log.info(
9069
- ` ${relativeFile}: ${u2.pkg} ${u2.current} \u2192 ${displayLatest} (${u2.field})`
9070
- );
9071
- }
9072
- log.info("\n[DRY RUN] No files modified");
9073
- } else {
9074
- log.info(
9075
- "\nMake sure you have backed up your package.json files before applying the bump."
9076
- );
9077
- shouldApply = await askForConfirmation("Apply updates?", true);
9078
- if (shouldApply) {
9079
- const updatedFiles = /* @__PURE__ */ new Map();
9080
- for (const u2 of updates) {
9081
- if (!updatedFiles.has(u2.file)) {
9082
- updatedFiles.set(u2.file, /* @__PURE__ */ new Set());
9083
- }
9084
- updatedFiles.get(u2.file).add(`${u2.pkg}:${u2.field}`);
9085
- }
9086
- for (const [file, packageKeys] of updatedFiles) {
9087
- const pkg = parsePackageJson(file);
9088
- if (!pkg) {
9089
- log.warn(
9090
- `Could not parse ${file} \u2014 skipping updates for this file`
9091
- );
9092
- continue;
9093
- }
9094
- let changed = false;
9095
- for (const packageKey of packageKeys) {
9096
- const [pkgName, field] = packageKey.split(":");
9097
- const update = updates.find(
9098
- (u2) => u2.file === file && u2.pkg === pkgName && u2.field === field
9099
- );
9100
- if (!update) continue;
9101
- const deps = pkg[field];
9102
- if (deps?.[pkgName]) {
9103
- const normalizedLatest = normalizeVersion(update.latest);
9104
- deps[pkgName] = field === "overrides" ? normalizedLatest : ensureCaretPrefix(normalizedLatest);
9105
- changed = true;
9106
- }
9107
- }
9108
- if (pkg.overrides) {
9109
- for (const u2 of updates) {
9110
- if (u2.file === file && u2.pkg.startsWith("@donotdev/") && u2.field !== "overrides" && pkg.overrides[u2.pkg]) {
9111
- const normalizedLatest = normalizeVersion(u2.latest);
9112
- pkg.overrides[u2.pkg] = normalizedLatest;
9113
- changed = true;
9114
- }
9115
- }
9116
- }
9117
- if (changed) {
9118
- writePackageJson(file, pkg);
9119
- const relativeFile = appRoot ? getRelativePathBetween(appRoot, file) : file;
9120
- log.info(`Updated: ${relativeFile}`);
9121
- }
9122
- }
9123
- if (updatedFiles.size > 0) {
9124
- log.success(
9125
- `
9126
- Done. Updated ${updatedFiles.size} file(s). Run "bun install" to apply.`
9127
- );
9128
- if (detectExecutionMode() === "development") {
9129
- clearMatrixCache();
9130
- const freshMatrix = loadMatrix();
9131
- if (freshMatrix) {
9132
- const freshVersions = buildDonotdevVersions();
9133
- const sync = syncDonotdevToMatrix(
9134
- freshMatrix.matrix,
9135
- freshVersions,
9136
- false
9137
- );
9138
- if (sync.changes.length > 0) {
9139
- log.success(
9140
- `Matrix updated (${sync.changes.length} template version(s) synced)`
9141
- );
9142
- }
9143
- }
9144
- }
9145
- }
9146
- } else {
9147
- log.info("\nUpdates not applied");
9148
- }
9149
- }
9150
- }
9151
- }
9152
9389
  export {
9153
9390
  main
9154
9391
  };