@incajs/cli 0.0.18 → 0.0.19

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/cli.js CHANGED
@@ -5,9 +5,9 @@ import f, { existsSync as p, lstatSync as m, readFileSync as h, realpathSync as
5
5
  import y, { resolve as b } from "node:path";
6
6
  import * as ee from "node:util";
7
7
  import { parseArgs as x, styleText as S } from "node:util";
8
- import { chmod as C, cp as w, link as T, mkdir as E, readFile as D, readdir as te, rm as O, writeFile as k } from "node:fs/promises";
9
- import { fileURLToPath as ne, pathToFileURL as re } from "node:url";
10
- import { homedir as ie } from "node:os";
8
+ import { chmod as C, cp as w, link as te, mkdir as T, readFile as E, readdir as ne, rm as D, writeFile as O } from "node:fs/promises";
9
+ import { fileURLToPath as re, pathToFileURL as ie } from "node:url";
10
+ import { homedir as k } from "node:os";
11
11
  import { createRequire as ae } from "node:module";
12
12
  import { spawn as oe } from "node:child_process";
13
13
  import { once as A } from "node:events";
@@ -365,7 +365,7 @@ function Re(e, t, n, r) {
365
365
  }
366
366
  //#endregion
367
367
  //#region package.json
368
- var ze = "0.0.18", Be = "Commands to develop, bundle, and package Incarnative.js apps.";
368
+ var ze = "0.0.19", Be = "Commands to develop, bundle, and package Incarnative.js apps.";
369
369
  //#endregion
370
370
  //#region ../../node_modules/.pnpm/rc9@3.1.0/node_modules/rc9/dist/_chunks/libs/flat.mjs
371
371
  function Ve(e) {
@@ -510,7 +510,7 @@ function q(e) {
510
510
  return e = nt(e), it(b(e.dir, e.name), e);
511
511
  }
512
512
  function at() {
513
- return process.env.XDG_CONFIG_HOME || b(ie(), ".config");
513
+ return process.env.XDG_CONFIG_HOME || b(k(), ".config");
514
514
  }
515
515
  function ot(e) {
516
516
  return e = nt(e), e.dir = at(), q(e);
@@ -703,7 +703,7 @@ async function xt(e) {
703
703
  dir: r
704
704
  })), t.push(ot({ name: e.rcFile })), t.push(q({
705
705
  name: e.rcFile,
706
- dir: ie()
706
+ dir: k()
707
707
  }));
708
708
  }
709
709
  i.rc = n({}, ...t);
@@ -780,9 +780,9 @@ async function Tt(e, o, s = {}) {
780
780
  let { downloadTemplate: n } = await import("./chunks/__vite-optional-peer-dep_giget_c12-BYcrHYBM.js").catch((t) => {
781
781
  throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``, { cause: t });
782
782
  }), { digest: c } = await import("./chunks/ohash-Cc4pJh84.js").then((e) => e.dist_exports), l = e.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + c(e).slice(0, 10).replace(/[-_]/g, ""), u, d = t(o.cwd, "node_modules"), f = a(o.cwd);
783
- u = r(f) === ".c12" ? i(f, l) : p(d) ? i(d, ".c12", l) : process.env.XDG_CACHE_HOME ? t(process.env.XDG_CACHE_HOME, "c12", l) : t(ie(), ".cache/c12", l);
783
+ u = r(f) === ".c12" ? i(f, l) : p(d) ? i(d, ".c12", l) : process.env.XDG_CACHE_HOME ? t(process.env.XDG_CACHE_HOME, "c12", l) : t(k(), ".cache/c12", l);
784
784
  let m = s.install ? K(s.install === !0 ? {} : s.install, { ignoreWorkspace: !0 }) : !1;
