@mediamonks/canopy-cli 0.2.0 → 0.3.0

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-OcWG7JAW.mjs";
2
+ import { t as version } from "./package-DyEUYkEq.mjs";
3
3
  import { i as runRefresh, r as notifyOfUpdate } from "./version-check-CoWgQs2h.mjs";
4
4
  import { defineCommand, runMain } from "citty";
5
5
  //#region src/index.ts
@@ -54,8 +54,8 @@ const main = defineCommand({
54
54
  db: () => import("./db-CtUG4vfG.mjs").then((m) => m.dbCommand),
55
55
  open: () => import("./open-xLiGUz_W.mjs").then((m) => m.openCommand),
56
56
  docs: () => import("./docs-C3aOAx_A.mjs").then((m) => m.docsCommand),
57
- skill: () => import("./skill-jbmERP1X.mjs").then((m) => m.skillCommand),
58
- upgrade: () => import("./upgrade-Y8ejvoeg.mjs").then((m) => m.upgradeCommand),
57
+ skill: () => import("./skill-nN0e59rO.mjs").then((m) => m.skillCommand),
58
+ upgrade: () => import("./upgrade-C5IoUEZg.mjs").then((m) => m.upgradeCommand),
59
59
  logs: planned("logs", "Tail worker logs", "2")
60
60
  }
61
61
  });
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.2.0";
2
+ var version = "0.3.0";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-OcWG7JAW.mjs";
1
+ import { t as version } from "./package-DyEUYkEq.mjs";
2
2
  import { n as reportErrors } from "./ui-C8VuPzGp.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -2,26 +2,58 @@ import { t as PACKAGE_NAME } from "./version-check-CoWgQs2h.mjs";
2
2
  import { n as reportErrors } from "./ui-C8VuPzGp.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { spawn } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
5
6
  //#region src/upgrade.ts
6
7
  /**
7
8
  * canopy upgrade — install the latest published CLI globally.
8
9
  *
9
- * We shell out to whichever package manager we can detect (npm/pnpm/yarn/bun),
10
- * defaulting to npm, and let it do the actual install so global prefixes,
11
- * permissions and lockfiles stay the manager's concern. `--pm` overrides the
12
- * guess; `--version` pins a specific release.
10
+ * We shell out to whichever installer we can detect (Vite+, npm, pnpm, yarn or
11
+ * bun), defaulting to npm, and let it do the actual install so global prefixes,
12
+ * permissions and lockfiles stay its concern. `--pm` overrides the guess;
13
+ * `--version` pins a specific release.
14
+ *
15
+ * Detecting Vite+ matters: `vp install -g` keeps its own global store under
16
+ * $VP_HOME and puts its bins first on PATH, so a plain `npm install -g` would
17
+ * install into npm's separate prefix and leave the active `canopy` untouched.
18
+ */
19
+ const VALID_PMS = [
20
+ "viteplus",
21
+ "npm",
22
+ "pnpm",
23
+ "yarn",
24
+ "bun"
25
+ ];
26
+ /** Where this CLI's own code lives — the surest hint at how it was installed. */
27
+ function installLocation() {
28
+ try {
29
+ return fileURLToPath(import.meta.url);
30
+ } catch {
31
+ return process.argv[1] ?? process.execPath;
32
+ }
33
+ }
34
+ /**
35
+ * Map the location of an installed binary to the installer that owns it — each
36
+ * keeps its global store in a recognisable place (Vite+ under $VP_HOME/packages,
37
+ * then …/pnpm/…, …/.bun/…, …/Yarn/…). Defaults to npm. Exported for testing.
13
38
  */
