@mediamonks/canopy-cli 0.7.52 → 0.7.53
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/{ai-BjnuSjmw.mjs → ai-BlqO9NhM.mjs} +2 -2
- package/dist/{api-DmJrIsE7.mjs → api-D4KUT6Ly.mjs} +9 -8
- package/dist/{audience-BSvOEbco.mjs → audience-Dlrsdthb.mjs} +3 -3
- package/dist/{browse-BPLWhoFI.mjs → browse-CW3CnhK_.mjs} +2 -2
- package/dist/{calls-COIxX32d.mjs → calls-DFtWVJfv.mjs} +3 -3
- package/dist/{db-D5SXZrp5.mjs → db-Dy1csI71.mjs} +15 -18
- package/dist/{deploy-D8OZyhH8.mjs → deploy-DHjZj2Pq.mjs} +13 -19
- package/dist/dev-CVC7elOr.mjs +2 -0
- package/dist/{dev-BnzJ8a1u.mjs → dev-L5slb6ke.mjs} +7 -7
- package/dist/docs/cli-schedule.md +1 -1
- package/dist/docs/cli-token.md +1 -1
- package/dist/docs/developers-architecture.md +1 -1
- package/dist/docs/outside-sign-in.md +1 -1
- package/dist/docs/platform-client-access.md +1 -1
- package/dist/docs/platform-credentials.md +2 -2
- package/dist/docs/platform-egress.md +4 -4
- package/dist/docs/platform-schedules.md +4 -4
- package/dist/docs/porting-nextjs.md +23 -23
- package/dist/docs/staging.md +1 -1
- package/dist/docs/static-serving.md +6 -3
- package/dist/docs/troubleshooting.md +1 -1
- package/dist/{docs-Od4duFhd.mjs → docs-bnQLqEOn.mjs} +4 -4
- package/dist/{egress-BoGWBHRa.mjs → egress-hKpsJF84.mjs} +4 -10
- package/dist/{feedback-XEIHbeor.mjs → feedback-vHJwLyWF.mjs} +4 -4
- package/dist/{files-B7toJRlj.mjs → files-DKtyMjY0.mjs} +3 -3
- package/dist/index.mjs +39 -52
- package/dist/{local-R-INkPbU.mjs → local-B15wYk6z.mjs} +3 -3
- package/dist/{login-DrMr99-A.mjs → login-cbwynFoT.mjs} +3 -3
- package/dist/{logs-DJWrL6ja.mjs → logs-ByDPHO28.mjs} +3 -3
- package/dist/{mcp-misDO7O8.mjs → mcp-BmT4Es_B.mjs} +3 -3
- package/dist/{migrations-BReMlGWP.mjs → migrations-k5pyUUR0.mjs} +3 -3
- package/dist/{open-6ev_6m0p.mjs → open-CYfkeTaw.mjs} +2 -2
- package/dist/{package-DBdEKZ6u.mjs → package-DtU4jB_Z.mjs} +1 -1
- package/dist/{project-template-Bas1UN2O.mjs → project-template-B297eCQ0.mjs} +3 -3
- package/dist/project-template-B6YpesjZ.mjs +2 -0
- package/dist/{projects-BEBYhy6k.mjs → projects-ztlDQi0P.mjs} +28 -28
- package/dist/{rename-PIJmdzHk.mjs → rename-BZ8hvUUt.mjs} +3 -3
- package/dist/{repo-Dry87b9d.mjs → repo-BUIM4d_1.mjs} +4 -10
- package/dist/repo-fDD4TcJ4.mjs +2 -0
- package/dist/{roles-CXY226VM.mjs → roles-DvywfJ8x.mjs} +1 -1
- package/dist/{roles-CUFRTp_R.mjs → roles-Yn8U3cr-.mjs} +3 -3
- package/dist/{schedule-DJsclUxC.mjs → schedule-Cv26MIfS.mjs} +3 -3
- package/dist/{secrets-CV2IwVwU.mjs → secrets-C6tF7BI9.mjs} +3 -3
- package/dist/{site-BL5Ik-yj.mjs → site-C0nf9RXY.mjs} +8 -3
- package/dist/{skill-3RZw4vSI.mjs → skill-CRTV3ZQ1.mjs} +2 -2
- package/dist/{staging-B9sjqvfh.mjs → staging-C9mn0EBS.mjs} +6 -14
- package/dist/templates/spa/AGENTS.md +3 -3
- package/dist/templates/spa/README.md +2 -2
- package/dist/templates/spa/package.json +1 -1
- package/dist/templates/static/AGENTS.md +3 -3
- package/dist/templates/static/README.md +2 -2
- package/dist/templates/worker/AGENTS.md +3 -3
- package/dist/templates/worker/README.md +2 -2
- package/dist/templates/worker/package.json +1 -1
- package/dist/{token-BT2_ELX6.mjs → token-DIJtUPrE.mjs} +3 -3
- package/dist/{ui-Ddw4d2Nn.mjs → ui-BPq6-hKS.mjs} +16 -3
- package/dist/{upgrade-Dy4XV7iP.mjs → upgrade-LTEfQn4L.mjs} +2 -2
- package/dist/{usage-VMT75MZ4.mjs → usage-DBhL6SUo.mjs} +3 -3
- package/package.json +3 -3
- package/dist/dev-DSI3e4qP.mjs +0 -2
- package/dist/project-template-Dti_Mmnb.mjs +0 -2
- package/dist/repo-CGTFmIWM.mjs +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
2
|
-
import {
|
|
1
|
+
import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
|
|
2
|
+
import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/ai.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as tryReadCanopyJson, p as rewriteCanopyJsonSlug, r as siteConfig, t as projectDir } from "./site-C0nf9RXY.mjs";
|
|
2
2
|
//#region src/api.ts
|
|
3
3
|
/**
|
|
4
4
|
* Authenticated requests to the Canopy control plane. Credentials, in order:
|
|
@@ -507,7 +507,7 @@ async function fail(response, kind, method, path) {
|
|
|
507
507
|
};
|
|
508
508
|
throw err;
|
|
509
509
|
}
|
|
510
|
-
async function apiRequest(method, path, body,
|
|
510
|
+
async function apiRequest(method, path, body, opts = {}) {
|
|
511
511
|
const { apiUrl, token, kind } = await credentials();
|
|
512
512
|
const isForm = body instanceof FormData;
|
|
513
513
|
const response = await fetch(`${apiUrl}/control/v1${path}`, {
|
|
@@ -515,10 +515,10 @@ async function apiRequest(method, path, body, rawContentType, headers) {
|
|
|
515
515
|
headers: {
|
|
516
516
|
...commonHeaders(),
|
|
517
517
|
authorization: `Bearer ${token}`,
|
|
518
|
-
...body === void 0 || isForm ? {} : { "content-type":
|
|
519
|
-
...headers
|
|
518
|
+
...body === void 0 || isForm ? {} : { "content-type": "application/json" },
|
|
519
|
+
...opts.headers
|
|
520
520
|
},
|
|
521
|
-
body: body === void 0 ? void 0 : isForm ? body :
|
|
521
|
+
body: body === void 0 ? void 0 : isForm ? body : JSON.stringify(body)
|
|
522
522
|
});
|
|
523
523
|
followRename(response, slugInPath(path));
|
|
524
524
|
if (!response.ok) return fail(response, kind, method, path);
|
|
@@ -560,7 +560,8 @@ async function apiDownload(path) {
|
|
|
560
560
|
* unscoped; the target project rides as X-Canopy-Project and the api. gateway
|
|
561
561
|
* re-vouches it (docs/10-cli-sites.md D17).
|
|
562
562
|
*/
|
|
563
|
-
async function apiDataRequest(method, path, projectSlug, body,
|
|
563
|
+
async function apiDataRequest(method, path, projectSlug, body, opts = {}) {
|
|
564
|
+
const { contentType, channel } = opts;
|
|
564
565
|
const { apiUrl, token, kind } = await credentials();
|
|
565
566
|
const response = await fetch(`${apiUrl}/data/v1${path}`, {
|
|
566
567
|
method,
|
|
@@ -569,9 +570,9 @@ async function apiDataRequest(method, path, projectSlug, body, rawContentType, c
|
|
|
569
570
|
authorization: `Bearer ${token}`,
|
|
570
571
|
"x-canopy-project": projectSlug,
|
|
571
572
|
...channel === "staging" ? { "x-canopy-channel": "staging" } : {},
|
|
572
|
-
...body === void 0 ? {} : { "content-type":
|
|
573
|
+
...body === void 0 ? {} : { "content-type": contentType ?? "application/json" }
|
|
573
574
|
},
|
|
574
|
-
body: body === void 0 ? void 0 :
|
|
575
|
+
body: body === void 0 ? void 0 : contentType !== void 0 ? body : JSON.stringify(body)
|
|
575
576
|
});
|
|
576
577
|
followRename(response, projectSlug);
|
|
577
578
|
if (!response.ok) return fail(response, kind, method, path);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
3
|
-
import {
|
|
1
|
+
import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
|
|
3
|
+
import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import * as p from "@clack/prompts";
|
|
6
6
|
//#region src/audience.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiRequest, t as ApiError } from "./api-
|
|
1
|
+
import { g as tryResolveProject, r as siteConfig } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest, t as ApiError } from "./api-D4KUT6Ly.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/browse.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
3
|
-
import {
|
|
1
|
+
import { f as resolveProject, l as projectDirArgs } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
|
|
3
|
+
import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
//#region src/calls.ts
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiRequest, m as withContext, r as apiDataRequest } from "./api-
|
|
3
|
-
import { a as
|
|
4
|
-
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-
|
|
1
|
+
import { f as resolveProject, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext, r as apiDataRequest } from "./api-D4KUT6Ly.mjs";
|
|
3
|
+
import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-BPq6-hKS.mjs";
|
|
4
|
+
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-k5pyUUR0.mjs";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
7
7
|
import * as p from "@clack/prompts";
|
|
@@ -49,7 +49,7 @@ const pullCommand = defineCommand({
|
|
|
49
49
|
const spin = spinner$1();
|
|
50
50
|
spin.start(`Exporting ${slug}${channelNote(args)}…`);
|
|
51
51
|
try {
|
|
52
|
-
const { url } = await apiDataRequest("POST", "/db/export", slug, void 0,
|
|
52
|
+
const { url } = await apiDataRequest("POST", "/db/export", slug, void 0, { channel: channelOf(args) });
|
|
53
53
|
const download = await fetch(url);
|
|
54
54
|
if (!download.ok) throw new Error(`Download failed (HTTP ${download.status}).`);
|
|
55
55
|
const sql = Buffer.from(await download.arrayBuffer());
|
|
@@ -76,7 +76,7 @@ const snapshotCommand = defineCommand({
|
|
|
76
76
|
spin.start(`Snapshotting ${slug}${channelNote(args)}…`);
|
|
77
77
|
let created;
|
|
78
78
|
try {
|
|
79
|
-
({snapshot: created} = await apiDataRequest("POST", "/db/snapshots", slug, void 0,
|
|
79
|
+
({snapshot: created} = await apiDataRequest("POST", "/db/snapshots", slug, void 0, { channel: channelOf(args) }));
|
|
80
80
|
} catch (err) {
|
|
81
81
|
spin.error("Snapshot failed.");
|
|
82
82
|
throw err;
|
|
@@ -147,7 +147,7 @@ const snapshotsDeleteCommand = defineCommand({
|
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
await withContext(apiDataRequest("DELETE", `/db/snapshots/${encodeURIComponent(args.key)}`, slug, void 0,
|
|
150
|
+
await withContext(apiDataRequest("DELETE", `/db/snapshots/${encodeURIComponent(args.key)}`, slug, void 0, { channel: channelOf(args) }), { action: `delete snapshot ${args.key} of "${slug}"` });
|
|
151
151
|
p.log.success(`Deleted ${args.key}${channelNote(args)}.`);
|
|
152
152
|
})
|
|
153
153
|
});
|
|
@@ -222,7 +222,7 @@ const snapshotsSettingsCommand = defineCommand({
|
|
|
222
222
|
});
|
|
223
223
|
const listSnapshotsRun = reportErrors("db snapshots", async ({ args }) => {
|
|
224
224
|
const { slug } = resolveProject(args);
|
|
225
|
-
const [{ snapshots }, settings] = await Promise.all([apiDataRequest("GET", "/db/snapshots", slug, void 0,
|
|
225
|
+
const [{ snapshots }, settings] = await Promise.all([apiDataRequest("GET", "/db/snapshots", slug, void 0, { channel: channelOf(args) }), apiRequest("GET", `/projects/${slug}/snapshot-settings`).catch(() => null)]);
|
|
226
226
|
if (settings) {
|
|
227
227
|
console.log(`Schedule: ${describeSchedule(settings)} · retention: ${describeRetention(settings)}`);
|
|
228
228
|
if (settings.lastRun) console.log(`Last scheduled run: ${describeLastRun(settings.lastRun)}`);
|
|
@@ -278,7 +278,7 @@ const restoreCommand = defineCommand({
|
|
|
278
278
|
let snapshotKey = args.snapshot;
|
|
279
279
|
if (!snapshotKey && !file) {
|
|
280
280
|
requireTty("pass a local .sql dump or --snapshot <key>.");
|
|
281
|
-
const { snapshots } = await apiDataRequest("GET", "/db/snapshots", slug, void 0,
|
|
281
|
+
const { snapshots } = await apiDataRequest("GET", "/db/snapshots", slug, void 0, { channel: channelOf(args) });
|
|
282
282
|
if (snapshots.length === 0) throw new Error(`No snapshots for ${slug} — run \`canopy db snapshot\` first, or pass a local .sql dump.`);
|
|
283
283
|
snapshotKey = unwrap(await p.select({
|
|
284
284
|
message: `Snapshot to restore into ${slug}`,
|
|
@@ -289,16 +289,13 @@ const restoreCommand = defineCommand({
|
|
|
289
289
|
}))
|
|
290
290
|
}));
|
|
291
291
|
}
|
|
292
|
-
if (!args.yes) {
|
|
293
|
-
requireTty("pass --yes to restore without confirmation.");
|
|
294
|
-
if (unwrap(await p.text({ message: `Restore will REPLACE all current data in "${slug}"${channelNote(args)} with ${snapshotKey ?? file}. Type the slug to confirm.` })).trim() !== slug) {
|
|
295
|
-
p.cancel("Aborted.");
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
292
|
+
if (!args.yes && !await confirmTypedSlug(slug, `Restore will REPLACE all current data in "${slug}"${channelNote(args)} with ${snapshotKey ?? file}. Type the slug to confirm.`, "pass --yes to restore without confirmation.")) return;
|
|
299
293
|
const restoreContext = { action: `restore "${slug}" from ${snapshotKey ?? file}` };
|
|
300
|
-
if (snapshotKey) await withContext(apiDataRequest("POST", "/db/restore", slug, { snapshot: snapshotKey },
|
|
301
|
-
else if (file) await withContext(apiDataRequest("POST", "/db/restore", slug, readFileSync(file, "utf8"),
|
|
294
|
+
if (snapshotKey) await withContext(apiDataRequest("POST", "/db/restore", slug, { snapshot: snapshotKey }, { channel: channelOf(args) }), restoreContext);
|
|
295
|
+
else if (file) await withContext(apiDataRequest("POST", "/db/restore", slug, readFileSync(file, "utf8"), {
|
|
296
|
+
contentType: "application/sql",
|
|
297
|
+
channel: channelOf(args)
|
|
298
|
+
}), restoreContext);
|
|
302
299
|
p.log.success(`Restored ${slug}${channelNote(args)}.`);
|
|
303
300
|
})
|
|
304
301
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiRequest, d as githubActionsCredentials, i as apiDownload, l as currentSlug, m as withContext, p as onGithubActions, r as apiDataRequest, t as ApiError } from "./api-
|
|
3
|
-
import {
|
|
4
|
-
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-
|
|
1
|
+
import { d as projectUrl, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, m as stagingUrl, r as siteConfig, s as parseVersionArg, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest, d as githubActionsCredentials, i as apiDownload, l as currentSlug, m as withContext, p as onGithubActions, r as apiDataRequest, t as ApiError } from "./api-D4KUT6Ly.mjs";
|
|
3
|
+
import { i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap } from "./ui-BPq6-hKS.mjs";
|
|
4
|
+
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-k5pyUUR0.mjs";
|
|
5
5
|
import { builtinModules } from "node:module";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -285,7 +285,7 @@ const deployCommand = defineCommand({
|
|
|
285
285
|
throw err;
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
const source =
|
|
288
|
+
const source = onGithubActions() ? { "x-canopy-source": "github-action" } : {};
|
|
289
289
|
const spin = spinner$1();
|
|
290
290
|
const workerNote = workerBytes ? " + worker" : "";
|
|
291
291
|
const channelNote = channel === "staging" ? " [staging]" : "";
|
|
@@ -297,7 +297,7 @@ const deployCommand = defineCommand({
|
|
|
297
297
|
const { upload } = await withContext(apiRequest("POST", `/projects/${slug}/deploys`, {
|
|
298
298
|
worker: workerBytes !== null,
|
|
299
299
|
channel
|
|
300
|
-
},
|
|
300
|
+
}, { headers: source }), { action: `deploy "${slug}"` });
|
|
301
301
|
stagingCreated = upload.stagingCreated === true;
|
|
302
302
|
const overLimit = bundleLimitError(files, upload);
|
|
303
303
|
if (overLimit) {
|
|
@@ -321,7 +321,7 @@ const deployCommand = defineCommand({
|
|
|
321
321
|
({deploy: result} = await withContext(apiRequest("POST", `/projects/${slug}/deploys/${upload.version}/complete`, {
|
|
322
322
|
grant: upload.grant,
|
|
323
323
|
migrations: migrateResult?.appliedNow ?? []
|
|
324
|
-
},
|
|
324
|
+
}, { headers: source }), { action: `deploy "${slug}"` }));
|
|
325
325
|
} catch (err) {
|
|
326
326
|
spin.error("Deploy failed.");
|
|
327
327
|
throw err;
|
|
@@ -360,10 +360,8 @@ const promoteCommand = defineCommand({
|
|
|
360
360
|
run: reportErrors("promote", async ({ args }) => {
|
|
361
361
|
const { slug } = resolveProject(args);
|
|
362
362
|
let target;
|
|
363
|
-
if (args.version !== void 0)
|
|
364
|
-
|
|
365
|
-
target = Number(args.version.replace(/^v/, ""));
|
|
366
|
-
} else {
|
|
363
|
+
if (args.version !== void 0) target = parseVersionArg(args.version);
|
|
364
|
+
else {
|
|
367
365
|
const { staging } = await apiRequest("GET", `/projects/${slug}/staging`);
|
|
368
366
|
if (!staging.provisioned || staging.version === null) throw new Error(`Nothing staged for "${slug}" — run \`canopy deploy --staging\` first, or pass a version explicitly.`);
|
|
369
367
|
target = staging.version;
|
|
@@ -493,10 +491,8 @@ const rollbackCommand = defineCommand({
|
|
|
493
491
|
run: reportErrors("rollback", async ({ args }) => {
|
|
494
492
|
const { slug } = resolveProject(args);
|
|
495
493
|
let target;
|
|
496
|
-
if (args.version !== void 0)
|
|
497
|
-
|
|
498
|
-
target = Number(args.version.replace(/^v/, ""));
|
|
499
|
-
} else {
|
|
494
|
+
if (args.version !== void 0) target = parseVersionArg(args.version);
|
|
495
|
+
else {
|
|
500
496
|
const { deploys, live } = await apiRequest("GET", `/projects/${slug}/deploys`);
|
|
501
497
|
if (deploys.length < 2) throw new Error("Nothing to roll back to — this project has fewer than two deploys.");
|
|
502
498
|
if (process.stdin.isTTY) {
|
|
@@ -537,10 +533,8 @@ const downloadCommand = defineCommand({
|
|
|
537
533
|
run: reportErrors("download", async ({ args }) => {
|
|
538
534
|
const { slug } = resolveProject(args);
|
|
539
535
|
let target;
|
|
540
|
-
if (args.version !== void 0)
|
|
541
|
-
|
|
542
|
-
target = Number(args.version.replace(/^v/, ""));
|
|
543
|
-
} else {
|
|
536
|
+
if (args.version !== void 0) target = parseVersionArg(args.version);
|
|
537
|
+
else {
|
|
544
538
|
const { deploys, live } = await apiRequest("GET", `/projects/${slug}/deploys`);
|
|
545
539
|
if (deploys.length === 0) throw new Error("Nothing to download — this project has no deploys yet.");
|
|
546
540
|
if (process.stdin.isTTY) target = await pickVersion(deploys, live, "Version to download", live ?? void 0);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { a as apiRequest, m as withContext, t as ApiError } from "./api-
|
|
3
|
-
import {
|
|
4
|
-
import { r as readMigrationFiles } from "./migrations-
|
|
1
|
+
import { c as projectDialect, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext, t as ApiError } from "./api-D4KUT6Ly.mjs";
|
|
3
|
+
import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
|
|
4
|
+
import { r as readMigrationFiles } from "./migrations-k5pyUUR0.mjs";
|
|
5
5
|
import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-UBUAqzqH.mjs";
|
|
6
|
-
import { a as parseAppRoleFlag } from "./roles-
|
|
6
|
+
import { a as parseAppRoleFlag } from "./roles-Yn8U3cr-.mjs";
|
|
7
7
|
import { n as writeDevServerRecord } from "./dev-server-file-Dk9pk4AR.mjs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { defineCommand } from "citty";
|
|
@@ -326,7 +326,7 @@ async function devRemote(flags, slug) {
|
|
|
326
326
|
async function devLocal(flags, slug) {
|
|
327
327
|
let dump;
|
|
328
328
|
if (flags.pull) {
|
|
329
|
-
const { fetchProjectDump } = await import("./local-
|
|
329
|
+
const { fetchProjectDump } = await import("./local-B15wYk6z.mjs");
|
|
330
330
|
console.log(`Pulling a fresh export of ${slug}${flags.staging ? " [staging]" : ""}…`);
|
|
331
331
|
dump = await fetchProjectDump(slug, flags.staging ? "staging" : "live");
|
|
332
332
|
}
|
|
@@ -343,7 +343,7 @@ async function devLocal(flags, slug) {
|
|
|
343
343
|
}
|
|
344
344
|
const workerAttest = randomBytes(24).toString("base64url");
|
|
345
345
|
const devRoles = await resolveDevRoles(slug, flags.asRoles);
|
|
346
|
-
const { createSandbox } = await import("./local-
|
|
346
|
+
const { createSandbox } = await import("./local-B15wYk6z.mjs");
|
|
347
347
|
const sandbox = await createSandbox({
|
|
348
348
|
slug,
|
|
349
349
|
persistDir: join(flags.dir, ".canopy", "local"),
|
|
@@ -4,7 +4,7 @@ description: List, add, and remove the project's cron schedules from the termina
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
`canopy schedule` manages the project's named cron jobs — the same schedules
|
|
7
|
-
as the dashboard's **
|
|
7
|
+
as the dashboard's **Backend → Schedules**, so a migration or an agent can
|
|
8
8
|
set up recurring jobs without leaving the terminal. See
|
|
9
9
|
[Schedules](https://docs.canopy.website/platform/schedules) for how schedules work and how your worker
|
|
10
10
|
handles them.
|
package/dist/docs/cli-token.md
CHANGED
|
@@ -32,7 +32,7 @@ The token belongs to the project rather than to whoever created it, so CI keeps
|
|
|
32
32
|
|
|
33
33
|
To use it in CI, put the value in the `CANOPY_DEPLOY_TOKEN` environment variable — the CLI checks it first, so `canopy deploy` works on a runner with no `canopy login`. In GitHub Actions a token wins over the linked repository, and keeps working while CI deploys are switched off.
|
|
34
34
|
|
|
35
|
-
If a deploy fails with a rejected token, it was likely revoked — create a fresh one here or in the dashboard (
|
|
35
|
+
If a deploy fails with a rejected token, it was likely revoked — create a fresh one here or in the dashboard (Deploys → Deploy tokens) and update the secret. Losing a token is never a problem: revoke the old id and mint a new one.
|
|
36
36
|
|
|
37
37
|
## Examples
|
|
38
38
|
|
|
@@ -114,7 +114,7 @@ else is still static serving. A few things to know:
|
|
|
114
114
|
const notes = await canopy.db.collection("notes").find();
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
- **Secrets and schedules come from the dashboard.** Secrets (
|
|
117
|
+
- **Secrets and schedules come from the dashboard.** Secrets (Backend →
|
|
118
118
|
Secrets) land as Workers-shaped bindings (`c.env.MY_API_KEY`, not
|
|
119
119
|
`process.env`); dashboard Schedules invoke an exported
|
|
120
120
|
`scheduled(event, env)` — switch on `event.name`.
|
|
@@ -14,7 +14,7 @@ one person without touching anyone else.
|
|
|
14
14
|
|
|
15
15
|
## Inviting someone
|
|
16
16
|
|
|
17
|
-
On the project's **Settings**
|
|
17
|
+
On the project's **Settings → Access** page, in the **Members** card, type the person's
|
|
18
18
|
full email address and add them. People outside Monks are always added as
|
|
19
19
|
**viewers**: they can open the app and nothing that manages it. You can give
|
|
20
20
|
them [app roles](https://docs.canopy.website/guides/roles) like anyone else.
|
|
@@ -28,7 +28,7 @@ The unlock is deliberately narrow:
|
|
|
28
28
|
|
|
29
29
|
## Enabling it
|
|
30
30
|
|
|
31
|
-
Open the project's **Settings**
|
|
31
|
+
Open the project's **Settings → Access** page and use the **Who outside Monks can open
|
|
32
32
|
it** card:
|
|
33
33
|
|
|
34
34
|
1. Set a password. Pick something you're comfortable saying out loud on a
|
|
@@ -66,8 +66,8 @@ too.
|
|
|
66
66
|
- **Your sign-in or a personal token:** use **Sign out everywhere** on your
|
|
67
67
|
Account page. It ends every browser session, CLI sign-in, `canopy dev` and
|
|
68
68
|
agent session, and personal token of yours at once.
|
|
69
|
-
- **A deploy token:** revoke it with `canopy token revoke` or
|
|
70
|
-
project's **
|
|
69
|
+
- **A deploy token:** revoke it with `canopy token revoke` or on the
|
|
70
|
+
project's **Deploys** tab, and make a new one.
|
|
71
71
|
- **A project key:** revoke it under the project's **Settings → Access**.
|
|
72
72
|
- **Not sure what it was?** Revoke it anyway. Making a new credential is
|
|
73
73
|
always cheap.
|
|
@@ -26,7 +26,7 @@ canopy egress list
|
|
|
26
26
|
canopy egress remove generativelanguage.googleapis.com
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Or in the dashboard: **
|
|
29
|
+
Or in the dashboard: **Backend → Outbound hosts**.
|
|
30
30
|
|
|
31
31
|
Changes apply to the **running** workers within moments — the platform re-rolls
|
|
32
32
|
the project's services with the new list, no deploy needed. Live and staging
|
|
@@ -75,7 +75,7 @@ so an allowed name can't lead your worker into the platform's own network.
|
|
|
75
75
|
|
|
76
76
|
You don't have to guess what got denied: the runtime reports every blocked
|
|
77
77
|
host back to the platform, and they show up as **Recently blocked** in
|
|
78
|
-
|
|
78
|
+
Backend → Outbound hosts (and in `canopy egress list`), with how often and
|
|
79
79
|
how recently each was hit. One click on **Allow** puts the host on the list
|
|
80
80
|
and clears it from the blocked section. Hosts that keep a low profile drop
|
|
81
81
|
off — the list remembers the 50 most recent — and allowing a host removes its
|
|
@@ -92,7 +92,7 @@ growing the list forever, switch the project to **open egress mode**:
|
|
|
92
92
|
canopy egress mode open
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
or in the dashboard: **
|
|
95
|
+
or in the dashboard: **Backend → Outbound hosts → Egress mode**. In open mode
|
|
96
96
|
the worker may fetch **any public hostname**. Three guardrails replace the
|
|
97
97
|
allowlist:
|
|
98
98
|
|
|
@@ -206,7 +206,7 @@ addresses. There the setting shows as always on and there is nothing to set.
|
|
|
206
206
|
In both modes, the platform keeps a per-project log of the hosts the worker
|
|
207
207
|
**actually fetched** — hostnames only, never paths, query strings, headers, or
|
|
208
208
|
bodies. Per host it tracks a fetch count and first/last seen. See it under
|
|
209
|
-
**Outbound traffic** in
|
|
209
|
+
**Outbound traffic** in Backend → Outbound hosts, or:
|
|
210
210
|
|
|
211
211
|
```bash
|
|
212
212
|
canopy egress log
|
|
@@ -10,12 +10,12 @@ platform wakes your project's backend at the right times; your code only
|
|
|
10
10
|
decides what each job does.
|
|
11
11
|
|
|
12
12
|
> **Note:** Schedules need a project with a custom backend. Per-project backends run on the **main** site and
|
|
13
|
-
> the **GCP pilot** site. On sites without backend support the Schedules section doesn't appear
|
|
14
|
-
>
|
|
13
|
+
> the **GCP pilot** site. On sites without backend support the Schedules section doesn't appear on
|
|
14
|
+
> the Backend tab, and the API answers `not_supported_on_target`.
|
|
15
15
|
|
|
16
16
|
## Defining a schedule
|
|
17
17
|
|
|
18
|
-
In the dashboard, open the project's **
|
|
18
|
+
In the dashboard, open the project's **Backend → Schedules**. Each schedule
|
|
19
19
|
has:
|
|
20
20
|
|
|
21
21
|
- a **name** (like `daily-digest`) — this is what your code switches on;
|
|
@@ -119,6 +119,6 @@ What happens around a run:
|
|
|
119
119
|
`kind: "worker"` and no identity.
|
|
120
120
|
- **All times are UTC.** `0 6 * * *` is 6:00 UTC, not local time.
|
|
121
121
|
- **Failures are visible.** A run that throws records its error on the
|
|
122
|
-
schedule row
|
|
122
|
+
schedule row on the Backend tab, so silent breakage doesn't stay silent.
|
|
123
123
|
|
|
124
124
|
- [How the platform serves your project](https://docs.canopy.website/developers/architecture) — Where your backend runs, and what it can reach — the same environment a scheduled run gets.
|
|
@@ -62,24 +62,24 @@ together as a single version, with rollback.
|
|
|
62
62
|
List everything in the app that runs on the server. Each item lands in one of
|
|
63
63
|
three buckets:
|
|
64
64
|
|
|
65
|
-
| Next.js feature | Where it goes on Canopy
|
|
66
|
-
| ----------------------------------------------- |
|
|
67
|
-
| Pages, layouts, client components | Static build (unchanged in spirit)
|
|
68
|
-
| Server components fetching data at request time | Client-side fetching, or a worker endpoint
|
|
69
|
-
| Route handlers (`app/api/*/route.ts`) | Worker endpoints under `/api/*`
|
|
70
|
-
| Server actions | Explicit worker endpoints, called with `fetch` from the client
|
|
71
|
-
| Middleware | Usually deleted (auth is platform-provided); anything else moves into the worker
|
|
72
|
-
| NextAuth / auth middleware | Deleted — use `canopy.auth.user()` (client) or `env.CALLER` (worker)
|
|
73
|
-
| Database (Prisma, Postgres, …) | `canopy.db` — per-project database, document API + SQL escape hatch
|
|
74
|
-
| File uploads (S3, …) | `canopy.blob` — per-project file storage with signed downloads
|
|
75
|
-
| AI SDK / OpenAI client | `canopy.ai.chat()`, or point the Vercel AI SDK at `canopy.ai.endpoint()`
|
|
76
|
-
| `NEXT_PUBLIC_*` env vars | Build-time env vars in your CI — the platform doesn't inject build config
|
|
77
|
-
| Server-side env vars / secrets | Project secrets (`canopy secrets set` or dashboard
|
|
78
|
-
| Cron (`vercel.json` crons) | [Schedules](https://docs.canopy.website/platform/schedules) — delivered to the worker's `scheduled()`
|
|
79
|
-
| ISR / `revalidate` / caching | Dropped — at internal-tool scale, fetch fresh or cache in the client
|
|
80
|
-
| `next/image` optimization | Plain `<img>`, or optimize at build time
|
|
81
|
-
| Custom domain | Not available — projects live at `<slug>.canopy.<domain>` behind sign-in
|
|
82
|
-
| Queues / background jobs | Not supported — restructure around request/response plus schedules
|
|
65
|
+
| Next.js feature | Where it goes on Canopy |
|
|
66
|
+
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
67
|
+
| Pages, layouts, client components | Static build (unchanged in spirit) |
|
|
68
|
+
| Server components fetching data at request time | Client-side fetching, or a worker endpoint |
|
|
69
|
+
| Route handlers (`app/api/*/route.ts`) | Worker endpoints under `/api/*` |
|
|
70
|
+
| Server actions | Explicit worker endpoints, called with `fetch` from the client |
|
|
71
|
+
| Middleware | Usually deleted (auth is platform-provided); anything else moves into the worker |
|
|
72
|
+
| NextAuth / auth middleware | Deleted — use `canopy.auth.user()` (client) or `env.CALLER` (worker) |
|
|
73
|
+
| Database (Prisma, Postgres, …) | `canopy.db` — per-project database, document API + SQL escape hatch |
|
|
74
|
+
| File uploads (S3, …) | `canopy.blob` — per-project file storage with signed downloads |
|
|
75
|
+
| AI SDK / OpenAI client | `canopy.ai.chat()`, or point the Vercel AI SDK at `canopy.ai.endpoint()` |
|
|
76
|
+
| `NEXT_PUBLIC_*` env vars | Build-time env vars in your CI — the platform doesn't inject build config |
|
|
77
|
+
| Server-side env vars / secrets | Project secrets (`canopy secrets set` or the dashboard's Backend tab) — injected into the worker's `env` |
|
|
78
|
+
| Cron (`vercel.json` crons) | [Schedules](https://docs.canopy.website/platform/schedules) — delivered to the worker's `scheduled()` |
|
|
79
|
+
| ISR / `revalidate` / caching | Dropped — at internal-tool scale, fetch fresh or cache in the client |
|
|
80
|
+
| `next/image` optimization | Plain `<img>`, or optimize at build time |
|
|
81
|
+
| Custom domain | Not available — projects live at `<slug>.canopy.<domain>` behind sign-in |
|
|
82
|
+
| Queues / background jobs | Not supported — restructure around request/response plus schedules |
|
|
83
83
|
|
|
84
84
|
If the last two rows are deal-breakers, stop here: see
|
|
85
85
|
[When not to port](#when-not-to-port).
|
|
@@ -126,7 +126,7 @@ type Env = {
|
|
|
126
126
|
CALLER: CanopyCaller | null;
|
|
127
127
|
/** The signed-in monk only; null for cron and client-password visitors. */
|
|
128
128
|
USER: { sub: string; email: string; name: string } | null;
|
|
129
|
-
/** Project secrets from dashboard
|
|
129
|
+
/** Project secrets from the dashboard's Backend tab appear as plain keys. */
|
|
130
130
|
MY_API_KEY?: string;
|
|
131
131
|
};
|
|
132
132
|
|
|
@@ -155,7 +155,7 @@ app.post("/api/submit", async (c) => {
|
|
|
155
155
|
|
|
156
156
|
export default {
|
|
157
157
|
fetch: app.fetch.bind(app),
|
|
158
|
-
// was: vercel.json crons — configure in dashboard
|
|
158
|
+
// was: vercel.json crons — configure in dashboard Backend → Schedules
|
|
159
159
|
async scheduled(event: { name: string }, env: Env) {
|
|
160
160
|
if (event.name === "nightly-report") {
|
|
161
161
|
// …
|
|
@@ -173,7 +173,7 @@ Rules of the road for the worker:
|
|
|
173
173
|
- **Outbound requests are controlled.** Calls to external APIs pass through a
|
|
174
174
|
per-project egress allowlist — deny-by-default, managed by you. Allow the
|
|
175
175
|
hosts your worker calls with `canopy egress allow <host>` or in dashboard
|
|
176
|
-
|
|
176
|
+
Backend → Outbound hosts (see [Outbound requests](https://docs.canopy.website/platform/egress)).
|
|
177
177
|
- Frontend calls are plain `fetch("/api/…")` — same origin, the platform
|
|
178
178
|
session cookie rides along automatically.
|
|
179
179
|
|
|
@@ -258,6 +258,6 @@ past greenhouse size (see [Use cases](https://docs.canopy.website/overview/use-c
|
|
|
258
258
|
- [ ] Worker: route handlers + server actions → `/api/*` endpoints in `worker/index.ts`
|
|
259
259
|
- [ ] Data: ORM → `canopy.db`; uploads → `canopy.blob`; AI clients → `canopy.ai`
|
|
260
260
|
- [ ] Delete NextAuth/middleware; read identity from `canopy.auth.user()` / `env.CALLER`
|
|
261
|
-
- [ ] Secrets via `canopy secrets set` (or dashboard
|
|
262
|
-
- [ ] Crons into
|
|
261
|
+
- [ ] Secrets via `canopy secrets set` (or dashboard Backend → Secrets); `NEXT_PUBLIC_*` into your CI build
|
|
262
|
+
- [ ] Crons into Backend → Schedules, handled in `scheduled()`
|
|
263
263
|
- [ ] `canopy.json` with `build`, `dist`, `worker` — then `canopy deploy`
|
package/dist/docs/staging.md
CHANGED
|
@@ -102,7 +102,7 @@ canopy staging destroy # removes the staging database, files and backend
|
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
Live is untouched, and the next `canopy deploy --staging` recreates the channel
|
|
105
|
-
from a fresh copy. The dashboard's
|
|
105
|
+
from a fresh copy. The dashboard's Deploys tab has the same controls, the
|
|
106
106
|
Overview tab shows what's staged with a Promote button, and a Live/Staging
|
|
107
107
|
toggle above the Data and Files tabs browses either channel's data.
|
|
108
108
|
|
|
@@ -39,13 +39,16 @@ a wrong path, not a broken server.
|
|
|
39
39
|
|
|
40
40
|
## Caching, and why a new deploy shows up immediately
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Three rules, picked automatically:
|
|
43
43
|
|
|
44
44
|
- **HTML always revalidates.** Browsers re-check it on every visit, so the
|
|
45
45
|
moment you deploy, people get the new build — no cache-busting dance, no
|
|
46
46
|
waiting.
|
|
47
|
-
- **
|
|
48
|
-
|
|
47
|
+
- **Hashed assets cache for a year.** A file with a content hash in its name
|
|
48
|
+
(like `index-a1b2c3d4.js`) never changes under that name, so the visitor's
|
|
49
|
+
browser keeps it and doesn't ask again. That is what keeps repeat visits fast.
|
|
50
|
+
- **Other files cache for an hour.** Anything without a hash in its name (a
|
|
51
|
+
favicon, files you copy in from `public/`) is re-checked after an hour.
|
|
49
52
|
|
|
50
53
|
This is the right shape for a normal build tool that puts a content hash in
|
|
51
54
|
asset filenames (Vite does this by default) — the HTML that names them is
|
|
@@ -91,7 +91,7 @@ pick the change up without a deploy):
|
|
|
91
91
|
canopy egress allow api.example.com
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
or use dashboard
|
|
94
|
+
or use dashboard Backend → Outbound hosts. Details and entry rules:
|
|
95
95
|
[Outbound requests](https://docs.canopy.website/platform/egress). Calls made through the SDK /
|
|
96
96
|
`env.CANOPY.fetch` don't count as egress and are unaffected.
|
|
97
97
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
2
|
-
import { r as siteConfig } from "./site-
|
|
1
|
+
import { t as version } from "./package-DtU4jB_Z.mjs";
|
|
2
|
+
import { r as siteConfig } from "./site-C0nf9RXY.mjs";
|
|
3
3
|
import { i as latestKnownVersion, r as compareSemver } from "./version-check-CcsA1QjI.mjs";
|
|
4
|
-
import { n as agentHeaders } from "./api-
|
|
5
|
-
import {
|
|
4
|
+
import { n as agentHeaders } from "./api-D4KUT6Ly.mjs";
|
|
5
|
+
import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { homedir } from "node:os";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
3
|
-
import { i as
|
|
1
|
+
import { f as resolveProject, l as projectDirArgs } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
|
|
3
|
+
import { i as reportErrors, n as formatDateTime, s as unwrap, t as confirmTypedSlug } from "./ui-BPq6-hKS.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import * as p from "@clack/prompts";
|
|
6
6
|
//#region src/egress.ts
|
|
@@ -136,13 +136,7 @@ const modeCommand = defineCommand({
|
|
|
136
136
|
const access = await apiRequest("GET", `/projects/${slug}/client-password`).catch(() => ({ enabled: false }));
|
|
137
137
|
console.log(openModeRiskSummary(slug, access.enabled));
|
|
138
138
|
console.log("");
|
|
139
|
-
if (!args["accept-risk"])
|
|
140
|
-
requireTty("pass --accept-risk to enable open mode without confirmation.");
|
|
141
|
-
if (unwrap(await p.text({ message: `Type the project slug ("${slug}") to enable open mode.` })).trim() !== slug) {
|
|
142
|
-
p.cancel("Aborted — egress mode unchanged.");
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
139
|
+
if (!args["accept-risk"] && !await confirmTypedSlug(slug, `Type the project slug ("${slug}") to enable open mode.`, "pass --accept-risk to enable open mode without confirmation.", "Aborted — egress mode unchanged.")) return;
|
|
146
140
|
}
|
|
147
141
|
const updated = await withContext(apiRequest("PUT", `/projects/${slug}/egress`, { mode: wanted }), {
|
|
148
142
|
action: `switch ${slug} to ${wanted} egress mode`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
2
|
-
import {
|
|
3
|
-
import { a as apiRequest, c as credentials, i as apiDownload, o as apiUpload, s as commonHeaders } from "./api-
|
|
4
|
-
import {
|
|
1
|
+
import { t as version } from "./package-DtU4jB_Z.mjs";
|
|
2
|
+
import { f as resolveProject, g as tryResolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-C0nf9RXY.mjs";
|
|
3
|
+
import { a as apiRequest, c as credentials, i as apiDownload, o as apiUpload, s as commonHeaders } from "./api-D4KUT6Ly.mjs";
|
|
4
|
+
import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { basename, extname, join } from "node:path";
|
|
7
7
|
import { readFile, writeFile } from "node:fs/promises";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiRequest } from "./api-
|
|
3
|
-
import {
|
|
1
|
+
import { f as resolveProject, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
|
|
2
|
+
import { a as apiRequest } from "./api-D4KUT6Ly.mjs";
|
|
3
|
+
import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
//#region src/files.ts
|
|
6
6
|
/**
|