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.
@@ -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 url = `http://${host}${port ? `:${port}` : ""}`;
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
- new MiniflareRequest(...reqArgs)
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.25",
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": "rm -rf wrangler-dist miniflare-dist emitted-types",
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
  }