@mediamonks/canopy-cli 0.7.57 → 0.7.59
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-00f2Mgqh.mjs → ai-4Mr9FbLU.mjs} +2 -2
- package/dist/{api-fmc8CEMT.mjs → api-CpG-9WSe.mjs} +13 -1
- package/dist/{audience-ByM1jUH3.mjs → audience-BXXdvGC_.mjs} +3 -3
- package/dist/{browse-CxwKuka0.mjs → browse-BegddW9V.mjs} +2 -2
- package/dist/{calls-DsbRjCcy.mjs → calls-NFUccBaQ.mjs} +3 -3
- package/dist/{db-BU-ni9fj.mjs → db-DIxujtt1.mjs} +13 -6
- package/dist/{deploy-7tgGJZUK.mjs → deploy-Bp5DMp_U.mjs} +381 -16
- package/dist/{dev-qp1VRNM_.mjs → dev-AkM6kLVb.mjs} +9 -9
- package/dist/dev-pj6lLjMR.mjs +2 -0
- package/dist/{dev-worker-7tqL9UFi.mjs → dev-worker-DEK8fOgz.mjs} +18 -1
- package/dist/docs/cli-deploy.md +20 -3
- package/dist/docs/cli-dev.md +1 -1
- package/dist/docs/data.md +18 -0
- package/dist/docs/migrations.md +22 -0
- package/dist/docs/platform-deploys-and-rollbacks.md +3 -0
- package/dist/docs/platform-project-data.md +7 -0
- package/dist/docs/sdk-database.md +51 -0
- package/dist/docs/static-serving.md +34 -2
- package/dist/{docs-hcHwEc6n.mjs → docs-F0GxdMrn.mjs} +4 -4
- package/dist/{egress-Bzn2VKDe.mjs → egress-Dwq-d6cB.mjs} +3 -3
- package/dist/{feedback-COujxFBV.mjs → feedback-ClCjUP3z.mjs} +4 -4
- package/dist/{files-CBbAtHIK.mjs → files-CUPtGcuZ.mjs} +3 -3
- package/dist/index.mjs +39 -39
- package/dist/{local-C1i2uhAf.mjs → local-CFxKguzg.mjs} +54 -19
- package/dist/{login-Baso-JE0.mjs → login-CP1fO_AH.mjs} +3 -3
- package/dist/{logs-c76jVOhb.mjs → logs-BwqG7lYU.mjs} +3 -3
- package/dist/{mcp-aWskwkXw.mjs → mcp-CnTfFA0U.mjs} +3 -3
- package/dist/{migrations-ChafLorm.mjs → migrations-DJrRnU7X.mjs} +2 -2
- package/dist/{open-Doat726T.mjs → open-5JLHiz_J.mjs} +2 -2
- package/dist/{package-BpOFa8Qi.mjs → package-tnyqU_dN.mjs} +1 -1
- package/dist/{project-template-BnX47DpF.mjs → project-template-CsTOpPto.mjs} +3 -3
- package/dist/project-template-xNjGs9ty.mjs +2 -0
- package/dist/{projects-DOqpkUVT.mjs → projects-DCFn4zcq.mjs} +6 -6
- package/dist/{rename-RA_oYbRT.mjs → rename-OeOI97da.mjs} +3 -3
- package/dist/repo-BW7dDQZL.mjs +2 -0
- package/dist/{repo-DD3eK1P_.mjs → repo-CIEG53hP.mjs} +3 -3
- package/dist/{roles-tqf4sYDM.mjs → roles-2Pkqiwrx.mjs} +1 -1
- package/dist/{roles-BS8-Gvv-.mjs → roles-BCJWHeGq.mjs} +3 -3
- package/dist/{schedule-D8AQ8MVF.mjs → schedule-Cy-7IFy5.mjs} +3 -3
- package/dist/{secrets-Bi7BYCla.mjs → secrets-Cgte8mvq.mjs} +3 -3
- package/dist/{site-BcZ0LOvm.mjs → site-Bz-fEyKS.mjs} +1 -1
- package/dist/skill/canopy/SKILL.md +3 -0
- package/dist/{skill-984KseKb.mjs → skill-CoPNcCaM.mjs} +2 -2
- package/dist/{src-DpjA-a59.mjs → src-Dlg7aeRj.mjs} +250 -23
- package/dist/{staging-BxG3Cffd.mjs → staging-D6-Ojy39.mjs} +3 -3
- package/dist/{token-bHdy_IoX.mjs → token-yAj7pF78.mjs} +3 -3
- package/dist/{ui-9f_lF2Ak.mjs → ui-BUeiY_zZ.mjs} +1 -1
- package/dist/{upgrade-DhK_PlAN.mjs → upgrade-CLFrKuJS.mjs} +2 -2
- package/dist/{usage-DFs2TERV.mjs → usage-BXPm04tk.mjs} +3 -3
- package/dist/{versions-Cgw7sB3h.mjs → versions-C204ivt9.mjs} +3 -3
- package/package.json +1 -1
- package/dist/dev-BtacZ4HE.mjs +0 -2
- package/dist/project-template--mESzwea.mjs +0 -2
- package/dist/repo-DayXVvyj.mjs +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
2
|
-
import { i as reportErrors } from "./ui-
|
|
1
|
+
import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
|
|
2
|
+
import { i as reportErrors } from "./ui-BUeiY_zZ.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/ai.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as tryReadCanopyJson, p as rewriteCanopyJsonSlug, r as siteConfig, t as projectDir } from "./site-
|
|
1
|
+
import { h as tryReadCanopyJson, p as rewriteCanopyJsonSlug, r as siteConfig, t as projectDir } from "./site-Bz-fEyKS.mjs";
|
|
2
2
|
//#region src/api.ts
|
|
3
3
|
/**
|
|
4
4
|
* Authenticated requests to the Canopy control plane. Credentials, in order:
|
|
@@ -226,6 +226,18 @@ const ERROR_COPY = {
|
|
|
226
226
|
why: "branches are full git refs, and the staging branch must differ from the live one",
|
|
227
227
|
fix: "Pass e.g. `--ref refs/heads/main --staging-ref refs/heads/develop`."
|
|
228
228
|
},
|
|
229
|
+
export_unsupported: {
|
|
230
|
+
why: "the database holds a table that exports and snapshots can't include",
|
|
231
|
+
fix: "The detail names the table. Remove it if you can, or report it with `canopy feedback report`."
|
|
232
|
+
},
|
|
233
|
+
snapshot_failed: {
|
|
234
|
+
why: "the platform could not export the database to take the snapshot",
|
|
235
|
+
fix: "Retry once. If it fails the same way, it isn't temporary: report it with `canopy feedback report` and include the request id."
|
|
236
|
+
},
|
|
237
|
+
export_failed: {
|
|
238
|
+
why: "the platform could not export the database",
|
|
239
|
+
fix: "Retry once. If it fails the same way, it isn't temporary: report it with `canopy feedback report` and include the request id."
|
|
240
|
+
},
|
|
229
241
|
version_expired: {
|
|
230
242
|
why: "version retention expired that version: its files are gone, so it can no longer be made live, staged, pinned or downloaded",
|
|
231
243
|
fix: "Pick a version that is still kept (`canopy versions` shows how many are), or rebuild it from source and deploy."
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-
|
|
2
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
3
|
-
import { i as reportErrors } from "./ui-
|
|
1
|
+
import { f as resolveProject, l as projectDirArgs, 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";
|
|
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 { g as tryResolveProject, r as siteConfig } from "./site-
|
|
2
|
-
import { a as apiRequest, t as ApiError } from "./api-
|
|
1
|
+
import { g as tryResolveProject, r as siteConfig } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, t as ApiError } from "./api-CpG-9WSe.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/browse.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as resolveProject, l as projectDirArgs } from "./site-
|
|
2
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
3
|
-
import { i as reportErrors, n as formatDateTime } from "./ui-
|
|
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 } from "./ui-BUeiY_zZ.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
//#region src/calls.ts
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as resolveProject, u as projectFlagArgs } from "./site-
|
|
2
|
-
import { a as apiRequest, m as withContext, r as apiDataRequest } from "./api-
|
|
3
|
-
import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-
|
|
4
|
-
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-
|
|
1
|
+
import { f as resolveProject, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext, r as apiDataRequest } from "./api-CpG-9WSe.mjs";
|
|
3
|
+
import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-BUeiY_zZ.mjs";
|
|
4
|
+
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-DJrRnU7X.mjs";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
7
7
|
import * as p from "@clack/prompts";
|
|
@@ -29,6 +29,10 @@ const stagingFlagArgs = { staging: {
|
|
|
29
29
|
} };
|
|
30
30
|
const channelOf = (args) => args.staging ? "staging" : "live";
|
|
31
31
|
const channelNote = (args) => args.staging ? " [staging]" : "";
|
|
32
|
+
/** The notes an export or snapshot came back with, one printable line each. */
|
|
33
|
+
function exportNoteLines(notes) {
|
|
34
|
+
return (notes ?? []).map((note) => `Note: ${note}`);
|
|
35
|
+
}
|
|
32
36
|
const formatSize = (bytes) => bytes < 1024 * 1024 ? `${(bytes / 1024).toFixed(1)} kB` : `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
33
37
|
const pullCommand = defineCommand({
|
|
34
38
|
meta: {
|
|
@@ -49,12 +53,13 @@ const pullCommand = defineCommand({
|
|
|
49
53
|
const spin = spinner$1();
|
|
50
54
|
spin.start(`Exporting ${slug}${channelNote(args)}…`);
|
|
51
55
|
try {
|
|
52
|
-
const { url } = await apiDataRequest("POST", "/db/export", slug, void 0, { channel: channelOf(args) });
|
|
56
|
+
const { url, notes } = await apiDataRequest("POST", "/db/export", slug, void 0, { channel: channelOf(args) });
|
|
53
57
|
const download = await fetch(url);
|
|
54
58
|
if (!download.ok) throw new Error(`Download failed (HTTP ${download.status}).`);
|
|
55
59
|
const sql = Buffer.from(await download.arrayBuffer());
|
|
56
60
|
writeFileSync(out, sql);
|
|
57
61
|
spin.stop(`Wrote ${out} (${formatSize(sql.byteLength)}).`);
|
|
62
|
+
for (const line of exportNoteLines(notes)) console.log(line);
|
|
58
63
|
} catch (err) {
|
|
59
64
|
spin.error("Export failed.");
|
|
60
65
|
throw err;
|
|
@@ -75,13 +80,15 @@ const snapshotCommand = defineCommand({
|
|
|
75
80
|
const spin = spinner$1();
|
|
76
81
|
spin.start(`Snapshotting ${slug}${channelNote(args)}…`);
|
|
77
82
|
let created;
|
|
83
|
+
let notes;
|
|
78
84
|
try {
|
|
79
|
-
({snapshot: created} = await apiDataRequest("POST", "/db/snapshots", slug, void 0, { channel: channelOf(args) }));
|
|
85
|
+
({snapshot: created, notes} = await apiDataRequest("POST", "/db/snapshots", slug, void 0, { channel: channelOf(args) }));
|
|
80
86
|
} catch (err) {
|
|
81
87
|
spin.error("Snapshot failed.");
|
|
82
88
|
throw err;
|
|
83
89
|
}
|
|
84
90
|
spin.stop(`Stored ${created.key} (${formatSize(created.size)}).`);
|
|
91
|
+
for (const line of exportNoteLines(notes)) console.log(line);
|
|
85
92
|
console.log(`Restore anytime with \`canopy db restore --snapshot ${created.key}\`.`);
|
|
86
93
|
})
|
|
87
94
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
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 { i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap } from "./ui-
|
|
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-Bz-fEyKS.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-CpG-9WSe.mjs";
|
|
3
|
+
import { i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap } from "./ui-BUeiY_zZ.mjs";
|
|
4
|
+
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-DJrRnU7X.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";
|
|
@@ -10,6 +10,7 @@ import { join, relative, resolve } from "node:path";
|
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
11
|
import * as p from "@clack/prompts";
|
|
12
12
|
import * as esbuild from "esbuild";
|
|
13
|
+
import { createHash } from "node:crypto";
|
|
13
14
|
//#region src/worker-bundle.ts
|
|
14
15
|
/**
|
|
15
16
|
* Bundle a project's `worker/` entry for deploy (G6).
|
|
@@ -149,6 +150,244 @@ const nodeBuiltins = {
|
|
|
149
150
|
}
|
|
150
151
|
};
|
|
151
152
|
//#endregion
|
|
153
|
+
//#region src/media.ts
|
|
154
|
+
/**
|
|
155
|
+
* Site media for `canopy deploy` (OpenSpec site-media): folders of the build
|
|
156
|
+
* output, declared in canopy.json (`"media": ["mocks/"]`), that are stored once
|
|
157
|
+
* per project instead of in every version and served on the same URLs.
|
|
158
|
+
*
|
|
159
|
+
* Pure helpers here (rules, the split, suggestions, messages); the deploy
|
|
160
|
+
* command does the network part. The rules mirror the server's
|
|
161
|
+
* (apps/api/src/site-media.ts); the server stays authoritative.
|
|
162
|
+
*/
|
|
163
|
+
/** Extensions site media may hold: data and media, never code. */
|
|
164
|
+
const MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
165
|
+
"json",
|
|
166
|
+
"csv",
|
|
167
|
+
"txt",
|
|
168
|
+
"png",
|
|
169
|
+
"jpg",
|
|
170
|
+
"jpeg",
|
|
171
|
+
"gif",
|
|
172
|
+
"webp",
|
|
173
|
+
"avif",
|
|
174
|
+
"ico",
|
|
175
|
+
"mp4",
|
|
176
|
+
"webm",
|
|
177
|
+
"mp3",
|
|
178
|
+
"wav",
|
|
179
|
+
"ogg",
|
|
180
|
+
"m4a",
|
|
181
|
+
"woff",
|
|
182
|
+
"woff2",
|
|
183
|
+
"glb",
|
|
184
|
+
"gltf",
|
|
185
|
+
"bin"
|
|
186
|
+
]);
|
|
187
|
+
function isMediaFile(path) {
|
|
188
|
+
const file = path.split("/").at(-1) ?? "";
|
|
189
|
+
const dot = file.lastIndexOf(".");
|
|
190
|
+
return dot > 0 && MEDIA_EXTENSIONS.has(file.slice(dot + 1).toLowerCase());
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Build output with a content hash in its name (Vite's `name-<8 chars>.ext`),
|
|
194
|
+
* same rule as the server's cache headers: such names change on every build,
|
|
195
|
+
* so they pile up in an additive store.
|
|
196
|
+
*/
|
|
197
|
+
function looksHashed(path) {
|
|
198
|
+
const file = path.split("/").at(-1) ?? "";
|
|
199
|
+
const match = /-([A-Za-z0-9_-]{8})\.[A-Za-z0-9]+(?:\.map)?$/.exec(file);
|
|
200
|
+
return match !== null && /[0-9A-Z_-]/.test(match[1] ?? "");
|
|
201
|
+
}
|
|
202
|
+
/** canopy.json `media`, normalized like the server does it; throws on a bad entry. */
|
|
203
|
+
function normalizeMediaFolders(raw) {
|
|
204
|
+
if (raw === void 0 || raw === null) return [];
|
|
205
|
+
if (!Array.isArray(raw) || !raw.every((e) => typeof e === "string")) throw new Error("canopy.json \"media\" must be a list of folders, e.g. [\"mocks/\"].");
|
|
206
|
+
const cleaned = raw.map((entry) => {
|
|
207
|
+
const trimmed = entry.trim().replace(/^\.?\//, "").replace(/\/+$/, "");
|
|
208
|
+
if (trimmed === "" || trimmed.includes("\\") || trimmed.includes("\0") || trimmed.includes("//") || trimmed.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) throw new Error(`canopy.json "media": "${entry}" is not a folder inside the build output (the root can't be media).`);
|
|
209
|
+
return `${trimmed}/`;
|
|
210
|
+
});
|
|
211
|
+
const unique = [...new Set(cleaned)].sort();
|
|
212
|
+
const folders = unique.filter((f) => !unique.some((g) => g !== f && f.startsWith(g)));
|
|
213
|
+
if (folders.length > 10) throw new Error(`canopy.json "media" lists ${folders.length} folders; the limit is 10.`);
|
|
214
|
+
return folders;
|
|
215
|
+
}
|
|
216
|
+
/** Version files and media files, by the declared folders. */
|
|
217
|
+
function splitMedia(files, folders) {
|
|
218
|
+
const bundle = [];
|
|
219
|
+
const media = [];
|
|
220
|
+
for (const file of files) (folders.some((f) => file.path.startsWith(f)) ? media : bundle).push(file);
|
|
221
|
+
return {
|
|
222
|
+
bundle,
|
|
223
|
+
media
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const sha256Hex = (data) => createHash("sha256").update(data).digest("hex");
|
|
227
|
+
/**
|
|
228
|
+
* Folders that could be site media: the topmost folders (not the output root,
|
|
229
|
+
* not already declared) whose files are all data or media, at least 1 MB, and
|
|
230
|
+
* mostly not content-hashed build output. Largest first.
|
|
231
|
+
*/
|
|
232
|
+
function mediaCandidates(files, declared = []) {
|
|
233
|
+
const stats = /* @__PURE__ */ new Map();
|
|
234
|
+
for (const file of files) {
|
|
235
|
+
const parts = file.path.split("/");
|
|
236
|
+
const ext = (parts.at(-1)?.split(".").at(-1) ?? "").toLowerCase();
|
|
237
|
+
for (let depth = 1; depth < parts.length; depth++) {
|
|
238
|
+
const folder = `${parts.slice(0, depth).join("/")}/`;
|
|
239
|
+
const s = stats.get(folder) ?? {
|
|
240
|
+
bytes: 0,
|
|
241
|
+
files: 0,
|
|
242
|
+
allMedia: true,
|
|
243
|
+
hashed: 0,
|
|
244
|
+
types: /* @__PURE__ */ new Set()
|
|
245
|
+
};
|
|
246
|
+
s.bytes += file.size;
|
|
247
|
+
s.files += 1;
|
|
248
|
+
s.allMedia &&= isMediaFile(file.path);
|
|
249
|
+
if (looksHashed(file.path)) s.hashed += 1;
|
|
250
|
+
s.types.add(ext);
|
|
251
|
+
stats.set(folder, s);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const qualifies = (folder) => {
|
|
255
|
+
const s = stats.get(folder);
|
|
256
|
+
return s !== void 0 && s.allMedia && s.bytes >= 1048576 && s.hashed * 2 < s.files && !declared.some((d) => folder.startsWith(d) || d.startsWith(folder));
|
|
257
|
+
};
|
|
258
|
+
const out = [];
|
|
259
|
+
for (const [folder, s] of stats) {
|
|
260
|
+
if (!qualifies(folder)) continue;
|
|
261
|
+
const parent = folder.slice(0, folder.slice(0, -1).lastIndexOf("/") + 1);
|
|
262
|
+
if (parent !== "" && qualifies(parent)) continue;
|
|
263
|
+
out.push({
|
|
264
|
+
folder,
|
|
265
|
+
bytes: s.bytes,
|
|
266
|
+
files: s.files,
|
|
267
|
+
types: [...s.types].sort()
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
return out.sort((a, b) => b.bytes - a.bytes || a.folder.localeCompare(b.folder));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The fewest of the largest candidates that bring the version under both
|
|
274
|
+
* limits, or null when even all of them are not enough.
|
|
275
|
+
*/
|
|
276
|
+
function candidatesToFit(candidates, version, limits) {
|
|
277
|
+
const fits = (bytes, count) => (limits.maxTotalBytes === void 0 || bytes <= limits.maxTotalBytes) && (limits.maxFiles === void 0 || count <= limits.maxFiles);
|
|
278
|
+
let { bytes, files } = version;
|
|
279
|
+
const picked = [];
|
|
280
|
+
for (const candidate of candidates) {
|
|
281
|
+
if (fits(bytes, files)) break;
|
|
282
|
+
picked.push(candidate);
|
|
283
|
+
bytes -= candidate.bytes;
|
|
284
|
+
files -= candidate.files;
|
|
285
|
+
}
|
|
286
|
+
return fits(bytes, files) ? picked : null;
|
|
287
|
+
}
|
|
288
|
+
const formatSize = (bytes) => bytes >= 1024 ** 3 ? `${(bytes / 1024 ** 3).toFixed(1)} GB` : bytes >= 1024 ** 2 ? `${(bytes / 1024 ** 2).toFixed(1)} MB` : `${Math.max(0, Math.round(bytes / 1024))} kB`;
|
|
289
|
+
/** The sentence every media suggestion carries, so an agent weighs it. */
|
|
290
|
+
const NOT_VERSIONED = "Media is not versioned: rollbacks and pinned versions serve the current files.";
|
|
291
|
+
/** The `canopy.json` snippet that declares `folders` (plus any already declared). */
|
|
292
|
+
function mediaSnippet(folders, declared = []) {
|
|
293
|
+
return `"media": ${JSON.stringify([...declared, ...folders])}`;
|
|
294
|
+
}
|
|
295
|
+
/** Lines naming the candidates: folder, size, files, types. */
|
|
296
|
+
function describeCandidates(candidates) {
|
|
297
|
+
const width = Math.max(...candidates.map((c) => c.folder.length));
|
|
298
|
+
return candidates.map((c) => ` ${c.folder.padEnd(width)} ${formatSize(c.bytes).padStart(9)} ${String(c.files).padStart(5)} files ${c.types.join(", ")}`);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The soft hint: the version has reached SUGGEST_AT_SHARE of a limit and
|
|
302
|
+
* there are folders that could move out of it. Null otherwise.
|
|
303
|
+
*/
|
|
304
|
+
function mediaHint(candidates, version, limits, declared = []) {
|
|
305
|
+
if (candidates.length === 0) return null;
|
|
306
|
+
const share = Math.max(limits.maxTotalBytes ? version.bytes / limits.maxTotalBytes : 0, limits.maxFiles ? version.files / limits.maxFiles : 0);
|
|
307
|
+
if (share < .3) return null;
|
|
308
|
+
return [
|
|
309
|
+
` hint: this version is ${formatSize(version.bytes)} in ${version.files} files (${Math.round(share * 100)}% of the deploy limit).`,
|
|
310
|
+
" These folders could be site media (stored once, not part of every version):",
|
|
311
|
+
...describeCandidates(candidates),
|
|
312
|
+
` Add to canopy.json: ${mediaSnippet(candidates.map((c) => c.folder), declared)}`,
|
|
313
|
+
` ${NOT_VERSIONED}`
|
|
314
|
+
].join("\n");
|
|
315
|
+
}
|
|
316
|
+
/** Text added to the over-limit refusal: what to move, or why moving won't do. */
|
|
317
|
+
function overLimitAdvice(candidates, version, limits, declared = []) {
|
|
318
|
+
if (candidates.length === 0) return "Bundle/minify assets or drop what isn't served, then redeploy.";
|
|
319
|
+
const picked = candidatesToFit(candidates, version, limits);
|
|
320
|
+
if (!picked) return [
|
|
321
|
+
"Even moving every data and media folder to site media would not bring it under the limit:",
|
|
322
|
+
...describeCandidates(candidates),
|
|
323
|
+
"Bundle/minify assets or drop what isn't served, then redeploy."
|
|
324
|
+
].join("\n");
|
|
325
|
+
return [
|
|
326
|
+
"Move these folders to site media (stored once, not part of every version):",
|
|
327
|
+
...describeCandidates(picked),
|
|
328
|
+
`Add to canopy.json: ${mediaSnippet(picked.map((c) => c.folder), declared)}`,
|
|
329
|
+
NOT_VERSIONED
|
|
330
|
+
].join("\n");
|
|
331
|
+
}
|
|
332
|
+
/** What to upload and what it adds up to, against the stored manifest. */
|
|
333
|
+
function planMedia(local, manifest, opts) {
|
|
334
|
+
const stored = new Map(manifest.map((f) => [f.path, f]));
|
|
335
|
+
const localPaths = new Set(local.map((f) => f.path));
|
|
336
|
+
const upload = [];
|
|
337
|
+
const blocked = [];
|
|
338
|
+
let unchanged = 0;
|
|
339
|
+
for (const file of local) {
|
|
340
|
+
const sha256 = sha256Hex(file.data);
|
|
341
|
+
const remote = stored.get(file.path);
|
|
342
|
+
if (remote?.sha256 === sha256) unchanged++;
|
|
343
|
+
else if (remote && opts.createOnly) blocked.push(file.path);
|
|
344
|
+
else upload.push({
|
|
345
|
+
...file,
|
|
346
|
+
sha256
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const stale = manifest.filter((f) => !localPaths.has(f.path)).map((f) => f.path);
|
|
350
|
+
const prunes = opts.prune && !opts.createOnly;
|
|
351
|
+
let bytes = 0;
|
|
352
|
+
let files = 0;
|
|
353
|
+
for (const remote of manifest) {
|
|
354
|
+
if (prunes && !localPaths.has(remote.path)) continue;
|
|
355
|
+
const replacing = upload.find((u) => u.path === remote.path);
|
|
356
|
+
bytes += replacing ? replacing.data.byteLength : remote.size;
|
|
357
|
+
files += 1;
|
|
358
|
+
}
|
|
359
|
+
for (const u of upload) if (!stored.has(u.path)) {
|
|
360
|
+
bytes += u.data.byteLength;
|
|
361
|
+
files += 1;
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
upload,
|
|
365
|
+
unchanged,
|
|
366
|
+
stale,
|
|
367
|
+
blocked,
|
|
368
|
+
projectedBytes: bytes,
|
|
369
|
+
projectedFiles: files
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/** Why the media plan breaks the limits, or null. */
|
|
373
|
+
function mediaLimitError(plan, limits) {
|
|
374
|
+
const big = plan.upload.find((f) => f.data.byteLength > limits.maxFileBytes);
|
|
375
|
+
if (big) return `Site media file ${big.path} is ${formatSize(big.data.byteLength)}; one file may be at most ${formatSize(limits.maxFileBytes)} on this site.`;
|
|
376
|
+
if (plan.projectedFiles > limits.maxFiles) return `Site media would hold ${plan.projectedFiles} files; the limit is ${limits.maxFiles}. Drop files or run with --prune-media to remove stored ones that are gone locally.`;
|
|
377
|
+
if (plan.projectedBytes > limits.maxBytes) return `Site media would hold ${formatSize(plan.projectedBytes)}; this project's limit is ${formatSize(limits.maxBytes)}. Run with --prune-media to remove stored files that are gone locally, or ask a Canopy admin to raise it.`;
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
/** The lines a deploy prints about its media sync. */
|
|
381
|
+
function describeMediaSync(plan, pruned, opts) {
|
|
382
|
+
const kept = plan.projectedBytes;
|
|
383
|
+
const lines = [` media: ${plan.upload.length} uploaded, ${plan.unchanged} unchanged, ${formatSize(kept)} stored`];
|
|
384
|
+
if (plan.blocked.length > 0) lines.push(` ${plan.blocked.length} changed media files were not replaced: this token deploys only to staging, and media is shared with live:`, ...plan.blocked.slice(0, 10).map((path) => ` ${path}`));
|
|
385
|
+
if (pruned.length > 0) lines.push(` pruned ${pruned.length} stored media files no longer in the build:`, ...pruned.slice(0, 20).map((path) => ` ${path}`), ...pruned.length > 20 ? [` … and ${pruned.length - 20} more`] : []);
|
|
386
|
+
else if (!opts.prune && plan.stale.length > 0) lines.push(` ${plan.stale.length} stored media files are no longer in the build; --prune-media removes them.`);
|
|
387
|
+
else if (opts.prune && opts.createOnly && plan.stale.length > 0) lines.push(" --prune-media skipped: this token deploys only to staging and can't delete media.");
|
|
388
|
+
return lines;
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
152
391
|
//#region src/deploy.ts
|
|
153
392
|
/**
|
|
154
393
|
* canopy deploy — build (optional), then the signed-upload flow
|
|
@@ -226,6 +465,11 @@ const deployCommand = defineCommand({
|
|
|
226
465
|
default: false,
|
|
227
466
|
description: "Deploy to the project's staging channel (created on first use, database cloned from live)"
|
|
228
467
|
},
|
|
468
|
+
"prune-media": {
|
|
469
|
+
type: "boolean",
|
|
470
|
+
default: false,
|
|
471
|
+
description: "Delete stored site media files that are no longer in the build (canopy.json media)"
|
|
472
|
+
},
|
|
229
473
|
worker: {
|
|
230
474
|
type: "boolean",
|
|
231
475
|
default: true,
|
|
@@ -271,6 +515,25 @@ const deployCommand = defineCommand({
|
|
|
271
515
|
data
|
|
272
516
|
});
|
|
273
517
|
}
|
|
518
|
+
const mediaFolders = normalizeMediaFolders(config.media);
|
|
519
|
+
const { bundle, media } = splitMedia(files, mediaFolders);
|
|
520
|
+
for (const folder of mediaFolders) if (!media.some((f) => f.path.startsWith(folder))) p.log.warn(`canopy.json "media": ${folder} is not in the build output; nothing to upload from it.`);
|
|
521
|
+
const notMedia = media.filter((f) => !isMediaFile(f.path)).map((f) => f.path);
|
|
522
|
+
if (notMedia.length > 0) throw new Error([
|
|
523
|
+
"Site media holds data and media files only (JSON, CSV, text, images, video, audio, fonts, 3D models). These can't be media:",
|
|
524
|
+
...notMedia.slice(0, 20).map((path) => ` ${path}`),
|
|
525
|
+
...notMedia.length > 20 ? [` … and ${notMedia.length - 20} more`] : [],
|
|
526
|
+
"Move them out of the media folders, or take the folder out of canopy.json \"media\"."
|
|
527
|
+
].join("\n"));
|
|
528
|
+
for (const folder of mediaFolders) {
|
|
529
|
+
const inFolder = media.filter((f) => f.path.startsWith(folder));
|
|
530
|
+
if (inFolder.length > 0 && inFolder.filter((f) => looksHashed(f.path)).length * 2 >= inFolder.length) p.log.warn(`${folder} holds mostly content-hashed build output. Their names change on every build, and site media keeps old files until you deploy with --prune-media.`);
|
|
531
|
+
}
|
|
532
|
+
const bundleBytes = bundle.reduce((sum, f) => sum + f.data.byteLength, 0);
|
|
533
|
+
const candidates = mediaCandidates(bundle.map((f) => ({
|
|
534
|
+
path: f.path,
|
|
535
|
+
size: f.data.byteLength
|
|
536
|
+
})), mediaFolders);
|
|
274
537
|
let workerBytes = null;
|
|
275
538
|
if (config.worker && !args.worker) p.log.warn(`Skipping the backend (${config.worker}) — deploying the frontend only.`);
|
|
276
539
|
if (config.worker && args.worker) {
|
|
@@ -289,24 +552,64 @@ const deployCommand = defineCommand({
|
|
|
289
552
|
const spin = spinner$1();
|
|
290
553
|
const workerNote = workerBytes ? " + worker" : "";
|
|
291
554
|
const channelNote = channel === "staging" ? " [staging]" : "";
|
|
292
|
-
|
|
555
|
+
const mediaNote = media.length > 0 ? ` + ${media.length} media files (${formatSize(total - bundleBytes - (workerBytes?.byteLength ?? 0))})` : "";
|
|
556
|
+
spin.start(`Deploying ${bundle.length} files${workerNote} (${(bundleBytes / 1024).toFixed(0)} kB)${mediaNote} → ${slug}${channelNote}`);
|
|
557
|
+
let mediaReport = [];
|
|
293
558
|
let result;
|
|
294
559
|
let migrateResult;
|
|
295
560
|
let stagingCreated = false;
|
|
296
561
|
let retentionHint = null;
|
|
562
|
+
let limitsSeen = {};
|
|
297
563
|
try {
|
|
298
564
|
const { upload, retention } = await withContext(apiRequest("POST", `/projects/${slug}/deploys`, {
|
|
299
565
|
worker: workerBytes !== null,
|
|
300
|
-
channel
|
|
566
|
+
channel,
|
|
567
|
+
...mediaFolders.length > 0 && { media: mediaFolders }
|
|
301
568
|
}, { headers: source }), { action: `deploy "${slug}"` });
|
|
302
569
|
stagingCreated = upload.stagingCreated === true;
|
|
570
|
+
limitsSeen = {
|
|
571
|
+
maxTotalBytes: upload.maxTotalBytes,
|
|
572
|
+
maxFiles: upload.maxFiles
|
|
573
|
+
};
|
|
303
574
|
retentionHint = retentionHintLine(retention);
|
|
304
|
-
const overLimit = bundleLimitError(
|
|
575
|
+
const overLimit = bundleLimitError(bundle, upload);
|
|
305
576
|
if (overLimit) {
|
|
306
577
|
spin.error("Deploy refused — nothing was uploaded.");
|
|
307
|
-
throw new Error(overLimit
|
|
578
|
+
throw new Error(`${overLimit}\n${overLimitAdvice(candidates, {
|
|
579
|
+
bytes: bundleBytes,
|
|
580
|
+
files: bundle.length
|
|
581
|
+
}, upload, mediaFolders)}`);
|
|
582
|
+
}
|
|
583
|
+
if (mediaFolders.length > 0 && !upload.media) {
|
|
584
|
+
spin.error("Deploy refused — nothing was uploaded.");
|
|
585
|
+
throw new Error("This site doesn't support site media yet. Take \"media\" out of canopy.json to deploy those folders as part of the version.");
|
|
308
586
|
}
|
|
309
|
-
|
|
587
|
+
if (upload.media) {
|
|
588
|
+
spin.message(`Checking site media → ${slug}`);
|
|
589
|
+
const plan = planMedia(media, (await mediaManifest(upload.grant)).files, {
|
|
590
|
+
prune: args["prune-media"],
|
|
591
|
+
createOnly: upload.media.createOnly
|
|
592
|
+
});
|
|
593
|
+
const mediaError = mediaLimitError(plan, upload.media);
|
|
594
|
+
if (mediaError) {
|
|
595
|
+
spin.error("Deploy refused — nothing was uploaded.");
|
|
596
|
+
throw new Error(mediaError);
|
|
597
|
+
}
|
|
598
|
+
if (plan.upload.length > 0) {
|
|
599
|
+
spin.message(`Uploading ${plan.upload.length} site media files (${formatSize(plan.upload.reduce((n, f) => n + f.data.byteLength, 0))}) → ${slug}`);
|
|
600
|
+
await uploadMedia(upload.grant, plan.upload);
|
|
601
|
+
}
|
|
602
|
+
let pruned = [];
|
|
603
|
+
if (args["prune-media"] && plan.stale.length > 0 && !upload.media.createOnly) {
|
|
604
|
+
await deleteMedia(upload.grant, plan.stale);
|
|
605
|
+
pruned = plan.stale;
|
|
606
|
+
}
|
|
607
|
+
mediaReport = describeMediaSync(plan, pruned, {
|
|
608
|
+
prune: args["prune-media"],
|
|
609
|
+
createOnly: upload.media.createOnly
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
const uploads = [...bundle, ...workerBytes ? [{
|
|
310
613
|
path: WORKER_BUNDLE_PATH,
|
|
311
614
|
data: workerBytes
|
|
312
615
|
}] : []];
|
|
@@ -335,6 +638,15 @@ const deployCommand = defineCommand({
|
|
|
335
638
|
console.log(` happy with it? \`canopy promote\` makes v${result.version} live`);
|
|
336
639
|
} else spin.stop(`Live: ${projectUrl(currentSlug(slug))} (v${result.version})${backend}`);
|
|
337
640
|
if (migrateResult !== void 0) for (const line of describeMigrateResult(migrateResult)) console.log(` ${line}`);
|
|
641
|
+
for (const line of mediaReport) console.log(line);
|
|
642
|
+
const hint = mediaHint(candidates, {
|
|
643
|
+
bytes: bundleBytes,
|
|
644
|
+
files: bundle.length
|
|
645
|
+
}, {
|
|
646
|
+
maxTotalBytes: limitsSeen.maxTotalBytes,
|
|
647
|
+
maxFiles: limitsSeen.maxFiles
|
|
648
|
+
}, mediaFolders);
|
|
649
|
+
if (hint) console.log(`\n${hint}`);
|
|
338
650
|
if (retentionHint) console.log(`\n${retentionHint}`);
|
|
339
651
|
})
|
|
340
652
|
});
|
|
@@ -406,11 +718,11 @@ const UPLOAD_CONCURRENCY = 8;
|
|
|
406
718
|
* that states no limits isn't checked here; completion still enforces them.
|
|
407
719
|
*/
|
|
408
720
|
function bundleLimitError(files, limits) {
|
|
409
|
-
if (limits.maxFiles !== void 0 && files.length > limits.maxFiles) return `This deploy has ${files.length} files; the limit is ${limits.maxFiles}
|
|
721
|
+
if (limits.maxFiles !== void 0 && files.length > limits.maxFiles) return `This deploy has ${files.length} files; the limit is ${limits.maxFiles}.`;
|
|
410
722
|
const bytes = files.reduce((sum, f) => sum + f.data.byteLength, 0);
|
|
411
723
|
if (limits.maxTotalBytes !== void 0 && bytes > limits.maxTotalBytes) {
|
|
412
724
|
const mb = (n) => `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
413
|
-
return `This deploy is ${mb(bytes)}; the limit is ${mb(limits.maxTotalBytes)}
|
|
725
|
+
return `This deploy is ${mb(bytes)}; the limit is ${mb(limits.maxTotalBytes)}.`;
|
|
414
726
|
}
|
|
415
727
|
return null;
|
|
416
728
|
}
|
|
@@ -451,17 +763,36 @@ function skipMessage(code, slug) {
|
|
|
451
763
|
const host = server ? new URL(server).host : void 0;
|
|
452
764
|
return `"${slug}" is not linked to this repository, so this run deployed nothing. The project owner can link it with \`canopy repo link ${repo ? `${host && host !== "github.com" ? `${host}/` : ""}${repo}` : "<owner/name>"}\`, or set a CANOPY_DEPLOY_TOKEN secret.`;
|
|
453
765
|
}
|
|
766
|
+
const PUT_ATTEMPTS = 3;
|
|
767
|
+
/**
|
|
768
|
+
* One upload PUT, tried again when the connection drops. Node's fetch speaks
|
|
769
|
+
* HTTP/2 to the edge, and with several uploads in flight a stream is now and
|
|
770
|
+
* then reset (ERR_HTTP2_STREAM_ERROR) on a different file each time. An HTTP
|
|
771
|
+
* answer, refusal or not, is returned as is: only network failures retry.
|
|
772
|
+
* Re-sending is safe: an upload replaces the same key with the same bytes.
|
|
773
|
+
*/
|
|
774
|
+
async function putWithRetry(url, headers, data, what) {
|
|
775
|
+
for (let attempt = 1;; attempt++) try {
|
|
776
|
+
return await fetch(url, {
|
|
777
|
+
method: "PUT",
|
|
778
|
+
headers,
|
|
779
|
+
body: Buffer.from(data)
|
|
780
|
+
});
|
|
781
|
+
} catch (err) {
|
|
782
|
+
if (attempt >= PUT_ATTEMPTS) {
|
|
783
|
+
const cause = err.cause;
|
|
784
|
+
throw new Error(`${what} failed after ${PUT_ATTEMPTS} tries: ${cause?.code ?? cause?.message ?? err.message}.`);
|
|
785
|
+
}
|
|
786
|
+
await new Promise((resolve) => setTimeout(resolve, 500 * attempt));
|
|
787
|
+
}
|
|
788
|
+
}
|
|
454
789
|
/** PUT each file to /data/v1/uploads/<grant> — the grant is the credential. */
|
|
455
790
|
async function uploadFiles(grant, files) {
|
|
456
791
|
const { apiUrl } = siteConfig();
|
|
457
792
|
const queue = [...files];
|
|
458
793
|
async function worker() {
|
|
459
794
|
for (let file = queue.shift(); file; file = queue.shift()) {
|
|
460
|
-
const
|
|
461
|
-
const res = await fetch(url, {
|
|
462
|
-
method: "PUT",
|
|
463
|
-
body: Buffer.from(file.data)
|
|
464
|
-
});
|
|
795
|
+
const res = await putWithRetry(`${apiUrl}/data/v1/uploads/${encodeURIComponent(grant)}?path=${encodeURIComponent(file.path)}`, {}, file.data, `Upload of ${file.path}`);
|
|
465
796
|
if (!res.ok) {
|
|
466
797
|
const payload = await res.json().catch(() => ({}));
|
|
467
798
|
throw new Error(`Upload of ${file.path} failed (HTTP ${res.status}${payload.error ? `, ${payload.error}` : ""}).`);
|
|
@@ -470,6 +801,40 @@ async function uploadFiles(grant, files) {
|
|
|
470
801
|
}
|
|
471
802
|
await Promise.all(Array.from({ length: UPLOAD_CONCURRENCY }, worker));
|
|
472
803
|
}
|
|
804
|
+
/** The project's stored media, under the deploy's grant. */
|
|
805
|
+
async function mediaManifest(grant) {
|
|
806
|
+
const { apiUrl } = siteConfig();
|
|
807
|
+
const res = await fetch(`${apiUrl}/data/v1/media/${encodeURIComponent(grant)}/manifest`);
|
|
808
|
+
if (!res.ok) throw new Error(`Reading the site media manifest failed (HTTP ${res.status}).`);
|
|
809
|
+
return await res.json();
|
|
810
|
+
}
|
|
811
|
+
/** PUT each new or changed media file with its hash; the store refuses a mismatch. */
|
|
812
|
+
async function uploadMedia(grant, files) {
|
|
813
|
+
const { apiUrl } = siteConfig();
|
|
814
|
+
const queue = [...files];
|
|
815
|
+
async function worker() {
|
|
816
|
+
for (let file = queue.shift(); file; file = queue.shift()) {
|
|
817
|
+
const res = await putWithRetry(`${apiUrl}/data/v1/media/${encodeURIComponent(grant)}?path=${encodeURIComponent(file.path)}`, { "x-canopy-sha256": file.sha256 }, file.data, `Site media upload of ${file.path} (${formatSize(file.data.byteLength)})`);
|
|
818
|
+
if (!res.ok) {
|
|
819
|
+
const payload = await res.json().catch(() => ({}));
|
|
820
|
+
throw new Error(`Site media upload of ${file.path} failed (HTTP ${res.status}${payload.error ? `, ${payload.error}` : ""})${payload.detail ? `: ${payload.detail}` : "."}`);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
await Promise.all(Array.from({ length: UPLOAD_CONCURRENCY }, worker));
|
|
825
|
+
}
|
|
826
|
+
/** --prune-media: delete stored media that's gone from the build, 1000 per call. */
|
|
827
|
+
async function deleteMedia(grant, paths) {
|
|
828
|
+
const { apiUrl } = siteConfig();
|
|
829
|
+
for (let i = 0; i < paths.length; i += 1e3) {
|
|
830
|
+
const res = await fetch(`${apiUrl}/data/v1/media/${encodeURIComponent(grant)}/delete`, {
|
|
831
|
+
method: "POST",
|
|
832
|
+
headers: { "content-type": "application/json" },
|
|
833
|
+
body: JSON.stringify({ paths: paths.slice(i, i + 1e3) })
|
|
834
|
+
});
|
|
835
|
+
if (!res.ok) throw new Error(`Pruning site media failed (HTTP ${res.status}).`);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
473
838
|
/** Show the deploy history and ask which version to act on. */
|
|
474
839
|
async function pickVersion(deploys, live, message, initial) {
|
|
475
840
|
return unwrap(await p.select({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as projectDialect, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-
|
|
2
|
-
import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-
|
|
3
|
-
import { a as apiRequest, m as withContext, t as ApiError } from "./api-
|
|
4
|
-
import { i as reportErrors, n as formatDateTime } from "./ui-
|
|
5
|
-
import { r as readMigrationFiles } from "./migrations-
|
|
6
|
-
import { s as parseAppRoleFlag } from "./roles-
|
|
1
|
+
import { c as projectDialect, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-Dlg7aeRj.mjs";
|
|
3
|
+
import { a as apiRequest, m as withContext, t as ApiError } from "./api-CpG-9WSe.mjs";
|
|
4
|
+
import { i as reportErrors, n as formatDateTime } from "./ui-BUeiY_zZ.mjs";
|
|
5
|
+
import { r as readMigrationFiles } from "./migrations-DJrRnU7X.mjs";
|
|
6
|
+
import { s as parseAppRoleFlag } from "./roles-BCJWHeGq.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";
|
|
@@ -107,7 +107,7 @@ async function workerPlugin(flags, slug, workerAttest, remoteUser, roles) {
|
|
|
107
107
|
console.log(`note: canopy.json points "worker" at ${entry}, which does not exist — skipping.`);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-
|
|
110
|
+
const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-DEK8fOgz.mjs");
|
|
111
111
|
const secrets = readDevVars(flags.dir);
|
|
112
112
|
const email = siteConfig().email;
|
|
113
113
|
const found = await remoteUser?.() ?? (email ? {
|
|
@@ -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-CFxKguzg.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-CFxKguzg.mjs");
|
|
347
347
|
const sandbox = await createSandbox({
|
|
348
348
|
slug,
|
|
349
349
|
persistDir: join(flags.dir, ".canopy", "local"),
|