wrangler 0.0.0-d84b568 → 0.0.0-d8ee04f
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/Cloudflare_CA.pem +18 -0
- package/README.md +1 -1
- package/bin/wrangler.js +36 -4
- package/kv-asset-handler.js +1 -0
- package/package.json +11 -5
- package/pages/functions/buildPlugin.ts +13 -0
- package/pages/functions/buildWorker.ts +14 -1
- package/pages/functions/template-plugin.ts +3 -2
- package/src/__tests__/configuration.test.ts +591 -229
- package/src/__tests__/dev.test.tsx +325 -77
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +80 -72
- package/src/__tests__/init.test.ts +252 -131
- package/src/__tests__/jest.setup.ts +8 -0
- package/src/__tests__/kv.test.ts +196 -148
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +478 -53
- package/src/__tests__/parse.test.ts +5 -1
- package/src/__tests__/publish.test.ts +1119 -246
- package/src/__tests__/r2.test.ts +55 -36
- package/src/__tests__/secret.test.ts +39 -4
- package/src/__tests__/whoami.test.tsx +34 -0
- package/src/abort.d.ts +3 -0
- package/src/bundle.ts +41 -6
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +23 -18
- package/src/config/config.ts +2 -2
- package/src/config/environment.ts +41 -15
- package/src/config/index.ts +162 -0
- package/src/config/validation-helpers.ts +10 -1
- package/src/config/validation.ts +202 -78
- package/src/create-worker-preview.ts +32 -22
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/dev.tsx +39 -62
- package/src/dev/local.tsx +13 -4
- package/src/dev/remote.tsx +44 -17
- package/src/dev/use-esbuild.ts +1 -4
- package/src/dialogs.tsx +48 -0
- package/src/durable.ts +102 -0
- package/src/entry.ts +64 -9
- package/src/index.tsx +510 -319
- package/src/inspect.ts +39 -0
- package/src/kv.ts +115 -26
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +392 -174
- package/src/parse.ts +42 -5
- package/src/proxy.ts +55 -26
- package/src/publish.ts +380 -128
- package/src/sites.tsx +61 -28
- package/src/user.tsx +23 -2
- package/src/whoami.tsx +3 -2
- package/src/worker.ts +10 -1
- package/src/zones.ts +73 -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/templates/static-asset-facade.js +2 -6
- package/wrangler-dist/cli.js +95362 -81792
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
- package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
- package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
- package/vendor/wrangler-mime/CHANGELOG.md +0 -289
- package/vendor/wrangler-mime/LICENSE +0 -21
- package/vendor/wrangler-mime/Mime.js +0 -97
- package/vendor/wrangler-mime/README.md +0 -187
- package/vendor/wrangler-mime/cli.js +0 -46
- package/vendor/wrangler-mime/index.js +0 -4
- package/vendor/wrangler-mime/lite.js +0 -4
- package/vendor/wrangler-mime/package.json +0 -52
- package/vendor/wrangler-mime/types/other.js +0 -1
- package/vendor/wrangler-mime/types/standard.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIC6zCCAkygAwIBAgIUI7b68p0pPrCBoW4ptlyvVcPItscwCgYIKoZIzj0EAwQw
|
|
3
|
+
gY0xCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T
|
|
4
|
+
YW4gRnJhbmNpc2NvMRgwFgYDVQQKEw9DbG91ZGZsYXJlLCBJbmMxNzA1BgNVBAMT
|
|
5
|
+
LkNsb3VkZmxhcmUgZm9yIFRlYW1zIEVDQyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw
|
|
6
|
+
HhcNMjAwMjA0MTYwNTAwWhcNMjUwMjAyMTYwNTAwWjCBjTELMAkGA1UEBhMCVVMx
|
|
7
|
+
EzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xGDAW
|
|
8
|
+
BgNVBAoTD0Nsb3VkZmxhcmUsIEluYzE3MDUGA1UEAxMuQ2xvdWRmbGFyZSBmb3Ig
|
|
9
|
+
VGVhbXMgRUNDIENlcnRpZmljYXRlIEF1dGhvcml0eTCBmzAQBgcqhkjOPQIBBgUr
|
|
10
|
+
gQQAIwOBhgAEAVdXsX8tpA9NAQeEQalvUIcVaFNDvGsR69ysZxOraRWNGHLfq1mi
|
|
11
|
+
P6o3wtmtx/C2OXG01Cw7UFJbKl5MEDxnT2KoAdFSynSJOF2NDoe5LoZHbUW+yR3X
|
|
12
|
+
FDl+MF6JzZ590VLGo6dPBf06UsXbH7PvHH2XKtFt8bBXVNMa5a21RdmpD0Pho0Uw
|
|
13
|
+
QzAOBgNVHQ8BAf8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBAjAdBgNVHQ4EFgQU
|
|
14
|
+
YBcQng1AEMMNteuRDAMG0/vgFe0wCgYIKoZIzj0EAwQDgYwAMIGIAkIBQU5OTA2h
|
|
15
|
+
YqmFk8paan5ezHVLcmcucsfYw4L/wmeEjCkczRmCVNm6L86LjhWU0v0wER0e+lHO
|
|
16
|
+
3efvjbsu8gIGSagCQgEBnyYMP9gwg8l96QnQ1khFA1ljFlnqc2XgJHDSaAJC0gdz
|
|
17
|
+
+NV3JMeWaD2Rb32jc9r6/a7xY0u0ByqxBQ1OQ0dt7A==
|
|
18
|
+
-----END CERTIFICATE-----
|
package/README.md
CHANGED
package/bin/wrangler.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { spawn } = require("
|
|
3
|
-
const
|
|
2
|
+
const { spawn } = require("child_process");
|
|
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";
|
|
@@ -20,6 +22,30 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
|
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
let pathToCACerts = process.env.NODE_EXTRA_CA_CERTS;
|
|
26
|
+
if (pathToCACerts) {
|
|
27
|
+
// TODO:
|
|
28
|
+
// - should we log a warning here?
|
|
29
|
+
// - maybe we can generate a certificate that concatenates with ours?
|
|
30
|
+
//
|
|
31
|
+
// I do think it'll be rare that someone wants to add a cert AND
|
|
32
|
+
// use cloudflare WARP, but let's wait till the situation actually
|
|
33
|
+
// arises before we do anything about it
|
|
34
|
+
} else {
|
|
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;
|
|
47
|
+
}
|
|
48
|
+
|
|
23
49
|
wranglerProcess = spawn(
|
|
24
50
|
process.execPath,
|
|
25
51
|
[
|
|
@@ -29,10 +55,16 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
|
|
|
29
55
|
"--no-warnings",
|
|
30
56
|
"--experimental-vm-modules",
|
|
31
57
|
...process.execArgv,
|
|
32
|
-
join(__dirname, "../wrangler-dist/cli.js"),
|
|
58
|
+
path.join(__dirname, "../wrangler-dist/cli.js"),
|
|
33
59
|
...process.argv.slice(2),
|
|
34
60
|
],
|
|
35
|
-
{
|
|
61
|
+
{
|
|
62
|
+
stdio: "inherit",
|
|
63
|
+
env: {
|
|
64
|
+
...process.env,
|
|
65
|
+
NODE_EXTRA_CA_CERTS: pathToCACerts,
|
|
66
|
+
},
|
|
67
|
+
}
|
|
36
68
|
).on("exit", (code) =>
|
|
37
69
|
process.exit(code === undefined || code === null ? 0 : code)
|
|
38
70
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@cloudflare/kv-asset-handler";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-d8ee04f",
|
|
4
4
|
"author": "wrangler@cloudflare.com",
|
|
5
5
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
6
|
"bin": {
|
|
@@ -36,11 +36,12 @@
|
|
|
36
36
|
"cli"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@cloudflare/kv-asset-handler": "^0.2.0",
|
|
39
40
|
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
40
41
|
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
|
41
42
|
"blake3-wasm": "^2.1.5",
|
|
42
43
|
"esbuild": "0.14.34",
|
|
43
|
-
"miniflare": "2.
|
|
44
|
+
"miniflare": "^2.5.0",
|
|
44
45
|
"nanoid": "^3.3.3",
|
|
45
46
|
"path-to-regexp": "^6.2.0",
|
|
46
47
|
"selfsigned": "^2.0.1",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"@types/supports-color": "^8.1.1",
|
|
63
64
|
"@types/ws": "^8.5.3",
|
|
64
65
|
"@types/yargs": "^17.0.10",
|
|
66
|
+
"@webcontainer/env": "^1.0.1",
|
|
65
67
|
"chokidar": "^3.5.3",
|
|
66
68
|
"clipboardy": "^3.0.0",
|
|
67
69
|
"cmd-shim": "^4.1.0",
|
|
@@ -74,6 +76,7 @@
|
|
|
74
76
|
"find-up": "^6.3.0",
|
|
75
77
|
"get-port": "^6.1.2",
|
|
76
78
|
"glob-to-regexp": "0.4.1",
|
|
79
|
+
"http-terminator": "^3.2.0",
|
|
77
80
|
"ignore": "^5.2.0",
|
|
78
81
|
"ink": "^3.2.0",
|
|
79
82
|
"ink-select-input": "^4.2.1",
|
|
@@ -85,6 +88,7 @@
|
|
|
85
88
|
"jest-websocket-mock": "^2.3.0",
|
|
86
89
|
"mime": "^3.0.0",
|
|
87
90
|
"open": "^8.4.0",
|
|
91
|
+
"p-queue": "^7.2.0",
|
|
88
92
|
"pretty-bytes": "^6.0.0",
|
|
89
93
|
"prompts": "^2.4.2",
|
|
90
94
|
"react": "^17.0.2",
|
|
@@ -95,7 +99,7 @@
|
|
|
95
99
|
"timeago.js": "^4.0.2",
|
|
96
100
|
"tmp-promise": "^3.0.3",
|
|
97
101
|
"ts-dedent": "^2.2.0",
|
|
98
|
-
"undici": "^
|
|
102
|
+
"undici": "^5.3.0",
|
|
99
103
|
"update-check": "^1.5.4",
|
|
100
104
|
"ws": "^8.5.0",
|
|
101
105
|
"yargs": "^17.4.1"
|
|
@@ -109,7 +113,9 @@
|
|
|
109
113
|
"wrangler-dist",
|
|
110
114
|
"templates",
|
|
111
115
|
"vendor",
|
|
112
|
-
"import_meta_url.js"
|
|
116
|
+
"import_meta_url.js",
|
|
117
|
+
"kv-asset-handler.js",
|
|
118
|
+
"Cloudflare_CA.pem"
|
|
113
119
|
],
|
|
114
120
|
"scripts": {
|
|
115
121
|
"clean": "rm -rf wrangler-dist miniflare-dist",
|
|
@@ -129,7 +135,7 @@
|
|
|
129
135
|
"testTimeout": 30000,
|
|
130
136
|
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
131
137
|
"transformIgnorePatterns": [
|
|
132
|
-
"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)"
|
|
138
|
+
"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)"
|
|
133
139
|
],
|
|
134
140
|
"moduleNameMapper": {
|
|
135
141
|
"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
|
{
|
|
@@ -122,7 +127,7 @@ export function buildWorker({
|
|
|
122
127
|
// TODO: Watch args.path for changes and re-copy when updated
|
|
123
128
|
contents: `export const onRequest = ({ request, env, functionPath }) => {
|
|
124
129
|
const url = new URL(request.url)
|
|
125
|
-
const relativePathname = url.pathname.split(functionPath)[1] ||
|
|
130
|
+
const relativePathname = \`/\${url.pathname.split(functionPath)[1] || ''}\`.replace(/^\\/\\//, '/');
|
|
126
131
|
url.pathname = '/cdn-cgi/pages-plugins/${identifier}' + relativePathname
|
|
127
132
|
request = new Request(url.toString(), request)
|
|
128
133
|
return env.ASSETS.fetch(request)
|
|
@@ -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
|
}
|
|
@@ -103,8 +103,9 @@ export default function (pluginArgs) {
|
|
|
103
103
|
const { env, next, data } = workerContext;
|
|
104
104
|
|
|
105
105
|
const url = new URL(request.url);
|
|
106
|
-
const relativePathname =
|
|
107
|
-
url.pathname.split(workerContext.functionPath)[1] || "
|
|
106
|
+
const relativePathname = `/${
|
|
107
|
+
url.pathname.split(workerContext.functionPath)[1] || ""
|
|
108
|
+
}`.replace(/^\/\//, "/");
|
|
108
109
|
|
|
109
110
|
const handlerIterator = executeRequest(request, relativePathname);
|
|
110
111
|
const pluginNext = async (input?: RequestInfo, init?: RequestInit) => {
|