785
- p(u) && !m && await O(u, { recursive: !0 }), e = (await n(e, {
785
+ p(u) && !m && await D(u, { recursive: !0 }), e = (await n(e, {
786
786
  dir: u,
787
787
  install: m,
788
788
  force: !!m,
@@ -804,12 +804,12 @@ async function Tt(e, o, s = {}) {
804
804
  if (h.configFile = J(t(m, e), o) || J(t(m, ".config", e.replace(/\.config$/, "")), o) || J(t(m, ".config", e), o) || e, !p(h.configFile)) return h;
805
805
  h._configFile = h.configFile;
806
806
  let g = n(h.configFile) || "";
807
- if (g in yt) h.config = (await yt[g]())(await D(h.configFile, "utf8"));
807
+ if (g in yt) h.config = (await yt[g]())(await E(h.configFile, "utf8"));
808
808
  else {
809
809
  let e = o.resolveModule || ((e) => e.default || e);
810
810
  if (o.import) h.config = e(await o.import(h.configFile));
811
811
  else {
812
- let t = re(h.configFile);
812
+ let t = ie(h.configFile);
813
813
  t.search = `_${++vt}`, h.config = await import(t.href).then(e, async (t) => {
814
814
  let { createJiti: n } = await import("./chunks/__vite-optional-peer-dep_jiti_c12-DZVJNj6v.js").catch(() => {
815
815
  throw Error(`Failed to load config file \`${h.configFile}\`: ${t?.message}. Hint install \`jiti\` for compatibility.`, { cause: t });
@@ -842,7 +842,7 @@ async function Et(e, t) {
842
842
  function J(e, t) {
843
843
  let n = s(e, {
844
844
  try: !0,
845
- from: re(i(t.cwd || ".", t.configFile || "/")),
845
+ from: ie(i(t.cwd || ".", t.configFile || "/")),
846
846
  suffixes: ["", "/index"],
847
847
  extensions: bt,
848
848
  cache: !1
@@ -936,7 +936,7 @@ async function zt(e) {
936
936
  async function Bt(e) {
937
937
  let t = y.join(e, "package.json"), n;
938
938
  try {
939
- n = await D(t, "utf8");
939
+ n = await E(t, "utf8");
940
940
  } catch {
941
941
  throw new Y("ERR_INCA_PACKAGE_JSON_NOT_FOUND", `no package.json found at ${t}`);
942
942
  }
@@ -967,7 +967,7 @@ function Vt(e) {
967
967
  };
968
968
  }
969
969
  async function Ht(e) {
970
- let { config: t } = await Rt(e), n = y.join(e, "package.json"), r = await D(n, "utf8").catch(() => void 0), i = r === void 0 ? {} : Lt(r, n), a = t.productName ?? u(i.name);
970
+ let { config: t } = await Rt(e), n = y.join(e, "package.json"), r = await E(n, "utf8").catch(() => void 0), i = r === void 0 ? {} : Lt(r, n), a = t.productName ?? u(i.name);
971
971
  a && jt(a);
972
972
  let o = {
973
973
  name: a,
@@ -1412,7 +1412,7 @@ function En(e) {
1412
1412
  return y.join(e, "node_modules/.inca/hmr");
1413
1413
  }
1414
1414
  function Dn() {
1415
- let e = y.dirname(ne(import.meta.url));
1415
+ let e = y.dirname(re(import.meta.url));
1416
1416
  for (; !p(y.join(e, "package.json"));) {
1417
1417
  let t = y.dirname(e);
1418
1418
  if (t === e) throw Error("could not locate @incajs/cli's own package.json");
@@ -1434,7 +1434,7 @@ function An(e) {
1434
1434
  }
1435
1435
  async function jn(e, t, n, r) {
1436
1436
  let i = En(e), a = y.join(i, "entry.js"), o = On(i, r ?? Dn()), s = t.split(y.sep).join("/");
1437
- return await k(a, wn`
1437
+ return await O(a, wn`
1438
1438
  import { start } from ${JSON.stringify(o)};
1439
1439
  await start(${JSON.stringify(s)}, ${JSON.stringify(n)});
1440
1440
  `), a;
@@ -1452,7 +1452,8 @@ function Pn(e, t, n, r, i) {
1452
1452
  let a = /* @__PURE__ */ new Map(), o = { send: s };
1453
1453
  function s(a) {
1454
1454
  if (a.type === "full-reload") {
1455
- t();
1455
+ let e = i.current;
1456
+ i.current = void 0, t(e);
1456
1457
  return;
1457
1458
  }
1458
1459
  let o = Mn(a);
@@ -1507,9 +1508,9 @@ function In(e) {
1507
1508
  };
1508
1509
  }
1509
1510
  async function Ln(e, t, { entry: n, cwd: r, runtimeConfig: i, runtimePath: a, stdout: o = process.stdout, stderr: s = process.stderr, quiet: c = !1, notify: l, reload: u, onError: d, onUpdate: f = () => {} }) {
1510
- await E(En(r), { recursive: !0 });
1511
+ await T(En(r), { recursive: !0 });
1511
1512
  let p = pn(i), m = y.join(En(r), fn);
1512
- p ? await k(m, p) : await O(m, { force: !0 });
1513
+ p ? await O(m, p) : await D(m, { force: !0 });
1513
1514
  let h = { current: void 0 }, { channel: g, dispatch: _ } = Pn(l, u, (t) => d(Tn(e, t)), f, h), v = await fe({
1514
1515
  configFile: !1,
1515
1516
  root: y.dirname(n),
@@ -1610,9 +1611,9 @@ async function Hn(e) {
1610
1611
  }
1611
1612
  async function Un(e, t) {
1612
1613
  let n = y.join(t, "node_modules/.inca");
1613
- await E(n, { recursive: !0 });
1614
+ await T(n, { recursive: !0 });
1614
1615
  let r = y.join(n, "entry.mts"), i = JSON.stringify(e.split(y.sep).join("/"));
1615
- return await k(r, wn`
1616
+ return await O(r, wn`
1616
1617
  import { createIncaApp } from "incajs/vue";
1617
1618
  import App from ${i};
1618
1619
  createIncaApp(App).mount();
@@ -1651,30 +1652,30 @@ function Jn(e) {
1651
1652
  }
1652
1653
  async function Yn(e) {
1653
1654
  let t = Gn(e), n = `${String(process.pid)}:${qn}`, r = `${t}.${me()}`;
1654
- await E(y.dirname(t), { recursive: !0 }), await k(r, n);
1655
+ await T(y.dirname(t), { recursive: !0 }), await O(r, n);
1655
1656
  let i = process.pid;
1656
1657
  try {
1657
1658
  for (let e = 0; e < 5; e++) {
1658
1659
  try {
1659
- return await T(r, t), Xn(t, n);
1660
+ return await te(r, t), Xn(t, n);
1660
1661
  } catch (e) {
1661
1662
  if (e.code !== "EEXIST") throw e;
1662
1663
  }
1663
- let e = await D(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
1664
+ let e = await E(t, "utf8").catch(() => ""), a = Number.parseInt(e, 10);
1664
1665
  if (a === process.pid) {
1665
1666
  if (e === n) throw Jn(a);
1666
1667
  } else if (Number.isSafeInteger(a) && a > 0 && Kn(a)) throw Jn(a);
1667
- i = Number.isSafeInteger(a) && a > 0 ? a : i, await O(t, { force: !0 });
1668
+ i = Number.isSafeInteger(a) && a > 0 ? a : i, await D(t, { force: !0 });
1668
1669
  }
1669
1670
  throw Jn(i);
1670
1671
  } finally {
1671
- await O(r, { force: !0 });
1672
+ await D(r, { force: !0 });
1672
1673
  }
1673
1674
  }
1674
1675
  function Xn(e, t) {
1675
1676
  let n = !1;
1676
1677
  return async () => {
1677
- n || (n = !0, await D(e, "utf8").catch(() => "") === t && await O(e, { force: !0 }));
1678
+ n || (n = !0, await E(e, "utf8").catch(() => "") === t && await D(e, { force: !0 }));
1678
1679
  };
1679
1680
  }
1680
1681
  //#endregion
@@ -1700,14 +1701,14 @@ function $n(e) {
1700
1701
  //#region src/macosApp.mts
1701
1702
  async function er(e) {
1702
1703
  let { appPath: t, metadata: n, hostBin: r } = e;
1703
- await O(t, {
1704
+ await D(t, {
1704
1705
  recursive: !0,
1705
1706
  force: !0
1706
1707
  });
1707
1708
  let i = y.join(t, "Contents"), a = y.join(i, "MacOS"), o = y.join(i, "Resources");
1708
- await E(a, { recursive: !0 }), await E(o, { recursive: !0 });
1709
+ await T(a, { recursive: !0 }), await T(o, { recursive: !0 });
1709
1710
  let s = y.join(a, n.productName);
1710
- e.link ? await T(r, s).catch(() => w(r, s)) : await w(r, s), await C(s, 493);
1711
+ e.link ? await te(r, s).catch(() => w(r, s)) : await w(r, s), await C(s, 493);
1711
1712
  let c = {
1712
1713
  CFBundleName: n.productName,
1713
1714
  CFBundleDisplayName: n.productName,
@@ -1723,7 +1724,7 @@ async function er(e) {
1723
1724
  let e = y.basename(n.icon);
1724
1725
  await w(n.icon, y.join(o, e)), c.CFBundleIconFile = e;
1725
1726
  }
1726
- return await k(y.join(i, "Info.plist"), $n(c)), await k(y.join(i, "PkgInfo"), "APPL????"), {
1727
+ return await O(y.join(i, "Info.plist"), $n(c)), await O(y.join(i, "PkgInfo"), "APPL????"), {
1727
1728
  appPath: t,
1728
1729
  executablePath: s,
1729
1730
  resourcesDir: o
@@ -1829,14 +1830,14 @@ async function lr(e, t, n, r) {
1829
1830
  async function ur(e, t) {
1830
1831
  let n = new Set(t), r;
1831
1832
  try {
1832
- r = await te(e, {
1833
+ r = await ne(e, {
1833
1834
  recursive: !0,
1834
1835
  withFileTypes: !0
1835
1836
  });
1836
1837
  } catch {
1837
1838
  return;
1838
1839
  }
1839
- await Promise.all(r.filter((e) => e.isFile()).map((t) => y.relative(e, y.join(t.parentPath, t.name))).filter((e) => !n.has(e)).map((t) => O(y.join(e, t), { force: !0 })));
1840
+ await Promise.all(r.filter((e) => e.isFile()).map((t) => y.relative(e, y.join(t.parentPath, t.name))).filter((e) => !n.has(e)).map((t) => D(y.join(e, t), { force: !0 })));
1840
1841
  }
1841
1842
  function dr(e) {
1842
1843
  let { NO_COLOR: t, FORCE_COLOR: n } = process.env;
@@ -1880,7 +1881,12 @@ async function fr(e) {
1880
1881
  return $(a, "reload failed", Q(e), X), !1;
1881
1882
  }
1882
1883
  }
1883
- async function C(e, t) {
1884
+ function C(e) {
1885
+ if (!e) return;
1886
+ let n = S("dim", y.relative(t, e.file), { stream: i }), r = Date.now() - e.at;
1887
+ Z(i, `${S("green", "reload")} ${n} (${r}ms)`, X);
1888
+ }
1889
+ async function w(e, t) {
1884
1890
  let n = new Qt({
1885
1891
  entryFile: e,
1886
1892
  hostBin: f,
@@ -1906,13 +1912,8 @@ async function fr(e) {
1906
1912
  }
1907
1913
  p = n;
1908
1914
  }
1909
- async function w(e) {
1910
- if (await ur(e.outDir, e.files), !p) await C(e.entryFile);
1911
- else if (!m) h = !0;
1912
- else if (await x() && e.changed) {
1913
- let n = S("dim", y.relative(t, e.changed.file), { stream: i }), r = Date.now() - e.changed.at;
1914
- Z(i, `${S("green", "reload")} ${n} (${r}ms)`, X);
1915
- }
1915
+ async function te(e) {
1916
+ await ur(e.outDir, e.files), p ? m ? await x() && C(e.changed) : h = !0 : await w(e.entryFile);
1916
1917
  }
1917
1918
  let T;
1918
1919
  if (o) {
@@ -1923,8 +1924,10 @@ async function fr(e) {
1923
1924
  stdout: i,
1924
1925
  stderr: a,
1925
1926
  notify: (e) => p?.notify("vite", e),
1926
- reload: () => {
1927
- m ? x() : h = !0;
1927
+ reload: (e) => {
1928
+ m ? x().then((t) => {
1929
+ t && C(e);
1930
+ }) : h = !0;
1928
1931
  },
1929
1932
  onError: (e) => $(a, "build failed", e, X),
1930
1933
  onUpdate: ({ file: e, took: n }) => {
@@ -1933,7 +1936,7 @@ async function fr(e) {
1933
1936
  Z(i, `${S("green", "update")} ${r} (${n}ms)`, X);
1934
1937
  }
1935
1938
  });
1936
- await C(e.entryFile, { vite: (t) => e.dispatch(t) }), T = e, p || b();
1939
+ await w(e.entryFile, { vite: (t) => e.dispatch(t) }), T = e, p || b();
1937
1940
  } else T = await r.watch({
1938
1941
  entry: l,
1939
1942
  outDir: c,
@@ -1942,7 +1945,7 @@ async function fr(e) {
1942
1945
  stdout: i,
1943
1946
  stderr: a,
1944
1947
  onBuild: (e) => {
1945
- v = v.then(() => w(e));
1948
+ v = v.then(() => te(e));
1946
1949
  },
1947
1950
  onError: (e) => {
1948
1951
  $(a, "build failed", e, X);
@@ -1967,7 +1970,7 @@ function pr() {
1967
1970
  async function mr(e, t) {
1968
1971
  await Promise.all(e.files.map(async (n) => {
1969
1972
  let r = y.join(t, n);
1970
- await E(y.dirname(r), { recursive: !0 }), await w(y.join(e.outDir, n), r);
1973
+ await T(y.dirname(r), { recursive: !0 }), await w(y.join(e.outDir, n), r);
1971
1974
  }));
1972
1975
  }
1973
1976
  function hr(e, t) {
@@ -1986,10 +1989,10 @@ async function _r({ metadata: e, output: t, hostBin: n }) {
1986
1989
  let r = c(e.productName);
1987
1990
  hr(t, r);
1988
1991
  let i = y.join(t.outDir, r);
1989
- await O(i, {
1992
+ await D(i, {
1990
1993
  recursive: !0,
1991
1994
  force: !0
1992
- }), await E(i, { recursive: !0 });
1995
+ }), await T(i, { recursive: !0 });
1993
1996
  let a = y.join(i, r);
1994
1997
  return await w(n, a), await C(a, 493), await mr(t, i), i;
1995
1998
  }
package/dist/types.d.mts CHANGED
@@ -85,8 +85,14 @@ export interface HmrOptions {
85
85
  quiet?: boolean;
86
86
  /** Delivers a bundler payload to the running app over the dev channel. */
87
87
  notify: (payload: unknown) => void;
88
- /** Called in place of forwarding a whole-app reload payload to the app. */
89
- reload: () => void;
88
+ /**
89
+ * Called in place of forwarding a whole-app reload payload to the app, with
90
+ * the edit that caused it when one was waiting.
91
+ */
92
+ reload: (changed?: {
93
+ file: string;
94
+ at: number;
95
+ }) => void;
90
96
  /** Called when an update the app fetched failed to compile. */
91
97
  onError: (error: BuildFailure) => void;
92
98
  /** Called after a successful update, with the file that changed and how long it took. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incajs/cli",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Commands to develop, bundle, and package Incarnative.js apps.",
5
5
  "keywords": [
6
6
  "bundler",
@@ -72,10 +72,10 @@
72
72
  }
73
73
  },
74
74
  "optionalDependencies": {
75
- "@incajs/host-darwin-arm64": "0.0.18",
76
- "@incajs/host-darwin-x64": "0.0.18",
77
- "@incajs/host-linux-arm64": "0.0.18",
78
- "@incajs/host-linux-x64": "0.0.18"
75
+ "@incajs/host-darwin-arm64": "0.0.19",
76
+ "@incajs/host-darwin-x64": "0.0.19",
77
+ "@incajs/host-linux-arm64": "0.0.19",
78
+ "@incajs/host-linux-x64": "0.0.19"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=22.18"