wrangler 4.21.1 → 4.21.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/package.json +1 -1
- package/wrangler-dist/cli.js +97 -59
- package/wrangler-dist/metafile-cjs.json +1 -1
package/package.json
CHANGED
package/wrangler-dist/cli.js
CHANGED
@@ -22287,14 +22287,13 @@ var init_utils = __esm({
|
|
22287
22287
|
});
|
22288
22288
|
});
|
22289
22289
|
}, "runDockerCmdWithOutput");
|
22290
|
-
verifyDockerInstalled = /* @__PURE__ */ __name(async (dockerPath) => {
|
22290
|
+
verifyDockerInstalled = /* @__PURE__ */ __name(async (dockerPath, isDev = true) => {
|
22291
22291
|
try {
|
22292
22292
|
await runDockerCmd(dockerPath, ["info"], ["inherit", "pipe", "pipe"]);
|
22293
22293
|
} catch {
|
22294
22294
|
throw new Error(
|
22295
|
-
`The Docker CLI could not be launched. Please ensure that Docker is installed and
|
22296
|
-
Other container tooling that is compatible with the Docker CLI may work, but is not yet guaranteed to do so.
|
22297
|
-
To suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or passing in --enable-containers=false.`
|
22295
|
+
`The Docker CLI could not be launched. Please ensure that the Docker CLI is installed and the daemon is running.
|
22296
|
+
Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so. You can specify an executable with the environment variable WRANGLER_DOCKER_BIN and a socket with WRANGLER_DOCKER_HOST.${isDev ? "\nTo suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or passing in --enable-containers=false." : ""}`
|
22298
22297
|
);
|
22299
22298
|
}
|
22300
22299
|
}, "verifyDockerInstalled");
|
@@ -22375,24 +22374,6 @@ var init_types = __esm({
|
|
22375
22374
|
});
|
22376
22375
|
|
22377
22376
|
// ../containers-shared/src/images.ts
|
22378
|
-
async function getDockerImageDigest(dockerPath, imageTag) {
|
22379
|
-
return new Promise((resolve24, reject) => {
|
22380
|
-
(0, import_child_process4.execFile)(
|
22381
|
-
dockerPath,
|
22382
|
-
["images", "--digests", "--format", "{{.Digest}}", imageTag],
|
22383
|
-
(error2, stdout2, stderr2) => {
|
22384
|
-
if (error2) {
|
22385
|
-
return reject(
|
22386
|
-
new Error(
|
22387
|
-
`Failed getting docker image digest for image: ${imageTag} with error: ${error2}.`
|
22388
|
-
)
|
22389
|
-
);
|
22390
|
-
}
|
22391
|
-
return resolve24(stdout2.trim());
|
22392
|
-
}
|
22393
|
-
);
|
22394
|
-
});
|
22395
|
-
}
|
22396
22377
|
async function pullImage(dockerPath, options) {
|
22397
22378
|
await dockerLoginManagedRegistry(dockerPath);
|
22398
22379
|
await runDockerCmd(dockerPath, [
|
@@ -22426,16 +22407,13 @@ To use an existing image from another repository, see https://developers.cloudfl
|
|
22426
22407
|
await checkExposedPorts(dockerPath, options);
|
22427
22408
|
}
|
22428
22409
|
}
|
22429
|
-
var import_child_process4;
|
22430
22410
|
var init_images = __esm({
|
22431
22411
|
"../containers-shared/src/images.ts"() {
|
22432
22412
|
init_import_meta_url();
|
22433
|
-
import_child_process4 = require("child_process");
|
22434
22413
|
init_build();
|
22435
22414
|
init_knobs();
|
22436
22415
|
init_login();
|
22437
22416
|
init_utils();
|
22438
|
-
__name(getDockerImageDigest, "getDockerImageDigest");
|
22439
22417
|
__name(pullImage, "pullImage");
|
22440
22418
|
__name(prepareContainerImagesForDev, "prepareContainerImagesForDev");
|
22441
22419
|
}
|
@@ -29508,7 +29486,7 @@ var name, version;
|
|
29508
29486
|
var init_package = __esm({
|
29509
29487
|
"package.json"() {
|
29510
29488
|
name = "wrangler";
|
29511
|
-
version = "4.21.
|
29489
|
+
version = "4.21.2";
|
29512
29490
|
}
|
29513
29491
|
});
|
29514
29492
|
|
@@ -38667,9 +38645,8 @@ function validateContainerApp(envName, topLevelName) {
|
|
38667
38645
|
);
|
38668
38646
|
return false;
|
38669
38647
|
}
|
38670
|
-
containerAppOptional.configuration ??= {
|
38671
|
-
|
38672
|
-
};
|
38648
|
+
containerAppOptional.configuration ??= {};
|
38649
|
+
containerAppOptional.configuration.image = containerAppOptional.image;
|
38673
38650
|
delete containerAppOptional["image"];
|
38674
38651
|
}
|
38675
38652
|
if (!isOptionalProperty(
|
@@ -49164,7 +49141,7 @@ async function getAccessToken(domain2) {
|
|
49164
49141
|
if (cache[domain2]) {
|
49165
49142
|
return cache[domain2];
|
49166
49143
|
}
|
49167
|
-
const output = (0,
|
49144
|
+
const output = (0, import_child_process4.spawnSync)("cloudflared", ["access", "login", domain2]);
|
49168
49145
|
if (output.error) {
|
49169
49146
|
throw new UserError(
|
49170
49147
|
"To use Wrangler with Cloudflare Access, please install `cloudflared` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation"
|
@@ -49178,11 +49155,11 @@ async function getAccessToken(domain2) {
|
|
49178
49155
|
}
|
49179
49156
|
throw new Error("Failed to authenticate with Cloudflare Access");
|
49180
49157
|
}
|
49181
|
-
var
|
49158
|
+
var import_child_process4, import_undici2, cache, usesAccessCache;
|
49182
49159
|
var init_access = __esm({
|
49183
49160
|
"src/user/access.ts"() {
|
49184
49161
|
init_import_meta_url();
|
49185
|
-
|
49162
|
+
import_child_process4 = require("child_process");
|
49186
49163
|
import_undici2 = __toESM(require_undici());
|
49187
49164
|
init_errors();
|
49188
49165
|
init_logger();
|
@@ -49799,11 +49776,7 @@ async function logout() {
|
|
49799
49776
|
}
|
49800
49777
|
function listScopes(message = "\u{1F481} Available scopes:") {
|
49801
49778
|
logger.log(message);
|
49802
|
-
|
49803
|
-
Scope: scope,
|
49804
|
-
Description: DefaultScopes[scope]
|
49805
|
-
}));
|
49806
|
-
logger.table(data);
|
49779
|
+
printScopes(DefaultScopeKeys);
|
49807
49780
|
}
|
49808
49781
|
async function getAccountId(complianceConfig) {
|
49809
49782
|
const cachedAccount2 = getAccountFromCache();
|
@@ -49877,6 +49850,13 @@ function getAccountFromCache() {
|
|
49877
49850
|
function getScopes() {
|
49878
49851
|
return LocalState.scopes;
|
49879
49852
|
}
|
49853
|
+
function printScopes(scopes) {
|
49854
|
+
const data = scopes.map((scope) => ({
|
49855
|
+
Scope: scope,
|
49856
|
+
Description: DefaultScopes[scope]
|
49857
|
+
}));
|
49858
|
+
logger.table(data);
|
49859
|
+
}
|
49880
49860
|
async function fetchAuthToken(body) {
|
49881
49861
|
const headers = {
|
49882
49862
|
"Content-Type": "application/x-www-form-urlencoded"
|
@@ -50155,6 +50135,7 @@ var init_user = __esm({
|
|
50155
50135
|
__name(saveAccountToCache, "saveAccountToCache");
|
50156
50136
|
__name(getAccountFromCache, "getAccountFromCache");
|
50157
50137
|
__name(getScopes, "getScopes");
|
50138
|
+
__name(printScopes, "printScopes");
|
50158
50139
|
__name(fetchAuthToken, "fetchAuthToken");
|
50159
50140
|
__name(getJSONFromResponse, "getJSONFromResponse");
|
50160
50141
|
}
|
@@ -62273,6 +62254,14 @@ async function fillOpenAPIConfiguration(config, _json2, scope) {
|
|
62273
62254
|
const headers = OpenAPI.HEADERS !== void 0 ? { ...OpenAPI.HEADERS } : {};
|
62274
62255
|
const accountId = await requireAuth(config);
|
62275
62256
|
const auth = requireApiToken();
|
62257
|
+
const scopes = getScopes();
|
62258
|
+
if (scopes !== void 0 && !scopes.includes(scope)) {
|
62259
|
+
logger.error(`You don't have '${scope}' in your list of scopes`);
|
62260
|
+
printScopes(scopes ?? []);
|
62261
|
+
throw new UserError(
|
62262
|
+
`You need '${scope}', try logging in again or creating an appropiate API token`
|
62263
|
+
);
|
62264
|
+
}
|
62276
62265
|
addAuthorizationHeaderIfUnspecified(headers, auth);
|
62277
62266
|
addUserAgent(headers);
|
62278
62267
|
OpenAPI.CREDENTIALS = "omit";
|
@@ -62743,9 +62732,9 @@ async function buildAndMaybePush(args, pathToDocker, push, containerConfig) {
|
|
62743
62732
|
});
|
62744
62733
|
const inspectOutput = await dockerImageInspect(pathToDocker, {
|
62745
62734
|
imageTag,
|
62746
|
-
formatString: "{{ .Size }} {{ len .RootFS.Layers }}"
|
62735
|
+
formatString: "{{ .Size }} {{ len .RootFS.Layers }} {{json .RepoDigests}}"
|
62747
62736
|
});
|
62748
|
-
const [sizeStr, layerStr] = inspectOutput.split(" ");
|
62737
|
+
const [sizeStr, layerStr, repoDigests] = inspectOutput.split(" ");
|
62749
62738
|
const size = parseInt(sizeStr, 10);
|
62750
62739
|
const layers = parseInt(layerStr, 10);
|
62751
62740
|
const MiB = 1024 * 1024;
|
@@ -62755,15 +62744,28 @@ async function buildAndMaybePush(args, pathToDocker, push, containerConfig) {
|
|
62755
62744
|
account,
|
62756
62745
|
containerApp: containerConfig
|
62757
62746
|
});
|
62747
|
+
let pushed = false;
|
62758
62748
|
if (push) {
|
62759
62749
|
await dockerLoginManagedRegistry(pathToDocker);
|
62760
62750
|
try {
|
62751
|
+
const parsedDigests = JSON.parse(repoDigests);
|
62752
|
+
if (!Array.isArray(parsedDigests)) {
|
62753
|
+
throw new Error(
|
62754
|
+
`Expected RepoDigests from docker inspect to be an array but got ${JSON.stringify(parsedDigests)}`
|
62755
|
+
);
|
62756
|
+
}
|
62761
62757
|
const repositoryOnly = imageTag.split(":")[0];
|
62762
|
-
const
|
62763
|
-
|
62758
|
+
const digests = parsedDigests.filter(
|
62759
|
+
(d6) => typeof d6 === "string" && d6.split("@")[0] === repositoryOnly
|
62760
|
+
);
|
62761
|
+
if (digests.length !== 1) {
|
62762
|
+
throw new Error(
|
62763
|
+
`Expected there to only be 1 valid digests for this repository: ${repositoryOnly} but there were ${digests.length}`
|
62764
|
+
);
|
62765
|
+
}
|
62764
62766
|
await runDockerCmd(
|
62765
62767
|
pathToDocker,
|
62766
|
-
["manifest", "inspect",
|
62768
|
+
["manifest", "inspect", digests[0]],
|
62767
62769
|
"ignore"
|
62768
62770
|
);
|
62769
62771
|
logger.log("Image already exists remotely, skipping push");
|
@@ -62771,13 +62773,19 @@ async function buildAndMaybePush(args, pathToDocker, push, containerConfig) {
|
|
62771
62773
|
`Untagging built image: ${imageTag} since there was no change.`
|
62772
62774
|
);
|
62773
62775
|
await runDockerCmd(pathToDocker, ["image", "rm", imageTag]);
|
62774
|
-
return
|
62776
|
+
return { image: digests[0], pushed: false };
|
62775
62777
|
} catch (error2) {
|
62776
62778
|
logger.log(`Image does not exist remotely, pushing: ${imageTag}`);
|
62779
|
+
if (error2 instanceof Error) {
|
62780
|
+
logger.debug(
|
62781
|
+
`Checking for local image ${imageTag} failed with error: ${error2.message}`
|
62782
|
+
);
|
62783
|
+
}
|
62777
62784
|
await runDockerCmd(pathToDocker, ["push", imageTag]);
|
62785
|
+
pushed = true;
|
62778
62786
|
}
|
62779
62787
|
}
|
62780
|
-
return imageTag;
|
62788
|
+
return { image: imageTag, pushed };
|
62781
62789
|
} catch (error2) {
|
62782
62790
|
if (error2 instanceof Error) {
|
62783
62791
|
throw new UserError(error2.message);
|
@@ -64004,6 +64012,9 @@ async function apply(args, config) {
|
|
64004
64012
|
`${config.name}-${appConfigNoDefaults.class_name}`];
|
64005
64013
|
if (!appConfigNoDefaults.configuration?.image && application) {
|
64006
64014
|
appConfigNoDefaults.configuration ??= {};
|
64015
|
+
}
|
64016
|
+
if (!args.imageUpdateRequired && application) {
|
64017
|
+
appConfigNoDefaults.configuration ??= {};
|
64007
64018
|
appConfigNoDefaults.configuration.image = application.configuration.image;
|
64008
64019
|
}
|
64009
64020
|
const appConfig = containerAppToCreateApplication(
|
@@ -64287,7 +64298,14 @@ ${err.message}`
|
|
64287
64298
|
}
|
64288
64299
|
async function applyCommand(args, config) {
|
64289
64300
|
return apply(
|
64290
|
-
{
|
64301
|
+
{
|
64302
|
+
skipDefaults: args.skipDefaults,
|
64303
|
+
env: args.env,
|
64304
|
+
json: args.json,
|
64305
|
+
// For the apply command we want this to default to true
|
64306
|
+
// so that the image can be updated if the user modified it.
|
64307
|
+
imageUpdateRequired: true
|
64308
|
+
},
|
64291
64309
|
config
|
64292
64310
|
);
|
64293
64311
|
}
|
@@ -64327,7 +64345,10 @@ async function maybeBuildContainer(containerConfig, imageTag, dryRun, pathToDock
|
|
64327
64345
|
if (!isDockerfile(
|
64328
64346
|
containerConfig.image ?? containerConfig.configuration?.image
|
64329
64347
|
)) {
|
64330
|
-
return
|
64348
|
+
return {
|
64349
|
+
image: containerConfig.image ?? containerConfig.configuration?.image,
|
64350
|
+
pushed: false
|
64351
|
+
};
|
64331
64352
|
}
|
64332
64353
|
} catch (err) {
|
64333
64354
|
if (err instanceof Error) {
|
@@ -64337,13 +64358,13 @@ async function maybeBuildContainer(containerConfig, imageTag, dryRun, pathToDock
|
|
64337
64358
|
}
|
64338
64359
|
const options = getBuildArguments(containerConfig, imageTag);
|
64339
64360
|
logger.log("Building image", options.tag);
|
64340
|
-
const
|
64361
|
+
const buildResult = await buildAndMaybePush(
|
64341
64362
|
options,
|
64342
64363
|
pathToDocker,
|
64343
64364
|
!dryRun,
|
64344
64365
|
containerConfig
|
64345
64366
|
);
|
64346
|
-
return
|
64367
|
+
return buildResult;
|
64347
64368
|
}
|
64348
64369
|
async function deployContainers(config, { versionId, accountId, scriptName, dryRun, env: env6 }) {
|
64349
64370
|
if (config.containers === void 0) {
|
@@ -64386,16 +64407,24 @@ async function deployContainers(config, { versionId, accountId, scriptName, dryR
|
|
64386
64407
|
}
|
64387
64408
|
]
|
64388
64409
|
};
|
64389
|
-
const
|
64410
|
+
const buildResult = await maybeBuildContainer(
|
64390
64411
|
container,
|
64391
64412
|
versionId,
|
64392
64413
|
dryRun,
|
64393
64414
|
pathToDocker
|
64394
64415
|
);
|
64395
64416
|
container.configuration ??= {};
|
64396
|
-
container.configuration.image = image;
|
64397
|
-
container.image = image;
|
64398
|
-
await apply(
|
64417
|
+
container.configuration.image = buildResult.image;
|
64418
|
+
container.image = buildResult.image;
|
64419
|
+
await apply(
|
64420
|
+
{
|
64421
|
+
skipDefaults: false,
|
64422
|
+
json: true,
|
64423
|
+
env: env6,
|
64424
|
+
imageUpdateRequired: buildResult.pushed
|
64425
|
+
},
|
64426
|
+
configuration
|
64427
|
+
);
|
64399
64428
|
}
|
64400
64429
|
}
|
64401
64430
|
function getBuildArguments(container, idForImageTag) {
|
@@ -119664,12 +119693,12 @@ var init_getValidatedProcessCredentials = __esm({
|
|
119664
119693
|
});
|
119665
119694
|
|
119666
119695
|
// ../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.716.0/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
|
119667
|
-
var
|
119696
|
+
var import_child_process5, import_util14, resolveProcessCredentials;
|
119668
119697
|
var init_resolveProcessCredentials = __esm({
|
119669
119698
|
"../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.716.0/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js"() {
|
119670
119699
|
init_import_meta_url();
|
119671
119700
|
init_dist_es17();
|
119672
|
-
|
119701
|
+
import_child_process5 = require("child_process");
|
119673
119702
|
import_util14 = require("util");
|
119674
119703
|
init_getValidatedProcessCredentials();
|
119675
119704
|
resolveProcessCredentials = /* @__PURE__ */ __name(async (profileName, profiles, logger4) => {
|
@@ -119677,7 +119706,7 @@ var init_resolveProcessCredentials = __esm({
|
|
119677
119706
|
if (profiles[profileName]) {
|
119678
119707
|
const credentialProcess = profile["credential_process"];
|
119679
119708
|
if (credentialProcess !== void 0) {
|
119680
|
-
const execPromise = (0, import_util14.promisify)(
|
119709
|
+
const execPromise = (0, import_util14.promisify)(import_child_process5.exec);
|
119681
119710
|
try {
|
119682
119711
|
const { stdout: stdout2 } = await execPromise(credentialProcess);
|
119683
119712
|
let data;
|
@@ -140306,7 +140335,7 @@ async function getDarwinInfo() {
|
|
140306
140335
|
};
|
140307
140336
|
try {
|
140308
140337
|
const output = await new Promise((resolve24, reject) => {
|
140309
|
-
(0,
|
140338
|
+
(0, import_child_process6.execFile)("/usr/bin/sw_vers", (error2, stdout2) => {
|
140310
140339
|
if (error2) {
|
140311
140340
|
reject(error2);
|
140312
140341
|
return;
|
@@ -140400,12 +140429,12 @@ function getCloudResourceContext() {
|
|
140400
140429
|
return void 0;
|
140401
140430
|
}
|
140402
140431
|
}
|
140403
|
-
var
|
140432
|
+
var import_child_process6, import_fs24, os8, import_path24, import_util16, readFileAsync, readDirAsync, Context, PLATFORM_NAMES, LINUX_DISTROS, LINUX_VERSIONS;
|
140404
140433
|
var init_context = __esm({
|
140405
140434
|
"../../node_modules/.pnpm/@sentry+node@7.87.0_supports-color@9.2.2/node_modules/@sentry/node/esm/integrations/context.js"() {
|
140406
140435
|
init_import_meta_url();
|
140407
140436
|
init_esm6();
|
140408
|
-
|
140437
|
+
import_child_process6 = require("child_process");
|
140409
140438
|
import_fs24 = require("fs");
|
140410
140439
|
os8 = __toESM(require("os"));
|
140411
140440
|
import_path24 = require("path");
|
@@ -152638,8 +152667,16 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
152638
152667
|
}
|
152639
152668
|
const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && prod && format9 === "modules" && migrations === void 0 && !config.first_party_worker && config.containers === void 0;
|
152640
152669
|
let workerBundle;
|
152670
|
+
const dockerPath = getDockerPath();
|
152671
|
+
if (config.containers) {
|
152672
|
+
const hasDockerfiles = config.containers?.some(
|
152673
|
+
(container) => isDockerfile(container.image ?? container.configuration?.image)
|
152674
|
+
);
|
152675
|
+
if (hasDockerfiles) {
|
152676
|
+
await verifyDockerInstalled(dockerPath, false);
|
152677
|
+
}
|
152678
|
+
}
|
152641
152679
|
if (props.dryRun) {
|
152642
|
-
const dockerPath = getDockerPath();
|
152643
152680
|
if (config.containers) {
|
152644
152681
|
for (const container of config.containers) {
|
152645
152682
|
await maybeBuildContainer(
|
@@ -153081,6 +153118,7 @@ var init_deploy7 = __esm({
|
|
153081
153118
|
import_node_path56 = __toESM(require("path"));
|
153082
153119
|
import_node_url9 = require("url");
|
153083
153120
|
init_cli();
|
153121
|
+
init_containers_shared();
|
153084
153122
|
init_dist2();
|
153085
153123
|
import_undici21 = __toESM(require_undici());
|
153086
153124
|
init_assets();
|