@mediamonks/canopy-cli 0.4.2 → 0.4.4

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.
@@ -0,0 +1,2 @@
1
+ import { t as devCommand } from "./dev-pPVCUaFp.mjs";
2
+ export { devCommand };
@@ -2,8 +2,10 @@ import { t as readConfig } from "./config-C-z7st1X.mjs";
2
2
  import { n as apiRequest } from "./api-BcX_w6Xf.mjs";
3
3
  import { i as resolveProject, t as projectDirArgs } from "./project-CpiPLNby.mjs";
4
4
  import { n as reportErrors } from "./ui-C8VuPzGp.mjs";
5
+ import { createRequire } from "node:module";
5
6
  import { defineCommand } from "citty";
6
7
  import { join } from "node:path";
8
+ import { pathToFileURL } from "node:url";
7
9
  //#region src/dev.ts
8
10
  /**
9
11
  * Mirror the gateway's project-host rewrite (apps/gateway/src/index.ts):
@@ -18,17 +20,54 @@ function rewriteApiPath(path, slug) {
18
20
  if (dataPlane) pathname = `/v1/projects/${slug}/${dataPlane[1]}${dataPlane[2] ?? ""}`;
19
21
  return pathname + query;
20
22
  }
23
+ /**
24
+ * Load Vite's `createServer`, preferring the Vite installed in the *project*
25
+ * over the copy bundled with the CLI. `bundled` reports which one we got.
26
+ *
27
+ * Why the project's own Vite: the dev server and the project's
28
+ * vite.config/plugins must run on ONE Vite instance. When they don't — e.g. the
29
+ * CLI serves with its Vite while the project's `vite.config.ts` and
30
+ * `@vitejs/plugin-react` pull in a second, separately-installed Vite (even the
31
+ * same version) — internal module resolution breaks: the server fails to
32
+ * resolve `/@vite/client` and the browser gets the HTML fallback instead of the
33
+ * client runtime. Scaffolds that ship a vite.config (spa/worker) always have
34
+ * their own Vite; the no-build `static` scaffold has none, so we fall back to
35
+ * the CLI's bundled Vite (aliased "vite-server"). Upstream Vite is used rather
36
+ * than the repo's Vite+ fork, whose native binding rides the devDependency-only
37
+ * `vite-plus` package and is absent from a user's global `npm i -g` install.
38
+ */
39
+ async function loadCreateServer(dir) {
40
+ try {
41
+ return {
42
+ createServer: (await import(pathToFileURL(createRequire(join(dir, "package.json")).resolve("vite")).href)).createServer,
43
+ bundled: false
44
+ };
45
+ } catch {
46
+ return {
47
+ createServer: (await import("vite-server")).createServer,
48
+ bundled: true
49
+ };
50
+ }
51
+ }
21
52
  async function startVite(flags, serverOverrides) {
22
- const { createServer } = await import("vite-server");
53
+ const { createServer, bundled } = await loadCreateServer(flags.dir);
54
+ const plugins = [{
55
+ name: "canopy-platform-api-external",
56
+ resolveId: (id) => id.startsWith("/_api/") ? {
57
+ id,
58
+ external: true
59
+ } : void 0
60
+ }];
61
+ if (bundled) plugins.push({
62
+ name: "canopy-no-build-static",
63
+ transformIndexHtml: {
64
+ order: "post",
65
+ handler: (html) => html.replace(/\s*<script type="module" src="\/@vite\/client"><\/script>/g, "")
66
+ }
67
+ });
23
68
  const server = await createServer({
24
69
  root: flags.dir,
25
- plugins: [{
26
- name: "canopy-platform-api-external",
27
- resolveId: (id) => id.startsWith("/_api/") ? {
28
- id,
29
- external: true
30
- } : void 0
31
- }],
70
+ plugins,
32
71
  server: {
33
72
  port: flags.port,
34
73
  ...serverOverrides
@@ -55,7 +94,7 @@ async function devRemote(flags, slug) {
55
94
  async function devLocal(flags, slug) {
56
95
  let dump;
57
96
  if (flags.pull) {
58
- const { fetchProjectDump } = await import("./local-Ba-pZf2O.mjs");
97
+ const { fetchProjectDump } = await import("./local-MLfuFVZb.mjs");
59
98
  console.log(`Pulling a fresh export of ${slug}…`);
60
99
  dump = await fetchProjectDump(slug);
61
100
  }
@@ -69,7 +108,7 @@ async function devLocal(flags, slug) {
69
108
  } catch (err) {
70
109
  console.log(`Note: ai/services will be unavailable — could not reach the platform (${err instanceof Error ? err.message : String(err)}).`);
71
110
  }
72
- const { createSandbox } = await import("./local-Ba-pZf2O.mjs");
111
+ const { createSandbox } = await import("./local-MLfuFVZb.mjs");
73
112
  const sandbox = await createSandbox({
74
113
  slug,
75
114
  persistDir: join(flags.dir, ".canopy", "local"),
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-CUjYxZem.mjs";
2
+ import { t as version } from "./package-BHlmIdUm.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
@@ -48,7 +48,7 @@ const main = defineCommand({
48
48
  init: () => import("./projects-oyjC4ZGb.mjs").then((m) => m.initCommand),
49
49
  projects: () => import("./projects-oyjC4ZGb.mjs").then((m) => m.projectsCommand),
50
50
  delete: () => import("./projects-oyjC4ZGb.mjs").then((m) => m.deleteCommand),
51
- dev: () => import("./dev-DBoGaChx.mjs").then((m) => m.devCommand),
51
+ dev: () => import("./dev-R6nzDtA-.mjs").then((m) => m.devCommand),
52
52
  deploy: () => import("./deploy-BO_-gK32.mjs").then((m) => m.deployCommand),
53
53
  rollback: () => import("./deploy-BO_-gK32.mjs").then((m) => m.rollbackCommand),
54
54
  download: () => import("./deploy-BO_-gK32.mjs").then((m) => m.downloadCommand),
@@ -56,8 +56,8 @@ const main = defineCommand({
56
56
  db: () => import("./db-Bkq-_qkd.mjs").then((m) => m.dbCommand),
57
57
  open: () => import("./open-xLiGUz_W.mjs").then((m) => m.openCommand),
58
58
  docs: () => import("./docs-C3aOAx_A.mjs").then((m) => m.docsCommand),
59
- skill: () => import("./skill-CObIJMP5.mjs").then((m) => m.skillCommand),
60
- upgrade: () => import("./upgrade-DxUNN79Q.mjs").then((m) => m.upgradeCommand),
59
+ skill: () => import("./skill-BsZKAgGI.mjs").then((m) => m.skillCommand),
60
+ upgrade: () => import("./upgrade-nYLjXxPk.mjs").then((m) => m.upgradeCommand),
61
61
  logs: planned("logs", "Tail worker logs", "2")
62
62
  }
63
63
  });
@@ -1,5 +1,5 @@
1
1
  import { n as apiRequest } from "./api-BcX_w6Xf.mjs";
2
- import { n as rewriteApiPath } from "./dev-DdUJbbfA.mjs";
2
+ import { n as rewriteApiPath } from "./dev-pPVCUaFp.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { existsSync, readFileSync } from "node:fs";
5
5
  import { dirname, join } from "node:path";
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.4.2";
2
+ var version = "0.4.4";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-CUjYxZem.mjs";
1
+ import { t as version } from "./package-BHlmIdUm.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";
@@ -112,11 +112,12 @@ const upgradeCommand = defineCommand({
112
112
  const spec = `${PACKAGE_NAME}@${args.version ?? "latest"}`;
113
113
  const command = pmCommand(pm);
114
114
  const cmd = installArgs(pm, spec);
115
+ const { skillInstalled } = await import("./skill-BsZKAgGI.mjs");
116
+ const refreshSkill = skillInstalled(process.cwd());
115
117
  console.log(`Upgrading via ${command}: ${command} ${cmd.join(" ")}`);
116
118
  await run(command, cmd);
117
119
  console.log(`\nDone. Run \`canopy --version\` to confirm.`);
118
- const { skillInstalled } = await import("./skill-CObIJMP5.mjs");
119
- if (skillInstalled(process.cwd())) {
120
+ if (refreshSkill) {
120
121
  console.log("Refreshing the Canopy agent skill in this repo…");
121
122
  await run("canopy", ["skill", "install"]).catch((err) => {
122
123
  console.warn(`Could not auto-refresh the skill (${err instanceof Error ? err.message : String(err)}). Run \`canopy skill install\` yourself.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
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-server": "npm:vite@^7",
22
- "@mediamonks/canopy": "0.0.2",
23
- "@mediamonks/canopy-data-plane": "0.0.1"
22
+ "@mediamonks/canopy-data-plane": "0.0.1",
23
+ "@mediamonks/canopy": "0.0.2"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^26.1.1",
@@ -1,2 +0,0 @@
1
- import { t as devCommand } from "./dev-DdUJbbfA.mjs";
2
- export { devCommand };