@cloudflare/deploy-helpers 0.24.4 → 0.24.5
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 +8 -4
- package/dist/index.mjs +41 -23
- package/dist/metafile-esm.json +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ import { FormData } from 'undici';
|
|
|
6
6
|
export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType } from './create-worker-upload-form.mjs';
|
|
7
7
|
import { Options } from '@cspotcode/source-map-support';
|
|
8
8
|
import Protocol from 'devtools-protocol';
|
|
9
|
-
import { NodeJSCompatMode } from '
|
|
9
|
+
import { NodeJSCompatMode } from '@cloudflare/workers-utils/node-compat';
|
|
10
10
|
import { ParsedOutputWorkerConfig, ParsedOutputRootConfig, ParsedOutputContainerConfig } from '@cloudflare/config';
|
|
11
11
|
import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
|
|
12
12
|
|
|
@@ -699,9 +699,11 @@ type RoutesRes = {
|
|
|
699
699
|
script: string;
|
|
700
700
|
}[];
|
|
701
701
|
/**
|
|
702
|
-
* Downloads
|
|
702
|
+
* Downloads the information required to construct a Wrangler config file for a Worker from the API.
|
|
703
|
+
* When `localRoutes` is provided, only fetches the route categories that the
|
|
704
|
+
* current deployment can change. Omit it when downloading a complete config.
|
|
703
705
|
*/
|
|
704
|
-
declare function fetchWorkerConfig(complianceConfig: ComplianceConfig, accountId: string, workerName: string, environment: string): Promise<{
|
|
706
|
+
declare function fetchWorkerConfig(complianceConfig: ComplianceConfig, accountId: string, workerName: string, environment: string, localRoutes?: Route[]): Promise<{
|
|
705
707
|
bindings: _cloudflare_workers_utils.WorkerMetadataBinding[];
|
|
706
708
|
routes: RoutesRes;
|
|
707
709
|
customDomains: CustomDomainsRes;
|
|
@@ -737,8 +739,10 @@ declare function fetchWorkerConfig(complianceConfig: ComplianceConfig, accountId
|
|
|
737
739
|
/**
|
|
738
740
|
* Downloads all the remote information we can gather for a worker and from them generates a raw configuration object that
|
|
739
741
|
* approximates what a wrangler config object for the worker was/would have been.
|
|
742
|
+
* When `localRoutes` is provided, route metadata is limited to categories that
|
|
743
|
+
* the current deployment can change. Omit it when downloading a complete config.
|
|
740
744
|
*/
|
|
741
|
-
declare function downloadWorkerConfig(complianceConfig: ComplianceConfig, workerName: string, environment: string, entrypoint: string, accountId: string): Promise<RawConfig>;
|
|
745
|
+
declare function downloadWorkerConfig(complianceConfig: ComplianceConfig, workerName: string, environment: string, entrypoint: string, accountId: string, localRoutes?: Route[]): Promise<RawConfig>;
|
|
742
746
|
|
|
743
747
|
/**
|
|
744
748
|
* For a given Worker + migrations config, figure out which migrations
|
package/dist/index.mjs
CHANGED
|
@@ -28,9 +28,10 @@ import { brandColor, white, gray, bold, yellow, dim, red, blue } from '@cloudfla
|
|
|
28
28
|
import { setTimeout as setTimeout$1 } from 'node:timers/promises';
|
|
29
29
|
import readline from 'node:readline';
|
|
30
30
|
import { parse as parse$1 } from 'dotenv';
|
|
31
|
-
import { getFreshSourceMapSupport
|
|
31
|
+
import { getFreshSourceMapSupport } from '@cloudflare/workers-utils/sourcemap';
|
|
32
32
|
import { createHash } from 'node:crypto';
|
|
33
33
|
import { execSync } from 'node:child_process';
|
|
34
|
+
import { getNodeCompat } from '@cloudflare/workers-utils/node-compat';
|
|
34
35
|
import { convertToWranglerConfig } from '@cloudflare/config';
|
|
35
36
|
|
|
36
37
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
@@ -2837,6 +2838,25 @@ function validateOwnedWorkflowDeclarations(config2, scriptName) {
|
|
|
2837
2838
|
}
|
|
2838
2839
|
__name(validateOwnedWorkflowDeclarations, "validateOwnedWorkflowDeclarations");
|
|
2839
2840
|
|
|
2841
|
+
// src/shared/partition-routes.ts
|
|
2842
|
+
function partitionRoutes(routes) {
|
|
2843
|
+
const routesOnly = [];
|
|
2844
|
+
const customDomainsOnly = [];
|
|
2845
|
+
for (const route of routes) {
|
|
2846
|
+
if (isCustomDomainRoute(route)) {
|
|
2847
|
+
customDomainsOnly.push(route);
|
|
2848
|
+
} else {
|
|
2849
|
+
routesOnly.push(route);
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
return { routesOnly, customDomainsOnly };
|
|
2853
|
+
}
|
|
2854
|
+
__name(partitionRoutes, "partitionRoutes");
|
|
2855
|
+
function isCustomDomainRoute(route) {
|
|
2856
|
+
return typeof route !== "string" && route.custom_domain === true;
|
|
2857
|
+
}
|
|
2858
|
+
__name(isCustomDomainRoute, "isCustomDomainRoute");
|
|
2859
|
+
|
|
2840
2860
|
// src/deploy/helpers/worker-not-found-error.ts
|
|
2841
2861
|
var WORKER_NOT_FOUND_ERR_CODE = 10007;
|
|
2842
2862
|
var WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE = 10090;
|
|
@@ -4146,15 +4166,7 @@ async function triggersDeploy(props) {
|
|
|
4146
4166
|
props.queueCreateCommand
|
|
4147
4167
|
);
|
|
4148
4168
|
}
|
|
4149
|
-
const routesOnly =
|
|
4150
|
-
const customDomainsOnly = [];
|
|
4151
|
-
for (const route of routes) {
|
|
4152
|
-
if (typeof route !== "string" && route.custom_domain) {
|
|
4153
|
-
customDomainsOnly.push(route);
|
|
4154
|
-
} else {
|
|
4155
|
-
routesOnly.push(route);
|
|
4156
|
-
}
|
|
4157
|
-
}
|
|
4169
|
+
const { routesOnly, customDomainsOnly } = partitionRoutes(routes);
|
|
4158
4170
|
const start = Date.now();
|
|
4159
4171
|
const workerUrl = `/accounts/${accountId}/workers/scripts/${scriptName}`;
|
|
4160
4172
|
const uploadMs = Date.now() - start;
|
|
@@ -30911,7 +30923,10 @@ function getDeployConfirmFunction(options) {
|
|
|
30911
30923
|
return confirm;
|
|
30912
30924
|
}
|
|
30913
30925
|
__name(getDeployConfirmFunction, "getDeployConfirmFunction");
|
|
30914
|
-
async function fetchWorkerConfig(complianceConfig, accountId, workerName, environment) {
|
|
30926
|
+
async function fetchWorkerConfig(complianceConfig, accountId, workerName, environment, localRoutes) {
|
|
30927
|
+
const partitionedRoutes = localRoutes === void 0 ? void 0 : partitionRoutes(localRoutes);
|
|
30928
|
+
const fetchRoutes = partitionedRoutes === void 0 || partitionedRoutes.routesOnly.length > 0;
|
|
30929
|
+
const fetchCustomDomains = partitionedRoutes === void 0 || partitionedRoutes.customDomainsOnly.length > 0;
|
|
30915
30930
|
const [
|
|
30916
30931
|
bindings,
|
|
30917
30932
|
routes,
|
|
@@ -30924,14 +30939,14 @@ async function fetchWorkerConfig(complianceConfig, accountId, workerName, enviro
|
|
|
30924
30939
|
complianceConfig,
|
|
30925
30940
|
`/accounts/${accountId}/workers/services/${workerName}/environments/${environment}/bindings`
|
|
30926
30941
|
),
|
|
30927
|
-
fetchResult(
|
|
30942
|
+
fetchRoutes ? fetchResult(
|
|
30928
30943
|
complianceConfig,
|
|
30929
30944
|
`/accounts/${accountId}/workers/services/${workerName}/environments/${environment}/routes?show_zonename=true`
|
|
30930
|
-
),
|
|
30931
|
-
fetchResult(
|
|
30945
|
+
) : Promise.resolve([]),
|
|
30946
|
+
fetchCustomDomains ? fetchResult(
|
|
30932
30947
|
complianceConfig,
|
|
30933
30948
|
`/accounts/${accountId}/workers/domains/records?page=0&per_page=5&service=${workerName}&environment=${environment}`
|
|
30934
|
-
),
|
|
30949
|
+
) : Promise.resolve([]),
|
|
30935
30950
|
fetchResult(
|
|
30936
30951
|
complianceConfig,
|
|
30937
30952
|
`/accounts/${accountId}/workers/services/${workerName}/environments/${environment}/subdomain`
|
|
@@ -30960,7 +30975,7 @@ async function fetchWorkerConfig(complianceConfig, accountId, workerName, enviro
|
|
|
30960
30975
|
};
|
|
30961
30976
|
}
|
|
30962
30977
|
__name(fetchWorkerConfig, "fetchWorkerConfig");
|
|
30963
|
-
async function downloadWorkerConfig(complianceConfig, workerName, environment, entrypoint, accountId) {
|
|
30978
|
+
async function downloadWorkerConfig(complianceConfig, workerName, environment, entrypoint, accountId, localRoutes) {
|
|
30964
30979
|
const {
|
|
30965
30980
|
bindings,
|
|
30966
30981
|
routes,
|
|
@@ -30972,7 +30987,8 @@ async function downloadWorkerConfig(complianceConfig, workerName, environment, e
|
|
|
30972
30987
|
complianceConfig,
|
|
30973
30988
|
accountId,
|
|
30974
30989
|
workerName,
|
|
30975
|
-
environment
|
|
30990
|
+
environment,
|
|
30991
|
+
localRoutes
|
|
30976
30992
|
);
|
|
30977
30993
|
return constructWranglerConfig({
|
|
30978
30994
|
name: workerName,
|
|
@@ -31310,12 +31326,14 @@ async function preUploadApiChecks(props, config2, queueCreateCommand) {
|
|
|
31310
31326
|
);
|
|
31311
31327
|
}
|
|
31312
31328
|
if (script.last_deployed_from === "dash") {
|
|
31329
|
+
const localRoutes = props.command === "deploy" ? props.routes : [];
|
|
31313
31330
|
const remoteWorkerConfig = await downloadWorkerConfig(
|
|
31314
31331
|
config2,
|
|
31315
31332
|
name,
|
|
31316
31333
|
serviceMetaData.default_environment.environment,
|
|
31317
31334
|
props.entry.file,
|
|
31318
|
-
accountId
|
|
31335
|
+
accountId,
|
|
31336
|
+
localRoutes
|
|
31319
31337
|
);
|
|
31320
31338
|
const configForDiff = props.command === "deploy" ? {
|
|
31321
31339
|
...config2,
|
|
@@ -33364,10 +33382,10 @@ async function prepareContainersForPreview(config2, workerName, previewSlug, opt
|
|
|
33364
33382
|
}
|
|
33365
33383
|
__name(prepareContainersForPreview, "prepareContainersForPreview");
|
|
33366
33384
|
var NO_ACTIVE_PREVIEW_URLS_MESSAGE = "Note: This Preview deployment has no active URLs.";
|
|
33367
|
-
function
|
|
33385
|
+
function isCustomDomainRoute2(route) {
|
|
33368
33386
|
return typeof route === "object" && route.custom_domain === true;
|
|
33369
33387
|
}
|
|
33370
|
-
__name(
|
|
33388
|
+
__name(isCustomDomainRoute2, "isCustomDomainRoute");
|
|
33371
33389
|
function formatPreviewConfigUpdate(config2, update) {
|
|
33372
33390
|
const configPath = config2.userConfigPath ?? config2.configPath;
|
|
33373
33391
|
if (!config2.targetEnvironment) {
|
|
@@ -33380,8 +33398,8 @@ function formatPreviewConfigUpdate(config2, update) {
|
|
|
33380
33398
|
}
|
|
33381
33399
|
__name(formatPreviewConfigUpdate, "formatPreviewConfigUpdate");
|
|
33382
33400
|
function formatNoActivePreviewUrlsMessage(config2, deployCommand = "your deploy command", previewCommand = "the preview command") {
|
|
33383
|
-
const customDomainRouteEntries = (config2.routes ?? []).filter(
|
|
33384
|
-
if (config2.route &&
|
|
33401
|
+
const customDomainRouteEntries = (config2.routes ?? []).filter(isCustomDomainRoute2).map((route) => ({ route, singular: false }));
|
|
33402
|
+
if (config2.route && isCustomDomainRoute2(config2.route)) {
|
|
33385
33403
|
customDomainRouteEntries.push({ route: config2.route, singular: true });
|
|
33386
33404
|
}
|
|
33387
33405
|
const customDomainRouteEntry = customDomainRouteEntries.find(
|
|
@@ -33710,7 +33728,7 @@ __name(formatPreviewDeploymentSummary, "formatPreviewDeploymentSummary");
|
|
|
33710
33728
|
function getPreviewCustomDomainHostnames(config2) {
|
|
33711
33729
|
const routes = config2.routes ?? (config2.route ? [config2.route] : []);
|
|
33712
33730
|
return routes.filter(
|
|
33713
|
-
(route) =>
|
|
33731
|
+
(route) => isCustomDomainRoute2(route) && route.previews_enabled === true
|
|
33714
33732
|
).map((route) => normalizeHostname(route.pattern));
|
|
33715
33733
|
}
|
|
33716
33734
|
__name(getPreviewCustomDomainHostnames, "getPreviewCustomDomainHostnames");
|