wrangler 2.0.5 → 2.0.8
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/README.md +1 -1
- package/bin/wrangler.js +16 -4
- package/package.json +6 -4
- package/pages/functions/buildPlugin.ts +13 -0
- package/pages/functions/buildWorker.ts +13 -0
- package/src/__tests__/configuration.test.ts +335 -86
- package/src/__tests__/dev.test.tsx +166 -15
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +30 -16
- package/src/__tests__/init.test.ts +249 -131
- package/src/__tests__/kv.test.ts +101 -101
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +369 -39
- package/src/__tests__/parse.test.ts +5 -1
- package/src/__tests__/publish.test.ts +556 -84
- package/src/__tests__/r2.test.ts +47 -24
- package/src/__tests__/secret.test.ts +39 -4
- package/src/abort.d.ts +3 -0
- package/src/bundle.ts +32 -1
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +14 -9
- package/src/config/environment.ts +40 -14
- package/src/config/index.ts +162 -0
- package/src/config/validation.ts +179 -64
- package/src/create-worker-preview.ts +17 -7
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/dev.tsx +2 -4
- package/src/dev/local.tsx +6 -0
- package/src/dev/remote.tsx +15 -1
- package/src/dialogs.tsx +48 -0
- package/src/durable.ts +102 -0
- package/src/index.tsx +314 -144
- package/src/inspect.ts +39 -0
- package/src/kv.ts +77 -13
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +210 -65
- package/src/parse.ts +21 -4
- package/src/proxy.ts +38 -22
- package/src/publish.ts +227 -113
- package/src/sites.tsx +11 -9
- package/src/worker.ts +8 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.ts +16 -1
- package/wrangler-dist/cli.js +35466 -22362
package/README.md
CHANGED
package/bin/wrangler.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { spawn } = require("child_process");
|
|
3
|
-
const
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
4
6
|
const semiver = require("semiver");
|
|
5
7
|
|
|
6
8
|
const MIN_NODE_VERSION = "16.7.0";
|
|
@@ -25,13 +27,23 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
|
|
|
25
27
|
// TODO:
|
|
26
28
|
// - should we log a warning here?
|
|
27
29
|
// - maybe we can generate a certificate that concatenates with ours?
|
|
28
|
-
// - is there a security concern/should we cleanup after we exit?
|
|
29
30
|
//
|
|
30
31
|
// I do think it'll be rare that someone wants to add a cert AND
|
|
31
32
|
// use cloudflare WARP, but let's wait till the situation actually
|
|
32
33
|
// arises before we do anything about it
|
|
33
34
|
} else {
|
|
34
|
-
|
|
35
|
+
const osTempDir = os.tmpdir();
|
|
36
|
+
const certDir = path.join(osTempDir, "wrangler-cert");
|
|
37
|
+
const certPath = path.join(certDir, "Cloudflare_CA.pem");
|
|
38
|
+
// copy cert to the system temp dir if needed
|
|
39
|
+
if (!fs.existsSync(certPath)) {
|
|
40
|
+
fs.mkdirSync(certDir, { recursive: true });
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
certPath,
|
|
43
|
+
fs.readFileSync(path.join(__dirname, "../Cloudflare_CA.pem"), "utf-8")
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
pathToCACerts = certPath;
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
wranglerProcess = spawn(
|
|
@@ -43,7 +55,7 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
|
|
|
43
55
|
"--no-warnings",
|
|
44
56
|
"--experimental-vm-modules",
|
|
45
57
|
...process.execArgv,
|
|
46
|
-
join(__dirname, "../wrangler-dist/cli.js"),
|
|
58
|
+
path.join(__dirname, "../wrangler-dist/cli.js"),
|
|
47
59
|
...process.argv.slice(2),
|
|
48
60
|
],
|
|
49
61
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"author": "wrangler@cloudflare.com",
|
|
5
5
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
6
|
"bin": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
|
41
41
|
"blake3-wasm": "^2.1.5",
|
|
42
42
|
"esbuild": "0.14.34",
|
|
43
|
-
"miniflare": "2.
|
|
43
|
+
"miniflare": "^2.5.0",
|
|
44
44
|
"nanoid": "^3.3.3",
|
|
45
45
|
"path-to-regexp": "^6.2.0",
|
|
46
46
|
"selfsigned": "^2.0.1",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"find-up": "^6.3.0",
|
|
76
76
|
"get-port": "^6.1.2",
|
|
77
77
|
"glob-to-regexp": "0.4.1",
|
|
78
|
+
"http-terminator": "^3.2.0",
|
|
78
79
|
"ignore": "^5.2.0",
|
|
79
80
|
"ink": "^3.2.0",
|
|
80
81
|
"ink-select-input": "^4.2.1",
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"jest-websocket-mock": "^2.3.0",
|
|
87
88
|
"mime": "^3.0.0",
|
|
88
89
|
"open": "^8.4.0",
|
|
90
|
+
"p-queue": "^7.2.0",
|
|
89
91
|
"pretty-bytes": "^6.0.0",
|
|
90
92
|
"prompts": "^2.4.2",
|
|
91
93
|
"react": "^17.0.2",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
"timeago.js": "^4.0.2",
|
|
97
99
|
"tmp-promise": "^3.0.3",
|
|
98
100
|
"ts-dedent": "^2.2.0",
|
|
99
|
-
"undici": "^
|
|
101
|
+
"undici": "^5.3.0",
|
|
100
102
|
"update-check": "^1.5.4",
|
|
101
103
|
"ws": "^8.5.0",
|
|
102
104
|
"yargs": "^17.4.1"
|
|
@@ -131,7 +133,7 @@
|
|
|
131
133
|
"testTimeout": 30000,
|
|
132
134
|
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
133
135
|
"transformIgnorePatterns": [
|
|
134
|
-
"node_modules/(?!find-up|locate-path|p-locate|p-limit|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes)"
|
|
136
|
+
"node_modules/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes)"
|
|
135
137
|
],
|
|
136
138
|
"moduleNameMapper": {
|
|
137
139
|
"clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { access, lstat } from "node:fs/promises";
|
|
2
2
|
import { dirname, relative, resolve } from "node:path";
|
|
3
|
+
import NodeGlobalsPolyfills from "@esbuild-plugins/node-globals-polyfill";
|
|
4
|
+
import NodeModulesPolyfills from "@esbuild-plugins/node-modules-polyfill";
|
|
3
5
|
import { build } from "esbuild";
|
|
4
6
|
|
|
5
7
|
type Options = {
|
|
@@ -8,6 +10,7 @@ type Options = {
|
|
|
8
10
|
minify?: boolean;
|
|
9
11
|
sourcemap?: boolean;
|
|
10
12
|
watch?: boolean;
|
|
13
|
+
nodeCompat?: boolean;
|
|
11
14
|
onEnd?: () => void;
|
|
12
15
|
};
|
|
13
16
|
|
|
@@ -17,6 +20,7 @@ export function buildPlugin({
|
|
|
17
20
|
minify = false,
|
|
18
21
|
sourcemap = false,
|
|
19
22
|
watch = false,
|
|
23
|
+
nodeCompat,
|
|
20
24
|
onEnd = () => {},
|
|
21
25
|
}: Options) {
|
|
22
26
|
return build({
|
|
@@ -30,6 +34,7 @@ export function buildPlugin({
|
|
|
30
34
|
sourcemap,
|
|
31
35
|
watch,
|
|
32
36
|
allowOverwrite: true,
|
|
37
|
+
define: { ...(nodeCompat ? { global: "globalThis" } : {}) },
|
|
33
38
|
plugins: [
|
|
34
39
|
{
|
|
35
40
|
name: "wrangler notifier and monitor",
|
|
@@ -87,6 +92,14 @@ export function buildPlugin({
|
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
},
|
|
95
|
+
...(nodeCompat
|
|
96
|
+
? [
|
|
97
|
+
NodeGlobalsPolyfills({
|
|
98
|
+
buffer: true,
|
|
99
|
+
}),
|
|
100
|
+
NodeModulesPolyfills(),
|
|
101
|
+
]
|
|
102
|
+
: []),
|
|
90
103
|
],
|
|
91
104
|
});
|
|
92
105
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { access, cp, lstat, rm } from "node:fs/promises";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
|
+
import NodeGlobalsPolyfills from "@esbuild-plugins/node-globals-polyfill";
|
|
4
|
+
import NodeModulesPolyfills from "@esbuild-plugins/node-modules-polyfill";
|
|
3
5
|
import { build } from "esbuild";
|
|
4
6
|
import { nanoid } from "nanoid";
|
|
5
7
|
|
|
@@ -12,6 +14,7 @@ type Options = {
|
|
|
12
14
|
watch?: boolean;
|
|
13
15
|
onEnd?: () => void;
|
|
14
16
|
buildOutputDirectory?: string;
|
|
17
|
+
nodeCompat?: boolean;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
export function buildWorker({
|
|
@@ -23,6 +26,7 @@ export function buildWorker({
|
|
|
23
26
|
watch = false,
|
|
24
27
|
onEnd = () => {},
|
|
25
28
|
buildOutputDirectory,
|
|
29
|
+
nodeCompat,
|
|
26
30
|
}: Options) {
|
|
27
31
|
return build({
|
|
28
32
|
entryPoints: [resolve(__dirname, "../pages/functions/template-worker.ts")],
|
|
@@ -37,6 +41,7 @@ export function buildWorker({
|
|
|
37
41
|
allowOverwrite: true,
|
|
38
42
|
define: {
|
|
39
43
|
__FALLBACK_SERVICE__: JSON.stringify(fallbackService),
|
|
44
|
+
...(nodeCompat ? { global: "globalThis" } : {}),
|
|
40
45
|
},
|
|
41
46
|
plugins: [
|
|
42
47
|
{
|
|
@@ -133,6 +138,14 @@ export function buildWorker({
|
|
|
133
138
|
);
|
|
134
139
|
},
|
|
135
140
|
},
|
|
141
|
+
...(nodeCompat
|
|
142
|
+
? [
|
|
143
|
+
NodeGlobalsPolyfills({
|
|
144
|
+
buffer: true,
|
|
145
|
+
}),
|
|
146
|
+
NodeModulesPolyfills(),
|
|
147
|
+
]
|
|
148
|
+
: []),
|
|
136
149
|
],
|
|
137
150
|
});
|
|
138
151
|
}
|