@cloudflare/deploy-helpers 0.6.1 → 0.6.3
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.
|
@@ -89,6 +89,8 @@ type SharedDeployVersionsProps = {
|
|
|
89
89
|
type DeployProps = SharedDeployVersionsProps & {
|
|
90
90
|
/** Discriminant for DeployProps vs VersionsUploadProps */
|
|
91
91
|
command: "deploy";
|
|
92
|
+
/** If set, automatically register this `workers.dev` account subdomain when the account has none. */
|
|
93
|
+
autoRegisterWorkersDevSubdomain?: string;
|
|
92
94
|
/** Merged from --site arg and config.site. */
|
|
93
95
|
legacyAssetPaths: LegacyAssetPaths | undefined;
|
|
94
96
|
/** Merged: --triggers arg ?? config.triggers.crons. */
|
package/dist/context.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { g as confirm, e as fetchKVGetValue, c as fetchListResult, d as fetchPagedListResult, f as fetchResult, i as initDeployHelpersContext, l as logger, p as prompt, s as select } from './context-
|
|
1
|
+
export { g as confirm, e as fetchKVGetValue, c as fetchListResult, d as fetchPagedListResult, f as fetchResult, i as initDeployHelpersContext, l as logger, p as prompt, s as select } from './context-CBjdngjr.mjs';
|
|
2
2
|
import '@cloudflare/workers-utils';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SharedDeployVersionsProps, D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment } from './context-
|
|
2
|
-
export { b as DeployHelpersContext, i as initDeployHelpersContext } from './context-
|
|
1
|
+
import { S as SharedDeployVersionsProps, D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment } from './context-CBjdngjr.mjs';
|
|
2
|
+
export { b as DeployHelpersContext, i as initDeployHelpersContext } from './context-CBjdngjr.mjs';
|
|
3
3
|
import * as _cloudflare_workers_utils from '@cloudflare/workers-utils';
|
|
4
4
|
import { ComplianceConfig, Config, AssetsOptions, LegacyAssetPaths, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, Binding as Binding$1, RawConfig, ConfigBindingFieldName, CfCapnp, CfScriptFormat, CfModule, ParseError, WorkerMetadataBinding, CfUserLimits, TailConsumer, StreamingTailConsumer, Observability, CfWorkerInit, ExportsReconciliationResult, ExportsReconciliationErrorDetail, StartDevWorkerInput, CfTailConsumer, ContainerApp, CacheOptions } from '@cloudflare/workers-utils';
|
|
5
5
|
import { ContainerNormalizedConfig, ImageURIConfig } from '@cloudflare/containers-shared';
|
|
@@ -83,8 +83,9 @@ declare function getSubdomainValuesAPIMock(config_workers_dev: boolean | undefin
|
|
|
83
83
|
|
|
84
84
|
type WorkersDevSubdomainRegistrationContext = "workers_dev" | "workflows";
|
|
85
85
|
type GetWorkersDevSubdomainOptions = {
|
|
86
|
-
configPath?: string | undefined;
|
|
87
86
|
abortSignal?: AbortSignal | undefined;
|
|
87
|
+
autoRegisterSubdomain?: string | undefined;
|
|
88
|
+
configPath?: string | undefined;
|
|
88
89
|
registrationContext?: WorkersDevSubdomainRegistrationContext | undefined;
|
|
89
90
|
};
|
|
90
91
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { cancel } from '@cloudflare/cli-shared-helpers';
|
|
|
13
13
|
import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports, getWranglerTmpDir, parsePackageJSON, getInstalledPackageVersion, FatalError, readFileSync as readFileSync$1, parseJSON, getBindingTypeFriendlyName, getBindingLocalSupport, assertNever, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, getTodaysCompatDate, hasDurableObjectExports, getDockerPath, parseNonHyphenedUuid, getWorkersCIBranchName } from '@cloudflare/workers-utils';
|
|
14
14
|
import { execSync, spawn } from 'node:child_process';
|
|
15
15
|
import { Response, FormData } from 'undici';
|
|
16
|
-
import
|
|
16
|
+
import chalk6 from 'chalk';
|
|
17
17
|
import PQueue from 'p-queue';
|
|
18
18
|
import { spinner, inputPrompt, leftT } from '@cloudflare/cli-shared-helpers/interactive';
|
|
19
19
|
import { writeFile, access, readFile, readdir, stat } from 'node:fs/promises';
|
|
@@ -3049,8 +3049,6 @@ function isWorkerNotFoundError(error) {
|
|
|
3049
3049
|
return typeof error === "object" && error !== null && "code" in error && (error.code === WORKER_NOT_FOUND_ERR_CODE || error.code === WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE);
|
|
3050
3050
|
}
|
|
3051
3051
|
__name(isWorkerNotFoundError, "isWorkerNotFoundError");
|
|
3052
|
-
|
|
3053
|
-
// src/triggers/email-routing-plan.ts
|
|
3054
3052
|
function isCatchAllAddress(address) {
|
|
3055
3053
|
return address.startsWith("*@") && address.length > "*@".length;
|
|
3056
3054
|
}
|
|
@@ -3099,10 +3097,10 @@ function planHasDestructiveChanges(plan) {
|
|
|
3099
3097
|
}
|
|
3100
3098
|
__name(planHasDestructiveChanges, "planHasDestructiveChanges");
|
|
3101
3099
|
var CHANGE_MARKERS = {
|
|
3102
|
-
added: "+",
|
|
3103
|
-
updated: "~",
|
|
3104
|
-
deleted: "-",
|
|
3105
|
-
conflict: "!"
|
|
3100
|
+
added: /* @__PURE__ */ __name(() => chalk6.green("+"), "added"),
|
|
3101
|
+
updated: /* @__PURE__ */ __name(() => chalk6.yellow("~"), "updated"),
|
|
3102
|
+
deleted: /* @__PURE__ */ __name(() => chalk6.red("-"), "deleted"),
|
|
3103
|
+
conflict: /* @__PURE__ */ __name(() => chalk6.red("!"), "conflict")
|
|
3106
3104
|
};
|
|
3107
3105
|
function describeRemoteAction(remote) {
|
|
3108
3106
|
const action = remote.actions[0];
|
|
@@ -3146,7 +3144,7 @@ function renderEmailRoutingPlan(plan, workerName) {
|
|
|
3146
3144
|
lines.push(zone.zone_name ?? zone.zone_id);
|
|
3147
3145
|
for (const change of zone.changes) {
|
|
3148
3146
|
counts[change.type]++;
|
|
3149
|
-
const marker = CHANGE_MARKERS[change.type];
|
|
3147
|
+
const marker = CHANGE_MARKERS[change.type]();
|
|
3150
3148
|
switch (change.type) {
|
|
3151
3149
|
case "added":
|
|
3152
3150
|
case "updated":
|
|
@@ -3190,6 +3188,7 @@ var PLAN_RETRY_WORKER_NOT_FOUND_CODE = 2016;
|
|
|
3190
3188
|
var PLAN_RETRY_TIMEOUT_MS = 3e4;
|
|
3191
3189
|
var PLAN_RETRY_DELAY_MS = 3e3;
|
|
3192
3190
|
var NON_INTERACTIVE_PROGRESS_INTERVAL = 10;
|
|
3191
|
+
var APPLY_ZONE_CONCURRENCY = 10;
|
|
3193
3192
|
function applyProgressMessage(done, total) {
|
|
3194
3193
|
return `Applying Email Routing changes (${done}/${total}, ${Math.floor(
|
|
3195
3194
|
done * 100 / total
|
|
@@ -3392,37 +3391,47 @@ async function applyEmailRoutingAddresses({
|
|
|
3392
3391
|
);
|
|
3393
3392
|
}
|
|
3394
3393
|
}
|
|
3395
|
-
const failures = [];
|
|
3396
3394
|
const totalChanges = plan.zones.reduce(
|
|
3397
3395
|
(total, zone) => total + zone.changes.length,
|
|
3398
3396
|
0
|
|
3399
3397
|
);
|
|
3400
3398
|
const progress = startApplyProgress(totalChanges);
|
|
3401
3399
|
let completedChanges = 0;
|
|
3400
|
+
const queue = new PQueue({ concurrency: APPLY_ZONE_CONCURRENCY });
|
|
3401
|
+
const failuresByZone = [];
|
|
3402
|
+
const zonePromises = [];
|
|
3402
3403
|
try {
|
|
3403
3404
|
for (const zone of plan.zones) {
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3405
|
+
const zoneFailures = [];
|
|
3406
|
+
failuresByZone.push(zoneFailures);
|
|
3407
|
+
zonePromises.push(
|
|
3408
|
+
queue.add(async () => {
|
|
3409
|
+
for (const change of zone.changes) {
|
|
3410
|
+
try {
|
|
3411
|
+
await applyChange(
|
|
3412
|
+
config,
|
|
3413
|
+
zone.zone_id,
|
|
3414
|
+
change,
|
|
3415
|
+
scriptName,
|
|
3416
|
+
ownerWorkerTag
|
|
3417
|
+
);
|
|
3418
|
+
} catch (e) {
|
|
3419
|
+
zoneFailures.push(
|
|
3420
|
+
`${change.target}: ${e instanceof Error ? e.message : String(e)}`
|
|
3421
|
+
);
|
|
3422
|
+
} finally {
|
|
3423
|
+
completedChanges++;
|
|
3424
|
+
progress.update(completedChanges);
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
})
|
|
3428
|
+
);
|
|
3422
3429
|
}
|
|
3430
|
+
await Promise.all(zonePromises);
|
|
3423
3431
|
} finally {
|
|
3424
3432
|
progress.stop();
|
|
3425
3433
|
}
|
|
3434
|
+
const failures = failuresByZone.flat();
|
|
3426
3435
|
if (failures.length > 0) {
|
|
3427
3436
|
for (const failure of failures) {
|
|
3428
3437
|
logger.error(`Email Routing change failed: ${failure}`);
|
|
@@ -4002,10 +4011,16 @@ async function ensureQueuesExistByConfig(config, accountId, includeProducers = t
|
|
|
4002
4011
|
}
|
|
4003
4012
|
}
|
|
4004
4013
|
__name(ensureQueuesExistByConfig, "ensureQueuesExistByConfig");
|
|
4014
|
+
function toValidSubdomain(input) {
|
|
4015
|
+
const subdomain = input.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+/, "").slice(0, 63).replace(/-+$/, "");
|
|
4016
|
+
return subdomain || "my-worker";
|
|
4017
|
+
}
|
|
4018
|
+
__name(toValidSubdomain, "toValidSubdomain");
|
|
4005
4019
|
async function getWorkersDevSubdomain(complianceConfig, accountId, options = {}) {
|
|
4006
4020
|
const {
|
|
4007
|
-
configPath,
|
|
4008
4021
|
abortSignal,
|
|
4022
|
+
autoRegisterSubdomain,
|
|
4023
|
+
configPath,
|
|
4009
4024
|
registrationContext = "workers_dev"
|
|
4010
4025
|
} = options;
|
|
4011
4026
|
try {
|
|
@@ -4023,6 +4038,15 @@ async function getWorkersDevSubdomain(complianceConfig, accountId, options = {})
|
|
|
4023
4038
|
throw e;
|
|
4024
4039
|
}
|
|
4025
4040
|
logger.warn(getRegistrationWarning(registrationContext));
|
|
4041
|
+
if (autoRegisterSubdomain) {
|
|
4042
|
+
return await registerSubdomain(
|
|
4043
|
+
complianceConfig,
|
|
4044
|
+
accountId,
|
|
4045
|
+
configPath,
|
|
4046
|
+
registrationContext,
|
|
4047
|
+
autoRegisterSubdomain
|
|
4048
|
+
);
|
|
4049
|
+
}
|
|
4026
4050
|
const wantsToRegister = await confirm(
|
|
4027
4051
|
"Would you like to register a workers.dev subdomain now?",
|
|
4028
4052
|
{ fallbackValue: false }
|
|
@@ -4081,12 +4105,14 @@ ${onboardingLink}`, {
|
|
|
4081
4105
|
}
|
|
4082
4106
|
}
|
|
4083
4107
|
__name(getRegistrationDeclinedError, "getRegistrationDeclinedError");
|
|
4084
|
-
async function registerSubdomain(complianceConfig, accountId, configPath, registrationContext) {
|
|
4108
|
+
async function registerSubdomain(complianceConfig, accountId, configPath, registrationContext, automaticSubdomain) {
|
|
4085
4109
|
let subdomain;
|
|
4110
|
+
let suggestedSubdomain = automaticSubdomain ? toValidSubdomain(automaticSubdomain) : void 0;
|
|
4086
4111
|
while (subdomain === void 0) {
|
|
4087
|
-
const potentialName = await prompt(
|
|
4112
|
+
const potentialName = suggestedSubdomain ?? await prompt(
|
|
4088
4113
|
"What would you like your workers.dev subdomain to be? It will be accessible at https://<subdomain>.workers.dev"
|
|
4089
4114
|
);
|
|
4115
|
+
suggestedSubdomain = void 0;
|
|
4090
4116
|
if (!/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/.test(potentialName)) {
|
|
4091
4117
|
logger.warn(
|
|
4092
4118
|
`${potentialName} is invalid, please choose another subdomain.`
|
|
@@ -4102,19 +4128,35 @@ async function registerSubdomain(complianceConfig, accountId, configPath, regist
|
|
|
4102
4128
|
const subdomainAvailabilityCheckError = err;
|
|
4103
4129
|
if (typeof subdomainAvailabilityCheckError === "object" && !!subdomainAvailabilityCheckError) {
|
|
4104
4130
|
if (subdomainAvailabilityCheckError.code === 10032) ; else if (subdomainAvailabilityCheckError.code === 10031) {
|
|
4131
|
+
if (automaticSubdomain) {
|
|
4132
|
+
throw new UserError(
|
|
4133
|
+
`Wrangler could not automatically register "${potentialName}" as your workers.dev subdomain because the name is unavailable. Register a different subdomain at https://dash.cloudflare.com/${accountId}/workers/onboarding.`,
|
|
4134
|
+
{
|
|
4135
|
+
telemetryMessage: "workers dev automatic registration name unavailable"
|
|
4136
|
+
}
|
|
4137
|
+
);
|
|
4138
|
+
}
|
|
4105
4139
|
logger.error(
|
|
4106
4140
|
"Subdomain is unavailable, please try a different subdomain"
|
|
4107
4141
|
);
|
|
4108
4142
|
continue;
|
|
4109
4143
|
} else {
|
|
4144
|
+
if (automaticSubdomain) {
|
|
4145
|
+
throw new UserError(
|
|
4146
|
+
`Wrangler could not verify whether "${potentialName}" is available as your \`workers.dev\` subdomain. Register a subdomain at https://dash.cloudflare.com/${accountId}/workers/onboarding.`,
|
|
4147
|
+
{
|
|
4148
|
+
telemetryMessage: "workers dev automatic registration availability check failed"
|
|
4149
|
+
}
|
|
4150
|
+
);
|
|
4151
|
+
}
|
|
4110
4152
|
logger.error("An unexpected error occurred, please try again.");
|
|
4111
4153
|
continue;
|
|
4112
4154
|
}
|
|
4113
4155
|
}
|
|
4114
4156
|
}
|
|
4115
|
-
const ok = await confirm(
|
|
4116
|
-
`Creating a workers.dev subdomain for your account at ${
|
|
4117
|
-
|
|
4157
|
+
const ok = automaticSubdomain !== void 0 || await confirm(
|
|
4158
|
+
`Creating a workers.dev subdomain for your account at ${chalk6.blue(
|
|
4159
|
+
chalk6.underline(
|
|
4118
4160
|
`https://${potentialName}${getComplianceRegionSubdomain(complianceConfig)}.workers.dev`
|
|
4119
4161
|
)
|
|
4120
4162
|
)}. Ok to proceed?`
|
|
@@ -4138,6 +4180,14 @@ async function registerSubdomain(complianceConfig, accountId, configPath, regist
|
|
|
4138
4180
|
subdomain = result.subdomain;
|
|
4139
4181
|
} catch (err) {
|
|
4140
4182
|
const subdomainCreationError = err;
|
|
4183
|
+
if (automaticSubdomain) {
|
|
4184
|
+
throw new UserError(
|
|
4185
|
+
`Wrangler could not automatically register "${potentialName}" as your \`workers.dev\` subdomain. Register a subdomain at https://dash.cloudflare.com/${accountId}/workers/onboarding.`,
|
|
4186
|
+
{
|
|
4187
|
+
telemetryMessage: "workers dev automatic registration creation failed"
|
|
4188
|
+
}
|
|
4189
|
+
);
|
|
4190
|
+
}
|
|
4141
4191
|
if (typeof subdomainCreationError === "object" && !!subdomainCreationError && subdomainCreationError.code !== void 0) {
|
|
4142
4192
|
switch (subdomainCreationError.code) {
|
|
4143
4193
|
case 10031:
|
|
@@ -4154,8 +4204,8 @@ async function registerSubdomain(complianceConfig, accountId, configPath, regist
|
|
|
4154
4204
|
}
|
|
4155
4205
|
logger.log("Success! It may take a few minutes for DNS records to update.");
|
|
4156
4206
|
logger.log(
|
|
4157
|
-
`Visit ${
|
|
4158
|
-
|
|
4207
|
+
`Visit ${chalk6.blue(
|
|
4208
|
+
chalk6.underline(
|
|
4159
4209
|
`https://dash.cloudflare.com/${accountId}/workers/subdomain`
|
|
4160
4210
|
)
|
|
4161
4211
|
)} to edit your workers.dev subdomain`
|
|
@@ -4236,12 +4286,12 @@ async function triggersDeploy(props) {
|
|
|
4236
4286
|
const assignedRoutes = routesWithOtherBindings[worker];
|
|
4237
4287
|
errorMessage += `"${worker}" is already assigned to routes:
|
|
4238
4288
|
${assignedRoutes.map(
|
|
4239
|
-
(r) => ` - ${
|
|
4289
|
+
(r) => ` - ${chalk6.underline(r)}
|
|
4240
4290
|
`
|
|
4241
4291
|
)}`;
|
|
4242
4292
|
}
|
|
4243
4293
|
const resolution = "Unassign other workers from the routes you want to deploy to, and then try again.";
|
|
4244
|
-
const dashHref =
|
|
4294
|
+
const dashHref = chalk6.blue.underline(
|
|
4245
4295
|
`https://dash.cloudflare.com/${accountId}/workers/overview`
|
|
4246
4296
|
);
|
|
4247
4297
|
const dashLink = `Visit ${dashHref} to unassign a worker from a route.`;
|
|
@@ -6091,7 +6141,7 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
|
|
|
6091
6141
|
} catch (e) {
|
|
6092
6142
|
if (attempts < MAX_UPLOAD_ATTEMPTS) {
|
|
6093
6143
|
logger.info(
|
|
6094
|
-
|
|
6144
|
+
chalk6.dim(
|
|
6095
6145
|
`Asset upload failed. Retrying... ${attempts + 1} of ${MAX_UPLOAD_ATTEMPTS} attempts.
|
|
6096
6146
|
`
|
|
6097
6147
|
)
|
|
@@ -6233,7 +6283,7 @@ function logAssetUpload(line, diffCount) {
|
|
|
6233
6283
|
logger.info(line);
|
|
6234
6284
|
} else if (diffCount === MAX_DIFF_LINES) {
|
|
6235
6285
|
const msg = " (truncating changed assets log, set `WRANGLER_LOG=debug` environment variable to see full diff)";
|
|
6236
|
-
logger.info(
|
|
6286
|
+
logger.info(chalk6.dim(msg));
|
|
6237
6287
|
}
|
|
6238
6288
|
return ++diffCount;
|
|
6239
6289
|
}
|
|
@@ -6331,7 +6381,7 @@ async function printBundleSize(main, modules) {
|
|
|
6331
6381
|
const { size, gzipSize } = await getSize([...modules, main]);
|
|
6332
6382
|
const bundleReport = `${(size / ONE_KIB_BYTES).toFixed(2)} KiB / gzip: ${(gzipSize / ONE_KIB_BYTES).toFixed(2)} KiB`;
|
|
6333
6383
|
const percentage = gzipSize / MAX_GZIP_SIZE_BYTES * 100;
|
|
6334
|
-
const colorizedReport = percentage > 90 ?
|
|
6384
|
+
const colorizedReport = percentage > 90 ? chalk6.red(bundleReport) : percentage > 70 ? chalk6.yellow(bundleReport) : chalk6.green(bundleReport);
|
|
6335
6385
|
logger.log(`Total Upload: ${colorizedReport}`);
|
|
6336
6386
|
}
|
|
6337
6387
|
__name(printBundleSize, "printBundleSize");
|
|
@@ -7696,7 +7746,7 @@ function printBindings(bindings, tailConsumers = [], streamingTailConsumers = []
|
|
|
7696
7746
|
if (output.length === 0) {
|
|
7697
7747
|
if (context.warnIfNoBindings) {
|
|
7698
7748
|
if (context.name && isMultiWorker) {
|
|
7699
|
-
log2(`No bindings found for ${
|
|
7749
|
+
log2(`No bindings found for ${chalk6.blue(context.name)}`);
|
|
7700
7750
|
} else {
|
|
7701
7751
|
log2("No bindings found.");
|
|
7702
7752
|
}
|
|
@@ -7706,7 +7756,7 @@ function printBindings(bindings, tailConsumers = [], streamingTailConsumers = []
|
|
|
7706
7756
|
if (context.provisioning) {
|
|
7707
7757
|
title2 = "The following bindings need to be provisioned:";
|
|
7708
7758
|
} else if (context.name && isMultiWorker) {
|
|
7709
|
-
title2 = `${
|
|
7759
|
+
title2 = `${chalk6.blue(context.name)} has access to the following bindings:`;
|
|
7710
7760
|
} else {
|
|
7711
7761
|
title2 = "Your Worker has access to the following bindings:";
|
|
7712
7762
|
}
|
|
@@ -7743,7 +7793,7 @@ function printBindings(bindings, tailConsumers = [], streamingTailConsumers = []
|
|
|
7743
7793
|
);
|
|
7744
7794
|
for (const binding of output) {
|
|
7745
7795
|
const bindingValue = dim(
|
|
7746
|
-
typeof binding.value === "symbol" ?
|
|
7796
|
+
typeof binding.value === "symbol" ? chalk6.italic("inherited") : binding.value ?? ""
|
|
7747
7797
|
);
|
|
7748
7798
|
const bindingString = padEndAnsi(
|
|
7749
7799
|
`${white(`env.${binding.name}`)}${binding.value && !shouldWrap ? ` (${bindingValue})` : ""}`,
|
|
@@ -7759,7 +7809,7 @@ function printBindings(bindings, tailConsumers = [], streamingTailConsumers = []
|
|
|
7759
7809
|
}
|
|
7760
7810
|
let title;
|
|
7761
7811
|
if (context.name && isMultiWorker) {
|
|
7762
|
-
title = `${
|
|
7812
|
+
title = `${chalk6.blue(context.name)} is sending Tail events to the following Workers:`;
|
|
7763
7813
|
} else {
|
|
7764
7814
|
title = "Your Worker is sending Tail events to the following Workers:";
|
|
7765
7815
|
}
|
|
@@ -7782,9 +7832,9 @@ ${allTailConsumers.map(({ service, streaming }) => {
|
|
|
7782
7832
|
const registryDefinition = context.registry?.[service];
|
|
7783
7833
|
hasConnectionStatus = true;
|
|
7784
7834
|
if (registryDefinition) {
|
|
7785
|
-
return `- ${displayName} ${
|
|
7835
|
+
return `- ${displayName} ${chalk6.green("[connected]")}`;
|
|
7786
7836
|
} else {
|
|
7787
|
-
return `- ${displayName} ${
|
|
7837
|
+
return `- ${displayName} ${chalk6.red("[not connected]")}`;
|
|
7788
7838
|
}
|
|
7789
7839
|
} else {
|
|
7790
7840
|
return `- ${displayName}`;
|
|
@@ -7795,7 +7845,7 @@ ${allTailConsumers.map(({ service, streaming }) => {
|
|
|
7795
7845
|
if (containers.length > 0 && !context.provisioning) {
|
|
7796
7846
|
let containersTitle = "The following containers are available:";
|
|
7797
7847
|
if (context.name && isMultiWorker) {
|
|
7798
|
-
containersTitle = `The following containers are available from ${
|
|
7848
|
+
containersTitle = `The following containers are available from ${chalk6.blue(context.name)}:`;
|
|
7799
7849
|
}
|
|
7800
7850
|
log2(
|
|
7801
7851
|
`${containersTitle}
|
|
@@ -7811,7 +7861,7 @@ ${containers.map((c) => `- ${c.name} (${c.image})`).join("\n")}`
|
|
|
7811
7861
|
log2(
|
|
7812
7862
|
dim(
|
|
7813
7863
|
`
|
|
7814
|
-
Service bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by ${
|
|
7864
|
+
Service bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by ${chalk6.green("[connected]")} or ${chalk6.red("[not connected]")}. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development
|
|
7815
7865
|
`
|
|
7816
7866
|
)
|
|
7817
7867
|
);
|
|
@@ -7837,7 +7887,7 @@ function createGetMode({
|
|
|
7837
7887
|
if (isSimulatedLocally === void 0) {
|
|
7838
7888
|
return dim("not supported");
|
|
7839
7889
|
}
|
|
7840
|
-
return `${isSimulatedLocally ?
|
|
7890
|
+
return `${isSimulatedLocally ? chalk6.blue("local") : chalk6.yellow("remote")}${connected === void 0 ? "" : connected ? chalk6.green(" [connected]") : chalk6.red(" [not connected]")}`;
|
|
7841
7891
|
}, "bindingMode");
|
|
7842
7892
|
}
|
|
7843
7893
|
__name(createGetMode, "createGetMode");
|
|
@@ -14662,6 +14712,7 @@ Edits that have been made via the script API will be overridden by your local co
|
|
|
14662
14712
|
const wantsWorkersDev = props.command === "deploy" && getSubdomainValues(config.workers_dev, config.preview_urls, props.routes).workers_dev;
|
|
14663
14713
|
if (!workerExists && wantsWorkersDev) {
|
|
14664
14714
|
await getWorkersDevSubdomain(config, accountId, {
|
|
14715
|
+
autoRegisterSubdomain: props.autoRegisterWorkersDevSubdomain,
|
|
14665
14716
|
configPath: config.configPath
|
|
14666
14717
|
});
|
|
14667
14718
|
}
|
|
@@ -16021,7 +16072,7 @@ function drawConnectedChildBox(contentLines, options = {}) {
|
|
|
16021
16072
|
return result.join("\n");
|
|
16022
16073
|
}
|
|
16023
16074
|
__name(drawConnectedChildBox, "drawConnectedChildBox");
|
|
16024
|
-
var CONFIG_MARKER =
|
|
16075
|
+
var CONFIG_MARKER = chalk6.hex("#FFA500")("\u25C6");
|
|
16025
16076
|
function getFriendlyBindingType(bindingType) {
|
|
16026
16077
|
return getBindingTypeFriendlyName(
|
|
16027
16078
|
bindingType
|
|
@@ -16033,7 +16084,7 @@ function formatAlignedRows(rows, indent = " ") {
|
|
|
16033
16084
|
const valueWidth = Math.max(...rows.map(([, value]) => value.length));
|
|
16034
16085
|
return rows.map(([label, value, fromConfig]) => {
|
|
16035
16086
|
const marker = fromConfig ? CONFIG_MARKER : " ";
|
|
16036
|
-
const coloredLabel =
|
|
16087
|
+
const coloredLabel = chalk6.cyan(padToVisibleWidth(label, labelWidth));
|
|
16037
16088
|
return `${indent}${coloredLabel} ${padToVisibleWidth(
|
|
16038
16089
|
value,
|
|
16039
16090
|
valueWidth
|
|
@@ -16045,7 +16096,7 @@ function formatBindings(env, indent = " ", options = {}) {
|
|
|
16045
16096
|
const showSourceMarker = options.showSourceMarker ?? true;
|
|
16046
16097
|
const entries = Object.entries(env);
|
|
16047
16098
|
if (entries.length === 0) {
|
|
16048
|
-
return [`${indent}${
|
|
16099
|
+
return [`${indent}${chalk6.dim("(none)")}`];
|
|
16049
16100
|
}
|
|
16050
16101
|
const nameWidth = Math.max(...entries.map(([name]) => name.length));
|
|
16051
16102
|
const typeWidth = Math.max(
|
|
@@ -16059,8 +16110,8 @@ function formatBindings(env, indent = " ", options = {}) {
|
|
|
16059
16110
|
return entries.map(([name, binding]) => {
|
|
16060
16111
|
const value = getBindingValue(binding);
|
|
16061
16112
|
const friendlyType = getFriendlyBindingType(binding.type);
|
|
16062
|
-
const coloredName =
|
|
16063
|
-
const dimType =
|
|
16113
|
+
const coloredName = chalk6.cyan(padToVisibleWidth(name, nameWidth));
|
|
16114
|
+
const dimType = chalk6.dim(padToVisibleWidth(friendlyType, typeWidth));
|
|
16064
16115
|
if (showSourceMarker) {
|
|
16065
16116
|
const marker = binding.fromConfig ? CONFIG_MARKER : " ";
|
|
16066
16117
|
return `${indent}${coloredName} ${dimType} ${padToVisibleWidth(
|
|
@@ -16077,9 +16128,9 @@ function formatBindings(env, indent = " ", options = {}) {
|
|
|
16077
16128
|
__name(formatBindings, "formatBindings");
|
|
16078
16129
|
function formatPreviewsSettings(workerName, previewDefaults) {
|
|
16079
16130
|
const lines = [];
|
|
16080
|
-
lines.push(`${
|
|
16131
|
+
lines.push(`${chalk6.bold.hex("#FFA500")("Worker:")} ${workerName}`);
|
|
16081
16132
|
lines.push("");
|
|
16082
|
-
lines.push(` ${
|
|
16133
|
+
lines.push(` ${chalk6.bold.underline("Previews settings")}`);
|
|
16083
16134
|
lines.push("");
|
|
16084
16135
|
const settingsRows = [];
|
|
16085
16136
|
if (previewDefaults.observability && typeof previewDefaults.observability === "object") {
|
|
@@ -16115,12 +16166,12 @@ function formatPreviewsSettings(workerName, previewDefaults) {
|
|
|
16115
16166
|
const labelWidth = Math.max(...settingsRows.map(([label]) => label.length));
|
|
16116
16167
|
for (const [label, value] of settingsRows) {
|
|
16117
16168
|
lines.push(
|
|
16118
|
-
` ${
|
|
16169
|
+
` ${chalk6.cyan(padToVisibleWidth(label, labelWidth))} ${value}`
|
|
16119
16170
|
);
|
|
16120
16171
|
}
|
|
16121
16172
|
}
|
|
16122
16173
|
lines.push("");
|
|
16123
|
-
lines.push(
|
|
16174
|
+
lines.push(chalk6.bold(" Bindings"));
|
|
16124
16175
|
const env = Object.fromEntries(
|
|
16125
16176
|
Object.entries(previewDefaults.env ?? {}).map(([name, binding]) => [
|
|
16126
16177
|
name,
|
|
@@ -16385,16 +16436,16 @@ function buildMergedVersionLevel(config, deployment) {
|
|
|
16385
16436
|
}
|
|
16386
16437
|
__name(buildMergedVersionLevel, "buildMergedVersionLevel");
|
|
16387
16438
|
function formatPreviewResource(previewResource, scriptLevel, isNew, configName) {
|
|
16388
|
-
const statusLabel = isNew ?
|
|
16439
|
+
const statusLabel = isNew ? chalk6.green("(new)") : chalk6.dim("(updated)");
|
|
16389
16440
|
const obsEnabled = scriptLevel.observability?.enabled ?? false;
|
|
16390
16441
|
const obsRate = scriptLevel.observability?.head_sampling_rate;
|
|
16391
16442
|
const formattedRate = obsRate !== void 0 ? obsRate.toFixed(1) : void 0;
|
|
16392
16443
|
const obsValue = obsEnabled ? `enabled${formattedRate !== void 0 ? `, ${formattedRate} sampling` : ""}` : "disabled";
|
|
16393
16444
|
const lines = [
|
|
16394
|
-
`${
|
|
16445
|
+
`${chalk6.bold("Preview:")} ${previewResource.name} ${statusLabel}`,
|
|
16395
16446
|
"",
|
|
16396
16447
|
...(previewResource.urls ?? []).map(
|
|
16397
|
-
(url2) => ` ${
|
|
16448
|
+
(url2) => ` ${chalk6.bold.underline(url2)}`
|
|
16398
16449
|
)
|
|
16399
16450
|
];
|
|
16400
16451
|
const settingsRows = [];
|
|
@@ -16424,15 +16475,15 @@ function formatPreviewResource(previewResource, scriptLevel, isNew, configName)
|
|
|
16424
16475
|
lines.push(...formatAlignedRows(settingsRows));
|
|
16425
16476
|
}
|
|
16426
16477
|
const hasConfigValues = settingsRows.some(([, , fromConfig]) => fromConfig);
|
|
16427
|
-
const footerLines = hasConfigValues ? ["",
|
|
16478
|
+
const footerLines = hasConfigValues ? ["", chalk6.hex("#FFA500")(`\u25C6 from ${configName}`)] : void 0;
|
|
16428
16479
|
return drawBox(lines, { footerLines, connectToChild: true });
|
|
16429
16480
|
}
|
|
16430
16481
|
__name(formatPreviewResource, "formatPreviewResource");
|
|
16431
16482
|
function formatDeploymentResource(deployment, versionLevel, configName) {
|
|
16432
16483
|
const lines = [
|
|
16433
|
-
`${
|
|
16484
|
+
`${chalk6.bold("Deployment:")} ${deployment.id}`,
|
|
16434
16485
|
"",
|
|
16435
|
-
...(deployment.urls ?? []).map((url2) => ` ${
|
|
16486
|
+
...(deployment.urls ?? []).map((url2) => ` ${chalk6.bold.underline(url2)}`)
|
|
16436
16487
|
];
|
|
16437
16488
|
const settingsRows = [];
|
|
16438
16489
|
if (versionLevel.compatibility_date) {
|
|
@@ -16480,7 +16531,7 @@ function formatDeploymentResource(deployment, versionLevel, configName) {
|
|
|
16480
16531
|
}
|
|
16481
16532
|
if (versionLevel.assets) {
|
|
16482
16533
|
lines.push("");
|
|
16483
|
-
lines.push(
|
|
16534
|
+
lines.push(chalk6.bold(" Assets"));
|
|
16484
16535
|
const assetsRows = [];
|
|
16485
16536
|
const assets = versionLevel.assets.value;
|
|
16486
16537
|
const fromConfig = versionLevel.assets.fromConfig;
|
|
@@ -16507,10 +16558,10 @@ function formatDeploymentResource(deployment, versionLevel, configName) {
|
|
|
16507
16558
|
lines.push(...formatAlignedRows(assetsRows, " "));
|
|
16508
16559
|
}
|
|
16509
16560
|
lines.push("");
|
|
16510
|
-
lines.push(
|
|
16561
|
+
lines.push(chalk6.bold(" Bindings"));
|
|
16511
16562
|
lines.push(...formatBindings(versionLevel.env));
|
|
16512
16563
|
const hasConfigValues = settingsRows.some(([, , fromConfig]) => fromConfig) || versionLevel.assets?.fromConfig || Object.values(versionLevel.env).some((binding) => binding.fromConfig);
|
|
16513
|
-
const footerLines = hasConfigValues ? ["",
|
|
16564
|
+
const footerLines = hasConfigValues ? ["", chalk6.hex("#FFA500")(`\u25C6 from ${configName}`)] : void 0;
|
|
16514
16565
|
return drawConnectedChildBox(lines, { footerLines, indent: " " });
|
|
16515
16566
|
}
|
|
16516
16567
|
__name(formatDeploymentResource, "formatDeploymentResource");
|
|
@@ -16531,10 +16582,10 @@ function logMissingPreviewsBindingsWarning(topLevelBindings, remotePreviewDefaul
|
|
|
16531
16582
|
The following bindings are configured at the top level of your Wrangler config file, but are missing from the Previews settings of your Worker.
|
|
16532
16583
|
|
|
16533
16584
|
${Object.entries(missingBindings).map(
|
|
16534
|
-
([name, binding]) => ` ${
|
|
16585
|
+
([name, binding]) => ` ${chalk6.cyan(name)} ${chalk6.dim(getBindingTypeFriendlyName(binding.type))}`
|
|
16535
16586
|
).join("\n")}
|
|
16536
16587
|
|
|
16537
|
-
Either include these bindings in the ${
|
|
16588
|
+
Either include these bindings in the ${chalk6.cyan(`"previews"`)} field of your Wrangler config or update the Previews settings of your Worker in the Cloudflare dashboard.`);
|
|
16538
16589
|
}
|
|
16539
16590
|
__name(logMissingPreviewsBindingsWarning, "logMissingPreviewsBindingsWarning");
|
|
16540
16591
|
async function preview(accountId, args, config, buildResult, assetsOptions) {
|
|
@@ -16738,7 +16789,7 @@ async function previewSettingsUpdate(accountId, args, config) {
|
|
|
16738
16789
|
if (!diff) {
|
|
16739
16790
|
logger.log(
|
|
16740
16791
|
`
|
|
16741
|
-
\u2728 Previews settings for Worker ${
|
|
16792
|
+
\u2728 Previews settings for Worker ${chalk6.bold.cyan(
|
|
16742
16793
|
workerName
|
|
16743
16794
|
)} are already up to date.`
|
|
16744
16795
|
);
|
|
@@ -16747,7 +16798,7 @@ async function previewSettingsUpdate(accountId, args, config) {
|
|
|
16747
16798
|
logger.log(`${diff}`);
|
|
16748
16799
|
if (!args.skipConfirmation) {
|
|
16749
16800
|
const shouldProceed = await confirm(
|
|
16750
|
-
`Apply these updates to the Previews settings of Worker ${
|
|
16801
|
+
`Apply these updates to the Previews settings of Worker ${chalk6.bold.cyan(
|
|
16751
16802
|
workerName
|
|
16752
16803
|
)}?`
|
|
16753
16804
|
);
|
|
@@ -16764,7 +16815,7 @@ async function previewSettingsUpdate(accountId, args, config) {
|
|
|
16764
16815
|
);
|
|
16765
16816
|
logger.log(
|
|
16766
16817
|
`
|
|
16767
|
-
\u2728 Updated Previews settings for Worker ${
|
|
16818
|
+
\u2728 Updated Previews settings for Worker ${chalk6.bold.cyan(workerName)}.`
|
|
16768
16819
|
);
|
|
16769
16820
|
logger.log(formatPreviewsSettings(workerName, updatedPreviewDefaults));
|
|
16770
16821
|
}
|