14
- /** Best-effort guess of the package manager that installed this CLI. */
39
+ function installerForPath(path) {
40
+ if (/[\\/]\.vite-plus[\\/]packages[\\/]/.test(path)) return "viteplus";
41
+ if (/[\\/](?:pnpm|\.pnpm)[\\/]/.test(path)) return "pnpm";
42
+ if (/[\\/]\.bun[\\/]/.test(path)) return "bun";
43
+ if (/[\\/](?:Yarn|\.yarn)[\\/]/i.test(path)) return "yarn";
44
+ return "npm";
45
+ }
46
+ /** Best-effort guess of the installer that put this CLI on the machine. */
15
47
  function detectPackageManager() {
16
48
  const ua = process.env["npm_config_user_agent"] ?? "";
17
49
  if (ua.startsWith("pnpm")) return "pnpm";
18
50
  if (ua.startsWith("yarn")) return "yarn";
19
51
  if (ua.startsWith("bun")) return "bun";
20
- const path = process.argv[1] ?? process.execPath;
21
- if (/[\\/](?:pnpm|\.pnpm)[\\/]/.test(path)) return "pnpm";
22
- if (/[\\/]\.bun[\\/]/.test(path)) return "bun";
23
- if (/[\\/](?:Yarn|\.yarn)[\\/]/i.test(path)) return "yarn";
24
- return "npm";
52
+ return installerForPath(installLocation());
53
+ }
54
+ /** The executable to invoke for `pm` (Vite+ drives installs through `vp`). */
55
+ function pmCommand(pm) {
56
+ return pm === "viteplus" ? "vp" : pm;
25
57
  }
26
58
  /** The global-install argv for `pm`, targeting `spec` (e.g. name@latest). */
27
59
  function installArgs(pm, spec) {
@@ -70,23 +102,20 @@ const upgradeCommand = defineCommand({
70
102
  },
71
103
  pm: {
72
104
  type: "string",
73
- description: "Package manager to use: npm, pnpm, yarn or bun (auto-detected by default)"
105
+ description: "Installer to use: vp, npm, pnpm, yarn or bun (auto-detected by default)"
74
106
  }
75
107
  },
76
108
  run: reportErrors("upgrade", async ({ args }) => {
77
- const chosen = args.pm;
78
- if (chosen && ![
79
- "npm",
80
- "pnpm",
81
- "yarn",
82
- "bun"
83
- ].includes(chosen)) throw new Error(`Unknown --pm "${chosen}" — use npm, pnpm, yarn or bun.`);
109
+ const chosen = args.pm === "vp" ? "viteplus" : args.pm;
110
+ if (chosen && !VALID_PMS.includes(chosen)) throw new Error(`Unknown --pm "${args.pm}" — use vp, npm, pnpm, yarn or bun.`);
84
111
  const pm = chosen ?? detectPackageManager();
85
- const cmd = installArgs(pm, `${PACKAGE_NAME}@${args.version ?? "latest"}`);
86
- console.log(`Upgrading via ${pm}: ${pm} ${cmd.join(" ")}`);
87
- await run(pm, cmd);
112
+ const spec = `${PACKAGE_NAME}@${args.version ?? "latest"}`;
113
+ const command = pmCommand(pm);
114
+ const cmd = installArgs(pm, spec);
115
+ console.log(`Upgrading via ${command}: ${command} ${cmd.join(" ")}`);
116
+ await run(command, cmd);
88
117
  console.log(`\nDone. Run \`canopy --version\` to confirm.`);
89
- const { skillInstalled } = await import("./skill-jbmERP1X.mjs");
118
+ const { skillInstalled } = await import("./skill-nN0e59rO.mjs");
90
119
  if (skillInstalled(process.cwd())) {
91
120
  console.log("Refreshing the Canopy agent skill in this repo…");
92
121
  await run("canopy", ["skill", "install"]).catch((err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"
@@ -19,8 +19,8 @@
19
19
  "hono": "^4.8.0",
20
20
  "miniflare": "^4.20260714.0",
21
21
  "vite": "npm:@voidzero-dev/vite-plus-core@0.2.5",
22
- "@mediamonks/canopy-data-plane": "0.0.1",
23
- "@mediamonks/canopy": "0.0.1"
22
+ "@mediamonks/canopy": "0.0.1",
23
+ "@mediamonks/canopy-data-plane": "0.0.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^26.1.1",