wrangler 0.0.18 → 0.0.22
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 +10 -6
- package/pages/functions/filepath-routing.test.ts +125 -25
- package/pages/functions/filepath-routing.ts +6 -3
- package/src/__tests__/configuration.test.ts +528 -116
- package/src/__tests__/dev.test.tsx +206 -8
- package/src/__tests__/dev2.test.tsx +154 -0
- package/src/__tests__/guess-worker-format.test.ts +9 -17
- package/src/__tests__/helpers/mock-account-id.ts +22 -4
- package/src/__tests__/helpers/mock-cfetch.ts +3 -3
- package/src/__tests__/helpers/mock-kv.ts +9 -16
- package/src/__tests__/helpers/mock-stdin.ts +103 -0
- package/src/__tests__/helpers/run-in-tmp.ts +3 -0
- package/src/__tests__/https-options.test.ts +127 -0
- package/src/__tests__/index.test.ts +125 -0
- package/src/__tests__/jest.setup.ts +1 -1
- package/src/__tests__/kv.test.ts +27 -53
- package/src/__tests__/logout.test.ts +15 -13
- package/src/__tests__/pages.test.ts +44 -0
- package/src/__tests__/publish.test.ts +528 -32
- package/src/__tests__/route.test.ts +45 -0
- package/src/__tests__/secret.test.ts +165 -63
- package/src/__tests__/whoami.test.tsx +21 -7
- package/src/bundle.ts +20 -11
- package/src/cfetch/internal.ts +11 -5
- package/src/config/config.ts +53 -44
- package/src/config/validation-helpers.ts +110 -12
- package/src/config/validation.ts +83 -45
- package/src/{api/preview.ts → create-worker-preview.ts} +27 -6
- package/src/{api/form_data.ts → create-worker-upload-form.ts} +1 -1
- package/src/dev/dev.tsx +362 -0
- package/src/dev/local.tsx +247 -0
- package/src/dev/remote.tsx +203 -0
- package/src/dev/use-esbuild.ts +100 -0
- package/src/entry.ts +111 -9
- package/src/https-options.ts +122 -0
- package/src/index.tsx +265 -154
- package/src/inspect.ts +9 -1
- package/src/{kv.tsx → kv.ts} +0 -0
- package/src/module-collection.ts +90 -2
- package/src/open-in-browser.ts +14 -2
- package/src/pages.tsx +1 -1
- package/src/proxy.ts +104 -40
- package/src/publish.ts +41 -50
- package/src/reporting.ts +25 -9
- package/src/selfsigned.d.ts +29 -0
- package/src/sites.tsx +51 -16
- package/src/user.tsx +151 -82
- package/src/{api/worker.ts → worker.ts} +1 -24
- package/wrangler-dist/cli.js +5105 -3153
- package/wrangler-dist/cli.js.map +3 -3
- package/src/__tests__/helpers/mock-user.ts +0 -27
- package/src/dev.tsx +0 -961
- package/src/guess-worker-format.ts +0 -68
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"author": "wrangler@cloudflare.com",
|
|
5
5
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
6
|
"bin": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"esbuild": "0.14.23",
|
|
40
40
|
"miniflare": "2.3.0",
|
|
41
41
|
"path-to-regexp": "^6.2.0",
|
|
42
|
+
"selfsigned": "^2.0.0",
|
|
42
43
|
"semiver": "^1.1.0",
|
|
43
44
|
"xxhash-wasm": "^1.0.1"
|
|
44
45
|
},
|
|
@@ -46,19 +47,19 @@
|
|
|
46
47
|
"fsevents": "~2.3.2"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@babel/types": "^7.16.0",
|
|
50
50
|
"@iarna/toml": "^2.2.5",
|
|
51
51
|
"@sentry/cli": "^1.71.0",
|
|
52
52
|
"@sentry/integrations": "^6.17.6",
|
|
53
53
|
"@sentry/node": "^6.17.6",
|
|
54
54
|
"@types/command-exists": "^1.2.0",
|
|
55
|
-
"@types/estree": "^0.0.50",
|
|
56
55
|
"@types/glob-to-regexp": "0.4.1",
|
|
57
56
|
"@types/mime": "^2.0.3",
|
|
58
57
|
"@types/prompts": "^2.0.14",
|
|
59
58
|
"@types/react": "^17.0.37",
|
|
59
|
+
"@types/react-test-renderer": "^17.0.1",
|
|
60
60
|
"@types/serve-static": "^1.13.10",
|
|
61
61
|
"@types/signal-exit": "^3.0.1",
|
|
62
|
+
"@types/supports-color": "^8.1.1",
|
|
62
63
|
"@types/ws": "^8.2.1",
|
|
63
64
|
"@types/yargs": "^17.0.7",
|
|
64
65
|
"chokidar": "^3.5.2",
|
|
@@ -85,10 +86,12 @@
|
|
|
85
86
|
"prompts": "^2.4.2",
|
|
86
87
|
"react": "^17.0.2",
|
|
87
88
|
"react-error-boundary": "^3.1.4",
|
|
89
|
+
"react-test-renderer": "^17.0.2",
|
|
88
90
|
"serve-static": "^1.14.1",
|
|
89
91
|
"signal-exit": "^3.0.6",
|
|
92
|
+
"supports-color": "^9.2.1",
|
|
90
93
|
"tmp-promise": "^3.0.3",
|
|
91
|
-
"undici": "4.
|
|
94
|
+
"undici": "^4.15.1",
|
|
92
95
|
"ws": "^8.3.0",
|
|
93
96
|
"yargs": "^17.3.0"
|
|
94
97
|
},
|
|
@@ -120,10 +123,11 @@
|
|
|
120
123
|
"testTimeout": 30000,
|
|
121
124
|
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
122
125
|
"transformIgnorePatterns": [
|
|
123
|
-
"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)"
|
|
126
|
+
"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)"
|
|
124
127
|
],
|
|
125
128
|
"moduleNameMapper": {
|
|
126
|
-
"clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js"
|
|
129
|
+
"clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js",
|
|
130
|
+
"miniflare/cli": "<rootDir>/../../node_modules/miniflare/dist/src/cli.js"
|
|
127
131
|
},
|
|
128
132
|
"transform": {
|
|
129
133
|
"^.+\\.c?(t|j)sx?$": [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFileSync } from "fs";
|
|
1
|
+
import { writeFileSync, mkdirSync } from "fs";
|
|
2
2
|
import { runInTempDir } from "../../src/__tests__/helpers/run-in-tmp";
|
|
3
3
|
import { toUrlPath } from "../../src/paths";
|
|
4
4
|
import { compareRoutes, generateConfigFromFileTree } from "./filepath-routing";
|
|
@@ -83,34 +83,134 @@ describe("filepath-routing", () => {
|
|
|
83
83
|
`
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
+
mkdirSync("todos");
|
|
87
|
+
|
|
88
|
+
writeFileSync(
|
|
89
|
+
"todos/[id].ts",
|
|
90
|
+
`
|
|
91
|
+
export function onRequestPost() {}
|
|
92
|
+
export function onRequestDelete() {}
|
|
93
|
+
`
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
mkdirSync("authors");
|
|
97
|
+
mkdirSync("authors/[authorId]");
|
|
98
|
+
mkdirSync("authors/[authorId]/todos");
|
|
99
|
+
|
|
100
|
+
writeFileSync(
|
|
101
|
+
"authors/[authorId]/todos/[todoId].ts",
|
|
102
|
+
`
|
|
103
|
+
export function onRequestPost() {}
|
|
104
|
+
`
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
mkdirSync("books");
|
|
108
|
+
|
|
109
|
+
writeFileSync(
|
|
110
|
+
"books/[[title]].ts",
|
|
111
|
+
`
|
|
112
|
+
export function onRequestPost() {}
|
|
113
|
+
`
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
mkdirSync("cats");
|
|
117
|
+
mkdirSync("cats/[[breed]]");
|
|
118
|
+
|
|
119
|
+
writeFileSync(
|
|
120
|
+
"cats/[[breed]]/blah.ts",
|
|
121
|
+
`
|
|
122
|
+
export function onRequestPost() {}
|
|
123
|
+
`
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// This won't actually work at runtime.
|
|
127
|
+
writeFileSync(
|
|
128
|
+
"cats/[[breed]]/[[name]].ts",
|
|
129
|
+
`
|
|
130
|
+
export function onRequestPost() {}
|
|
131
|
+
`
|
|
132
|
+
);
|
|
133
|
+
|
|
86
134
|
const entries = await generateConfigFromFileTree({
|
|
87
135
|
baseDir: ".",
|
|
88
136
|
baseURL: "/base" as UrlPath,
|
|
89
137
|
});
|
|
90
|
-
expect(entries).
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
138
|
+
expect(entries).toMatchInlineSnapshot(`
|
|
139
|
+
Object {
|
|
140
|
+
"routes": Array [
|
|
141
|
+
Object {
|
|
142
|
+
"method": "POST",
|
|
143
|
+
"module": Array [
|
|
144
|
+
"authors/[authorId]/todos/[todoId].ts:onRequestPost",
|
|
145
|
+
],
|
|
146
|
+
"routePath": "/base/authors/:authorId/todos/:todoId",
|
|
147
|
+
},
|
|
148
|
+
Object {
|
|
149
|
+
"method": "POST",
|
|
150
|
+
"module": Array [
|
|
151
|
+
"cats/[[breed]]/blah.ts:onRequestPost",
|
|
152
|
+
],
|
|
153
|
+
"routePath": "/base/cats/:breed*/blah",
|
|
154
|
+
},
|
|
155
|
+
Object {
|
|
156
|
+
"method": "POST",
|
|
157
|
+
"module": Array [
|
|
158
|
+
"cats/[[breed]]/[[name]].ts:onRequestPost",
|
|
159
|
+
],
|
|
160
|
+
"routePath": "/base/cats/:breed*/:name*",
|
|
161
|
+
},
|
|
162
|
+
Object {
|
|
163
|
+
"method": "DELETE",
|
|
164
|
+
"module": Array [
|
|
165
|
+
"todos/[id].ts:onRequestDelete",
|
|
166
|
+
],
|
|
167
|
+
"routePath": "/base/todos/:id",
|
|
168
|
+
},
|
|
169
|
+
Object {
|
|
170
|
+
"method": "POST",
|
|
171
|
+
"module": Array [
|
|
172
|
+
"todos/[id].ts:onRequestPost",
|
|
173
|
+
],
|
|
174
|
+
"routePath": "/base/todos/:id",
|
|
175
|
+
},
|
|
176
|
+
Object {
|
|
177
|
+
"method": "POST",
|
|
178
|
+
"module": Array [
|
|
179
|
+
"books/[[title]].ts:onRequestPost",
|
|
180
|
+
],
|
|
181
|
+
"routePath": "/base/books/:title*",
|
|
182
|
+
},
|
|
183
|
+
Object {
|
|
184
|
+
"method": "DELETE",
|
|
185
|
+
"module": Array [
|
|
186
|
+
"bar.ts:onRequestDelete",
|
|
187
|
+
],
|
|
188
|
+
"routePath": "/base/bar",
|
|
189
|
+
},
|
|
190
|
+
Object {
|
|
191
|
+
"method": "PUT",
|
|
192
|
+
"module": Array [
|
|
193
|
+
"bar.ts:onRequestPut",
|
|
194
|
+
],
|
|
195
|
+
"routePath": "/base/bar",
|
|
196
|
+
},
|
|
197
|
+
Object {
|
|
198
|
+
"method": "GET",
|
|
199
|
+
"module": Array [
|
|
200
|
+
"foo.ts:onRequestGet",
|
|
201
|
+
],
|
|
202
|
+
"routePath": "/base/foo",
|
|
203
|
+
},
|
|
204
|
+
Object {
|
|
205
|
+
"method": "POST",
|
|
206
|
+
"module": Array [
|
|
207
|
+
"foo.ts:onRequestPost",
|
|
208
|
+
],
|
|
209
|
+
"routePath": "/base/foo",
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
}
|
|
213
|
+
`);
|
|
114
214
|
});
|
|
115
215
|
});
|
|
116
216
|
});
|
|
@@ -64,14 +64,17 @@ export async function generateConfigFromFileTree({
|
|
|
64
64
|
|
|
65
65
|
routePath = `${baseURL}/${routePath}`;
|
|
66
66
|
|
|
67
|
-
routePath = routePath.replace(/\[\[(
|
|
68
|
-
routePath = routePath.
|
|
67
|
+
routePath = routePath.replace(/\[\[([^\]]+)\]\]/g, ":$1*"); // transform [[id]] => :id*
|
|
68
|
+
routePath = routePath.replaceAll(/\[([^\]]+)\]/g, ":$1"); // transform [id] => :id
|
|
69
|
+
|
|
70
|
+
// These are used as module specifiers so UrlPaths are okay to use even on Windows
|
|
71
|
+
const modulePath = toUrlPath(path.relative(baseDir, filepath));
|
|
69
72
|
|
|
70
73
|
const routeEntry: RouteConfig = {
|
|
71
74
|
routePath: toUrlPath(routePath),
|
|
72
75
|
method: method.toUpperCase() as HTTPMethod,
|
|
73
76
|
[isMiddlewareFile ? "middleware" : "module"]: [
|
|
74
|
-
`${
|
|
77
|
+
`${modulePath}:${exportName}`,
|
|
75
78
|
],
|
|
76
79
|
};
|
|
77
80
|
|