@apex-stack/core 0.7.7 → 0.7.8

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.
@@ -90,6 +90,8 @@ async function offerExtension(choice) {
90
90
  }
91
91
 
92
92
  export {
93
+ cmpVersion,
93
94
  openInEditor,
95
+ promptYesNo,
94
96
  offerExtension
95
97
  };
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  offerExtension
4
- } from "./chunk-P6KQSPAV.js";
4
+ } from "./chunk-TWAGSGFN.js";
5
5
  import {
6
6
  VERSION,
7
7
  banner,
@@ -147,13 +147,13 @@ var main = defineCommand2({
147
147
  },
148
148
  subCommands: {
149
149
  new: newCommand,
150
- dev: () => import("./dev-SXOWAX4N.js").then((m) => m.devCommand),
150
+ dev: () => import("./dev-73J25PUW.js").then((m) => m.devCommand),
151
151
  build: () => import("./build-C3FW7BTM.js").then((m) => m.buildCommand),
152
152
  start: () => import("./start-VBGP3HFC.js").then((m) => m.startCommand),
153
153
  make: () => import("./make-VAYO5GWA.js").then((m) => m.makeCommand),
154
154
  add: () => import("./add-M3YLIFF5.js").then((m) => m.addCommand),
155
155
  theme: () => import("./theme-UUOIV44V.js").then((m) => m.themeCommand),
156
- upgrade: () => import("./upgrade-KGUW3C3O.js").then((m) => m.upgradeCommand),
156
+ upgrade: () => import("./upgrade-YZN6TVNI.js").then((m) => m.upgradeCommand),
157
157
  migrate: () => import("./migrate-X6LIHMIE.js").then((m) => m.migrateCommand),
158
158
  mcp: () => import("./mcp-CH7L4GF3.js").then((m) => m.mcpCommand)
159
159
  },
@@ -24,7 +24,7 @@ var devCommand = defineCommand({
24
24
  process.stdout.write(banner());
25
25
  const sp = spinner(`Starting dev server${args.islands ? " (islands mode)" : ""}\u2026`);
26
26
  try {
27
- const { startDevServer } = await import("./server-AV533LKD.js");
27
+ const { startDevServer } = await import("./server-J7X54UI3.js");
28
28
  const { port: actual } = await startDevServer({ root, port, islands: Boolean(args.islands) });
29
29
  sp.succeed("Dev server ready");
30
30
  ready([
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  openInEditor
3
- } from "./chunk-P6KQSPAV.js";
3
+ } from "./chunk-TWAGSGFN.js";
4
4
  import {
5
5
  loadComponents
6
6
  } from "./chunk-4VG3CZ6H.js";
@@ -1,6 +1,8 @@
1
1
  import {
2
- offerExtension
3
- } from "./chunk-P6KQSPAV.js";
2
+ cmpVersion,
3
+ offerExtension,
4
+ promptYesNo
5
+ } from "./chunk-TWAGSGFN.js";
4
6
  import {
5
7
  VERSION,
6
8
  banner,
@@ -8,12 +10,69 @@ import {
8
10
  } from "./chunk-QIXJSQLW.js";
9
11
 
10
12
  // src/commands/upgrade.ts
11
- import { spawnSync } from "child_process";
13
+ import { spawnSync as spawnSync2 } from "child_process";
12
14
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
13
- import { basename, dirname, join, relative, resolve } from "path";
14
- import { fileURLToPath } from "url";
15
+ import { basename, dirname, join, relative, resolve as resolve2 } from "path";
16
+ import { fileURLToPath as fileURLToPath2 } from "url";
15
17
  import { defineCommand } from "citty";
16
- var TEMPLATE_DIR = fileURLToPath(new URL("../templates/default", import.meta.url));
18
+
19
+ // src/selfUpdate.ts
20
+ import { spawnSync } from "child_process";
21
+ import { resolve, sep } from "path";
22
+ import { fileURLToPath } from "url";
23
+ var PKG = "@apex-stack/core";
24
+ var WIN = process.platform === "win32";
25
+ function latestPublished() {
26
+ try {
27
+ const r = spawnSync("npm", ["view", PKG, "version"], {
28
+ encoding: "utf8",
29
+ timeout: 4e3,
30
+ shell: WIN
31
+ });
32
+ if (r.status !== 0 || !r.stdout) return null;
33
+ const v = r.stdout.trim();
34
+ return /^\d+\.\d+\.\d+/.test(v) ? v : null;
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+ function isGlobalInstall() {
40
+ const self = fileURLToPath(import.meta.url);
41
+ const localRoot = resolve(process.cwd(), "node_modules") + sep;
42
+ return !self.startsWith(localRoot);
43
+ }
44
+ function installGlobalLatest() {
45
+ return spawnSync("npm", ["install", "-g", `${PKG}@latest`], { stdio: "inherit", shell: WIN }).status === 0;
46
+ }
47
+ async function maybeSelfUpdate(reexecArgv, choice) {
48
+ if (choice === false) return false;
49
+ if (!isGlobalInstall()) return false;
50
+ const latest = latestPublished();
51
+ if (!latest || cmpVersion(latest, VERSION) <= 0) return false;
52
+ const log = console.log;
53
+ log(
54
+ `
55
+ ${color.cyan("\u2191")} A newer Apex CLI is available: ${color.gray(VERSION)} \u2192 ${color.green(latest)}`
56
+ );
57
+ const yes = choice ?? (process.stdin.isTTY ? await promptYesNo(` Update the global CLI now?`) : false);
58
+ if (!yes) {
59
+ log(` ${color.gray("Skipped. Update later with")} ${color.cyan(`npm i -g ${PKG}@latest`)}
60
+ `);
61
+ return false;
62
+ }
63
+ if (!installGlobalLatest()) {
64
+ log(` ${color.red("\u2717")} Global update failed \u2014 run ${color.cyan(`npm i -g ${PKG}@latest`)}
65
+ `);
66
+ return false;
67
+ }
68
+ log(` ${color.green("\u2713")} CLI updated to ${latest} \u2014 re-running on the new engine\u2026
69
+ `);
70
+ const r = spawnSync("apex", reexecArgv, { stdio: "inherit", shell: WIN });
71
+ process.exit(r.status ?? 0);
72
+ }
73
+
74
+ // src/commands/upgrade.ts
75
+ var TEMPLATE_DIR = fileURLToPath2(new URL("../templates/default", import.meta.url));
17
76
  var PROTECTED = /* @__PURE__ */ new Set(["package.json"]);
18
77
  function projectName(root) {
19
78
  try {
@@ -79,10 +138,14 @@ var upgradeCommand = defineCommand({
79
138
  vscode: {
80
139
  type: "boolean",
81
140
  description: "Install the Apex VS Code extension (skip the prompt)"
141
+ },
142
+ self: {
143
+ type: "boolean",
144
+ description: "Update the global Apex CLI first if a newer one is published (default: ask)"
82
145
  }
83
146
  },
84
147
  async run({ args }) {
85
- const root = resolve(process.cwd(), String(args.root));
148
+ const root = resolve2(process.cwd(), String(args.root));
86
149
  const log = console.log;
87
150
  if (!existsSync(join(root, "package.json"))) {
88
151
  console.error(`
@@ -90,6 +153,15 @@ var upgradeCommand = defineCommand({
90
153
  `);
91
154
  process.exit(1);
92
155
  }
156
+ const reexecArgv = [
157
+ "upgrade",
158
+ String(args.root),
159
+ ...args.force ? ["--force"] : [],
160
+ ...args.install === false ? ["--no-install"] : [],
161
+ ...args.vscode === true ? ["--vscode"] : args.vscode === false ? ["--no-vscode"] : [],
162
+ "--no-self"
163
+ ];
164
+ if (await maybeSelfUpdate(reexecArgv, args.self)) return;
93
165
  const name = projectName(root);
94
166
  process.stdout.write(banner());
95
167
  const added = [];
@@ -141,7 +213,7 @@ var upgradeCommand = defineCommand({
141
213
  const pm = detectPm();
142
214
  log(`
143
215
  ${color.gray(`Installing with ${pm}\u2026`)}`);
144
- const ok = spawnSync(pm, ["install"], {
216
+ const ok = spawnSync2(pm, ["install"], {
145
217
  cwd: root,
146
218
  stdio: "inherit",
147
219
  shell: process.platform === "win32"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apex-stack/core",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "The full-stack meta-framework for Alpine.js — CLI and runtime",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -47,9 +47,9 @@
47
47
  "h3": "^1.13.0",
48
48
  "vite": "^6.0.7",
49
49
  "zod": "^4.4.3",
50
- "@apex-stack/kit": "0.3.0",
51
50
  "@apex-stack/vite": "0.1.7",
52
- "@apex-stack/theme": "0.3.0"
51
+ "@apex-stack/theme": "0.3.0",
52
+ "@apex-stack/kit": "0.3.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "alpinejs": "^3.14.0"