@mediamonks/canopy-cli 0.7.61 → 0.7.62

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.
Files changed (50) hide show
  1. package/dist/{ai-4Mr9FbLU.mjs → ai-CGYbKeZq.mjs} +2 -2
  2. package/dist/{api-CpG-9WSe.mjs → api-C2cvuMD1.mjs} +6 -5
  3. package/dist/{audience-BXXdvGC_.mjs → audience-BspIO-MA.mjs} +2 -2
  4. package/dist/{browse-BegddW9V.mjs → browse-CAidI-BT.mjs} +1 -1
  5. package/dist/{calls-NFUccBaQ.mjs → calls-CSO-qNB2.mjs} +2 -2
  6. package/dist/{cors-B90J32_O.mjs → cors-Csvzy1Oo.mjs} +2 -2
  7. package/dist/{db-DIxujtt1.mjs → db-BKo39uJt.mjs} +3 -3
  8. package/dist/{deploy-Qe5jRWpi.mjs → deploy-D57a-99C.mjs} +3 -3
  9. package/dist/dev-CiMcqGqA.mjs +2 -0
  10. package/dist/{dev-AkM6kLVb.mjs → dev-CtjY0gJX.mjs} +6 -6
  11. package/dist/docs/cli-preview.md +55 -0
  12. package/dist/docs/cli.md +4 -0
  13. package/dist/docs/index.json +10 -0
  14. package/dist/docs/platform-link-previews.md +53 -0
  15. package/dist/docs/platform-members-and-access.md +3 -0
  16. package/dist/{docs-Cvrkba0X.mjs → docs-D1SWYMZ-.mjs} +3 -3
  17. package/dist/{egress-Dwq-d6cB.mjs → egress-bVy6U5ho.mjs} +2 -2
  18. package/dist/{feedback-DqZqxMQr.mjs → feedback-w28FscrZ.mjs} +3 -3
  19. package/dist/{files-CUPtGcuZ.mjs → files-DVFs1rmn.mjs} +2 -2
  20. package/dist/index.mjs +40 -39
  21. package/dist/{local-CFxKguzg.mjs → local-BZWFMNJI.mjs} +2 -2
  22. package/dist/login-DAHC8CD3.mjs +355 -0
  23. package/dist/{logs-BwqG7lYU.mjs → logs-DTXFm5DB.mjs} +2 -2
  24. package/dist/{mcp-CkCiu-1J.mjs → mcp-LQyQtnsW.mjs} +2 -2
  25. package/dist/{migrations-DJrRnU7X.mjs → migrations-Bmid64rT.mjs} +1 -1
  26. package/dist/{open-5JLHiz_J.mjs → open-B2fimu3z.mjs} +1 -1
  27. package/dist/{package-CyuzTQmN.mjs → package-Cc9gi9C-.mjs} +1 -1
  28. package/dist/preview-BRehGrPg.mjs +134 -0
  29. package/dist/{project-template-CsTOpPto.mjs → project-template-BGMJlxXz.mjs} +2 -2
  30. package/dist/project-template-Ckh8JDkS.mjs +2 -0
  31. package/dist/{projects-DCFn4zcq.mjs → projects-B3ycJGaX.mjs} +4 -4
  32. package/dist/{rename-OeOI97da.mjs → rename-BY2_4F4b.mjs} +2 -2
  33. package/dist/{repo-CIEG53hP.mjs → repo-DW3fAOnG.mjs} +2 -2
  34. package/dist/repo-xl6Rb6BC.mjs +2 -0
  35. package/dist/{roles-BCJWHeGq.mjs → roles-IYzhMOb4.mjs} +2 -2
  36. package/dist/{roles-2Pkqiwrx.mjs → roles-wEgE5ICf.mjs} +1 -1
  37. package/dist/{schedule-Cy-7IFy5.mjs → schedule-D6tTBal3.mjs} +2 -2
  38. package/dist/{secrets-Cgte8mvq.mjs → secrets-CBVVCn6s.mjs} +2 -2
  39. package/dist/{skill-CCz7sQ1t.mjs → skill-BUWRlQd3.mjs} +2 -2
  40. package/dist/{staging-D6-Ojy39.mjs → staging-CSv8OWNT.mjs} +2 -2
  41. package/dist/{token-yAj7pF78.mjs → token-DakMHZEr.mjs} +2 -2
  42. package/dist/{ui-BUeiY_zZ.mjs → ui-CVzXhfWN.mjs} +1 -1
  43. package/dist/{upgrade-vJEkO28k.mjs → upgrade-B-ELQVun.mjs} +2 -2
  44. package/dist/{usage-BXPm04tk.mjs → usage-DcDBqrLf.mjs} +2 -2
  45. package/dist/{versions-C204ivt9.mjs → versions-DKVNY2Zo.mjs} +2 -2
  46. package/package.json +1 -1
  47. package/dist/dev-pj6lLjMR.mjs +0 -2
  48. package/dist/login-CP1fO_AH.mjs +0 -355
  49. package/dist/project-template-xNjGs9ty.mjs +0 -2
  50. package/dist/repo-BW7dDQZL.mjs +0 -2
