wrangler 2.0.25 → 2.0.26
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/miniflare-dist/index.mjs +15 -3
- package/package.json +3 -3
- package/src/__tests__/helpers/mock-cfetch.ts +33 -0
- package/src/__tests__/init.test.ts +537 -359
- package/src/__tests__/jest.setup.ts +3 -0
- package/src/__tests__/pages.test.ts +14 -0
- package/src/__tests__/tail.test.ts +19 -3
- package/src/api/dev.ts +1 -0
- package/src/cfetch/internal.ts +39 -0
- package/src/dev/dev.tsx +4 -0
- package/src/dev.tsx +2 -2
- package/src/init.ts +111 -38
- package/src/miniflare-cli/assets.ts +8 -0
- package/src/miniflare-cli/index.ts +6 -3
- package/src/pages/build.tsx +41 -15
- package/src/pages/constants.ts +1 -0
- package/src/pages/dev.tsx +86 -24
- package/src/pages/errors.ts +22 -0
- package/src/pages/functions/routes-consolidation.test.ts +185 -1
- package/src/pages/functions/routes-consolidation.ts +46 -2
- package/src/pages/functions/routes-transformation.ts +0 -3
- package/src/pages/functions.tsx +96 -0
- package/src/pages/index.tsx +65 -55
- package/src/pages/publish.tsx +27 -16
- package/src/tail/filters.ts +3 -1
- package/src/tail/printing.ts +2 -0
- package/templates/pages-template-plugin.ts +16 -4
- package/templates/pages-template-worker.ts +16 -5
- package/templates/service-bindings-module-facade.js +10 -7
- package/templates/service-bindings-sw-facade.js +10 -7
- package/wrangler-dist/cli.d.ts +1 -0
- package/wrangler-dist/cli.js +1034 -738
package/miniflare-dist/index.mjs
CHANGED
|
@@ -5277,6 +5277,14 @@ async function generateAssetsFetch(directory, log) {
|
|
|
5277
5277
|
return deconstructedResponse;
|
|
5278
5278
|
}
|
|
5279
5279
|
} else if (hasFileExtension(assetName)) {
|
|
5280
|
+
if (asset = getAsset(assetName + ".html")) {
|
|
5281
|
+
deconstructedResponse.body = serveAsset(asset);
|
|
5282
|
+
deconstructedResponse.headers.set(
|
|
5283
|
+
"Content-Type",
|
|
5284
|
+
(0, import_mime.getType)(asset) || "application/octet-stream"
|
|
5285
|
+
);
|
|
5286
|
+
return deconstructedResponse;
|
|
5287
|
+
}
|
|
5280
5288
|
notFound();
|
|
5281
5289
|
return deconstructedResponse;
|
|
5282
5290
|
}
|
|
@@ -5409,10 +5417,14 @@ async function main() {
|
|
|
5409
5417
|
namespace.get = (id) => {
|
|
5410
5418
|
const stub = new DurableObjectStub(factory, id);
|
|
5411
5419
|
stub.fetch = (...reqArgs) => {
|
|
5412
|
-
const
|
|
5420
|
+
const requestFromArgs = new MiniflareRequest(...reqArgs);
|
|
5421
|
+
const url = new URL(requestFromArgs.url);
|
|
5422
|
+
url.host = host;
|
|
5423
|
+
if (port !== void 0)
|
|
5424
|
+
url.port = port.toString();
|
|
5413
5425
|
const request = new MiniflareRequest(
|
|
5414
|
-
url,
|
|
5415
|
-
|
|
5426
|
+
url.toString(),
|
|
5427
|
+
requestFromArgs
|
|
5416
5428
|
);
|
|
5417
5429
|
request.headers.set("x-miniflare-durable-object-name", name);
|
|
5418
5430
|
request.headers.set("x-miniflare-durable-object-id", id.toString());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.26",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"build": "npm run clean && npm run bundle && npm run emit-types",
|
|
53
53
|
"bundle": "node -r esbuild-register scripts/bundle.ts",
|
|
54
54
|
"check:type": "tsc",
|
|
55
|
-
"clean": "
|
|
55
|
+
"clean": "rimraf wrangler-dist miniflare-dist emitted-types",
|
|
56
56
|
"dev": "npm run clean && concurrently -c black,blue --kill-others-on-fail false 'npm run bundle -- --watch' 'npm run check:type -- --watch --preserveWatchOutput'",
|
|
57
57
|
"emit-types": "tsc -p tsconfig.emit.json && node -r esbuild-register scripts/emit-types.ts",
|
|
58
58
|
"prepublishOnly": "SOURCEMAPS=false npm run build",
|
|
59
|
-
"start": "npm run bundle && NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
59
|
+
"start": "npm run bundle && cross-env NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
60
60
|
"test": "jest --silent=false --verbose=true",
|
|
61
61
|
"test-watch": "npm run test -- --runInBand --testTimeout=50000 --watch",
|
|
62
62
|
"test:ci": "npm run test -- --verbose=true --coverage"
|
|
@@ -183,6 +183,7 @@ export function unsetAllMocks() {
|
|
|
183
183
|
|
|
184
184
|
const kvGetMocks = new Map<string, string | Buffer>();
|
|
185
185
|
const r2GetMocks = new Map<string, string | undefined>();
|
|
186
|
+
const dashScriptMocks = new Map<string, string | undefined>();
|
|
186
187
|
|
|
187
188
|
/**
|
|
188
189
|
* @mocked typeof fetchKVGetValue
|
|
@@ -260,4 +261,36 @@ export function setMockFetchR2Objects({
|
|
|
260
261
|
export function unsetSpecialMockFns() {
|
|
261
262
|
kvGetMocks.clear();
|
|
262
263
|
r2GetMocks.clear();
|
|
264
|
+
dashScriptMocks.clear();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @mocked typeof fetchDashScript
|
|
269
|
+
* multipart/form-data is the response for modules and raw text for the Script endpoint.
|
|
270
|
+
*/
|
|
271
|
+
export async function mockFetchDashScript(resource: string): Promise<string> {
|
|
272
|
+
if (dashScriptMocks.has(resource)) {
|
|
273
|
+
const value = dashScriptMocks.get(resource) ?? "";
|
|
274
|
+
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
throw new Error(`no mock found for \`init from-dash\` - ${resource}`);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Mock setter for usage within test blocks, companion helper to `mockFetchDashScript`
|
|
282
|
+
*/
|
|
283
|
+
export function setMockFetchDashScript({
|
|
284
|
+
accountId,
|
|
285
|
+
fromDashScriptName,
|
|
286
|
+
mockResponse,
|
|
287
|
+
}: {
|
|
288
|
+
accountId: string;
|
|
289
|
+
fromDashScriptName: string;
|
|
290
|
+
mockResponse?: string;
|
|
291
|
+
}) {
|
|
292
|
+
dashScriptMocks.set(
|
|
293
|
+
`/accounts/${accountId}/workers/scripts/${fromDashScriptName}`,
|
|
294
|
+
mockResponse
|
|
295
|
+
);
|
|
263
296
|
}
|