wrangler 0.0.0-e95bea2 → 0.0.0-ea8e701
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 +3 -3
- package/bin/wrangler.js +10 -1
- package/miniflare-dist/index.mjs +79 -0
- package/miniflare-dist/index.mjs.map +7 -0
- package/package.json +7 -6
- package/pages/functions/filepath-routing.test.ts +125 -25
- package/pages/functions/filepath-routing.ts +6 -3
- package/src/__tests__/configuration.test.ts +826 -223
- package/src/__tests__/dev.test.tsx +145 -9
- package/src/__tests__/guess-worker-format.test.ts +26 -1
- package/src/__tests__/helpers/mock-account-id.ts +4 -0
- package/src/__tests__/helpers/mock-kv.ts +9 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +178 -0
- package/src/__tests__/helpers/run-in-tmp.ts +3 -0
- package/src/__tests__/index.test.ts +9 -13
- package/src/__tests__/jest.setup.ts +5 -0
- package/src/__tests__/kv.test.ts +43 -71
- package/src/__tests__/pages.test.ts +48 -10
- package/src/__tests__/publish.test.ts +1456 -327
- package/src/__tests__/r2.test.ts +4 -4
- package/src/__tests__/tail.test.ts +78 -4
- package/src/__tests__/user.test.ts +83 -0
- package/src/__tests__/whoami.test.tsx +16 -7
- package/src/bundle.ts +15 -2
- package/src/cfetch/internal.ts +9 -5
- package/src/config/README.md +6 -6
- package/src/config/config.ts +17 -78
- package/src/config/environment.ts +67 -1
- package/src/config/index.ts +13 -3
- package/src/config/validation-helpers.ts +177 -11
- package/src/config/validation.ts +305 -100
- package/src/dev/dev.tsx +76 -41
- package/src/dev/local.tsx +105 -114
- package/src/dev/remote.tsx +2 -0
- package/src/dev/use-esbuild.ts +4 -0
- package/src/entry.ts +103 -6
- package/src/index.tsx +251 -189
- package/src/intl-polyfill.d.ts +139 -0
- package/src/{kv/index.tsx → kv.ts} +8 -28
- package/src/miniflare-cli/README.md +30 -0
- package/src/miniflare-cli/enum-keys.ts +17 -0
- package/src/miniflare-cli/index.ts +37 -0
- package/src/module-collection.ts +58 -53
- package/src/pages.tsx +26 -10
- package/src/proxy.ts +5 -3
- package/src/publish.ts +17 -21
- package/src/sites.tsx +67 -25
- package/src/tail/index.ts +1 -1
- package/src/tail/printing.ts +2 -2
- package/src/user.tsx +161 -81
- package/wrangler-dist/cli.js +3418 -1437
- package/wrangler-dist/cli.js.map +3 -3
- package/src/__tests__/dev2.test.tsx +0 -152
- package/src/__tests__/helpers/mock-user.ts +0 -27
- package/src/__tests__/logout.test.ts +0 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-ea8e701",
|
|
4
4
|
"author": "wrangler@cloudflare.com",
|
|
5
5
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
6
|
"bin": {
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@types/mime": "^2.0.3",
|
|
57
57
|
"@types/prompts": "^2.0.14",
|
|
58
58
|
"@types/react": "^17.0.37",
|
|
59
|
-
"@types/react-test-renderer": "^17.0.1",
|
|
60
59
|
"@types/serve-static": "^1.13.10",
|
|
61
60
|
"@types/signal-exit": "^3.0.1",
|
|
61
|
+
"@types/supports-color": "^8.1.1",
|
|
62
62
|
"@types/ws": "^8.2.1",
|
|
63
63
|
"@types/yargs": "^17.0.7",
|
|
64
64
|
"chokidar": "^3.5.2",
|
|
@@ -84,12 +84,12 @@
|
|
|
84
84
|
"open": "^8.4.0",
|
|
85
85
|
"prompts": "^2.4.2",
|
|
86
86
|
"react": "^17.0.2",
|
|
87
|
-
"react-test-renderer": "^17.0.2",
|
|
88
87
|
"react-error-boundary": "^3.1.4",
|
|
89
88
|
"serve-static": "^1.14.1",
|
|
90
89
|
"signal-exit": "^3.0.6",
|
|
90
|
+
"supports-color": "^9.2.1",
|
|
91
91
|
"tmp-promise": "^3.0.3",
|
|
92
|
-
"undici": "4.
|
|
92
|
+
"undici": "^4.15.1",
|
|
93
93
|
"ws": "^8.3.0",
|
|
94
94
|
"yargs": "^17.3.0"
|
|
95
95
|
},
|
|
@@ -98,13 +98,14 @@
|
|
|
98
98
|
"bin",
|
|
99
99
|
"pages",
|
|
100
100
|
"miniflare-config-stubs",
|
|
101
|
+
"miniflare-dist",
|
|
101
102
|
"wrangler-dist",
|
|
102
103
|
"templates",
|
|
103
104
|
"vendor",
|
|
104
105
|
"import_meta_url.js"
|
|
105
106
|
],
|
|
106
107
|
"scripts": {
|
|
107
|
-
"clean": "rm -rf wrangler-dist",
|
|
108
|
+
"clean": "rm -rf wrangler-dist miniflare-dist",
|
|
108
109
|
"check:type": "tsc",
|
|
109
110
|
"bundle": "node -r esbuild-register scripts/bundle.ts",
|
|
110
111
|
"build": "npm run clean && npm run bundle",
|
|
@@ -121,7 +122,7 @@
|
|
|
121
122
|
"testTimeout": 30000,
|
|
122
123
|
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
123
124
|
"transformIgnorePatterns": [
|
|
124
|
-
"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)"
|
|
125
|
+
"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)"
|
|
125
126
|
],
|
|
126
127
|
"moduleNameMapper": {
|
|
127
128
|
"clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js",
|
|
@@ -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
|
|