wrangler 0.0.0-e492c10 → 0.0.0-e5a3814
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/package.json +9 -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 +590 -228
- package/src/__tests__/dev.test.tsx +229 -73
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +31 -16
- package/src/__tests__/init.test.ts +252 -131
- package/src/__tests__/kv.test.ts +140 -101
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +466 -39
- package/src/__tests__/parse.test.ts +5 -1
- package/src/__tests__/publish.test.ts +1021 -215
- package/src/__tests__/r2.test.ts +47 -24
- 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 +33 -5
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +23 -18
- package/src/config/config.ts +1 -1
- 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 +205 -77
- package/src/create-worker-preview.ts +32 -22
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/dev.tsx +14 -31
- package/src/dev/local.tsx +10 -0
- package/src/dev/remote.tsx +40 -16
- package/src/dialogs.tsx +48 -0
- package/src/durable.ts +102 -0
- package/src/entry.ts +64 -9
- package/src/index.tsx +455 -307
- package/src/inspect.ts +39 -0
- package/src/kv.ts +114 -25
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +381 -163
- package/src/parse.ts +23 -5
- package/src/proxy.ts +55 -26
- package/src/publish.ts +374 -127
- package/src/sites.tsx +61 -28
- package/src/user.tsx +12 -1
- 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 +0 -4
- package/wrangler-dist/cli.js +96875 -83512
- 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
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-e5a3814",
|
|
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",
|
|
@@ -75,6 +76,7 @@
|
|
|
75
76
|
"find-up": "^6.3.0",
|
|
76
77
|
"get-port": "^6.1.2",
|
|
77
78
|
"glob-to-regexp": "0.4.1",
|
|
79
|
+
"http-terminator": "^3.2.0",
|
|
78
80
|
"ignore": "^5.2.0",
|
|
79
81
|
"ink": "^3.2.0",
|
|
80
82
|
"ink-select-input": "^4.2.1",
|
|
@@ -86,6 +88,7 @@
|
|
|
86
88
|
"jest-websocket-mock": "^2.3.0",
|
|
87
89
|
"mime": "^3.0.0",
|
|
88
90
|
"open": "^8.4.0",
|
|
91
|
+
"p-queue": "^7.2.0",
|
|
89
92
|
"pretty-bytes": "^6.0.0",
|
|
90
93
|
"prompts": "^2.4.2",
|
|
91
94
|
"react": "^17.0.2",
|
|
@@ -96,7 +99,7 @@
|
|
|
96
99
|
"timeago.js": "^4.0.2",
|
|
97
100
|
"tmp-promise": "^3.0.3",
|
|
98
101
|
"ts-dedent": "^2.2.0",
|
|
99
|
-
"undici": "^
|
|
102
|
+
"undici": "^5.3.0",
|
|
100
103
|
"update-check": "^1.5.4",
|
|
101
104
|
"ws": "^8.5.0",
|
|
102
105
|
"yargs": "^17.4.1"
|
|
@@ -110,7 +113,8 @@
|
|
|
110
113
|
"wrangler-dist",
|
|
111
114
|
"templates",
|
|
112
115
|
"vendor",
|
|
113
|
-
"import_meta_url.js"
|
|
116
|
+
"import_meta_url.js",
|
|
117
|
+
"Cloudflare_CA.pem"
|
|
114
118
|
],
|
|
115
119
|
"scripts": {
|
|
116
120
|
"clean": "rm -rf wrangler-dist miniflare-dist",
|
|
@@ -130,7 +134,7 @@
|
|
|
130
134
|
"testTimeout": 30000,
|
|
131
135
|
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
132
136
|
"transformIgnorePatterns": [
|
|
133
|
-
"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)"
|
|
137
|
+
"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)"
|
|
134
138
|
],
|
|
135
139
|
"moduleNameMapper": {
|
|
136
140
|
"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) => {
|