@mediamonks/canopy-cli 0.7.54 → 0.7.55

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.
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-BDKvR7By.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { r as siteConfig } from "./site-C0nf9RXY.mjs";
3
3
  import { i as latestKnownVersion, r as compareSemver } from "./version-check-CcsA1QjI.mjs";
4
4
  import { n as agentHeaders } from "./api-D4KUT6Ly.mjs";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-BDKvR7By.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { f as resolveProject, g as tryResolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-C0nf9RXY.mjs";
3
3
  import { a as apiRequest, c as credentials, i as apiDownload, o as apiUpload, s as commonHeaders } from "./api-D4KUT6Ly.mjs";
4
4
  import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-BDKvR7By.mjs";
2
+ import { t as version } from "./package-B_o_DJ8u.mjs";
3
3
  import { i as siteHeaderLine, n as setInvocationProfile } from "./site-C0nf9RXY.mjs";
4
4
  import { a as notifyOfUpdate, o as runRefresh } from "./version-check-CcsA1QjI.mjs";
5
5
  import { defineCommand, runMain } from "citty";
@@ -54,10 +54,10 @@ const main = defineCommand({
54
54
  login: () => import("./login-cbwynFoT.mjs").then((m) => m.loginCommand),
55
55
  whoami: () => import("./login-cbwynFoT.mjs").then((m) => m.whoamiCommand),
56
56
  logout: () => import("./login-cbwynFoT.mjs").then((m) => m.logoutCommand),
57
- create: () => import("./projects-ztlDQi0P.mjs").then((m) => m.createCommand),
58
- init: () => import("./projects-ztlDQi0P.mjs").then((m) => m.initCommand),
59
- projects: () => import("./projects-ztlDQi0P.mjs").then((m) => m.projectsCommand),
60
- delete: () => import("./projects-ztlDQi0P.mjs").then((m) => m.deleteCommand),
57
+ create: () => import("./projects-BBm9nQb0.mjs").then((m) => m.createCommand),
58
+ init: () => import("./projects-BBm9nQb0.mjs").then((m) => m.initCommand),
59
+ projects: () => import("./projects-BBm9nQb0.mjs").then((m) => m.projectsCommand),
60
+ delete: () => import("./projects-BBm9nQb0.mjs").then((m) => m.deleteCommand),
61
61
  rename: () => import("./rename-BZ8hvUUt.mjs").then((m) => m.renameCommand),
62
62
  dev: () => import("./dev-wHv8RrDn.mjs").then((m) => m.devCommand),
63
63
  deploy: () => import("./deploy-DHjZj2Pq.mjs").then((m) => m.deployCommand),
@@ -72,18 +72,18 @@ const main = defineCommand({
72
72
  roles: () => import("./roles-DvywfJ8x.mjs").then((m) => m.rolesCommand),
73
73
  members: () => import("./roles-DvywfJ8x.mjs").then((m) => m.membersCommand),
74
74
  schedule: () => import("./schedule-Cv26MIfS.mjs").then((m) => m.scheduleCommand),
75
- feedback: () => import("./feedback-CFaqNiiw.mjs").then((m) => m.feedbackCommand),
75
+ feedback: () => import("./feedback-Bzu_KQtb.mjs").then((m) => m.feedbackCommand),
76
76
  db: () => import("./db-Dy1csI71.mjs").then((m) => m.dbCommand),
77
77
  files: () => import("./files-DKtyMjY0.mjs").then((m) => m.filesCommand),
78
78
  usage: () => import("./usage-DBhL6SUo.mjs").then((m) => m.usageCommand),
79
79
  ai: () => import("./ai-BlqO9NhM.mjs").then((m) => m.aiCommand),
80
80
  open: () => import("./open-CYfkeTaw.mjs").then((m) => m.openCommand),
81
81
  browse: () => import("./browse-CW3CnhK_.mjs").then((m) => m.browseCommand),
82
- docs: () => import("./docs-CoH01QrG.mjs").then((m) => m.docsCommand),
83
- skill: () => import("./skill-BXlKClK3.mjs").then((m) => m.skillCommand),
84
- upgrade: () => import("./upgrade-CJln-B-I.mjs").then((m) => m.upgradeCommand),
82
+ docs: () => import("./docs-DdSbSiCj.mjs").then((m) => m.docsCommand),
83
+ skill: () => import("./skill-DAlJwr4A.mjs").then((m) => m.skillCommand),
84
+ upgrade: () => import("./upgrade-DN0JQ7gm.mjs").then((m) => m.upgradeCommand),
85
85
  logs: () => import("./logs-ByDPHO28.mjs").then((m) => m.logsCommand),
86
- mcp: () => import("./mcp-B8VXA-TE.mjs").then((m) => m.mcpCommand),
86
+ mcp: () => import("./mcp-DmWfG-NS.mjs").then((m) => m.mcpCommand),
87
87
  repo: () => import("./repo-fDD4TcJ4.mjs").then((m) => m.repoCommand),
88
88
  template: () => import("./project-template-B6YpesjZ.mjs").then((m) => m.templateCommand),
89
89
  audience: () => import("./audience-Dlrsdthb.mjs").then((m) => m.audienceCommand)
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-BDKvR7By.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { d as projectUrl, g as tryResolveProject, m as stagingUrl, r as siteConfig } from "./site-C0nf9RXY.mjs";
3
3
  import { a as apiRequest, f as noticeRenamesOnly, l as currentSlug, t as ApiError } from "./api-D4KUT6Ly.mjs";
4
4
  import { t as liveDevServer } from "./dev-server-file-Dk9pk4AR.mjs";
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.7.54";
2
+ var version = "0.7.55";
3
3
  //#endregion
4
4
  export { version as t };
@@ -8,6 +8,54 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from
8
8
  import { join, relative, resolve, sep } from "node:path";
9
9
  import * as p from "@clack/prompts";
10
10
  import { fileURLToPath } from "node:url";
11
+ const SLUG_RE = new RegExp(`^[a-z](?:[a-z0-9-]{0,38}[a-z0-9])?$`);
12
+ /** The gateway's host-label separator (`v12-dot-<slug>` preview hosts) — never in a slug. */
13
+ const HOST_LABEL_SEPARATOR = "-dot-";
14
+ /** Hostnames the gateway owns or that would confuse humans — never project slugs. */
15
+ const RESERVED_SLUGS = /* @__PURE__ */ new Set([
16
+ "admin",
17
+ "api",
18
+ "app",
19
+ "auth",
20
+ "canopy",
21
+ "dashboard",
22
+ "dev",
23
+ "docs",
24
+ "mail",
25
+ "staging",
26
+ "status",
27
+ "www"
28
+ ]);
29
+ /** Why the API would refuse `slug`, as a prompt message, or undefined when it is fine. */
30
+ function slugRuleProblem(slug) {
31
+ if (!SLUG_RE.test(slug)) return "Up to 40 characters: lowercase letters, digits and dashes, starting with a letter and not ending in a dash.";
32
+ if (slug.includes("-dot-")) return `"-dot-" is reserved for preview hostnames.`;
33
+ if (RESERVED_SLUGS.has(slug)) return `"${slug}" is reserved for the platform.`;
34
+ }
35
+ /** Prefix for a name that starts with a digit: "2026 plan" → "p-2026-plan". */
36
+ const DIGIT_PREFIX = "p-";
37
+ /** Slug for a name with nothing usable in it ("!!!", "Ωμέγα"). */
38
+ const EMPTY_FALLBACK = "project";
39
+ /** Suffix that frees a reserved name: "Admin" → "admin-project". */
40
+ const RESERVED_SUFFIX = "-project";
41
+ /**
42
+ * A project slug from a free-form name that the API always accepts:
43
+ * lowercase, runs of anything but a-z 0-9 become one dash, no "-dot-",
44
+ * at most 40 characters, never ending in a dash. A name starting with a
45
+ * digit gets a `p-` prefix (slugs start with a letter), a reserved name gets
46
+ * a `-project` suffix, and a name with nothing usable becomes `project`.
47
+ * Whether the slug is still free is the API's call.
48
+ */
49
+ function slugify(input) {
50
+ let slug = input.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/(^-+|-+$)/g, "");
51
+ while (slug.includes(HOST_LABEL_SEPARATOR)) slug = slug.replaceAll(HOST_LABEL_SEPARATOR, "-");
52
+ if (/^\d/.test(slug)) slug = DIGIT_PREFIX + slug;
53
+ slug = slug.slice(0, 40).replace(/-+$/, "");
54
+ if (!slug) return EMPTY_FALLBACK;
55
+ if (RESERVED_SLUGS.has(slug)) return slug + RESERVED_SUFFIX;
56
+ return slug;
57
+ }
58
+ //#endregion
11
59
  //#region src/template.ts
12
60
  /**
13
61
  * Template registry + scaffolder for `canopy create`. Templates are real,
@@ -92,11 +140,6 @@ function projectRows(projects, isAdmin) {
92
140
  const roleWidth = Math.max(...roles.map((role) => role.length));
93
141
  return projects.map((project, i) => `${project.slug.padEnd(width)} ${project.status.padEnd(7)} ${roles[i].padEnd(roleWidth)} ${projectUrl(project.slug)} ${project.name}`);
94
142
  }
95
- function slugify(input) {
96
- let slug = input.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/(^-+|-+$)/g, "").slice(0, 40);
97
- while (slug.includes("-dot-")) slug = slug.replaceAll("-dot-", "-");
98
- return slug;
99
- }
100
143
  function shouldScaffoldCreate(requested, cwd = process.cwd()) {
101
144
  return requested ?? !existsSync(join(cwd, "canopy.json"));
102
145
  }
@@ -160,10 +203,7 @@ const createCommand = defineCommand({
160
203
  message: "Slug",
161
204
  defaultValue: slugify(name),
162
205
  placeholder: slugify(name),
163
- validate: (value) => {
164
- if (value && !/^[a-z0-9][a-z0-9-]*$/.test(value)) return "Lowercase letters, digits and dashes only.";
165
- if (value?.includes("-dot-")) return `"-dot-" is reserved for preview hostnames.`;
166
- }
206
+ validate: (value) => value ? slugRuleProblem(value) : void 0
167
207
  })).trim();
168
208
  slug ||= slugify(name);
169
209
  if (args.from) {
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-BDKvR7By.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -112,7 +112,7 @@ 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-BXlKClK3.mjs");
115
+ const { skillInstalled } = await import("./skill-DAlJwr4A.mjs");
116
116
  const { homedir } = await import("node:os");
117
117
  const refreshGlobal = skillInstalled(homedir());
118
118
  const refreshRepo = process.cwd() !== homedir() && skillInstalled(process.cwd());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.7.54",
3
+ "version": "0.7.55",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"