wrangler 0.0.0-e33bea9b → 0.0.0-e351afcf
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 +167 -93
- package/package.json +14 -9
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +59 -12
- package/src/__tests__/constellation.test.ts +371 -0
- package/src/__tests__/d1/execute.test.ts +2 -0
- package/src/__tests__/d1/migrate.test.ts +102 -0
- package/src/__tests__/delete.test.ts +6 -0
- package/src/__tests__/deployments.test.ts +335 -95
- package/src/__tests__/dev.test.tsx +71 -56
- package/src/__tests__/generate.test.ts +3 -4
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +70 -3
- package/src/__tests__/helpers/msw/index.ts +4 -2
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/index.test.ts +14 -6
- package/src/__tests__/init.test.ts +127 -96
- package/src/__tests__/jest.setup.ts +4 -0
- package/src/__tests__/kv.test.ts +9 -9
- package/src/__tests__/logger.test.ts +68 -2
- package/src/__tests__/middleware.scheduled.test.ts +2 -2
- package/src/__tests__/middleware.test.ts +2 -2
- package/src/__tests__/mtls-certificates.test.ts +7 -3
- package/src/__tests__/pages/deployment-list.test.ts +2 -0
- package/src/__tests__/pages/functions-build.test.ts +70 -0
- package/src/__tests__/pages/project-list.test.ts +2 -0
- package/src/__tests__/pages/project-upload.test.ts +43 -24
- package/src/__tests__/pages/publish.test.ts +136 -92
- package/src/__tests__/publish.test.ts +878 -332
- package/src/__tests__/pubsub.test.ts +3 -0
- package/src/__tests__/queues.test.ts +5 -2
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +1 -1
- package/src/__tests__/worker-namespace.test.ts +1 -0
- package/src/api/dev.ts +12 -18
- package/src/api/pages/create-worker-bundle-contents.ts +1 -0
- package/src/api/pages/publish.tsx +28 -12
- package/src/bundle.ts +26 -9
- package/src/config/environment.ts +27 -0
- package/src/config/index.ts +18 -0
- package/src/config/validation.ts +91 -1
- package/src/constellation/createProject.tsx +51 -0
- package/src/constellation/deleteProject.ts +51 -0
- package/src/constellation/deleteProjectModel.ts +68 -0
- package/src/constellation/index.ts +75 -0
- package/src/constellation/listCatalog.tsx +35 -0
- package/src/constellation/listModel.tsx +41 -0
- package/src/constellation/listProject.tsx +28 -0
- package/src/constellation/listRuntime.tsx +28 -0
- package/src/constellation/options.ts +17 -0
- package/src/constellation/types.ts +17 -0
- package/src/constellation/uploadModel.tsx +64 -0
- package/src/constellation/utils.ts +90 -0
- package/src/create-worker-upload-form.ts +18 -1
- package/src/d1/backups.tsx +19 -15
- package/src/d1/create.tsx +45 -39
- package/src/d1/delete.ts +1 -1
- package/src/d1/execute.tsx +23 -20
- package/src/d1/list.tsx +14 -12
- package/src/d1/migrations/apply.tsx +36 -30
- package/src/d1/migrations/create.tsx +15 -12
- package/src/d1/migrations/helpers.ts +5 -8
- package/src/d1/migrations/list.tsx +10 -7
- package/src/deployments.ts +260 -8
- package/src/dev/dev.tsx +2 -0
- package/src/dev/local.tsx +48 -20
- package/src/dev/start-server.ts +49 -46
- package/src/dev/use-esbuild.ts +52 -49
- package/src/dev-registry.ts +2 -1
- package/src/dev.tsx +11 -5
- package/src/docs/helpers.ts +50 -0
- package/src/docs/index.ts +25 -68
- package/src/entry.ts +19 -8
- package/src/environment-variables/factory.ts +2 -1
- package/src/generate/index.ts +2 -2
- package/src/index.ts +86 -23
- package/src/init.ts +144 -135
- package/src/kv/helpers.ts +7 -4
- package/src/logger.ts +23 -4
- package/src/metrics/send-event.ts +2 -1
- package/src/miniflare-cli/index.ts +2 -2
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
- package/src/module-collection.ts +92 -26
- package/src/pages/build.ts +29 -17
- package/src/pages/deployments.tsx +3 -5
- package/src/pages/dev.ts +24 -6
- package/src/pages/functions/buildPlugin.ts +1 -0
- package/src/pages/functions/buildWorker.ts +59 -8
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/projects.tsx +2 -5
- package/src/pages/upload.tsx +24 -4
- package/src/publish/publish.ts +10 -26
- package/src/queues/cli/commands/consumer/add.ts +6 -0
- package/src/queues/client.ts +1 -0
- package/src/secret/index.ts +1 -0
- package/src/sites.ts +164 -52
- package/src/traverse-module-graph.ts +53 -0
- package/src/user/user.ts +1 -0
- package/src/utils/render.ts +93 -0
- package/src/worker.ts +10 -0
- package/wrangler-dist/cli.d.ts +29 -2
- package/wrangler-dist/cli.js +23270 -22110
- package/src/__tests__/api-devregistry.test.js +0 -64
|
@@ -362,7 +362,7 @@ describe("wrangler", () => {
|
|
|
362
362
|
"wrangler
|
|
363
363
|
|
|
364
364
|
Commands:
|
|
365
|
-
wrangler docs [command]
|
|
365
|
+
wrangler docs [command..] 📚 Open wrangler's docs in your browser
|
|
366
366
|
wrangler init [name] 📥 Initialize a basic Worker project, including a wrangler.toml file
|
|
367
367
|
wrangler generate [name] [template] ✨ Generate a new Worker project from an existing Worker template. See https://github.com/cloudflare/templates
|
|
368
368
|
wrangler dev [script] 👂 Start a local server for developing your worker
|
|
@@ -379,20 +379,24 @@ describe("wrangler", () => {
|
|
|
379
379
|
wrangler r2 📦 Interact with an R2 store
|
|
380
380
|
wrangler dispatch-namespace 📦 Interact with a dispatch namespace
|
|
381
381
|
wrangler d1 🗄 Interact with a D1 database
|
|
382
|
+
wrangler constellation 🤖 Interact with Constellation AI models
|
|
382
383
|
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
|
|
383
384
|
wrangler mtls-certificate 🪪 Manage certificates used for mTLS connections
|
|
384
385
|
wrangler login 🔓 Login to Cloudflare
|
|
385
386
|
wrangler logout 🚪 Logout from Cloudflare
|
|
386
387
|
wrangler whoami 🕵️ Retrieve your user info and test your auth config
|
|
387
388
|
wrangler types 📝 Generate types from bindings & module rules in config
|
|
388
|
-
wrangler deployments 🚢
|
|
389
|
+
wrangler deployments 🚢 List and view details for deployments
|
|
390
|
+
wrangler rollback [deployment-id] 🔙 Rollback a deployment
|
|
389
391
|
|
|
390
392
|
Flags:
|
|
391
393
|
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
392
394
|
-c, --config Path to .toml configuration file [string]
|
|
393
395
|
-e, --env Environment to use for operations and .env files [string]
|
|
394
396
|
-h, --help Show help [boolean]
|
|
395
|
-
-v, --version Show version number [boolean]
|
|
397
|
+
-v, --version Show version number [boolean]
|
|
398
|
+
|
|
399
|
+
🚧\`wrangler rollback\` is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose"
|
|
396
400
|
`);
|
|
397
401
|
});
|
|
398
402
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { rest } from "msw";
|
|
2
2
|
import { endEventLoop } from "../helpers/end-event-loop";
|
|
3
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
3
4
|
import { mockAccountId, mockApiToken } from "./../helpers/mock-account-id";
|
|
4
5
|
import { msw } from "./../helpers/msw";
|
|
5
6
|
import { runInTempDir } from "./../helpers/run-in-tmp";
|
|
@@ -10,6 +11,7 @@ describe("deployment list", () => {
|
|
|
10
11
|
runInTempDir();
|
|
11
12
|
mockAccountId();
|
|
12
13
|
mockApiToken();
|
|
14
|
+
mockConsoleMethods();
|
|
13
15
|
|
|
14
16
|
afterEach(async () => {
|
|
15
17
|
// Force a tick to ensure that all promises resolve
|
|
@@ -449,4 +449,74 @@ export default {
|
|
|
449
449
|
hello.js:2:36: ERROR: Could not resolve \\"node:async_hooks\\""
|
|
450
450
|
`);
|
|
451
451
|
});
|
|
452
|
+
|
|
453
|
+
it("should compile a _worker.js/ directory", async () => {
|
|
454
|
+
mkdirSync("public");
|
|
455
|
+
mkdirSync("public/_worker.js");
|
|
456
|
+
writeFileSync(
|
|
457
|
+
"public/_worker.js/index.js",
|
|
458
|
+
`
|
|
459
|
+
import { cat } from "./cat.js";
|
|
460
|
+
|
|
461
|
+
export default {
|
|
462
|
+
async fetch(request, env) {
|
|
463
|
+
return new Response("Hello from _worker.js/index.js" + cat);
|
|
464
|
+
},
|
|
465
|
+
};`
|
|
466
|
+
);
|
|
467
|
+
writeFileSync(
|
|
468
|
+
"public/_worker.js/cat.js",
|
|
469
|
+
`
|
|
470
|
+
export const cat = "cat";`
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
await runWrangler(`pages functions build --outfile=public/_worker.bundle`);
|
|
474
|
+
|
|
475
|
+
expect(existsSync("public/_worker.bundle")).toBe(true);
|
|
476
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
477
|
+
"🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
|
|
478
|
+
✨ Compiled Worker successfully"
|
|
479
|
+
`);
|
|
480
|
+
|
|
481
|
+
const workerBundleContents = readFileSync("public/_worker.bundle", "utf-8");
|
|
482
|
+
const workerBundleWithConstantData = replaceRandomWithConstantData(
|
|
483
|
+
workerBundleContents,
|
|
484
|
+
[
|
|
485
|
+
[/------formdata-undici-0.[0-9]*/g, "------formdata-undici-0.test"],
|
|
486
|
+
[/bundledWorker-0.[0-9]*.mjs/g, "bundledWorker-0.test.mjs"],
|
|
487
|
+
[/bundledWorker-0.[0-9]*.map/g, "bundledWorker-0.test.map"],
|
|
488
|
+
]
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
expect(workerBundleWithConstantData).toMatchInlineSnapshot(`
|
|
492
|
+
"------formdata-undici-0.test
|
|
493
|
+
Content-Disposition: form-data; name=\\"metadata\\"
|
|
494
|
+
|
|
495
|
+
{\\"main_module\\":\\"bundledWorker-0.test.mjs\\"}
|
|
496
|
+
------formdata-undici-0.test
|
|
497
|
+
Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
|
|
498
|
+
Content-Type: application/javascript+module
|
|
499
|
+
|
|
500
|
+
import { cat } from \\"./cat.js\\";
|
|
501
|
+
var worker_default = {
|
|
502
|
+
async fetch(request, env) {
|
|
503
|
+
return new Response(\\"Hello from _worker.js/index.js\\" + cat);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
export {
|
|
507
|
+
worker_default as default
|
|
508
|
+
};
|
|
509
|
+
//# sourceMappingURL=bundledWorker-0.test.mjs.map
|
|
510
|
+
|
|
511
|
+
------formdata-undici-0.test
|
|
512
|
+
Content-Disposition: form-data; name=\\"cat.js\\"; filename=\\"cat.js\\"
|
|
513
|
+
Content-Type: application/javascript+module
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
export const cat = \\"cat\\";
|
|
517
|
+
------formdata-undici-0.test--"
|
|
518
|
+
`);
|
|
519
|
+
|
|
520
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
521
|
+
});
|
|
452
522
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { rest } from "msw";
|
|
2
2
|
import { endEventLoop } from "../helpers/end-event-loop";
|
|
3
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
3
4
|
import { mockAccountId, mockApiToken } from "./../helpers/mock-account-id";
|
|
4
5
|
import { msw } from "./../helpers/msw";
|
|
5
6
|
import { runInTempDir } from "./../helpers/run-in-tmp";
|
|
@@ -8,6 +9,7 @@ import type { Project } from "./../../pages/types";
|
|
|
8
9
|
|
|
9
10
|
describe("project list", () => {
|
|
10
11
|
runInTempDir();
|
|
12
|
+
mockConsoleMethods();
|
|
11
13
|
mockAccountId();
|
|
12
14
|
mockApiToken();
|
|
13
15
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/* eslint-disable no-shadow */
|
|
1
|
+
// /* eslint-disable no-shadow */
|
|
2
2
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { rest } from "msw";
|
|
4
4
|
import { endEventLoop } from "../helpers/end-event-loop";
|
|
5
|
+
import { mockAccountId, mockApiToken } from "../helpers/mock-account-id";
|
|
6
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
5
7
|
import { mockGetUploadTokenRequest } from "../helpers/mock-get-pages-upload-token";
|
|
6
8
|
import { mockSetTimeout } from "../helpers/mock-set-timeout";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { runWrangler } from "./../helpers/run-wrangler";
|
|
12
|
-
import type { UploadPayloadFile } from "./../../pages/types";
|
|
9
|
+
import { msw } from "../helpers/msw";
|
|
10
|
+
import { runInTempDir } from "../helpers/run-in-tmp";
|
|
11
|
+
import { runWrangler } from "../helpers/run-wrangler";
|
|
12
|
+
import type { UploadPayloadFile } from "../../pages/types";
|
|
13
13
|
import type { RestRequest } from "msw";
|
|
14
14
|
|
|
15
15
|
describe("project upload", () => {
|
|
@@ -92,11 +92,11 @@ describe("project upload", () => {
|
|
|
92
92
|
|
|
93
93
|
await runWrangler("pages project upload .");
|
|
94
94
|
|
|
95
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
96
|
-
|
|
95
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
96
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
✨ Upload complete!"
|
|
99
|
+
`);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it("should avoid uploading some files", async () => {
|
|
@@ -172,7 +172,7 @@ describe("project upload", () => {
|
|
|
172
172
|
|
|
173
173
|
const requestMap = resolvedRequests.reduce<{
|
|
174
174
|
[key: string]: UploadPayloadFile;
|
|
175
|
-
}>((
|
|
175
|
+
}>((map, req) => Object.assign(map, { [req.key]: req }), {});
|
|
176
176
|
|
|
177
177
|
for (const req of requests) {
|
|
178
178
|
expect(req.headers.get("Authorization")).toBe(
|
|
@@ -209,11 +209,11 @@ describe("project upload", () => {
|
|
|
209
209
|
value: "ZnVuYw==",
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
213
|
-
|
|
212
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
213
|
+
"✨ Success! Uploaded 3 files (TIMINGS)
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
✨ Upload complete!"
|
|
216
|
+
`);
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
it("should retry uploads", async () => {
|
|
@@ -296,11 +296,11 @@ describe("project upload", () => {
|
|
|
296
296
|
]);
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
300
|
-
|
|
299
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
300
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
301
301
|
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
✨ Upload complete!"
|
|
303
|
+
`);
|
|
304
304
|
});
|
|
305
305
|
|
|
306
306
|
it("should try to use multiple buckets (up to the max concurrency)", async () => {
|
|
@@ -402,11 +402,11 @@ describe("project upload", () => {
|
|
|
402
402
|
])
|
|
403
403
|
);
|
|
404
404
|
|
|
405
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
406
|
-
|
|
405
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
406
|
+
"✨ Success! Uploaded 4 files (TIMINGS)
|
|
407
407
|
|
|
408
|
-
|
|
409
|
-
|
|
408
|
+
✨ Upload complete!"
|
|
409
|
+
`);
|
|
410
410
|
});
|
|
411
411
|
|
|
412
412
|
it("should not error when directory names contain periods and houses a extensionless file", async () => {
|
|
@@ -479,3 +479,22 @@ describe("project upload", () => {
|
|
|
479
479
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
480
480
|
});
|
|
481
481
|
});
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* When uploading assets we print out progress messages that look like:
|
|
485
|
+
*
|
|
486
|
+
* Uploading... (1/4)
|
|
487
|
+
* Uploading... (2/4)
|
|
488
|
+
* Uploading... (4/4)
|
|
489
|
+
*
|
|
490
|
+
* Note that we don't always get a progress message for every item uploaded.
|
|
491
|
+
* These upload counts are not deterministic and can change from test run to test run.
|
|
492
|
+
*
|
|
493
|
+
* Also if you run the tests in --runInBand mode then we never see any of
|
|
494
|
+
* these progress messages in the tests!!
|
|
495
|
+
*
|
|
496
|
+
* So this helper removes these message from the snapshots to keep them consistent.
|
|
497
|
+
*/
|
|
498
|
+
export function normalizeProgressSteps(str: string): string {
|
|
499
|
+
return str.replace(/Uploading... \(\d\/\d\)\r?\n?/g, "");
|
|
500
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/* eslint-disable no-shadow */
|
|
2
1
|
import { Blob } from "node:buffer";
|
|
3
2
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { chdir } from "node:process";
|
|
5
4
|
import { MockedRequest, rest } from "msw";
|
|
6
5
|
import { FormData } from "undici";
|
|
6
|
+
import { version } from "../../../package.json";
|
|
7
|
+
import { ROUTES_SPEC_VERSION } from "../../pages/constants";
|
|
8
|
+
import { isRoutesJSONSpec } from "../../pages/functions/routes-validation";
|
|
9
|
+
import { endEventLoop } from "../helpers/end-event-loop";
|
|
10
|
+
import { mockAccountId, mockApiToken } from "../helpers/mock-account-id";
|
|
7
11
|
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
8
12
|
import { mockGetUploadTokenRequest } from "../helpers/mock-get-pages-upload-token";
|
|
9
13
|
import { mockSetTimeout } from "../helpers/mock-set-timeout";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { FileReaderSync } from "./../helpers/msw/read-file-sync";
|
|
17
|
-
import { runInTempDir } from "./../helpers/run-in-tmp";
|
|
18
|
-
import { runWrangler } from "./../helpers/run-wrangler";
|
|
19
|
-
import type { Project, UploadPayloadFile } from "./../../pages/types";
|
|
14
|
+
import { msw } from "../helpers/msw";
|
|
15
|
+
import { FileReaderSync } from "../helpers/msw/read-file-sync";
|
|
16
|
+
import { runInTempDir } from "../helpers/run-in-tmp";
|
|
17
|
+
import { runWrangler } from "../helpers/run-wrangler";
|
|
18
|
+
import { normalizeProgressSteps } from "./project-upload.test";
|
|
19
|
+
import type { Project, UploadPayloadFile } from "../../pages/types";
|
|
20
20
|
import type { RestRequest } from "msw";
|
|
21
21
|
|
|
22
22
|
describe("deployment create", () => {
|
|
@@ -171,11 +171,11 @@ describe("deployment create", () => {
|
|
|
171
171
|
|
|
172
172
|
await runWrangler("pages publish . --project-name=foo");
|
|
173
173
|
|
|
174
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
175
|
-
|
|
174
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
175
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
178
|
+
`);
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
it("should retry uploads", async () => {
|
|
@@ -300,11 +300,11 @@ describe("deployment create", () => {
|
|
|
300
300
|
|
|
301
301
|
await runWrangler("pages publish . --project-name=foo");
|
|
302
302
|
|
|
303
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
304
|
-
|
|
303
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
304
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
307
|
+
`);
|
|
308
308
|
});
|
|
309
309
|
|
|
310
310
|
it("should refetch a JWT if it expires while uploading", async () => {
|
|
@@ -437,11 +437,11 @@ describe("deployment create", () => {
|
|
|
437
437
|
"Bearer <<funfetti-auth-jwt2>>"
|
|
438
438
|
);
|
|
439
439
|
|
|
440
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
441
|
-
|
|
440
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
441
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
442
442
|
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
444
|
+
`);
|
|
445
445
|
});
|
|
446
446
|
|
|
447
447
|
it("should try to use multiple buckets (up to the max concurrency)", async () => {
|
|
@@ -592,11 +592,11 @@ describe("deployment create", () => {
|
|
|
592
592
|
])
|
|
593
593
|
);
|
|
594
594
|
|
|
595
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
596
|
-
|
|
595
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
596
|
+
"✨ Success! Uploaded 4 files (TIMINGS)
|
|
597
597
|
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
599
|
+
`);
|
|
600
600
|
});
|
|
601
601
|
|
|
602
602
|
it("should resolve child directories correctly", async () => {
|
|
@@ -744,11 +744,11 @@ describe("deployment create", () => {
|
|
|
744
744
|
])
|
|
745
745
|
);
|
|
746
746
|
|
|
747
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
748
|
-
|
|
747
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
748
|
+
"✨ Success! Uploaded 4 files (TIMINGS)
|
|
749
749
|
|
|
750
|
-
|
|
751
|
-
|
|
750
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
751
|
+
`);
|
|
752
752
|
});
|
|
753
753
|
|
|
754
754
|
it("should resolve the current directory correctly", async () => {
|
|
@@ -897,11 +897,11 @@ describe("deployment create", () => {
|
|
|
897
897
|
])
|
|
898
898
|
);
|
|
899
899
|
|
|
900
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
901
|
-
|
|
900
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
901
|
+
"✨ Success! Uploaded 4 files (TIMINGS)
|
|
902
902
|
|
|
903
|
-
|
|
904
|
-
|
|
903
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
904
|
+
`);
|
|
905
905
|
});
|
|
906
906
|
|
|
907
907
|
it("should not error when directory names contain periods and houses a extensionless file", async () => {
|
|
@@ -1211,13 +1211,13 @@ describe("deployment create", () => {
|
|
|
1211
1211
|
|
|
1212
1212
|
await runWrangler("pages publish public --project-name=foo");
|
|
1213
1213
|
|
|
1214
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
1215
|
-
|
|
1216
|
-
|
|
1214
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
1215
|
+
"✨ Compiled Worker successfully
|
|
1216
|
+
✨ Success! Uploaded 1 files (TIMINGS)
|
|
1217
1217
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1218
|
+
✨ Uploading Functions bundle
|
|
1219
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
1220
|
+
`);
|
|
1221
1221
|
|
|
1222
1222
|
expect(std.err).toMatchInlineSnapshot('""');
|
|
1223
1223
|
});
|
|
@@ -1361,13 +1361,13 @@ describe("deployment create", () => {
|
|
|
1361
1361
|
|
|
1362
1362
|
await runWrangler("pages publish public --project-name=foo");
|
|
1363
1363
|
|
|
1364
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
1365
|
-
|
|
1364
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
1365
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
1366
1366
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1367
|
+
✨ Compiled Worker successfully
|
|
1368
|
+
✨ Uploading Worker bundle
|
|
1369
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
1370
|
+
`);
|
|
1371
1371
|
|
|
1372
1372
|
expect(std.err).toMatchInlineSnapshot('""');
|
|
1373
1373
|
});
|
|
@@ -1583,14 +1583,14 @@ describe("deployment create", () => {
|
|
|
1583
1583
|
|
|
1584
1584
|
await runWrangler("pages publish public --project-name=foo");
|
|
1585
1585
|
|
|
1586
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
1587
|
-
|
|
1588
|
-
|
|
1586
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
1587
|
+
"✨ Compiled Worker successfully
|
|
1588
|
+
✨ Success! Uploaded 1 files (TIMINGS)
|
|
1589
1589
|
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1590
|
+
✨ Uploading Functions bundle
|
|
1591
|
+
✨ Uploading _routes.json
|
|
1592
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
1593
|
+
`);
|
|
1594
1594
|
|
|
1595
1595
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1596
1596
|
expect(std.err).toMatchInlineSnapshot('""');
|
|
@@ -1920,14 +1920,14 @@ and that at least one include rule is provided.
|
|
|
1920
1920
|
|
|
1921
1921
|
await runWrangler("pages publish public --project-name=foo");
|
|
1922
1922
|
|
|
1923
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
1924
|
-
|
|
1923
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
1924
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
1925
1925
|
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1926
|
+
✨ Compiled Worker successfully
|
|
1927
|
+
✨ Uploading Worker bundle
|
|
1928
|
+
✨ Uploading _routes.json
|
|
1929
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
1930
|
+
`);
|
|
1931
1931
|
|
|
1932
1932
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1933
1933
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -2229,13 +2229,13 @@ and that at least one include rule is provided.
|
|
|
2229
2229
|
|
|
2230
2230
|
await runWrangler("pages publish public --project-name=foo");
|
|
2231
2231
|
|
|
2232
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
2233
|
-
|
|
2232
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
2233
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
2234
2234
|
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2235
|
+
✨ Compiled Worker successfully
|
|
2236
|
+
✨ Uploading Worker bundle
|
|
2237
|
+
✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
2238
|
+
`);
|
|
2239
2239
|
|
|
2240
2240
|
expect(std.err).toMatchInlineSnapshot('""');
|
|
2241
2241
|
});
|
|
@@ -2245,20 +2245,22 @@ and that at least one include rule is provided.
|
|
|
2245
2245
|
mkdirSync("public");
|
|
2246
2246
|
writeFileSync("public/README.md", "This is a readme");
|
|
2247
2247
|
|
|
2248
|
-
// set up
|
|
2249
|
-
mkdirSync("
|
|
2250
|
-
writeFileSync("
|
|
2248
|
+
// set up some "external" modules
|
|
2249
|
+
mkdirSync("external");
|
|
2250
|
+
writeFileSync("external/hello.wasm", "Hello Wasm modules world!");
|
|
2251
|
+
writeFileSync("external/hello.txt", "Hello Text modules world!");
|
|
2251
2252
|
|
|
2252
2253
|
// set up Functions
|
|
2253
2254
|
mkdirSync("functions");
|
|
2254
2255
|
writeFileSync(
|
|
2255
2256
|
"functions/hello.js",
|
|
2256
2257
|
`
|
|
2257
|
-
import
|
|
2258
|
+
import wasm from "./../external/hello.wasm";
|
|
2259
|
+
import text from "./../external/hello.txt"
|
|
2258
2260
|
export async function onRequest() {
|
|
2259
|
-
const helloModule = await WebAssembly.instantiate(
|
|
2260
|
-
const
|
|
2261
|
-
return new Response(
|
|
2261
|
+
const helloModule = await WebAssembly.instantiate(wasm);
|
|
2262
|
+
const wasmGreeting = helloModule.exports.hello;
|
|
2263
|
+
return new Response(wasmGreeting + text);
|
|
2262
2264
|
}
|
|
2263
2265
|
`
|
|
2264
2266
|
);
|
|
@@ -2363,6 +2365,10 @@ and that at least one include rule is provided.
|
|
|
2363
2365
|
/[0-9a-z]*-hello.wasm/g,
|
|
2364
2366
|
"test-hello.wasm"
|
|
2365
2367
|
);
|
|
2368
|
+
workerBundleWithConstantData = workerBundleWithConstantData.replace(
|
|
2369
|
+
/[0-9a-z]*-hello.txt/g,
|
|
2370
|
+
"test-hello.txt"
|
|
2371
|
+
);
|
|
2366
2372
|
|
|
2367
2373
|
// check we appended the metadata
|
|
2368
2374
|
expect(workerBundleWithConstantData).toContain(
|
|
@@ -2377,18 +2383,29 @@ and that at least one include rule is provided.
|
|
|
2377
2383
|
`Content-Disposition: form-data; name="functionsWorker-0.test.js"; filename="functionsWorker-0.test.js"`
|
|
2378
2384
|
);
|
|
2379
2385
|
expect(workerBundleWithConstantData).toContain(`
|
|
2380
|
-
import
|
|
2386
|
+
import wasm from "./test-hello.wasm";
|
|
2387
|
+
import text from "./test-hello.txt";
|
|
2381
2388
|
async function onRequest() {
|
|
2382
|
-
const helloModule = await WebAssembly.instantiate(
|
|
2383
|
-
const
|
|
2384
|
-
return new Response(
|
|
2389
|
+
const helloModule = await WebAssembly.instantiate(wasm);
|
|
2390
|
+
const wasmGreeting = helloModule.exports.hello;
|
|
2391
|
+
return new Response(wasmGreeting + text);
|
|
2385
2392
|
}`);
|
|
2386
2393
|
|
|
2387
2394
|
// check we appended the wasm module
|
|
2388
2395
|
expect(workerBundleWithConstantData).toContain(
|
|
2389
2396
|
`Content-Disposition: form-data; name="./test-hello.wasm"; filename="./test-hello.wasm"`
|
|
2390
2397
|
);
|
|
2391
|
-
expect(workerBundleWithConstantData).toContain(
|
|
2398
|
+
expect(workerBundleWithConstantData).toContain(
|
|
2399
|
+
`Hello Wasm modules world!`
|
|
2400
|
+
);
|
|
2401
|
+
|
|
2402
|
+
// check we appended the text module
|
|
2403
|
+
expect(workerBundleWithConstantData).toContain(
|
|
2404
|
+
`Content-Disposition: form-data; name="./test-hello.txt"; filename="./test-hello.txt"`
|
|
2405
|
+
);
|
|
2406
|
+
expect(workerBundleWithConstantData).toContain(
|
|
2407
|
+
`Hello Text modules world!`
|
|
2408
|
+
);
|
|
2392
2409
|
|
|
2393
2410
|
return res.once(
|
|
2394
2411
|
ctx.status(200),
|
|
@@ -2427,7 +2444,7 @@ async function onRequest() {
|
|
|
2427
2444
|
|
|
2428
2445
|
await runWrangler("pages publish public --project-name=foo");
|
|
2429
2446
|
|
|
2430
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
2447
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
2431
2448
|
"✨ Compiled Worker successfully
|
|
2432
2449
|
✨ Success! Uploaded 1 files (TIMINGS)
|
|
2433
2450
|
|
|
@@ -2445,20 +2462,31 @@ async function onRequest() {
|
|
|
2445
2462
|
writeFileSync("public/README.md", "This is a readme");
|
|
2446
2463
|
|
|
2447
2464
|
// set up hello.wasm
|
|
2448
|
-
mkdirSync("
|
|
2449
|
-
writeFileSync("
|
|
2465
|
+
mkdirSync("external");
|
|
2466
|
+
writeFileSync("external/hello.wasm", "Hello wasm modules");
|
|
2467
|
+
writeFileSync(
|
|
2468
|
+
"external/hello.html",
|
|
2469
|
+
"<html><body>Hello text modules</body></html>"
|
|
2470
|
+
);
|
|
2450
2471
|
|
|
2451
2472
|
// set up _worker.js
|
|
2452
2473
|
writeFileSync(
|
|
2453
2474
|
"public/_worker.js",
|
|
2454
2475
|
`
|
|
2455
|
-
import
|
|
2476
|
+
import wasm from "./../external/hello.wasm";
|
|
2477
|
+
import html from "./../external/hello.html";
|
|
2456
2478
|
export default {
|
|
2457
2479
|
async fetch(request, env) {
|
|
2458
2480
|
const url = new URL(request.url);
|
|
2459
|
-
const helloModule = await WebAssembly.instantiate(
|
|
2460
|
-
const
|
|
2461
|
-
|
|
2481
|
+
const helloModule = await WebAssembly.instantiate(wasm);
|
|
2482
|
+
const wasmGreeting = helloModule.exports.hello;
|
|
2483
|
+
if(url.pathname.startsWith('/hello-wasm')) {
|
|
2484
|
+
return new Response(wasmGreeting);
|
|
2485
|
+
}
|
|
2486
|
+
if(url.pathname.startsWith('/hello-text')) {
|
|
2487
|
+
return new Response(html);
|
|
2488
|
+
}
|
|
2489
|
+
return env.ASSETS.fetch(request);
|
|
2462
2490
|
}
|
|
2463
2491
|
};
|
|
2464
2492
|
`
|
|
@@ -2558,6 +2586,10 @@ async function onRequest() {
|
|
|
2558
2586
|
/[0-9a-z]*-hello.wasm/g,
|
|
2559
2587
|
"test-hello.wasm"
|
|
2560
2588
|
);
|
|
2589
|
+
workerBundleWithConstantData = workerBundleWithConstantData.replace(
|
|
2590
|
+
/[0-9a-z]*-hello.html/g,
|
|
2591
|
+
"test-hello.html"
|
|
2592
|
+
);
|
|
2561
2593
|
|
|
2562
2594
|
// we care about a couple of things here, like the presence of `metadata`,
|
|
2563
2595
|
// `bundledWorker`, the wasm import, etc., and since `workerBundle` is
|
|
@@ -2572,13 +2604,20 @@ async function onRequest() {
|
|
|
2572
2604
|
Content-Type: application/javascript+module
|
|
2573
2605
|
|
|
2574
2606
|
// _worker.js
|
|
2575
|
-
import
|
|
2607
|
+
import wasm from \\"./test-hello.wasm\\";
|
|
2608
|
+
import html from \\"./test-hello.html\\";
|
|
2576
2609
|
var worker_default = {
|
|
2577
2610
|
async fetch(request, env) {
|
|
2578
2611
|
const url = new URL(request.url);
|
|
2579
|
-
const helloModule = await WebAssembly.instantiate(
|
|
2580
|
-
const
|
|
2581
|
-
|
|
2612
|
+
const helloModule = await WebAssembly.instantiate(wasm);
|
|
2613
|
+
const wasmGreeting = helloModule.exports.hello;
|
|
2614
|
+
if (url.pathname.startsWith(\\"/hello-wasm\\")) {
|
|
2615
|
+
return new Response(wasmGreeting);
|
|
2616
|
+
}
|
|
2617
|
+
if (url.pathname.startsWith(\\"/hello-text\\")) {
|
|
2618
|
+
return new Response(html);
|
|
2619
|
+
}
|
|
2620
|
+
return env.ASSETS.fetch(request);
|
|
2582
2621
|
}
|
|
2583
2622
|
};
|
|
2584
2623
|
export {
|
|
@@ -2590,7 +2629,12 @@ async function onRequest() {
|
|
|
2590
2629
|
Content-Disposition: form-data; name=\\"./test-hello.wasm\\"; filename=\\"./test-hello.wasm\\"
|
|
2591
2630
|
Content-Type: application/wasm
|
|
2592
2631
|
|
|
2593
|
-
|
|
2632
|
+
Hello wasm modules
|
|
2633
|
+
------formdata-undici-0.test
|
|
2634
|
+
Content-Disposition: form-data; name=\\"./test-hello.html\\"; filename=\\"./test-hello.html\\"
|
|
2635
|
+
Content-Type: text/plain
|
|
2636
|
+
|
|
2637
|
+
<html><body>Hello text modules</body></html>
|
|
2594
2638
|
------formdata-undici-0.test--"
|
|
2595
2639
|
`);
|
|
2596
2640
|
|
|
@@ -2631,7 +2675,7 @@ async function onRequest() {
|
|
|
2631
2675
|
|
|
2632
2676
|
await runWrangler("pages publish public --project-name=foo");
|
|
2633
2677
|
|
|
2634
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
2678
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
2635
2679
|
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
2636
2680
|
|
|
2637
2681
|
✨ Compiled Worker successfully
|