@@ -0,0 +1,134 @@
1
+ import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
2
+ import { a as apiRequest, m as withContext, o as apiUpload } from "./api-C2cvuMD1.mjs";
3
+ import { i as reportErrors } from "./ui-CVzXhfWN.mjs";
4
+ import { defineCommand } from "citty";
5
+ import { readFileSync } from "node:fs";
6
+ import { basename } from "node:path";
7
+ import * as p from "@clack/prompts";
8
+ //#region src/preview.ts
9
+ /**
10
+ * Link preview (OpenSpec change project-link-preview): `canopy preview
11
+ * show|on|off|image|icon`. What a shared link to the project shows while the
12
+ * project stays behind sign-in: its name and description, plus an optional
13
+ * preview image and icon. Stored on the platform (never in canopy.json); the
14
+ * icon is also the project's mark on the dashboard.
15
+ */
16
+ const FIXES = {
17
+ unsupported_image_type: "A preview image must be PNG, JPEG or WebP; an icon PNG, WebP, ICO or SVG.",
18
+ unsafe_svg: "Use a plain SVG: no scripts, event handlers, embedded HTML or links to other files. Exporting it again from a design tool usually does it.",
19
+ image_too_large: "A preview image can be up to 1 MB, an icon up to 256 KB."
20
+ };
21
+ function size(bytes) {
22
+ return bytes < 1024 * 1024 ? `${Math.max(1, Math.round(bytes / 1024))} KB` : `${(bytes / 1024 / 1024).toFixed(1)} MB`;
23
+ }
24
+ const TYPE_LABELS = {
25
+ "image/png": "PNG",
26
+ "image/jpeg": "JPEG",
27
+ "image/webp": "WebP",
28
+ "image/x-icon": "ICO",
29
+ "image/svg+xml": "SVG"
30
+ };
31
+ function fileLine(label, file) {
32
+ return file ? `${label}: ${TYPE_LABELS[file.content_type] ?? file.content_type}, ${size(file.size_bytes)}` : `${label}: none`;
33
+ }
34
+ /** The settings as a few lines for people. */
35
+ function describePreview(slug, settings) {
36
+ return [
37
+ settings.link_preview ? `Link preview is on: shared links to ${slug} show its name, description, image and icon.` : `Link preview is off: shared links to ${slug} show "${slug} · Sign in · Canopy".`,
38
+ fileLine("Preview image", settings.image),
39
+ fileLine("Icon", settings.icon)
40
+ ];
41
+ }
42
+ /** A content-type hint from the file name; the platform reads the bytes anyway. */
43
+ function contentTypeHint(path) {
44
+ return {
45
+ png: "image/png",
46
+ jpg: "image/jpeg",
47
+ jpeg: "image/jpeg",
48
+ webp: "image/webp",
49
+ ico: "image/x-icon",
50
+ svg: "image/svg+xml"
51
+ }[path.slice(path.lastIndexOf(".") + 1).toLowerCase()] ?? "application/octet-stream";
52
+ }
53
+ const read = (slug) => withContext(apiRequest("GET", `/projects/${slug}/preview`), { action: `read ${slug}'s link preview` });
54
+ const showCommand = defineCommand({
55
+ meta: {
56
+ name: "show",
57
+ description: "Show whether link preview is on, and the image and icon"
58
+ },
59
+ args: { ...projectDirArgs },
60
+ run: reportErrors("preview show", async ({ args }) => {
61
+ const { slug } = resolveProject(args);
62
+ for (const line of describePreview(slug, await read(slug))) console.log(line);
63
+ })
64
+ });
65
+ function switchCommand(on) {
66
+ return defineCommand({
67
+ meta: {
68
+ name: on ? "on" : "off",
69
+ description: on ? "Show the project's name, description, image and icon in shared links" : "Show only the slug in shared links"
70
+ },
71
+ args: { ...projectDirArgs },
72
+ run: reportErrors(`preview ${on ? "on" : "off"}`, async ({ args }) => {
73
+ const { slug } = resolveProject(args);
74
+ await withContext(apiRequest("PATCH", `/projects/${slug}`, { link_preview: on }), { action: `update ${slug}` });
75
+ for (const line of describePreview(slug, await read(slug))) p.log.info(line);
76
+ if (on) p.log.warn("Anyone with a link can now see the name, description, image and icon without signing in.");
77
+ })
78
+ });
79
+ }
80
+ function fileCommand(kind) {
81
+ const what = kind === "image" ? "preview image" : "icon";
82
+ return defineCommand({
83
+ meta: {
84
+ name: kind,
85
+ description: kind === "image" ? "Set the preview image (PNG, JPEG or WebP, up to 1 MB), or --remove it" : "Set the icon (PNG, WebP, ICO or SVG, up to 256 KB), or --remove it"
86
+ },
87
+ args: {
88
+ file: {
89
+ type: "positional",
90
+ description: `The ${what} file`,
91
+ required: false
92
+ },
93
+ remove: {
94
+ type: "boolean",
95
+ description: `Remove the ${what}`
96
+ },
97
+ ...projectFlagArgs
98
+ },
99
+ run: reportErrors(`preview ${kind}`, async ({ args }) => {
100
+ const { slug } = resolveProject({ project: args.project });
101
+ if (args.remove) {
102
+ await withContext(apiRequest("DELETE", `/projects/${slug}/preview/${kind}`), { action: `remove ${slug}'s ${what}` });
103
+ p.log.success(`Removed the ${what}.`);
104
+ return;
105
+ }
106
+ if (!args.file) {
107
+ console.error(`Name the file: canopy preview ${kind} <file>, or --remove.`);
108
+ process.exit(1);
109
+ }
110
+ const bytes = new Uint8Array(readFileSync(args.file));
111
+ const settings = await withContext(apiUpload(`/projects/${slug}/preview/${kind}`, bytes, contentTypeHint(args.file), "PUT"), {
112
+ action: `upload ${basename(args.file)}`,
113
+ fixes: FIXES
114
+ });
115
+ p.log.success(fileLine(kind === "image" ? "Preview image" : "Icon", settings[kind]));
116
+ if (!settings.link_preview) p.log.info(kind === "icon" ? "It is the project's mark on the dashboard now. Shared links show it once you run `canopy preview on`." : "Shared links show it once you run `canopy preview on`.");
117
+ })
118
+ });
119
+ }
120
+ const previewCommand = defineCommand({
121
+ meta: {
122
+ name: "preview",
123
+ description: "What shared links to the project show (show, on, off, image, icon)"
124
+ },
125
+ subCommands: {
126
+ show: showCommand,
127
+ on: switchCommand(true),
128
+ off: switchCommand(false),
129
+ image: fileCommand("image"),
130
+ icon: fileCommand("icon")
131
+ }
132
+ });
133
+ //#endregion
134
+ export { previewCommand };
@@ -1,6 +1,6 @@
1
1
  import { f as resolveProject, l as projectDirArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  /** Plain words for the API's template errors. */
@@ -0,0 +1,2 @@
1
+ import { a as templateCommand } from "./project-template-BGMJlxXz.mjs";
2
+ export { templateCommand };
@@ -1,9 +1,9 @@
1
1
  import { d as projectUrl, h as tryReadCanopyJson, r as siteConfig } from "./site-Bz-fEyKS.mjs";
2
2
  import { d as HOST_LABEL_SEPARATOR } from "./src-Dlg7aeRj.mjs";
3
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
4
- import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-BUeiY_zZ.mjs";
5
- import { i as nextSteps, n as describeCopy, r as fetchTemplate, t as TEMPLATE_FIXES } from "./project-template-CsTOpPto.mjs";
6
- import { a as offerRepoOnCreate, i as githubOrigin, n as cloneProjectRepo } from "./repo-CIEG53hP.mjs";
3
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
4
+ import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-CVzXhfWN.mjs";
5
+ import { i as nextSteps, n as describeCopy, r as fetchTemplate, t as TEMPLATE_FIXES } from "./project-template-BGMJlxXz.mjs";
6
+ import { a as offerRepoOnCreate, i as githubOrigin, n as cloneProjectRepo } from "./repo-DW3fAOnG.mjs";
7
7
  import { defineCommand } from "citty";
8
8
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
9
9
  import { join, relative, resolve, sep } from "node:path";
@@ -1,6 +1,6 @@
1
1
  import { d as projectUrl, f as resolveProject, l as projectDirArgs, p as rewriteCanopyJsonSlug } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/rename.ts
@@ -1,6 +1,6 @@
1
1
  import { a as parseGithubRemote, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, o as parseRepositoryArg, r as siteConfig, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, f as noticeRenamesOnly, m as withContext, n as agentHeaders, u as followRename } from "./api-CpG-9WSe.mjs";
3
- import { i as reportErrors, n as formatDateTime, s as unwrap, t as confirmTypedSlug } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, f as noticeRenamesOnly, m as withContext, n as agentHeaders, u as followRename } from "./api-C2cvuMD1.mjs";
3
+ import { i as reportErrors, n as formatDateTime, s as unwrap, t as confirmTypedSlug } from "./ui-CVzXhfWN.mjs";
4
4
  import { a as parseCredentialInput, i as helperCommand, o as runCredentialHelper, r as fileTokenCache, t as RepoCredentialError } from "./repo-credential-CNDRM-tG.mjs";
