wrangler 3.28.4 → 3.30.0
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 +5 -5
- package/wrangler-dist/cli.d.ts +15 -0
- package/wrangler-dist/cli.js +246 -113
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.0",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"source-map": "0.6.1",
|
|
97
97
|
"xxhash-wasm": "^1.0.1",
|
|
98
98
|
"@cloudflare/kv-asset-handler": "0.3.1",
|
|
99
|
-
"miniflare": "3.
|
|
99
|
+
"miniflare": "3.20240223.0"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@cloudflare/ai": "^1.0.35",
|
|
@@ -186,9 +186,9 @@
|
|
|
186
186
|
"xdg-app-paths": "^8.3.0",
|
|
187
187
|
"yargs": "^17.7.2",
|
|
188
188
|
"yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
|
|
189
|
-
"@cloudflare/
|
|
190
|
-
"@cloudflare/
|
|
191
|
-
"@cloudflare/
|
|
189
|
+
"@cloudflare/cli": "1.1.1",
|
|
190
|
+
"@cloudflare/pages-shared": "^0.11.15",
|
|
191
|
+
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
192
192
|
},
|
|
193
193
|
"optionalDependencies": {
|
|
194
194
|
"fsevents": "~2.3.2"
|
package/wrangler-dist/cli.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { URL as URL_2 } from 'url';
|
|
|
25
25
|
import { UrlObject } from 'url';
|
|
26
26
|
import { URLSearchParams as URLSearchParams_2 } from 'url';
|
|
27
27
|
import { WebSocket as WebSocket_3 } from 'miniflare';
|
|
28
|
+
import type { WorkerOptions } from 'miniflare';
|
|
28
29
|
import { Writable } from 'stream';
|
|
29
30
|
|
|
30
31
|
declare type AbortSignal_2 = unknown;
|
|
@@ -1359,6 +1360,13 @@ declare interface EnvironmentInheritable {
|
|
|
1359
1360
|
* @inheritable
|
|
1360
1361
|
*/
|
|
1361
1362
|
find_additional_modules: boolean | undefined;
|
|
1363
|
+
/**
|
|
1364
|
+
* Determines whether Wrangler will preserve bundled file names.
|
|
1365
|
+
* Defaults to false.
|
|
1366
|
+
* If left unset, files will be named using the pattern ${fileHash}-${basename},
|
|
1367
|
+
* for example, `34de60b44167af5c5a709e62a4e20c4f18c9e3b6-favicon.ico`.
|
|
1368
|
+
*/
|
|
1369
|
+
preserve_file_names: boolean | undefined;
|
|
1362
1370
|
/**
|
|
1363
1371
|
* The directory in which module rules should be evaluated when including additional files into a worker deployment.
|
|
1364
1372
|
* This defaults to the directory containing the `main` entry point of the worker if not specified.
|
|
@@ -23414,6 +23422,8 @@ declare function setGlobalOrigin(origin: string | URL | undefined): void;
|
|
|
23414
23422
|
|
|
23415
23423
|
declare type SimpleRoute = string;
|
|
23416
23424
|
|
|
23425
|
+
export declare type SourcelessWorkerOptions = Omit<WorkerOptions, "script" | "scriptPath" | "modules" | "modulesRoot" | "modulesRule">;
|
|
23426
|
+
|
|
23417
23427
|
/**
|
|
23418
23428
|
* Information about Wrangler's bundling process that needs passed through
|
|
23419
23429
|
* for DevTools sourcemap transformation
|
|
@@ -23708,6 +23718,11 @@ export declare class unstable_DevEnv extends EventEmitter_2 {
|
|
|
23708
23718
|
emitErrorEvent(ev: ErrorEvent_2): void;
|
|
23709
23719
|
}
|
|
23710
23720
|
|
|
23721
|
+
export declare function unstable_getMiniflareWorkerOptions(configPath: string): {
|
|
23722
|
+
workerOptions: SourcelessWorkerOptions;
|
|
23723
|
+
main?: string;
|
|
23724
|
+
};
|
|
23725
|
+
|
|
23711
23726
|
export declare const unstable_pages: {
|
|
23712
23727
|
deploy: typeof deploy;
|
|
23713
23728
|
};
|
package/wrangler-dist/cli.js
CHANGED
|
@@ -105448,6 +105448,7 @@ async function generateHandler({
|
|
|
105448
105448
|
xServerEnvHeader,
|
|
105449
105449
|
xDeploymentIdHeader,
|
|
105450
105450
|
logError,
|
|
105451
|
+
setMetrics,
|
|
105451
105452
|
findAssetEntryForPath,
|
|
105452
105453
|
getAssetKey,
|
|
105453
105454
|
negotiateContent,
|
|
@@ -105599,7 +105600,15 @@ async function generateHandler({
|
|
|
105599
105600
|
const earlyHintsLinkHeader = earlyHintsResponse.headers.get("Link");
|
|
105600
105601
|
if (earlyHintsLinkHeader) {
|
|
105601
105602
|
headers.set("Link", earlyHintsLinkHeader);
|
|
105603
|
+
if (setMetrics)
|
|
105604
|
+
setMetrics({ earlyHintsResult: "used-hit" });
|
|
105605
|
+
} else {
|
|
105606
|
+
if (setMetrics)
|
|
105607
|
+
setMetrics({ earlyHintsResult: "notused-hit" });
|
|
105602
105608
|
}
|
|
105609
|
+
} else {
|
|
105610
|
+
if (setMetrics)
|
|
105611
|
+
setMetrics({ earlyHintsResult: "notused-miss" });
|
|
105603
105612
|
}
|
|
105604
105613
|
const clonedResponse = response.clone();
|
|
105605
105614
|
if (waitUntil) {
|
|
@@ -105644,6 +105653,9 @@ async function generateHandler({
|
|
|
105644
105653
|
})()
|
|
105645
105654
|
);
|
|
105646
105655
|
}
|
|
105656
|
+
} else {
|
|
105657
|
+
if (setMetrics)
|
|
105658
|
+
setMetrics({ earlyHintsResult: "disabled" });
|
|
105647
105659
|
}
|
|
105648
105660
|
const headersMatcher = generateRulesMatcher(
|
|
105649
105661
|
headerRules,
|
|
@@ -105774,8 +105786,16 @@ async function generateHandler({
|
|
|
105774
105786
|
);
|
|
105775
105787
|
const preservedResponse = await assetPreservationCache.match(request3.url);
|
|
105776
105788
|
if (preservedResponse) {
|
|
105789
|
+
if (setMetrics)
|
|
105790
|
+
setMetrics({ preservationCacheResult: "checked-hit" });
|
|
105777
105791
|
return preservedResponse;
|
|
105792
|
+
} else {
|
|
105793
|
+
if (setMetrics)
|
|
105794
|
+
setMetrics({ preservationCacheResult: "checked-miss" });
|
|
105778
105795
|
}
|
|
105796
|
+
} else {
|
|
105797
|
+
if (setMetrics)
|
|
105798
|
+
setMetrics({ preservationCacheResult: "disabled" });
|
|
105779
105799
|
}
|
|
105780
105800
|
let cwd2 = pathname;
|
|
105781
105801
|
while (cwd2) {
|
|
@@ -116039,6 +116059,7 @@ __export(cli_exports, {
|
|
|
116039
116059
|
getPlatformProxy: () => getPlatformProxy,
|
|
116040
116060
|
unstable_DevEnv: () => DevEnv,
|
|
116041
116061
|
unstable_dev: () => unstable_dev,
|
|
116062
|
+
unstable_getMiniflareWorkerOptions: () => unstable_getMiniflareWorkerOptions,
|
|
116042
116063
|
unstable_pages: () => unstable_pages
|
|
116043
116064
|
});
|
|
116044
116065
|
module.exports = __toCommonJS(cli_exports);
|
|
@@ -119622,7 +119643,7 @@ var import_node_assert2 = __toESM(require("node:assert"));
|
|
|
119622
119643
|
var import_undici3 = __toESM(require_undici());
|
|
119623
119644
|
|
|
119624
119645
|
// package.json
|
|
119625
|
-
var version = "3.
|
|
119646
|
+
var version = "3.30.0";
|
|
119626
119647
|
var package_default = {
|
|
119627
119648
|
name: "wrangler",
|
|
119628
119649
|
version,
|
|
@@ -122536,6 +122557,14 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envNam
|
|
|
122536
122557
|
isBoolean,
|
|
122537
122558
|
void 0
|
|
122538
122559
|
),
|
|
122560
|
+
preserve_file_names: inheritable(
|
|
122561
|
+
diagnostics,
|
|
122562
|
+
topLevelEnv,
|
|
122563
|
+
rawEnv,
|
|
122564
|
+
"preserve_file_names",
|
|
122565
|
+
isBoolean,
|
|
122566
|
+
void 0
|
|
122567
|
+
),
|
|
122539
122568
|
base_dir: normalizeAndValidateBaseDirField(
|
|
122540
122569
|
configPath,
|
|
122541
122570
|
inheritable(
|
|
@@ -124970,7 +124999,7 @@ function createModuleCollector(props) {
|
|
|
124970
124999
|
);
|
|
124971
125000
|
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
124972
125001
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
|
124973
|
-
const fileName = `./${fileHash}-${import_node_path9.default.basename(args.path)}`;
|
|
125002
|
+
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path9.default.basename(args.path)}`;
|
|
124974
125003
|
const { rule } = rulesMatchers.find(({ regex: regex2 }) => regex2.test(fileName)) || {};
|
|
124975
125004
|
if (rule) {
|
|
124976
125005
|
modules.push({
|
|
@@ -125051,7 +125080,7 @@ function createModuleCollector(props) {
|
|
|
125051
125080
|
}
|
|
125052
125081
|
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
125053
125082
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
|
125054
|
-
const fileName = props.preserveFileNames ?
|
|
125083
|
+
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path9.default.basename(args.path)}`;
|
|
125055
125084
|
modules.push({
|
|
125056
125085
|
name: fileName,
|
|
125057
125086
|
filePath,
|
|
@@ -126759,7 +126788,7 @@ __name(generateAddScriptNameExamples, "generateAddScriptNameExamples");
|
|
|
126759
126788
|
// src/dev/dev.tsx
|
|
126760
126789
|
init_import_meta_url();
|
|
126761
126790
|
var import_node_child_process6 = require("node:child_process");
|
|
126762
|
-
var
|
|
126791
|
+
var path52 = __toESM(require("node:path"));
|
|
126763
126792
|
var util2 = __toESM(require("node:util"));
|
|
126764
126793
|
var import_chokidar4 = require("chokidar");
|
|
126765
126794
|
|
|
@@ -128031,13 +128060,6 @@ function buildLog() {
|
|
|
128031
128060
|
return new WranglerLog(level, { prefix: "wrangler-UserWorker" });
|
|
128032
128061
|
}
|
|
128033
128062
|
__name(buildLog, "buildLog");
|
|
128034
|
-
function stripPySuffix(modulePath, type) {
|
|
128035
|
-
if (type === "python" && modulePath.endsWith(".py")) {
|
|
128036
|
-
return modulePath.slice(0, -3);
|
|
128037
|
-
}
|
|
128038
|
-
return modulePath;
|
|
128039
|
-
}
|
|
128040
|
-
__name(stripPySuffix, "stripPySuffix");
|
|
128041
128063
|
async function buildSourceOptions(config) {
|
|
128042
128064
|
const scriptPath3 = (0, import_node_fs11.realpathSync)(config.bundle.path);
|
|
128043
128065
|
if (config.format === "modules") {
|
|
@@ -128052,16 +128074,13 @@ async function buildSourceOptions(config) {
|
|
|
128052
128074
|
// Entrypoint
|
|
128053
128075
|
{
|
|
128054
128076
|
type: ModuleTypeToRuleType[config.bundle.type],
|
|
128055
|
-
path:
|
|
128077
|
+
path: scriptPath3,
|
|
128056
128078
|
contents: entrypointSource
|
|
128057
128079
|
},
|
|
128058
128080
|
// Misc (WebAssembly, etc, ...)
|
|
128059
128081
|
...modules.map((module3) => ({
|
|
128060
128082
|
type: ModuleTypeToRuleType[module3.type ?? "esm"],
|
|
128061
|
-
path:
|
|
128062
|
-
import_node_path19.default.resolve(modulesRoot, module3.name),
|
|
128063
|
-
module3.type
|
|
128064
|
-
),
|
|
128083
|
+
path: import_node_path19.default.resolve(modulesRoot, module3.name),
|
|
128065
128084
|
contents: module3.content
|
|
128066
128085
|
}))
|
|
128067
128086
|
]
|
|
@@ -128229,7 +128248,9 @@ function buildPersistOptions(localPersistencePath) {
|
|
|
128229
128248
|
}
|
|
128230
128249
|
}
|
|
128231
128250
|
__name(buildPersistOptions, "buildPersistOptions");
|
|
128232
|
-
function buildSitesOptions({
|
|
128251
|
+
function buildSitesOptions({
|
|
128252
|
+
assetPaths
|
|
128253
|
+
}) {
|
|
128233
128254
|
if (assetPaths !== void 0) {
|
|
128234
128255
|
const { baseDirectory, assetDirectory, includePatterns, excludePatterns } = assetPaths;
|
|
128235
128256
|
return {
|
|
@@ -145961,32 +145982,42 @@ function buildNotifierPlugin(onEnd) {
|
|
|
145961
145982
|
};
|
|
145962
145983
|
}
|
|
145963
145984
|
__name(buildNotifierPlugin, "buildNotifierPlugin");
|
|
145964
|
-
async function checkRawWorker(scriptPath3, onEnd) {
|
|
145985
|
+
async function checkRawWorker(scriptPath3, nodejsCompat, onEnd) {
|
|
145965
145986
|
await (0, import_esbuild3.build)({
|
|
145966
145987
|
entryPoints: [scriptPath3],
|
|
145967
145988
|
write: false,
|
|
145968
145989
|
// we need it to be bundled so that any imports that are used are affected by the blocker plugin
|
|
145969
145990
|
bundle: true,
|
|
145970
|
-
plugins: [blockWorkerJsImports, buildNotifierPlugin(onEnd)]
|
|
145991
|
+
plugins: [blockWorkerJsImports(nodejsCompat), buildNotifierPlugin(onEnd)],
|
|
145992
|
+
logLevel: "silent"
|
|
145971
145993
|
});
|
|
145972
145994
|
}
|
|
145973
145995
|
__name(checkRawWorker, "checkRawWorker");
|
|
145974
|
-
|
|
145975
|
-
|
|
145976
|
-
|
|
145977
|
-
build5
|
|
145978
|
-
|
|
145979
|
-
|
|
145980
|
-
|
|
145981
|
-
|
|
145982
|
-
|
|
145983
|
-
|
|
145984
|
-
|
|
145985
|
-
|
|
145986
|
-
|
|
145987
|
-
|
|
145988
|
-
|
|
145989
|
-
}
|
|
145996
|
+
function blockWorkerJsImports(nodejsCompat) {
|
|
145997
|
+
return {
|
|
145998
|
+
name: "block-worker-js-imports",
|
|
145999
|
+
setup(build5) {
|
|
146000
|
+
build5.onResolve({ filter: /.*/g }, (args) => {
|
|
146001
|
+
if (args.kind === "entry-point") {
|
|
146002
|
+
return {
|
|
146003
|
+
path: args.path
|
|
146004
|
+
};
|
|
146005
|
+
}
|
|
146006
|
+
if (nodejsCompat && args.path.startsWith("node:") || args.path.startsWith("cloudflare:")) {
|
|
146007
|
+
return {
|
|
146008
|
+
path: args.path,
|
|
146009
|
+
external: true
|
|
146010
|
+
};
|
|
146011
|
+
}
|
|
146012
|
+
throw new FatalError(
|
|
146013
|
+
"_worker.js is not being bundled by Wrangler but it is importing from another file.\nThis will throw an error if deployed.\nYou should bundle the Worker in a pre-build step, remove the import if it is unused, or ask Wrangler to bundle it by setting `--bundle`.",
|
|
146014
|
+
1
|
|
146015
|
+
);
|
|
146016
|
+
});
|
|
146017
|
+
}
|
|
146018
|
+
};
|
|
146019
|
+
}
|
|
146020
|
+
__name(blockWorkerJsImports, "blockWorkerJsImports");
|
|
145990
146021
|
|
|
145991
146022
|
// src/pages/functions/buildPlugin.ts
|
|
145992
146023
|
function buildPluginFromFunctions({
|
|
@@ -147810,7 +147841,7 @@ async function deploy2({
|
|
|
147810
147841
|
isProduction = project.production_branch === branch;
|
|
147811
147842
|
}
|
|
147812
147843
|
const deploymentConfig = project.deployment_configs[isProduction ? "production" : "preview"];
|
|
147813
|
-
const nodejsCompat = deploymentConfig.compatibility_flags?.includes("nodejs_compat");
|
|
147844
|
+
const nodejsCompat = deploymentConfig.compatibility_flags?.includes("nodejs_compat") ?? false;
|
|
147814
147845
|
const defineNavigatorUserAgent = isNavigatorDefined(
|
|
147815
147846
|
deploymentConfig.compatibility_date,
|
|
147816
147847
|
deploymentConfig.compatibility_flags
|
|
@@ -147916,7 +147947,7 @@ async function deploy2({
|
|
|
147916
147947
|
defineNavigatorUserAgent
|
|
147917
147948
|
});
|
|
147918
147949
|
} else {
|
|
147919
|
-
await checkRawWorker(_workerPath, () => {
|
|
147950
|
+
await checkRawWorker(_workerPath, nodejsCompat, () => {
|
|
147920
147951
|
});
|
|
147921
147952
|
workerBundle = {
|
|
147922
147953
|
modules: [],
|
|
@@ -149383,7 +149414,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for
|
|
|
149383
149414
|
const functionsDirectory = "./functions";
|
|
149384
149415
|
let usingFunctions = !usingWorkerScript && (0, import_node_fs28.existsSync)(functionsDirectory);
|
|
149385
149416
|
let scriptPath3 = "";
|
|
149386
|
-
const nodejsCompat = compatibilityFlags?.includes("nodejs_compat");
|
|
149417
|
+
const nodejsCompat = compatibilityFlags?.includes("nodejs_compat") ?? false;
|
|
149387
149418
|
const defineNavigatorUserAgent = isNavigatorDefined(
|
|
149388
149419
|
compatibilityDate,
|
|
149389
149420
|
compatibilityFlags
|
|
@@ -149418,7 +149449,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for
|
|
|
149418
149449
|
} else if (usingWorkerScript) {
|
|
149419
149450
|
scriptPath3 = workerScriptPath;
|
|
149420
149451
|
let runBuild = /* @__PURE__ */ __name(async () => {
|
|
149421
|
-
await checkRawWorker(
|
|
149452
|
+
await checkRawWorker(
|
|
149453
|
+
workerScriptPath,
|
|
149454
|
+
nodejsCompat,
|
|
149455
|
+
() => scriptReadyResolve()
|
|
149456
|
+
);
|
|
149422
149457
|
}, "runBuild");
|
|
149423
149458
|
if (enableBundling) {
|
|
149424
149459
|
scriptPath3 = (0, import_node_path43.join)(
|
|
@@ -161494,10 +161529,110 @@ __name(tailHandler, "tailHandler");
|
|
|
161494
161529
|
|
|
161495
161530
|
// src/type-generation.ts
|
|
161496
161531
|
init_import_meta_url();
|
|
161497
|
-
var fs21 = __toESM(require("fs"));
|
|
161498
|
-
|
|
161532
|
+
var fs21 = __toESM(require("node:fs"));
|
|
161533
|
+
|
|
161534
|
+
// src/dev/dev-vars.ts
|
|
161535
|
+
init_import_meta_url();
|
|
161536
|
+
var path45 = __toESM(require("node:path"));
|
|
161537
|
+
function getVarsForDev(config, env5, silent = false) {
|
|
161538
|
+
const configDir = path45.resolve(path45.dirname(config.configPath ?? "."));
|
|
161539
|
+
const devVarsPath = path45.resolve(configDir, ".dev.vars");
|
|
161540
|
+
const loaded = loadDotEnv(devVarsPath, env5);
|
|
161541
|
+
if (loaded !== void 0) {
|
|
161542
|
+
const devVarsRelativePath = path45.relative(process.cwd(), loaded.path);
|
|
161543
|
+
if (!silent) {
|
|
161544
|
+
logger.log(`Using vars defined in ${devVarsRelativePath}`);
|
|
161545
|
+
}
|
|
161546
|
+
return {
|
|
161547
|
+
...config.vars,
|
|
161548
|
+
...loaded.parsed
|
|
161549
|
+
};
|
|
161550
|
+
} else {
|
|
161551
|
+
return config.vars;
|
|
161552
|
+
}
|
|
161553
|
+
}
|
|
161554
|
+
__name(getVarsForDev, "getVarsForDev");
|
|
161555
|
+
|
|
161556
|
+
// src/type-generation.ts
|
|
161557
|
+
function typesOptions(yargs) {
|
|
161558
|
+
return yargs.positional("path", {
|
|
161559
|
+
describe: "The path to the declaration file to generate",
|
|
161560
|
+
type: "string",
|
|
161561
|
+
default: "worker-configuration.d.ts",
|
|
161562
|
+
demandOption: false
|
|
161563
|
+
}).option("env-interface", {
|
|
161564
|
+
type: "string",
|
|
161565
|
+
default: "Env",
|
|
161566
|
+
describe: "The name of the generated environment interface",
|
|
161567
|
+
requiresArg: true
|
|
161568
|
+
});
|
|
161569
|
+
}
|
|
161570
|
+
__name(typesOptions, "typesOptions");
|
|
161571
|
+
async function typesHandler(args) {
|
|
161572
|
+
const { envInterface, path: outputPath } = args;
|
|
161573
|
+
const validInterfaceRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
161574
|
+
if (!validInterfaceRegex.test(envInterface)) {
|
|
161575
|
+
throw new CommandLineArgsError(
|
|
161576
|
+
`The provided env-interface value ("${envInterface}") does not satisfy the validation regex: ${validInterfaceRegex}`
|
|
161577
|
+
);
|
|
161578
|
+
}
|
|
161579
|
+
if (!outputPath.endsWith(".d.ts")) {
|
|
161580
|
+
throw new CommandLineArgsError(
|
|
161581
|
+
`The provided path value ("${outputPath}") does not point to a declaration file (please use the 'd.ts' extension)`
|
|
161582
|
+
);
|
|
161583
|
+
}
|
|
161584
|
+
await printWranglerBanner();
|
|
161585
|
+
const configPath = args.config ?? findWranglerToml(process.cwd(), args.experimentalJsonConfig);
|
|
161586
|
+
if (!configPath || !fs21.existsSync(configPath) || fs21.statSync(configPath).isDirectory()) {
|
|
161587
|
+
logger.warn(
|
|
161588
|
+
`No config file detected${args.config ? ` (at ${args.config})` : ""}, aborting`
|
|
161589
|
+
);
|
|
161590
|
+
return;
|
|
161591
|
+
}
|
|
161592
|
+
const config = readConfig(configPath, args);
|
|
161593
|
+
const secrets = getVarsForDev(
|
|
161594
|
+
{ configPath, vars: {} },
|
|
161595
|
+
args.env,
|
|
161596
|
+
true
|
|
161597
|
+
);
|
|
161598
|
+
const configBindingsWithSecrets = {
|
|
161599
|
+
kv_namespaces: config.kv_namespaces ?? [],
|
|
161600
|
+
vars: { ...config.vars },
|
|
161601
|
+
wasm_modules: config.wasm_modules,
|
|
161602
|
+
text_blobs: {
|
|
161603
|
+
...config.text_blobs
|
|
161604
|
+
},
|
|
161605
|
+
data_blobs: config.data_blobs,
|
|
161606
|
+
durable_objects: config.durable_objects,
|
|
161607
|
+
r2_buckets: config.r2_buckets,
|
|
161608
|
+
d1_databases: config.d1_databases,
|
|
161609
|
+
services: config.services,
|
|
161610
|
+
analytics_engine_datasets: config.analytics_engine_datasets,
|
|
161611
|
+
dispatch_namespaces: config.dispatch_namespaces,
|
|
161612
|
+
logfwdr: config.logfwdr,
|
|
161613
|
+
unsafe: config.unsafe,
|
|
161614
|
+
rules: config.rules,
|
|
161615
|
+
queues: config.queues,
|
|
161616
|
+
constellation: config.constellation,
|
|
161617
|
+
secrets
|
|
161618
|
+
};
|
|
161619
|
+
await generateTypes(
|
|
161620
|
+
configBindingsWithSecrets,
|
|
161621
|
+
config,
|
|
161622
|
+
envInterface,
|
|
161623
|
+
outputPath
|
|
161624
|
+
);
|
|
161625
|
+
}
|
|
161626
|
+
__name(typesHandler, "typesHandler");
|
|
161627
|
+
async function generateTypes(configToDTS, config, envInterface, outputPath) {
|
|
161499
161628
|
const configContainsEntryPoint = config.main !== void 0 || !!config.site?.["entry-point"];
|
|
161500
161629
|
const entrypointFormat = configContainsEntryPoint ? (await getEntry({}, config, "types")).format : "modules";
|
|
161630
|
+
const userProvidedEnvInterface = envInterface !== "Env";
|
|
161631
|
+
if (userProvidedEnvInterface && entrypointFormat === "service-worker") {
|
|
161632
|
+
throw new Error(
|
|
161633
|
+
"An env-interface value has been provided but the worker uses the incompatible Service Worker syntax"
|
|
161634
|
+
);
|
|
161635
|
+
}
|
|
161501
161636
|
const envTypeStructure = [];
|
|
161502
161637
|
if (configToDTS.kv_namespaces) {
|
|
161503
161638
|
for (const kvNamespace2 of configToDTS.kv_namespaces) {
|
|
@@ -161505,8 +161640,10 @@ async function generateTypes(configToDTS, config) {
|
|
|
161505
161640
|
}
|
|
161506
161641
|
}
|
|
161507
161642
|
if (configToDTS.vars) {
|
|
161508
|
-
|
|
161509
|
-
|
|
161643
|
+
const vars = Object.entries(configToDTS.vars).filter(
|
|
161644
|
+
([key]) => !(key in configToDTS.secrets)
|
|
161645
|
+
);
|
|
161646
|
+
for (const [varName, varValue] of vars) {
|
|
161510
161647
|
if (typeof varValue === "string" || typeof varValue === "number" || typeof varValue === "boolean") {
|
|
161511
161648
|
envTypeStructure.push(`${varName}: "${varValue}";`);
|
|
161512
161649
|
}
|
|
@@ -161515,6 +161652,9 @@ async function generateTypes(configToDTS, config) {
|
|
|
161515
161652
|
}
|
|
161516
161653
|
}
|
|
161517
161654
|
}
|
|
161655
|
+
for (const secretName in configToDTS.secrets) {
|
|
161656
|
+
envTypeStructure.push(`${secretName}: string;`);
|
|
161657
|
+
}
|
|
161518
161658
|
if (configToDTS.durable_objects?.bindings) {
|
|
161519
161659
|
for (const durableObject of configToDTS.durable_objects.bindings) {
|
|
161520
161660
|
envTypeStructure.push(`${durableObject.name}: DurableObjectNamespace;`);
|
|
@@ -161599,20 +161739,24 @@ async function generateTypes(configToDTS, config) {
|
|
|
161599
161739
|
writeDTSFile({
|
|
161600
161740
|
envTypeStructure,
|
|
161601
161741
|
modulesTypeStructure,
|
|
161602
|
-
formatType: entrypointFormat
|
|
161742
|
+
formatType: entrypointFormat,
|
|
161743
|
+
envInterface,
|
|
161744
|
+
path: outputPath
|
|
161603
161745
|
});
|
|
161604
161746
|
}
|
|
161605
161747
|
__name(generateTypes, "generateTypes");
|
|
161606
161748
|
function writeDTSFile({
|
|
161607
161749
|
envTypeStructure,
|
|
161608
161750
|
modulesTypeStructure,
|
|
161609
|
-
formatType
|
|
161751
|
+
formatType,
|
|
161752
|
+
envInterface,
|
|
161753
|
+
path: path58
|
|
161610
161754
|
}) {
|
|
161611
|
-
const wranglerOverrideDTSPath = findUpSync(
|
|
161755
|
+
const wranglerOverrideDTSPath = findUpSync(path58);
|
|
161612
161756
|
try {
|
|
161613
161757
|
if (wranglerOverrideDTSPath !== void 0 && !fs21.readFileSync(wranglerOverrideDTSPath, "utf8").includes("Generated by Wrangler")) {
|
|
161614
161758
|
throw new UserError(
|
|
161615
|
-
|
|
161759
|
+
`A non-wrangler ${path58} already exists, please rename and try again.`
|
|
161616
161760
|
);
|
|
161617
161761
|
}
|
|
161618
161762
|
} catch (error2) {
|
|
@@ -161622,7 +161766,7 @@ function writeDTSFile({
|
|
|
161622
161766
|
}
|
|
161623
161767
|
let combinedTypeStrings = "";
|
|
161624
161768
|
if (formatType === "modules") {
|
|
161625
|
-
combinedTypeStrings += `interface
|
|
161769
|
+
combinedTypeStrings += `interface ${envInterface} {
|
|
161626
161770
|
${envTypeStructure.map((value) => ` ${value}`).join("\n")}
|
|
161627
161771
|
}
|
|
161628
161772
|
${modulesTypeStructure.join("\n")}`;
|
|
@@ -161633,11 +161777,16 @@ ${envTypeStructure.map((value) => ` const ${value}`).join("\n")}
|
|
|
161633
161777
|
}
|
|
161634
161778
|
${modulesTypeStructure.join("\n")}`;
|
|
161635
161779
|
}
|
|
161780
|
+
const wranglerCommandUsed = ["wrangler", ...process.argv.slice(2)].join(" ");
|
|
161636
161781
|
if (envTypeStructure.length || modulesTypeStructure.length) {
|
|
161637
161782
|
fs21.writeFileSync(
|
|
161638
|
-
|
|
161639
|
-
|
|
161640
|
-
|
|
161783
|
+
path58,
|
|
161784
|
+
[
|
|
161785
|
+
`// Generated by Wrangler on ${/* @__PURE__ */ new Date()}`,
|
|
161786
|
+
`// by running \`${wranglerCommandUsed}\``,
|
|
161787
|
+
"",
|
|
161788
|
+
combinedTypeStrings
|
|
161789
|
+
].join("\n")
|
|
161641
161790
|
);
|
|
161642
161791
|
logger.log(combinedTypeStrings);
|
|
161643
161792
|
}
|
|
@@ -163127,35 +163276,10 @@ function createCLIParser(argv) {
|
|
|
163127
163276
|
}
|
|
163128
163277
|
);
|
|
163129
163278
|
wrangler.command(
|
|
163130
|
-
"types",
|
|
163279
|
+
"types [path]",
|
|
163131
163280
|
"\u{1F4DD} Generate types from bindings & module rules in config",
|
|
163132
|
-
|
|
163133
|
-
|
|
163134
|
-
async (args) => {
|
|
163135
|
-
await printWranglerBanner();
|
|
163136
|
-
const config = readConfig(void 0, args);
|
|
163137
|
-
const configBindings = {
|
|
163138
|
-
kv_namespaces: config.kv_namespaces ?? [],
|
|
163139
|
-
vars: { ...config.vars },
|
|
163140
|
-
wasm_modules: config.wasm_modules,
|
|
163141
|
-
text_blobs: {
|
|
163142
|
-
...config.text_blobs
|
|
163143
|
-
},
|
|
163144
|
-
data_blobs: config.data_blobs,
|
|
163145
|
-
durable_objects: config.durable_objects,
|
|
163146
|
-
r2_buckets: config.r2_buckets,
|
|
163147
|
-
d1_databases: config.d1_databases,
|
|
163148
|
-
services: config.services,
|
|
163149
|
-
analytics_engine_datasets: config.analytics_engine_datasets,
|
|
163150
|
-
dispatch_namespaces: config.dispatch_namespaces,
|
|
163151
|
-
logfwdr: config.logfwdr,
|
|
163152
|
-
unsafe: config.unsafe,
|
|
163153
|
-
rules: config.rules,
|
|
163154
|
-
queues: config.queues,
|
|
163155
|
-
constellation: config.constellation
|
|
163156
|
-
};
|
|
163157
|
-
await generateTypes(configBindings, config);
|
|
163158
|
-
}
|
|
163281
|
+
typesOptions,
|
|
163282
|
+
typesHandler
|
|
163159
163283
|
);
|
|
163160
163284
|
const deploymentsWarning = "\u{1F6A7}`wrangler deployments` is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose";
|
|
163161
163285
|
wrangler.command(
|
|
@@ -164867,7 +164991,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
164867
164991
|
// `moduleCollector` doesn't get used when `props.noBundle` is set, so
|
|
164868
164992
|
// `findAdditionalModules` always defaults to `false`
|
|
164869
164993
|
findAdditionalModules: config.find_additional_modules ?? false,
|
|
164870
|
-
rules: props.rules
|
|
164994
|
+
rules: props.rules,
|
|
164995
|
+
preserveFileNames: config.preserve_file_names ?? false
|
|
164871
164996
|
});
|
|
164872
164997
|
const { modules, dependencies, resolvedEntryPointPath, bundleType } = props.noBundle ? await noBundleWorker2(props.entry, props.rules, props.outDir) : await bundleWorker(
|
|
164873
164998
|
props.entry,
|
|
@@ -164985,7 +165110,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
164985
165110
|
const worker = {
|
|
164986
165111
|
name: scriptName,
|
|
164987
165112
|
main: {
|
|
164988
|
-
name:
|
|
165113
|
+
name: entryPointName,
|
|
164989
165114
|
filePath: resolvedEntryPointPath,
|
|
164990
165115
|
content,
|
|
164991
165116
|
type: bundleType
|
|
@@ -165381,13 +165506,6 @@ function updateQueueConsumers(config) {
|
|
|
165381
165506
|
});
|
|
165382
165507
|
}
|
|
165383
165508
|
__name(updateQueueConsumers, "updateQueueConsumers");
|
|
165384
|
-
function stripPySuffix2(modulePath, type) {
|
|
165385
|
-
if (type === "python" && modulePath.endsWith(".py")) {
|
|
165386
|
-
return modulePath.slice(0, -3);
|
|
165387
|
-
}
|
|
165388
|
-
return modulePath;
|
|
165389
|
-
}
|
|
165390
|
-
__name(stripPySuffix2, "stripPySuffix");
|
|
165391
165509
|
async function noBundleWorker2(entry, rules, outDir) {
|
|
165392
165510
|
const modules = await findAdditionalModules(entry, rules);
|
|
165393
165511
|
if (outDir) {
|
|
@@ -165395,10 +165513,7 @@ async function noBundleWorker2(entry, rules, outDir) {
|
|
|
165395
165513
|
}
|
|
165396
165514
|
const bundleType = getBundleType(entry.format, entry.file);
|
|
165397
165515
|
return {
|
|
165398
|
-
modules
|
|
165399
|
-
...m2,
|
|
165400
|
-
name: stripPySuffix2(m2.name, m2.type)
|
|
165401
|
-
})),
|
|
165516
|
+
modules,
|
|
165402
165517
|
dependencies: {},
|
|
165403
165518
|
resolvedEntryPointPath: entry.file,
|
|
165404
165519
|
bundleType
|
|
@@ -166999,7 +167114,7 @@ function useCustomBuild(expectedEntry, build5, onBundleStart) {
|
|
|
166999
167114
|
persistent: true,
|
|
167000
167115
|
ignoreInitial: true
|
|
167001
167116
|
}).on("all", (_event, filePath) => {
|
|
167002
|
-
const relativeFile =
|
|
167117
|
+
const relativeFile = path52.relative(expectedEntry.directory, expectedEntry.file) || ".";
|
|
167003
167118
|
logger.log(`The file ${filePath} changed, restarting build...`);
|
|
167004
167119
|
onBundleStart();
|
|
167005
167120
|
runCustomBuild(expectedEntry.file, relativeFile, build5).catch((err) => {
|
|
@@ -167151,26 +167266,6 @@ var dev_default = withErrorBoundary(DevImplementation, {
|
|
|
167151
167266
|
FallbackComponent: ErrorFallback
|
|
167152
167267
|
});
|
|
167153
167268
|
|
|
167154
|
-
// src/dev/dev-vars.ts
|
|
167155
|
-
init_import_meta_url();
|
|
167156
|
-
var path52 = __toESM(require("node:path"));
|
|
167157
|
-
function getVarsForDev(config, env5) {
|
|
167158
|
-
const configDir = path52.resolve(path52.dirname(config.configPath ?? "."));
|
|
167159
|
-
const devVarsPath = path52.resolve(configDir, ".dev.vars");
|
|
167160
|
-
const loaded = loadDotEnv(devVarsPath, env5);
|
|
167161
|
-
if (loaded !== void 0) {
|
|
167162
|
-
const devVarsRelativePath = path52.relative(process.cwd(), loaded.path);
|
|
167163
|
-
logger.log(`Using vars defined in ${devVarsRelativePath}`);
|
|
167164
|
-
return {
|
|
167165
|
-
...config.vars,
|
|
167166
|
-
...loaded.parsed
|
|
167167
|
-
};
|
|
167168
|
-
} else {
|
|
167169
|
-
return config.vars;
|
|
167170
|
-
}
|
|
167171
|
-
}
|
|
167172
|
-
__name(getVarsForDev, "getVarsForDev");
|
|
167173
|
-
|
|
167174
167269
|
// src/dev/start-server.ts
|
|
167175
167270
|
init_import_meta_url();
|
|
167176
167271
|
var path53 = __toESM(require("node:path"));
|
|
@@ -169426,6 +169521,43 @@ function deepFreeze(obj) {
|
|
|
169426
169521
|
});
|
|
169427
169522
|
}
|
|
169428
169523
|
__name(deepFreeze, "deepFreeze");
|
|
169524
|
+
function unstable_getMiniflareWorkerOptions(configPath) {
|
|
169525
|
+
const config = readConfig(configPath, { experimentalJsonConfig: true });
|
|
169526
|
+
const env5 = void 0;
|
|
169527
|
+
const bindings = getBindings(config, env5, true, {});
|
|
169528
|
+
const { bindingOptions } = buildMiniflareBindingOptions({
|
|
169529
|
+
name: void 0,
|
|
169530
|
+
bindings,
|
|
169531
|
+
workerDefinitions: void 0,
|
|
169532
|
+
queueConsumers: config.queues.consumers,
|
|
169533
|
+
serviceBindings: {}
|
|
169534
|
+
});
|
|
169535
|
+
if (bindings.services !== void 0) {
|
|
169536
|
+
bindingOptions.serviceBindings = Object.fromEntries(
|
|
169537
|
+
bindings.services.map((binding) => {
|
|
169538
|
+
return [binding.binding, binding.service];
|
|
169539
|
+
})
|
|
169540
|
+
);
|
|
169541
|
+
}
|
|
169542
|
+
if (bindings.durable_objects !== void 0) {
|
|
169543
|
+
bindingOptions.durableObjects = Object.fromEntries(
|
|
169544
|
+
bindings.durable_objects.bindings.map((binding) => [
|
|
169545
|
+
binding.name,
|
|
169546
|
+
{ className: binding.class_name, scriptName: binding.script_name }
|
|
169547
|
+
])
|
|
169548
|
+
);
|
|
169549
|
+
}
|
|
169550
|
+
const assetPaths = config.assets ? getAssetPaths(config, void 0) : getSiteAssetPaths(config);
|
|
169551
|
+
const sitesOptions = buildSitesOptions({ assetPaths });
|
|
169552
|
+
const workerOptions = {
|
|
169553
|
+
compatibilityDate: config.compatibility_date,
|
|
169554
|
+
compatibilityFlags: config.compatibility_flags,
|
|
169555
|
+
...bindingOptions,
|
|
169556
|
+
...sitesOptions
|
|
169557
|
+
};
|
|
169558
|
+
return { workerOptions, main: config.main };
|
|
169559
|
+
}
|
|
169560
|
+
__name(unstable_getMiniflareWorkerOptions, "unstable_getMiniflareWorkerOptions");
|
|
169429
169561
|
|
|
169430
169562
|
// src/api/integrations/deprecated/index.ts
|
|
169431
169563
|
init_import_meta_url();
|
|
@@ -169454,6 +169586,7 @@ if (typeof jest === "undefined" && require.main === module) {
|
|
|
169454
169586
|
getPlatformProxy,
|
|
169455
169587
|
unstable_DevEnv,
|
|
169456
169588
|
unstable_dev,
|
|
169589
|
+
unstable_getMiniflareWorkerOptions,
|
|
169457
169590
|
unstable_pages
|
|
169458
169591
|
});
|
|
169459
169592
|
/*!
|