@mediamonks/canopy-cli 0.7.0 → 0.7.1

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.
@@ -51,6 +51,14 @@ canopy promote # the same migrations replay against live, then v g
51
51
  A migration that fails on staging costs you nothing — live never saw it. See
52
52
  [Schema migrations](https://docs.canopy.website/guides/migrations) for the migration system itself.
53
53
 
54
+ ## Staging an older version
55
+
56
+ Any version in the deploy history can be pointed at the staging channel —
57
+ from the dashboard's deploy list (the **Stage** action, next to Rollback) or
58
+ with `canopy staging use v3`. Like rollback, it's a pointer move: nothing is
59
+ rebuilt, and live is untouched. Handy for comparing an old build against the
60
+ staging data, or re-testing a version before promoting it.
61
+
54
62
  ## Keeping staging fresh
55
63
 
56
64
  Staging data drifts as you test. Re-clone it from live anytime:
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-CDB-uxy3.mjs";
2
+ import { t as version } from "./package-WhBa4V15.mjs";
3
3
  import { r as siteHeaderLine, t as setInvocationProfile } from "./site-BUlQR117.mjs";
4
4
  import { i as runRefresh, r as notifyOfUpdate } from "./version-check-Cuh6HaLX.mjs";
5
5
  import { defineCommand, runMain } from "citty";
@@ -83,7 +83,7 @@ const main = defineCommand({
83
83
  dev: () => import("./dev-CvtoGFW0.mjs").then((m) => m.devCommand),
84
84
  deploy: () => import("./deploy-BcczXlSQ.mjs").then((m) => m.deployCommand),
85
85
  promote: () => import("./deploy-BcczXlSQ.mjs").then((m) => m.promoteCommand),
86
- staging: () => import("./staging-CfF2-pHs.mjs").then((m) => m.stagingCommand),
86
+ staging: () => import("./staging-9bvgl2B5.mjs").then((m) => m.stagingCommand),
87
87
  rollback: () => import("./deploy-BcczXlSQ.mjs").then((m) => m.rollbackCommand),
88
88
  download: () => import("./deploy-BcczXlSQ.mjs").then((m) => m.downloadCommand),
89
89
  token: () => import("./token-nieJV1w7.mjs").then((m) => m.tokenCommand),
@@ -91,8 +91,8 @@ const main = defineCommand({
91
91
  usage: () => import("./usage-qqPtkDtT.mjs").then((m) => m.usageCommand),
92
92
  open: () => import("./open-DD9oa-Ho.mjs").then((m) => m.openCommand),
93
93
  docs: () => import("./docs-2cUEug69.mjs").then((m) => m.docsCommand),
94
- skill: () => import("./skill-DrWzmUMv.mjs").then((m) => m.skillCommand),
95
- upgrade: () => import("./upgrade-CH_jHkc7.mjs").then((m) => m.upgradeCommand),
94
+ skill: () => import("./skill-Di9GQYYx.mjs").then((m) => m.skillCommand),
95
+ upgrade: () => import("./upgrade-CZwo05Tz.mjs").then((m) => m.upgradeCommand),
96
96
  logs: planned("logs", "Tail worker logs", "2")
97
97
  }
98
98
  });
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.7.0";
2
+ var version = "0.7.1";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-CDB-uxy3.mjs";
1
+ import { t as version } from "./package-WhBa4V15.mjs";
2
2
  import { n as reportErrors } from "./ui-D8HxX0Ng.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -13,7 +13,7 @@ const fetchStatus = (slug) => apiRequest("GET", `/projects/${slug}/staging`);
13
13
  const stagingCommand = defineCommand({
14
14
  meta: {
15
15
  name: "staging",
16
- description: "Staging channel: status, sync, destroy"
16
+ description: "Staging channel: status, use, sync, destroy"
17
17
  },
18
18
  subCommands: {
19
19
  status: defineCommand({
@@ -35,6 +35,48 @@ const stagingCommand = defineCommand({
35
35
  if (staging.version !== null && staging.version !== staging.live) console.log(` \`canopy promote\` makes v${staging.version} live`);
36
36
  })
37
37
  }),
38
+ use: defineCommand({
39
+ meta: {
40
+ name: "use",
41
+ description: "Serve an existing version on the staging channel (pick from history)"
42
+ },
43
+ args: {
44
+ version: {
45
+ type: "positional",
46
+ description: "Version to stage, e.g. v3 (picked from a list when omitted)",
47
+ required: false
48
+ },
49
+ ...projectFlagArgs
50
+ },
51
+ run: reportErrors("staging use", async ({ args }) => {
52
+ const { slug } = resolveProject(args);
53
+ let target;
54
+ if (args.version !== void 0) {
55
+ if (!/^v?\d+$/.test(args.version)) throw new Error(`Invalid version "${args.version}" — expected a number like 3 or v3.`);
56
+ target = Number(args.version.replace(/^v/, ""));
57
+ } else {
58
+ requireTty("pass a version, e.g. `canopy staging use v3`.");
59
+ const { deploys, live, staging: staged } = await apiRequest("GET", `/projects/${slug}/deploys`);
60
+ if (deploys.length === 0) throw new Error("This project has no deploys yet.");
61
+ target = unwrap(await p.select({
62
+ message: "Version to serve on staging",
63
+ options: deploys.map((deploy) => ({
64
+ value: deploy.version,
65
+ label: `v${deploy.version} ${deploy.created_at} (${deploy.source})`,
66
+ hint: deploy.version === staged ? "staged" : deploy.version === live ? "live" : void 0
67
+ }))
68
+ }));
69
+ }
70
+ const { staging: result } = await withContext(apiRequest("POST", `/projects/${slug}/deploys/${target}/stage`), {
71
+ action: `stage "${slug}" v${target}`,
72
+ fixes: {
73
+ staging_not_provisioned: "This project has no staging channel yet — create one in the dashboard's Settings, or with `canopy deploy --staging`.",
74
+ already_staged: `v${target} is already the staged version.`
75
+ }
76
+ });
77
+ console.log(`Staging: ${stagingUrl(slug)} (v${result.version}, was v${result.previous ?? "—"})`);
78
+ })
79
+ }),
38
80
  sync: defineCommand({
39
81
  meta: {
40
82
  name: "sync",
@@ -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-DrWzmUMv.mjs");
115
+ const { skillInstalled } = await import("./skill-Di9GQYYx.mjs");
116
116
  const refreshSkill = skillInstalled(process.cwd());
117
117
  console.log(`Upgrading via ${command}: ${command} ${cmd.join(" ")}`);
118
118
  await run(command, cmd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"