@void/deploy-cloudflare 0.20.1 → 0.20.2
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/index.d.mts +19 -0
- package/dist/index.mjs +147 -39
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -321,4 +321,23 @@ export declare function normalizeWorkersDevSubdomain(value: string | undefined):
|
|
|
321
321
|
/** Extract the account subdomain from a Wrangler-reported workers.dev URL. */
|
|
322
322
|
export declare function extractWorkersDevSubdomain(url: string): string | undefined;
|
|
323
323
|
//#endregion
|
|
324
|
+
//#region src/metadata.d.ts
|
|
325
|
+
/**
|
|
326
|
+
* Share one authenticated transport for the activator's read-only metadata calls.
|
|
327
|
+
* Writes and unsupported commands retain the pinned Wrangler runner. Responses
|
|
328
|
+
* keep its JSON contract so activation and concurrency checks remain unchanged.
|
|
329
|
+
*/
|
|
330
|
+
export declare function createCloudflareMetadataRunner(options: {
|
|
331
|
+
runWrangler: CloudflareCommandRunner;
|
|
332
|
+
accountId: string;
|
|
333
|
+
apiBaseUrl: string;
|
|
334
|
+
workerName: string;
|
|
335
|
+
configPath?: string;
|
|
336
|
+
getToken: () => Promise<string | null>;
|
|
337
|
+
verifyUploader: () => boolean;
|
|
338
|
+
fetch?: typeof globalThis.fetch;
|
|
339
|
+
/** Environment used to decide whether Wrangler's proxy-aware transport is required. */
|
|
340
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
341
|
+
}): CloudflareCommandRunner;
|
|
342
|
+
//#endregion
|
|
324
343
|
export type { ApprovedCloudflareKvBinding, CloudflareCommandResult, CloudflareCommandRunner, CloudflareDeployExecution, CloudflareFrameworkDeployConfig, CloudflareStaticDeployConfig, CloudflareTrafficConfig, CloudflareTriggerConfig, CloudflareTriggerStabilization, CloudflareVersionActivation, CloudflareVersionActivationOptions, CloudflareVersionMetadata, CloudflareWorkerMigrationTagOptions, ExistingCloudflareWorker };
|
package/dist/index.mjs
CHANGED
|
@@ -130,7 +130,7 @@ async function readCloudflareWorker(options, allowMissing) {
|
|
|
130
130
|
}
|
|
131
131
|
try {
|
|
132
132
|
const value = JSON.parse(result.stdout);
|
|
133
|
-
if (record(value)) return value;
|
|
133
|
+
if (record$1(value)) return value;
|
|
134
134
|
} catch {}
|
|
135
135
|
throw new Error("Cloudflare returned an invalid existing Worker response.");
|
|
136
136
|
};
|
|
@@ -141,7 +141,7 @@ async function readCloudflareWorker(options, allowMissing) {
|
|
|
141
141
|
if (deployment === null) return null;
|
|
142
142
|
const versions = deployment.versions;
|
|
143
143
|
if (allowMissing && Array.isArray(versions) && versions.length === 0) return null;
|
|
144
|
-
if (!Array.isArray(versions) || versions.length !== 1 || !record(versions[0]) || versions[0].percentage !== 100 || typeof versions[0].version_id !== "string") throw new Error("The existing Worker must have one deployed version receiving all traffic. Finish any gradual rollout before linking.");
|
|
144
|
+
if (!Array.isArray(versions) || versions.length !== 1 || !record$1(versions[0]) || versions[0].percentage !== 100 || typeof versions[0].version_id !== "string") throw new Error("The existing Worker must have one deployed version receiving all traffic. Finish any gradual rollout before linking.");
|
|
145
145
|
const versionId = versions[0].version_id;
|
|
146
146
|
const version = await read([
|
|
147
147
|
"versions",
|
|
@@ -150,7 +150,7 @@ async function readCloudflareWorker(options, allowMissing) {
|
|
|
150
150
|
]);
|
|
151
151
|
if (version === null) throw new Error("Cloudflare did not return the existing Worker configuration.");
|
|
152
152
|
const resources = version.resources;
|
|
153
|
-
if (version.id !== versionId || !record(resources) || !Array.isArray(resources.bindings) || !resources.bindings.every(record) || !record(resources.script_runtime) || !record(resources.script)) throw new Error("Cloudflare did not return the existing Worker configuration.");
|
|
153
|
+
if (version.id !== versionId || !record$1(resources) || !Array.isArray(resources.bindings) || !resources.bindings.every(record$1) || !record$1(resources.script_runtime) || !record$1(resources.script)) throw new Error("Cloudflare did not return the existing Worker configuration.");
|
|
154
154
|
const after = options.versionId ? deployment : await read(["deployments", "status"]);
|
|
155
155
|
if (after === null || !isDeepStrictEqual(deployment.versions, after.versions)) throw new Error("Cloudflare production changed while linking. Retry from the current deployment.");
|
|
156
156
|
return {
|
|
@@ -165,12 +165,12 @@ async function readCloudflareWorker(options, allowMissing) {
|
|
|
165
165
|
}
|
|
166
166
|
/** Parse legacy version-detail shapes; this is not authoritative Worker migration state. */
|
|
167
167
|
function readCloudflareVersionMigrationTag(version) {
|
|
168
|
-
if (!record(version)) return null;
|
|
169
|
-
const resources = record(version.resources) ? version.resources : void 0;
|
|
168
|
+
if (!record$1(version)) return null;
|
|
169
|
+
const resources = record$1(version.resources) ? version.resources : void 0;
|
|
170
170
|
const tag = [
|
|
171
|
-
resources && record(resources.script_runtime) ? resources.script_runtime.migration_tag : null,
|
|
172
|
-
resources && record(resources.script) ? resources.script.migration_tag : null,
|
|
173
|
-
record(version.script) ? version.script.migration_tag : null,
|
|
171
|
+
resources && record$1(resources.script_runtime) ? resources.script_runtime.migration_tag : null,
|
|
172
|
+
resources && record$1(resources.script) ? resources.script.migration_tag : null,
|
|
173
|
+
record$1(version.script) ? version.script.migration_tag : null,
|
|
174
174
|
version.migration_tag
|
|
175
175
|
].find((candidate) => typeof candidate === "string");
|
|
176
176
|
return typeof tag === "string" && tag.length > 0 ? tag : null;
|
|
@@ -195,9 +195,9 @@ async function readCloudflareWorkerMigrationTag(options) {
|
|
|
195
195
|
} catch {
|
|
196
196
|
throw new Error(`Cloudflare returned an invalid Durable Object migration response for Worker "${options.workerName}".`);
|
|
197
197
|
}
|
|
198
|
-
if (!response.ok || !record(body) || body.success !== true || !Array.isArray(body.result)) throw new Error(`Could not verify Durable Object migration state for Cloudflare Worker "${options.workerName}".`);
|
|
199
|
-
const worker = body.result.find((candidate) => record(candidate) && candidate.id === options.workerName);
|
|
200
|
-
if (!record(worker)) throw new Error(`Cloudflare did not return migration state for Worker "${options.workerName}".`);
|
|
198
|
+
if (!response.ok || !record$1(body) || body.success !== true || !Array.isArray(body.result)) throw new Error(`Could not verify Durable Object migration state for Cloudflare Worker "${options.workerName}".`);
|
|
199
|
+
const worker = body.result.find((candidate) => record$1(candidate) && candidate.id === options.workerName);
|
|
200
|
+
if (!record$1(worker)) throw new Error(`Cloudflare did not return migration state for Worker "${options.workerName}".`);
|
|
201
201
|
if (worker.migration_tag === void 0 || worker.migration_tag === null) return null;
|
|
202
202
|
if (typeof worker.migration_tag !== "string" || worker.migration_tag.length === 0) throw new Error(`Cloudflare returned an invalid Durable Object migration response for Worker "${options.workerName}".`);
|
|
203
203
|
return worker.migration_tag;
|
|
@@ -215,7 +215,7 @@ async function readCloudflareApiAuthentication(runWrangler) {
|
|
|
215
215
|
} catch {
|
|
216
216
|
throw new Error("Cloudflare returned an invalid authentication response.");
|
|
217
217
|
}
|
|
218
|
-
if (!record(value)) throw new Error("Cloudflare returned an invalid authentication response.");
|
|
218
|
+
if (!record$1(value)) throw new Error("Cloudflare returned an invalid authentication response.");
|
|
219
219
|
if ((value.type === "oauth" || value.type === "api_token") && typeof value.token === "string" && value.token.length > 0) return { Authorization: `Bearer ${value.token}` };
|
|
220
220
|
if (value.type === "api_key" && typeof value.key === "string" && value.key.length > 0 && typeof value.email === "string" && value.email.length > 0) return {
|
|
221
221
|
"X-Auth-Key": value.key,
|
|
@@ -260,7 +260,7 @@ function parseDurableObjectMigrations(value) {
|
|
|
260
260
|
if (value === void 0) return [];
|
|
261
261
|
if (!Array.isArray(value)) throw new Error("deploy: generated Cloudflare config has a malformed migrations field.");
|
|
262
262
|
return value.map((migration) => {
|
|
263
|
-
if (!record(migration) || typeof migration.tag !== "string") throw new Error("deploy: generated Cloudflare config has a malformed class migration.");
|
|
263
|
+
if (!record$1(migration) || typeof migration.tag !== "string") throw new Error("deploy: generated Cloudflare config has a malformed class migration.");
|
|
264
264
|
const fields = [
|
|
265
265
|
migration.new_classes,
|
|
266
266
|
migration.new_sqlite_classes,
|
|
@@ -301,7 +301,7 @@ function assertCloudflareBindingsPreserved(before, after, approvedKv = [], optio
|
|
|
301
301
|
}
|
|
302
302
|
function isAssetsOnlyWorker(worker) {
|
|
303
303
|
const handlers = worker.script.handlers;
|
|
304
|
-
return record(worker.runtime.assets) && (handlers === null || Array.isArray(handlers) && handlers.length === 0);
|
|
304
|
+
return record$1(worker.runtime.assets) && (handlers === null || Array.isArray(handlers) && handlers.length === 0);
|
|
305
305
|
}
|
|
306
306
|
function existingWorkerHandlers(worker) {
|
|
307
307
|
return isAssetsOnlyWorker(worker) ? [] : worker.script.handlers;
|
|
@@ -312,12 +312,12 @@ function assertExistingCloudflareConfig(existing, config, built = false, approve
|
|
|
312
312
|
if (additions.length > 0) {
|
|
313
313
|
const entries = config.kv_namespaces;
|
|
314
314
|
for (const addition of additions) {
|
|
315
|
-
const matches = Array.isArray(entries) ? entries.filter((entry) => record(entry) && entry.binding === addition.binding) : [];
|
|
315
|
+
const matches = Array.isArray(entries) ? entries.filter((entry) => record$1(entry) && entry.binding === addition.binding) : [];
|
|
316
316
|
if ((built || matches.length > 0) && (matches.length !== 1 || matches[0].id !== addition.id)) throw new Error(`Binding ${addition.binding} must reference its approved KV namespace when linking.`);
|
|
317
317
|
}
|
|
318
318
|
if (Array.isArray(entries)) config = {
|
|
319
319
|
...config,
|
|
320
|
-
kv_namespaces: entries.filter((entry) => !record(entry) || !additions.some((addition) => addition.binding === entry.binding))
|
|
320
|
+
kv_namespaces: entries.filter((entry) => !record$1(entry) || !additions.some((addition) => addition.binding === entry.binding))
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
const handlers = existingWorkerHandlers(existing);
|
|
@@ -334,7 +334,7 @@ function assertExistingCloudflareConfig(existing, config, built = false, approve
|
|
|
334
334
|
const value = config[field];
|
|
335
335
|
if (hasContent(value)) throw new Error(`The existing Worker handoff cannot change ${field}. Keep this deployment limited to the existing site.`);
|
|
336
336
|
}
|
|
337
|
-
if (record(existing.runtime.exports) && Object.values(existing.runtime.exports).some((value) => record(value) && value.type !== "worker")) throw new Error("The existing Worker exports stateful classes. Migrate those classes separately before linking.");
|
|
337
|
+
if (record$1(existing.runtime.exports) && Object.values(existing.runtime.exports).some((value) => record$1(value) && value.type !== "worker")) throw new Error("The existing Worker exports stateful classes. Migrate those classes separately before linking.");
|
|
338
338
|
for (const field of [
|
|
339
339
|
"compatibility_date",
|
|
340
340
|
"compatibility_flags",
|
|
@@ -345,7 +345,7 @@ function assertExistingCloudflareConfig(existing, config, built = false, approve
|
|
|
345
345
|
const equal = field === "compatibility_flags" ? stringSetEqual(actual, expected) : isDeepStrictEqual(actual, expected);
|
|
346
346
|
if ((built || config[field] !== void 0) && !equal) throw new Error(`Keep the existing Worker's ${field} when linking. Update it in a later deployment.`);
|
|
347
347
|
}
|
|
348
|
-
const vars = record(config.vars) ? config.vars : {};
|
|
348
|
+
const vars = record$1(config.vars) ? config.vars : {};
|
|
349
349
|
const remote = new Map(existing.bindings.map((binding) => [binding.name, binding]));
|
|
350
350
|
for (const [name, value] of Object.entries(vars)) {
|
|
351
351
|
const binding = remote.get(name);
|
|
@@ -389,21 +389,21 @@ function assertExistingCloudflareConfig(existing, config, built = false, approve
|
|
|
389
389
|
"secret_key"
|
|
390
390
|
].includes(String(binding.type))) continue;
|
|
391
391
|
if (binding.type === "assets") {
|
|
392
|
-
if (built && (!record(config.assets) || config.assets.binding !== binding.name)) throw new Error(`Keep the existing assets binding ${binding.name} when linking.`);
|
|
392
|
+
if (built && (!record$1(config.assets) || config.assets.binding !== binding.name)) throw new Error(`Keep the existing assets binding ${binding.name} when linking.`);
|
|
393
393
|
continue;
|
|
394
394
|
}
|
|
395
395
|
const mapping = supported[String(binding.type)];
|
|
396
396
|
if (!mapping) throw new Error(`The existing binding ${binding.name} (${String(binding.type)}) is not yet supported when linking.`);
|
|
397
397
|
const [field, localId, remoteId] = mapping;
|
|
398
398
|
const entries = config[field];
|
|
399
|
-
const matches = Array.isArray(entries) ? entries.filter((entry) => record(entry) && entry.binding === binding.name) : [];
|
|
399
|
+
const matches = Array.isArray(entries) ? entries.filter((entry) => record$1(entry) && entry.binding === binding.name) : [];
|
|
400
400
|
const entry = matches[0];
|
|
401
|
-
if (matches.length !== 1 || !record(entry) || typeof binding[remoteId] !== "string" || entry[localId] !== binding[remoteId] || binding.type === "service" && ((entry.environment ?? "production") !== (binding.environment ?? "production") || entry.entrypoint !== binding.entrypoint) || binding.type === "r2_bucket" && (entry.jurisdiction ?? "default") !== (binding.jurisdiction ?? "default")) throw new Error(`Binding ${binding.name} must reference the existing Cloudflare resource when linking.`);
|
|
401
|
+
if (matches.length !== 1 || !record$1(entry) || typeof binding[remoteId] !== "string" || entry[localId] !== binding[remoteId] || binding.type === "service" && ((entry.environment ?? "production") !== (binding.environment ?? "production") || entry.entrypoint !== binding.entrypoint) || binding.type === "r2_bucket" && (entry.jurisdiction ?? "default") !== (binding.jurisdiction ?? "default")) throw new Error(`Binding ${binding.name} must reference the existing Cloudflare resource when linking.`);
|
|
402
402
|
found.add(binding.name);
|
|
403
403
|
}
|
|
404
404
|
for (const [field] of Object.values(supported)) {
|
|
405
405
|
const entries = config[field];
|
|
406
|
-
if (Array.isArray(entries) && entries.some((entry) => !record(entry) || !found.has(String(entry.binding)))) throw new Error(`Linking cannot add or replace ${field}. Use the existing resource bindings.`);
|
|
406
|
+
if (Array.isArray(entries) && entries.some((entry) => !record$1(entry) || !found.has(String(entry.binding)))) throw new Error(`Linking cannot add or replace ${field}. Use the existing resource bindings.`);
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
function newApprovedKvBindings(existing, approved) {
|
|
@@ -426,13 +426,13 @@ function stringSetEqual(left, right) {
|
|
|
426
426
|
if (!Array.isArray(left) || !left.every((value) => typeof value === "string") || !Array.isArray(right) || !right.every((value) => typeof value === "string")) return false;
|
|
427
427
|
return isDeepStrictEqual([...new Set(left)].sort(), [...new Set(right)].sort());
|
|
428
428
|
}
|
|
429
|
-
function record(value) {
|
|
429
|
+
function record$1(value) {
|
|
430
430
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
431
431
|
}
|
|
432
432
|
function hasContent(value) {
|
|
433
433
|
if (value === void 0 || value === null) return false;
|
|
434
434
|
if (Array.isArray(value)) return value.length > 0;
|
|
435
|
-
if (record(value)) return Object.values(value).some(hasContent);
|
|
435
|
+
if (record$1(value)) return Object.values(value).some(hasContent);
|
|
436
436
|
return true;
|
|
437
437
|
}
|
|
438
438
|
//#endregion
|
|
@@ -1166,10 +1166,10 @@ async function activateCloudflareVersionWithSecretsFile(options) {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
const desiredMetadata = parseCloudflareVersionMessage(options.message);
|
|
1168
1168
|
let desiredTriggerConfig = desiredMetadata?.schema === 2 ? desiredMetadata.triggerConfig : options.configPath ? readCloudflareTriggerConfig(options.configPath) : triggerConfigFromWrangler({});
|
|
1169
|
-
let previousVersion = previousVersionId && desiredMetadata?.schema === 2 ? await readCloudflareVersionInspection(options, commonArgs, previousVersionId) : null;
|
|
1169
|
+
let previousVersion = previousVersionId && desiredMetadata?.schema === 2 ? await readCloudflareVersionInspection(options, commonArgs, previousVersionId, inheritanceBaseline?.map((version) => version.inspection)) : null;
|
|
1170
1170
|
async function previousIsSecretOnlyDraft() {
|
|
1171
1171
|
if (!previousVersionId) return false;
|
|
1172
|
-
previousVersion ??= await readCloudflareVersionInspection(options, commonArgs, previousVersionId);
|
|
1172
|
+
previousVersion ??= await readCloudflareVersionInspection(options, commonArgs, previousVersionId, inheritanceBaseline?.map((version) => version.inspection));
|
|
1173
1173
|
return previousVersion?.isSecretOnlyDraft === true;
|
|
1174
1174
|
}
|
|
1175
1175
|
const previousMetadata = desiredMetadata?.schema === 2 ? previousVersion?.metadata : null;
|
|
@@ -1539,18 +1539,21 @@ async function restorePreviousVersionAndTriggers(options, commonArgs, previousVe
|
|
|
1539
1539
|
async function readCloudflareVersionMetadata(options, commonArgs, versionId) {
|
|
1540
1540
|
return (await readCloudflareVersionInspection(options, commonArgs, versionId))?.metadata ?? null;
|
|
1541
1541
|
}
|
|
1542
|
-
async function readCloudflareVersionInspection(options, commonArgs, versionId) {
|
|
1543
|
-
const result = await Promise.resolve(options.runWrangler([
|
|
1544
|
-
"versions",
|
|
1545
|
-
"list",
|
|
1546
|
-
...commonArgs,
|
|
1547
|
-
"--name",
|
|
1548
|
-
options.workerName,
|
|
1549
|
-
"--json"
|
|
1550
|
-
], { capture: true }));
|
|
1551
|
-
if (!isCleanCommandExit(result)) return null;
|
|
1542
|
+
async function readCloudflareVersionInspection(options, commonArgs, versionId, knownVersions) {
|
|
1552
1543
|
try {
|
|
1553
|
-
|
|
1544
|
+
let versions = knownVersions;
|
|
1545
|
+
if (versions === void 0) {
|
|
1546
|
+
const result = await options.runWrangler([
|
|
1547
|
+
"versions",
|
|
1548
|
+
"list",
|
|
1549
|
+
...commonArgs,
|
|
1550
|
+
"--name",
|
|
1551
|
+
options.workerName,
|
|
1552
|
+
"--json"
|
|
1553
|
+
], { capture: true });
|
|
1554
|
+
if (!isCleanCommandExit(result)) return null;
|
|
1555
|
+
versions = JSON.parse(result.stdout);
|
|
1556
|
+
}
|
|
1554
1557
|
if (!Array.isArray(versions)) return null;
|
|
1555
1558
|
for (const entry of versions) {
|
|
1556
1559
|
if (!isRecord(entry) || entry.id !== versionId) continue;
|
|
@@ -1600,7 +1603,8 @@ async function readRecentCloudflareVersionIds(options, commonArgs) {
|
|
|
1600
1603
|
if (!Array.isArray(versions) || !versions.every((version) => isRecord(version) && typeof version.id === "string" && typeof version.number === "number" && Number.isSafeInteger(version.number))) return null;
|
|
1601
1604
|
return versions.map((version) => ({
|
|
1602
1605
|
id: version.id,
|
|
1603
|
-
number: version.number
|
|
1606
|
+
number: version.number,
|
|
1607
|
+
inspection: version
|
|
1604
1608
|
}));
|
|
1605
1609
|
} catch {
|
|
1606
1610
|
return null;
|
|
@@ -1963,4 +1967,108 @@ function defaultSleep(milliseconds) {
|
|
|
1963
1967
|
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
1964
1968
|
}
|
|
1965
1969
|
//#endregion
|
|
1966
|
-
|
|
1970
|
+
//#region src/metadata.ts
|
|
1971
|
+
/**
|
|
1972
|
+
* Share one authenticated transport for the activator's read-only metadata calls.
|
|
1973
|
+
* Writes and unsupported commands retain the pinned Wrangler runner. Responses
|
|
1974
|
+
* keep its JSON contract so activation and concurrency checks remain unchanged.
|
|
1975
|
+
*/
|
|
1976
|
+
function createCloudflareMetadataRunner(options) {
|
|
1977
|
+
let tokenPromise;
|
|
1978
|
+
const common = [
|
|
1979
|
+
...options.configPath ? ["-c", options.configPath] : [],
|
|
1980
|
+
"--env=",
|
|
1981
|
+
"--name",
|
|
1982
|
+
options.workerName,
|
|
1983
|
+
"--json"
|
|
1984
|
+
];
|
|
1985
|
+
const prefix = `${options.apiBaseUrl.replace(/\/$/, "")}/accounts/${encodeURIComponent(options.accountId)}/workers/scripts/${encodeURIComponent(options.workerName)}`;
|
|
1986
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
1987
|
+
const proxyEnv = options.env ?? process.env;
|
|
1988
|
+
const requiresWranglerProxy = Boolean(proxyEnv.https_proxy || proxyEnv.HTTPS_PROXY || proxyEnv.http_proxy || proxyEnv.HTTP_PROXY);
|
|
1989
|
+
const refused = {
|
|
1990
|
+
status: 1,
|
|
1991
|
+
stdout: "",
|
|
1992
|
+
stderr: "Cloudflare uploader integrity check failed.",
|
|
1993
|
+
error: "uploader-changed"
|
|
1994
|
+
};
|
|
1995
|
+
const fallback = (args, runOptions) => options.verifyUploader() ? options.runWrangler(args, runOptions) : refused;
|
|
1996
|
+
return async (args, runOptions) => {
|
|
1997
|
+
let kind;
|
|
1998
|
+
let resource;
|
|
1999
|
+
let rest = [];
|
|
2000
|
+
if (args[0] === "deployments" && args[1] === "status") {
|
|
2001
|
+
kind = "deployment";
|
|
2002
|
+
resource = "/deployments";
|
|
2003
|
+
rest = args.slice(2);
|
|
2004
|
+
} else if (args[0] === "versions" && args[1] === "list") {
|
|
2005
|
+
kind = "versions";
|
|
2006
|
+
resource = "/versions?deployable=true";
|
|
2007
|
+
rest = args.slice(2);
|
|
2008
|
+
} else if (args[0] === "versions" && args[1] === "view" && /^[0-9a-f-]{36}$/i.test(args[2] ?? "")) {
|
|
2009
|
+
kind = "version";
|
|
2010
|
+
resource = `/versions/${encodeURIComponent(args[2])}`;
|
|
2011
|
+
rest = args.slice(3);
|
|
2012
|
+
}
|
|
2013
|
+
if (!kind || !runOptions.capture || rest.length !== common.length || rest.some((value, i) => value !== common[i])) return fallback(args, runOptions);
|
|
2014
|
+
if (requiresWranglerProxy) return fallback(args, runOptions);
|
|
2015
|
+
let response;
|
|
2016
|
+
try {
|
|
2017
|
+
if (!tokenPromise && !options.verifyUploader()) return refused;
|
|
2018
|
+
const token = await (tokenPromise ??= options.getToken());
|
|
2019
|
+
if (token) {
|
|
2020
|
+
response = await fetcher(prefix + resource, {
|
|
2021
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
2022
|
+
redirect: "manual",
|
|
2023
|
+
signal: AbortSignal.timeout(1e4)
|
|
2024
|
+
});
|
|
2025
|
+
if (response.status === 401 || response.status === 403) tokenPromise = void 0;
|
|
2026
|
+
if (response.ok) {
|
|
2027
|
+
const body = await response.json();
|
|
2028
|
+
if (record(body) && body.success === true && record(body.result)) {
|
|
2029
|
+
const result = body.result;
|
|
2030
|
+
if (kind === "deployment" && Array.isArray(result.deployments)) {
|
|
2031
|
+
const latest = result.deployments[0];
|
|
2032
|
+
if (result.deployments.length === 0) return {
|
|
2033
|
+
status: 1,
|
|
2034
|
+
stdout: "",
|
|
2035
|
+
stderr: `The Worker ${options.workerName} has no deployments.`
|
|
2036
|
+
};
|
|
2037
|
+
if (record(latest) && Array.isArray(latest.versions)) return {
|
|
2038
|
+
status: 0,
|
|
2039
|
+
stdout: JSON.stringify(latest),
|
|
2040
|
+
stderr: ""
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
if (kind === "version" && result.id === args[2]) return {
|
|
2044
|
+
status: 0,
|
|
2045
|
+
stdout: JSON.stringify(result),
|
|
2046
|
+
stderr: ""
|
|
2047
|
+
};
|
|
2048
|
+
if (kind === "versions" && Array.isArray(result.items)) {
|
|
2049
|
+
const items = result.items;
|
|
2050
|
+
if (items.every((item) => record(item) && record(item.metadata) && typeof item.metadata.created_on === "string")) {
|
|
2051
|
+
const sorted = items.sort((a, b) => a.metadata.created_on.localeCompare(b.metadata.created_on)).slice(-10);
|
|
2052
|
+
return {
|
|
2053
|
+
status: 0,
|
|
2054
|
+
stdout: JSON.stringify(sorted),
|
|
2055
|
+
stderr: ""
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
} catch {
|
|
2063
|
+
tokenPromise = void 0;
|
|
2064
|
+
} finally {
|
|
2065
|
+
if (response && !response.bodyUsed) await response.body?.cancel().catch(() => {});
|
|
2066
|
+
}
|
|
2067
|
+
return fallback(args, runOptions);
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
function record(value) {
|
|
2071
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2072
|
+
}
|
|
2073
|
+
//#endregion
|
|
2074
|
+
export { activateCloudflareVersion, assertCloudflareBindingsPreserved, assertCloudflareDurableObjectLifecycleSupported, assertExistingCloudflareConfig, createCloudflareMetadataRunner, deployCloudflareVersionTraffic, deployCloudflareVersionTriggers, encodeCloudflareVersionMessage, executeCloudflareDeploy, extractWorkersDevSubdomain, normalizeWorkersDevSubdomain, parseCloudflareVersionMessage, parseRootWranglerConfig, readBindingFieldPresence, readCloudflareTriggerConfig, readCloudflareVersionMigrationTag, readCloudflareWorkerMigrationTag, readConfigEntryString, readExistingCloudflareWorker, readStoredResourceName, readWranglerTopLevelString, renderCloudflareStaticEntry, resolveD1MigrateTarget, stabilizeCloudflareVersionTriggers, stageCloudflareStaticAssets, writeCloudflareFrameworkDeployConfig, writeCloudflareStaticDeployConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/deploy-cloudflare",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/voidzero-dev/void.git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@void/deploy-core": "0.20.
|
|
23
|
+
"@void/deploy-core": "0.20.2",
|
|
24
24
|
"jsonc-parser": "3.3.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|