5
5
  import { defineCommand } from "citty";
6
6
  import { existsSync, realpathSync } from "node:fs";
@@ -0,0 +1,2 @@
1
+ import { o as repoCommand } from "./repo-DW3fAOnG.mjs";
2
+ export { repoCommand };
@@ -1,6 +1,6 @@
1
1
  import { d as projectUrl, f as resolveProject, l as projectDirArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/roles.ts
@@ -1,2 +1,2 @@
1
- import { c as rolesCommand, o as membersCommand } from "./roles-BCJWHeGq.mjs";
1
+ import { c as rolesCommand, o as membersCommand } from "./roles-IYzhMOb4.mjs";
2
2
  export { membersCommand, rolesCommand };
@@ -1,6 +1,6 @@
1
1
  import { f as resolveProject, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { i as reportErrors, n as formatDateTime } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { i as reportErrors, n as formatDateTime } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  //#region src/schedule.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { f as resolveProject, l as projectDirArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { i as reportErrors, n as formatDateTime, s as unwrap } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { i as reportErrors, n as formatDateTime, s as unwrap } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/secrets.ts
@@ -1,5 +1,5 @@
1
- import { t as version } from "./package-CyuzTQmN.mjs";
2
- import { i as reportErrors } from "./ui-BUeiY_zZ.mjs";
1
+ import { t as version } from "./package-Cc9gi9C-.mjs";
2
+ import { i as reportErrors } from "./ui-CVzXhfWN.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
@@ -1,6 +1,6 @@
1
1
  import { d as projectUrl, f as resolveProject, m as stagingUrl, s as parseVersionArg, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { a as requireTty, i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { a as requireTty, i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/staging.ts
@@ -1,6 +1,6 @@
1
1
  import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest } from "./api-CpG-9WSe.mjs";
3
- import { i as reportErrors, n as formatDateTime } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest } from "./api-C2cvuMD1.mjs";
3
+ import { i as reportErrors, n as formatDateTime } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  const tokenCommand = defineCommand({
6
6
  meta: {
@@ -1,4 +1,4 @@
1
- import { t as ApiError } from "./api-CpG-9WSe.mjs";
1
+ import { t as ApiError } from "./api-C2cvuMD1.mjs";
2
2
  import { spawn } from "node:child_process";
3
3
  import { cancel, isCancel, spinner, text } from "@clack/prompts";
4
4
  //#region src/ui.ts
@@ -1,5 +1,5 @@
1
1
  import { t as PACKAGE_NAME } from "./version-check-CcsA1QjI.mjs";
2
- import { i as reportErrors } from "./ui-BUeiY_zZ.mjs";
2
+ import { i as reportErrors } from "./ui-CVzXhfWN.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { spawn } from "node:child_process";
5
5
  import { fileURLToPath } from "node:url";
@@ -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-CCz7sQ1t.mjs");
115
+ const { skillInstalled } = await import("./skill-BUWRlQd3.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());
@@ -1,6 +1,6 @@
1
1
  import { f as resolveProject, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { i as reportErrors } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { i as reportErrors } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  //#region src/usage.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { f as resolveProject, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
3
- import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-BUeiY_zZ.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-C2cvuMD1.mjs";
3
+ import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-CVzXhfWN.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/versions.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.7.61",
3
+ "version": "0.7.62",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"
@@ -1,2 +0,0 @@
1
- import { n as devCommand } from "./dev-AkM6kLVb.mjs";
2
- export { devCommand };