wrangler 2.12.3 → 2.14.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 +11 -7
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +59 -12
- package/src/__tests__/deployments.test.ts +335 -95
- package/src/__tests__/helpers/msw/handlers/deployments.ts +70 -3
- package/src/__tests__/helpers/msw/index.ts +4 -2
- package/src/__tests__/index.test.ts +10 -4
- package/src/__tests__/jest.setup.ts +4 -0
- package/src/__tests__/mtls-certificates.test.ts +5 -2
- package/src/__tests__/pages/publish.test.ts +67 -23
- package/src/__tests__/publish.test.ts +138 -59
- package/src/__tests__/queues.test.ts +5 -2
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/api/dev.ts +7 -18
- package/src/api/pages/create-worker-bundle-contents.ts +1 -0
- package/src/bundle.ts +19 -5
- package/src/config/environment.ts +27 -0
- package/src/config/index.ts +18 -0
- package/src/config/validation.ts +91 -1
- package/src/create-worker-upload-form.ts +18 -1
- package/src/d1/execute.tsx +1 -1
- package/src/d1/migrations/apply.tsx +2 -1
- package/src/deployments.ts +260 -8
- package/src/dev/start-server.ts +2 -8
- package/src/dev/use-esbuild.ts +2 -8
- package/src/dev-registry.ts +2 -1
- package/src/dev.tsx +1 -0
- package/src/entry.ts +18 -8
- package/src/index.ts +75 -22
- package/src/init.ts +144 -135
- package/src/metrics/send-event.ts +2 -1
- package/src/module-collection.ts +91 -25
- package/src/pages/functions/buildPlugin.ts +1 -0
- package/src/pages/functions/buildWorker.ts +2 -8
- package/src/publish/publish.ts +10 -26
- package/src/queues/cli/commands/consumer/add.ts +6 -0
- package/src/queues/client.ts +1 -0
- package/src/secret/index.ts +1 -0
- package/src/traverse-module-graph.ts +53 -0
- package/src/worker.ts +10 -0
- package/wrangler-dist/cli.d.ts +24 -0
- package/wrangler-dist/cli.js +19083 -18680
- package/src/__tests__/api-devregistry.test.js +0 -64
- package/src/__tests__/tsconfig.tsbuildinfo +0 -1
- package/src/miniflare-cli/tsconfig.tsbuildinfo +0 -1
- package/src/pages/functions/tsconfig.tsbuildinfo +0 -1
- package/templates/__tests__/tsconfig.tsbuildinfo +0 -1
- package/templates/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { logger } from "./logger";
|
|
5
|
+
import { matchFiles, parseRules } from "./module-collection";
|
|
6
|
+
import type { BundleResult } from "./bundle";
|
|
7
|
+
import type { Config } from "./config";
|
|
8
|
+
import type { Entry } from "./entry";
|
|
9
|
+
|
|
10
|
+
async function getFiles(root: string, relativeTo: string): Promise<string[]> {
|
|
11
|
+
const files = [];
|
|
12
|
+
for (const file of await readdir(root, { withFileTypes: true })) {
|
|
13
|
+
if (file.isDirectory()) {
|
|
14
|
+
files.push(...(await getFiles(path.join(root, file.name), relativeTo)));
|
|
15
|
+
} else {
|
|
16
|
+
files.push(path.relative(relativeTo, path.join(root, file.name)));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return files;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default async function traverseModuleGraph(
|
|
23
|
+
entry: Entry,
|
|
24
|
+
rules: Config["rules"]
|
|
25
|
+
): Promise<BundleResult> {
|
|
26
|
+
const files = await getFiles(entry.moduleRoot, entry.moduleRoot);
|
|
27
|
+
const relativeEntryPoint = path.relative(entry.moduleRoot, entry.file);
|
|
28
|
+
|
|
29
|
+
const modules = (await matchFiles(files, entry.moduleRoot, parseRules(rules)))
|
|
30
|
+
.filter((m) => m.name !== relativeEntryPoint)
|
|
31
|
+
.map((m) => ({
|
|
32
|
+
...m,
|
|
33
|
+
name: m.name,
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const bundleType = entry.format === "modules" ? "esm" : "commonjs";
|
|
37
|
+
|
|
38
|
+
if (modules.length > 0) {
|
|
39
|
+
logger.info(`Uploading additional modules:`);
|
|
40
|
+
modules.forEach(({ name, type }) => {
|
|
41
|
+
logger.info(`- ${chalk.blue(name)} (${chalk.green(type ?? "")})`);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
modules,
|
|
47
|
+
dependencies: {},
|
|
48
|
+
resolvedEntryPointPath: entry.file,
|
|
49
|
+
bundleType,
|
|
50
|
+
stop: undefined,
|
|
51
|
+
sourceMapPath: undefined,
|
|
52
|
+
};
|
|
53
|
+
}
|
package/src/worker.ts
CHANGED
|
@@ -79,6 +79,15 @@ export interface CfKvNamespace {
|
|
|
79
79
|
id: string;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* A binding to send email.
|
|
84
|
+
*/
|
|
85
|
+
export interface CfSendEmailBindings {
|
|
86
|
+
name: string;
|
|
87
|
+
destination_address?: string;
|
|
88
|
+
allowed_destination_addresses?: string[];
|
|
89
|
+
}
|
|
90
|
+
|
|
82
91
|
/**
|
|
83
92
|
* A binding to a wasm module (in service-worker format)
|
|
84
93
|
*/
|
|
@@ -216,6 +225,7 @@ export interface CfWorkerInit {
|
|
|
216
225
|
bindings: {
|
|
217
226
|
vars: CfVars | undefined;
|
|
218
227
|
kv_namespaces: CfKvNamespace[] | undefined;
|
|
228
|
+
send_email: CfSendEmailBindings[] | undefined;
|
|
219
229
|
wasm_modules: CfWasmModuleBindings | undefined;
|
|
220
230
|
text_blobs: CfTextBlobBindings | undefined;
|
|
221
231
|
data_blobs: CfDataBlobBindings | undefined;
|
package/wrangler-dist/cli.d.ts
CHANGED
|
@@ -532,6 +532,11 @@ declare interface EnvironmentInheritable {
|
|
|
532
532
|
* The entrypoint/path to the JavaScript file that will be executed.
|
|
533
533
|
*/
|
|
534
534
|
main: string | undefined;
|
|
535
|
+
/**
|
|
536
|
+
* The directory in which module rules should be evaluated in a `--no-bundle` worker
|
|
537
|
+
* This defaults to dirname(main) when left undefined
|
|
538
|
+
*/
|
|
539
|
+
base_dir: string | undefined;
|
|
535
540
|
/**
|
|
536
541
|
* Whether we use <name>.<subdomain>.workers.dev to
|
|
537
542
|
* test and deploy your worker.
|
|
@@ -770,6 +775,23 @@ declare interface EnvironmentNonInheritable {
|
|
|
770
775
|
/** The ID of the KV namespace used during `wrangler dev` */
|
|
771
776
|
preview_id?: string;
|
|
772
777
|
}[];
|
|
778
|
+
/**
|
|
779
|
+
* These specify bindings to send email from inside your Worker.
|
|
780
|
+
*
|
|
781
|
+
* NOTE: This field is not automatically inherited from the top level environment,
|
|
782
|
+
* and so must be specified in every named environment.
|
|
783
|
+
*
|
|
784
|
+
* @default `[]`
|
|
785
|
+
* @nonInheritable
|
|
786
|
+
*/
|
|
787
|
+
send_email: {
|
|
788
|
+
/** The binding name used to refer to the this binding */
|
|
789
|
+
name: string;
|
|
790
|
+
/** If this binding should be restricted to a specific verified address */
|
|
791
|
+
destination_address?: string;
|
|
792
|
+
/** If this binding should be restricted to a set of verified addresses */
|
|
793
|
+
allowed_destination_addresses?: string[];
|
|
794
|
+
}[];
|
|
773
795
|
/**
|
|
774
796
|
* Specifies Queues that are bound to this Worker environment.
|
|
775
797
|
*
|
|
@@ -799,6 +821,8 @@ declare interface EnvironmentNonInheritable {
|
|
|
799
821
|
max_retries?: number;
|
|
800
822
|
/** The queue to send messages that failed to be consumed. */
|
|
801
823
|
dead_letter_queue?: string;
|
|
824
|
+
/** The maximum number of concurrent consumer Worker invocations. Leaving this unset will allow your consumer to scale to the maximum concurrency needed to keep up with the message backlog. */
|
|
825
|
+
max_concurrency?: number | null;
|
|
802
826
|
}[];
|
|
803
827
|
};
|
|
804
828
|
/**
|