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
|
@@ -635,7 +635,7 @@ describe("wrangler dev", () => {
|
|
|
635
635
|
it("should run a custom build before starting `dev`", async () => {
|
|
636
636
|
writeWranglerToml({
|
|
637
637
|
build: {
|
|
638
|
-
command: `node -e "
|
|
638
|
+
command: `node -e "4+4; require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')"`,
|
|
639
639
|
},
|
|
640
640
|
});
|
|
641
641
|
|
|
@@ -648,12 +648,12 @@ describe("wrangler dev", () => {
|
|
|
648
648
|
// and the command would pass through
|
|
649
649
|
expect((Dev as jest.Mock).mock.calls[0][0].build).toEqual({
|
|
650
650
|
command:
|
|
651
|
-
"node -e \"
|
|
651
|
+
"node -e \"4+4; require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')\"",
|
|
652
652
|
cwd: undefined,
|
|
653
653
|
watch_dir: "src",
|
|
654
654
|
});
|
|
655
655
|
expect(std.out).toMatchInlineSnapshot(
|
|
656
|
-
`"Running custom build: node -e \\"
|
|
656
|
+
`"Running custom build: node -e \\"4+4; require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')\\""`
|
|
657
657
|
);
|
|
658
658
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
659
659
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -663,7 +663,7 @@ describe("wrangler dev", () => {
|
|
|
663
663
|
it("should run a custom build of multiple steps combined by && before starting `dev`", async () => {
|
|
664
664
|
writeWranglerToml({
|
|
665
665
|
build: {
|
|
666
|
-
command: `echo "
|
|
666
|
+
command: `echo "export default { fetch(){ return new Response(123) } }" > index.js`,
|
|
667
667
|
},
|
|
668
668
|
});
|
|
669
669
|
|
|
@@ -675,7 +675,7 @@ describe("wrangler dev", () => {
|
|
|
675
675
|
`);
|
|
676
676
|
|
|
677
677
|
expect(std.out).toMatchInlineSnapshot(
|
|
678
|
-
`"Running custom build: echo \\"
|
|
678
|
+
`"Running custom build: echo \\"export default { fetch(){ return new Response(123) } }\\" > index.js"`
|
|
679
679
|
);
|
|
680
680
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
681
681
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -686,27 +686,27 @@ describe("wrangler dev", () => {
|
|
|
686
686
|
writeWranglerToml({
|
|
687
687
|
main: "index.js",
|
|
688
688
|
build: {
|
|
689
|
-
command: `node -e "
|
|
689
|
+
command: `node -e "4+4;"`,
|
|
690
690
|
},
|
|
691
691
|
});
|
|
692
692
|
|
|
693
693
|
await expect(runWrangler("dev")).rejects
|
|
694
694
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
695
|
+
"The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"4+4;\\".
|
|
696
|
+
The \`main\` property in wrangler.toml should point to the file generated by the custom build."
|
|
697
|
+
`);
|
|
698
698
|
expect(std.out).toMatchInlineSnapshot(`
|
|
699
|
-
|
|
699
|
+
"Running custom build: node -e \\"4+4;\\"
|
|
700
700
|
|
|
701
|
-
|
|
702
|
-
|
|
701
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose[0m"
|
|
702
|
+
`);
|
|
703
703
|
expect(std.err).toMatchInlineSnapshot(`
|
|
704
|
-
|
|
704
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mThe expected output file at \\"index.js\\" was not found after running custom build: node -e \\"4+4;\\".[0m
|
|
705
705
|
|
|
706
|
-
|
|
706
|
+
The \`main\` property in wrangler.toml should point to the file generated by the custom build.
|
|
707
707
|
|
|
708
|
-
|
|
709
|
-
|
|
708
|
+
"
|
|
709
|
+
`);
|
|
710
710
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
711
711
|
});
|
|
712
712
|
|
|
@@ -894,6 +894,7 @@ describe("wrangler dev", () => {
|
|
|
894
894
|
Object {
|
|
895
895
|
"debug": "",
|
|
896
896
|
"err": "",
|
|
897
|
+
"info": "",
|
|
897
898
|
"out": "",
|
|
898
899
|
"warn": "",
|
|
899
900
|
}
|
|
@@ -911,6 +912,7 @@ describe("wrangler dev", () => {
|
|
|
911
912
|
Object {
|
|
912
913
|
"debug": "",
|
|
913
914
|
"err": "",
|
|
915
|
+
"info": "",
|
|
914
916
|
"out": "",
|
|
915
917
|
"warn": "",
|
|
916
918
|
}
|
|
@@ -928,6 +930,7 @@ describe("wrangler dev", () => {
|
|
|
928
930
|
Object {
|
|
929
931
|
"debug": "",
|
|
930
932
|
"err": "",
|
|
933
|
+
"info": "",
|
|
931
934
|
"out": "",
|
|
932
935
|
"warn": "",
|
|
933
936
|
}
|
|
@@ -948,6 +951,7 @@ describe("wrangler dev", () => {
|
|
|
948
951
|
Object {
|
|
949
952
|
"debug": "",
|
|
950
953
|
"err": "",
|
|
954
|
+
"info": "",
|
|
951
955
|
"out": "",
|
|
952
956
|
"warn": "",
|
|
953
957
|
}
|
|
@@ -1209,6 +1213,7 @@ describe("wrangler dev", () => {
|
|
|
1209
1213
|
"err": "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough arguments following: site[0m
|
|
1210
1214
|
|
|
1211
1215
|
",
|
|
1216
|
+
"info": "",
|
|
1212
1217
|
"out": "
|
|
1213
1218
|
wrangler dev [script]
|
|
1214
1219
|
|
|
@@ -1343,15 +1348,16 @@ describe("wrangler dev", () => {
|
|
|
1343
1348
|
|
|
1344
1349
|
await runWrangler('dev --assets "./assets"');
|
|
1345
1350
|
expect(std).toMatchInlineSnapshot(`
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1351
|
+
Object {
|
|
1352
|
+
"debug": "",
|
|
1353
|
+
"err": "",
|
|
1354
|
+
"info": "",
|
|
1355
|
+
"out": "",
|
|
1356
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe --assets argument is experimental and may change or break at any time[0m
|
|
1357
|
+
|
|
1358
|
+
",
|
|
1359
|
+
}
|
|
1360
|
+
`);
|
|
1355
1361
|
});
|
|
1356
1362
|
|
|
1357
1363
|
it("should warn if config.assets is used", async () => {
|
|
@@ -1364,17 +1370,18 @@ describe("wrangler dev", () => {
|
|
|
1364
1370
|
|
|
1365
1371
|
await runWrangler("dev");
|
|
1366
1372
|
expect(std).toMatchInlineSnapshot(`
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1373
|
+
Object {
|
|
1374
|
+
"debug": "",
|
|
1375
|
+
"err": "",
|
|
1376
|
+
"info": "",
|
|
1377
|
+
"out": "",
|
|
1378
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
1372
1379
|
|
|
1373
|
-
|
|
1380
|
+
- \\"assets\\" fields are experimental and may change or break at any time.
|
|
1374
1381
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1382
|
+
",
|
|
1383
|
+
}
|
|
1384
|
+
`);
|
|
1378
1385
|
});
|
|
1379
1386
|
});
|
|
1380
1387
|
|
|
@@ -1383,15 +1390,16 @@ describe("wrangler dev", () => {
|
|
|
1383
1390
|
fs.writeFileSync("index.js", `export default {};`);
|
|
1384
1391
|
await runWrangler("dev index.js --inspect");
|
|
1385
1392
|
expect(std).toMatchInlineSnapshot(`
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1393
|
+
Object {
|
|
1394
|
+
"debug": "",
|
|
1395
|
+
"err": "",
|
|
1396
|
+
"info": "",
|
|
1397
|
+
"out": "",
|
|
1398
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mPassing --inspect is unnecessary, now you can always connect to devtools.[0m
|
|
1399
|
+
|
|
1400
|
+
",
|
|
1401
|
+
}
|
|
1402
|
+
`);
|
|
1395
1403
|
});
|
|
1396
1404
|
|
|
1397
1405
|
it("should default to true, without a warning", async () => {
|
|
@@ -1402,6 +1410,7 @@ describe("wrangler dev", () => {
|
|
|
1402
1410
|
Object {
|
|
1403
1411
|
"debug": "",
|
|
1404
1412
|
"err": "",
|
|
1413
|
+
"info": "",
|
|
1405
1414
|
"out": "",
|
|
1406
1415
|
"warn": "",
|
|
1407
1416
|
}
|
|
@@ -1416,6 +1425,7 @@ describe("wrangler dev", () => {
|
|
|
1416
1425
|
Object {
|
|
1417
1426
|
"debug": "",
|
|
1418
1427
|
"err": "",
|
|
1428
|
+
"info": "",
|
|
1419
1429
|
"out": "",
|
|
1420
1430
|
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mPassing --inspect is unnecessary, now you can always connect to devtools.[0m
|
|
1421
1431
|
|
|
@@ -1432,6 +1442,7 @@ describe("wrangler dev", () => {
|
|
|
1432
1442
|
Object {
|
|
1433
1443
|
"debug": "",
|
|
1434
1444
|
"err": "",
|
|
1445
|
+
"info": "",
|
|
1435
1446
|
"out": "",
|
|
1436
1447
|
"warn": "",
|
|
1437
1448
|
}
|
|
@@ -1447,6 +1458,7 @@ describe("wrangler dev", () => {
|
|
|
1447
1458
|
Object {
|
|
1448
1459
|
"debug": "",
|
|
1449
1460
|
"err": "",
|
|
1461
|
+
"info": "",
|
|
1450
1462
|
"out": "",
|
|
1451
1463
|
"warn": "",
|
|
1452
1464
|
}
|
|
@@ -1460,6 +1472,7 @@ describe("wrangler dev", () => {
|
|
|
1460
1472
|
Object {
|
|
1461
1473
|
"debug": "",
|
|
1462
1474
|
"err": "",
|
|
1475
|
+
"info": "",
|
|
1463
1476
|
"out": "",
|
|
1464
1477
|
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mPassing --inspect is unnecessary, now you can always connect to devtools.[0m
|
|
1465
1478
|
|
|
@@ -1516,23 +1529,24 @@ describe("wrangler dev", () => {
|
|
|
1516
1529
|
fs.writeFileSync("index.js", `export default {};`);
|
|
1517
1530
|
await runWrangler("dev index.js");
|
|
1518
1531
|
expect(std).toMatchInlineSnapshot(`
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1532
|
+
Object {
|
|
1533
|
+
"debug": "",
|
|
1534
|
+
"err": "",
|
|
1535
|
+
"info": "",
|
|
1536
|
+
"out": "Your worker has access to the following bindings:
|
|
1537
|
+
- Services:
|
|
1538
|
+
- WorkerA: A
|
|
1539
|
+
- WorkerB: B - staging",
|
|
1540
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
1527
1541
|
|
|
1528
|
-
|
|
1542
|
+
- \\"services\\" fields are experimental and may change or break at any time.
|
|
1529
1543
|
|
|
1530
1544
|
|
|
1531
|
-
|
|
1545
|
+
[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThis worker is bound to live services: WorkerA (A), WorkerB (B@staging)[0m
|
|
1532
1546
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1547
|
+
",
|
|
1548
|
+
}
|
|
1549
|
+
`);
|
|
1536
1550
|
});
|
|
1537
1551
|
|
|
1538
1552
|
it("should mask vars that were overriden in .dev.vars", async () => {
|
|
@@ -1555,6 +1569,7 @@ describe("wrangler dev", () => {
|
|
|
1555
1569
|
Object {
|
|
1556
1570
|
"debug": "",
|
|
1557
1571
|
"err": "",
|
|
1572
|
+
"info": "",
|
|
1558
1573
|
"out": "Using vars defined in .dev.vars
|
|
1559
1574
|
Your worker has access to the following bindings:
|
|
1560
1575
|
- Vars:
|
|
@@ -107,7 +107,7 @@ describe("generate", () => {
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
describe("cloning", () => {
|
|
110
|
-
it
|
|
110
|
+
it("clones a cloudflare template with sparse checkouts", async () => {
|
|
111
111
|
await expect(
|
|
112
112
|
runWrangler("generate my-worker worker-typescript")
|
|
113
113
|
).resolves.toBeUndefined();
|
|
@@ -116,10 +116,9 @@ describe("generate", () => {
|
|
|
116
116
|
".git": expect.any(Object),
|
|
117
117
|
".gitignore": expect.any(String),
|
|
118
118
|
"README.md": expect.stringContaining("Template: worker-typescript"),
|
|
119
|
-
"jest.config.json": expect.any(String),
|
|
120
119
|
"package.json": expect.stringContaining("@cloudflare/workers-types"),
|
|
121
|
-
src: expect.objectContaining({
|
|
122
|
-
|
|
120
|
+
src: expect.objectContaining({
|
|
121
|
+
"index.ts": expect.any(String),
|
|
123
122
|
"index.test.ts": expect.any(String),
|
|
124
123
|
}),
|
|
125
124
|
"tsconfig.json": expect.any(String),
|
|
@@ -8,6 +8,7 @@ import { logger } from "../../logger";
|
|
|
8
8
|
|
|
9
9
|
let debugSpy: jest.SpyInstance,
|
|
10
10
|
logSpy: jest.SpyInstance,
|
|
11
|
+
infoSpy: jest.SpyInstance,
|
|
11
12
|
errorSpy: jest.SpyInstance,
|
|
12
13
|
warnSpy: jest.SpyInstance;
|
|
13
14
|
|
|
@@ -18,6 +19,9 @@ const std = {
|
|
|
18
19
|
get out() {
|
|
19
20
|
return normalizeOutput(logSpy);
|
|
20
21
|
},
|
|
22
|
+
get info() {
|
|
23
|
+
return normalizeOutput(infoSpy);
|
|
24
|
+
},
|
|
21
25
|
get err() {
|
|
22
26
|
return normalizeOutput(errorSpy);
|
|
23
27
|
},
|
|
@@ -47,12 +51,14 @@ export function mockConsoleMethods() {
|
|
|
47
51
|
logger.columns = 100;
|
|
48
52
|
debugSpy = jest.spyOn(console, "debug").mockImplementation();
|
|
49
53
|
logSpy = jest.spyOn(console, "log").mockImplementation();
|
|
54
|
+
infoSpy = jest.spyOn(console, "info").mockImplementation();
|
|
50
55
|
errorSpy = jest.spyOn(console, "error").mockImplementation();
|
|
51
56
|
warnSpy = jest.spyOn(console, "warn").mockImplementation();
|
|
52
57
|
});
|
|
53
58
|
afterEach(() => {
|
|
54
59
|
debugSpy.mockRestore();
|
|
55
60
|
logSpy.mockRestore();
|
|
61
|
+
infoSpy.mockRestore();
|
|
56
62
|
errorSpy.mockRestore();
|
|
57
63
|
warnSpy.mockRestore();
|
|
58
64
|
});
|
|
@@ -49,6 +49,7 @@ export const mswSuccessDeployments = [
|
|
|
49
49
|
annotations: {
|
|
50
50
|
"workers/triggered_by": "rollback",
|
|
51
51
|
"workers/rollback_from": "MOCK-DEPLOYMENT-ID-1111",
|
|
52
|
+
"workers/message": "Rolled back for this version",
|
|
52
53
|
},
|
|
53
54
|
metadata: {
|
|
54
55
|
author_id: "Kathryn-Jane-Gamma-6-0-7-3",
|
|
@@ -59,7 +60,7 @@ export const mswSuccessDeployments = [
|
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
|
-
id: "Intrepid-
|
|
63
|
+
id: "3mEgaU1T-Intrepid-someThing",
|
|
63
64
|
number: "NCC-74656",
|
|
64
65
|
metadata: {
|
|
65
66
|
author_id: "Kathryn-Jane-Gamma-6-0-7-3",
|
|
@@ -77,17 +78,83 @@ export const mswSuccessDeployments = [
|
|
|
77
78
|
),
|
|
78
79
|
];
|
|
79
80
|
|
|
80
|
-
export const
|
|
81
|
+
export const mswSuccessDeploymentScriptMetadata = [
|
|
81
82
|
rest.get(
|
|
82
83
|
"*/accounts/:accountId/workers/services/:scriptName",
|
|
83
84
|
(_, res, ctx) => {
|
|
84
85
|
return res.once(
|
|
85
86
|
ctx.json(
|
|
86
87
|
createFetchResult({
|
|
87
|
-
default_environment: {
|
|
88
|
+
default_environment: {
|
|
89
|
+
script: { last_deployed_from: "wrangler", tag: "MOCK-TAG" },
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
export const mswSuccessDeploymentDetails = [
|
|
99
|
+
rest.get(
|
|
100
|
+
"*/accounts/:accountId/workers/deployments/by-script/:scriptTag/detail/:deploymentId",
|
|
101
|
+
(req, res, ctx) => {
|
|
102
|
+
let bindings: object[] = [];
|
|
103
|
+
if (req.url.toString().includes("bindings-tag")) {
|
|
104
|
+
bindings = [
|
|
105
|
+
{
|
|
106
|
+
bucket_name: "testr2",
|
|
107
|
+
name: "MY_BUCKET",
|
|
108
|
+
type: "r2_bucket",
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
expect(req.url.toString().includes("1701-E"));
|
|
114
|
+
return res.once(
|
|
115
|
+
ctx.json(
|
|
116
|
+
createFetchResult({
|
|
117
|
+
id: "1701-E",
|
|
118
|
+
Number: 0,
|
|
119
|
+
metadata: {
|
|
120
|
+
author_id: "Picard-Gamma-6-0-7-3",
|
|
121
|
+
author_email: "Jean-Luc-Picard@federation.org",
|
|
122
|
+
source: "wrangler",
|
|
123
|
+
created_on: "2021-01-01T00:00:00.000000Z",
|
|
124
|
+
modified_on: "2021-01-01T00:00:00.000000Z",
|
|
125
|
+
},
|
|
126
|
+
resources: {
|
|
127
|
+
script: {
|
|
128
|
+
etag: "mock-e-tag",
|
|
129
|
+
handlers: ["fetch"],
|
|
130
|
+
last_deployed_from: "wrangler",
|
|
131
|
+
},
|
|
132
|
+
script_runtime: {
|
|
133
|
+
usage_model: "bundled",
|
|
134
|
+
},
|
|
135
|
+
bindings: bindings,
|
|
136
|
+
},
|
|
88
137
|
})
|
|
89
138
|
)
|
|
90
139
|
);
|
|
91
140
|
}
|
|
92
141
|
),
|
|
142
|
+
// ?deployment=<deploymentid> param used to get deployment <script content> as text
|
|
143
|
+
rest.get(
|
|
144
|
+
"*/accounts/:accountId/workers/scripts/:scriptName",
|
|
145
|
+
(req, res, ctx) => {
|
|
146
|
+
let scriptContent = "";
|
|
147
|
+
if (req.url.searchParams.get("deployment") === "1701-E") {
|
|
148
|
+
scriptContent = `
|
|
149
|
+
export default {
|
|
150
|
+
async fetch(request) {
|
|
151
|
+
return new Response('Hello World from Deployment 1701-E');
|
|
152
|
+
},
|
|
153
|
+
};`;
|
|
154
|
+
} else {
|
|
155
|
+
return res(ctx.status(400));
|
|
156
|
+
}
|
|
157
|
+
return res.once(ctx.text(scriptContent));
|
|
158
|
+
}
|
|
159
|
+
),
|
|
93
160
|
];
|
|
@@ -2,7 +2,8 @@ import { setupServer } from "msw/node";
|
|
|
2
2
|
import { default as mswAccessHandlers } from "./handlers/access";
|
|
3
3
|
import {
|
|
4
4
|
mswSuccessDeployments,
|
|
5
|
-
|
|
5
|
+
mswSuccessDeploymentScriptMetadata,
|
|
6
|
+
mswSuccessDeploymentDetails,
|
|
6
7
|
} from "./handlers/deployments";
|
|
7
8
|
import { mswSuccessNamespacesHandlers } from "./handlers/namespaces";
|
|
8
9
|
import { mswSuccessOauthHandlers } from "./handlers/oauth";
|
|
@@ -45,6 +46,7 @@ export {
|
|
|
45
46
|
mswSucessScriptHandlers,
|
|
46
47
|
mswZoneHandlers,
|
|
47
48
|
mswSuccessDeployments,
|
|
49
|
+
mswSuccessDeploymentDetails,
|
|
48
50
|
mswAccessHandlers,
|
|
49
|
-
|
|
51
|
+
mswSuccessDeploymentScriptMetadata,
|
|
50
52
|
};
|
|
@@ -2,7 +2,10 @@ export default {
|
|
|
2
2
|
async fetch(req, env) {
|
|
3
3
|
const resp = await env.CHILD.fetch(req);
|
|
4
4
|
const text = await resp.text();
|
|
5
|
-
|
|
5
|
+
// TODO: we should capture console logs when running `dev` programmatically
|
|
6
|
+
// (and locally) and expose it on the DevWorker object instead of allowing
|
|
7
|
+
// the log to appear in the output of the test runner.
|
|
8
|
+
// console.log("text: ", text);
|
|
6
9
|
return new Response(`Parent worker sees: ${text}`);
|
|
7
10
|
},
|
|
8
11
|
};
|
|
@@ -32,7 +32,7 @@ describe("wrangler", () => {
|
|
|
32
32
|
"wrangler
|
|
33
33
|
|
|
34
34
|
Commands:
|
|
35
|
-
wrangler docs [command]
|
|
35
|
+
wrangler docs [command..] 📚 Open wrangler's docs in your browser
|
|
36
36
|
wrangler init [name] 📥 Initialize a basic Worker project, including a wrangler.toml file
|
|
37
37
|
wrangler generate [name] [template] ✨ Generate a new Worker project from an existing Worker template. See https://github.com/cloudflare/templates
|
|
38
38
|
wrangler dev [script] 👂 Start a local server for developing your worker
|
|
@@ -49,20 +49,24 @@ describe("wrangler", () => {
|
|
|
49
49
|
wrangler r2 📦 Interact with an R2 store
|
|
50
50
|
wrangler dispatch-namespace 📦 Interact with a dispatch namespace
|
|
51
51
|
wrangler d1 🗄 Interact with a D1 database
|
|
52
|
+
wrangler constellation 🤖 Interact with Constellation AI models
|
|
52
53
|
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
|
|
53
54
|
wrangler mtls-certificate 🪪 Manage certificates used for mTLS connections
|
|
54
55
|
wrangler login 🔓 Login to Cloudflare
|
|
55
56
|
wrangler logout 🚪 Logout from Cloudflare
|
|
56
57
|
wrangler whoami 🕵️ Retrieve your user info and test your auth config
|
|
57
58
|
wrangler types 📝 Generate types from bindings & module rules in config
|
|
58
|
-
wrangler deployments 🚢
|
|
59
|
+
wrangler deployments 🚢 List and view details for deployments
|
|
60
|
+
wrangler rollback [deployment-id] 🔙 Rollback a deployment
|
|
59
61
|
|
|
60
62
|
Flags:
|
|
61
63
|
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
62
64
|
-c, --config Path to .toml configuration file [string]
|
|
63
65
|
-e, --env Environment to use for operations and .env files [string]
|
|
64
66
|
-h, --help Show help [boolean]
|
|
65
|
-
-v, --version Show version number [boolean]
|
|
67
|
+
-v, --version Show version number [boolean]
|
|
68
|
+
|
|
69
|
+
🚧\`wrangler rollback\` is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose"
|
|
66
70
|
`);
|
|
67
71
|
|
|
68
72
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -82,7 +86,7 @@ describe("wrangler", () => {
|
|
|
82
86
|
wrangler
|
|
83
87
|
|
|
84
88
|
Commands:
|
|
85
|
-
wrangler docs [command]
|
|
89
|
+
wrangler docs [command..] 📚 Open wrangler's docs in your browser
|
|
86
90
|
wrangler init [name] 📥 Initialize a basic Worker project, including a wrangler.toml file
|
|
87
91
|
wrangler generate [name] [template] ✨ Generate a new Worker project from an existing Worker template. See https://github.com/cloudflare/templates
|
|
88
92
|
wrangler dev [script] 👂 Start a local server for developing your worker
|
|
@@ -99,20 +103,24 @@ describe("wrangler", () => {
|
|
|
99
103
|
wrangler r2 📦 Interact with an R2 store
|
|
100
104
|
wrangler dispatch-namespace 📦 Interact with a dispatch namespace
|
|
101
105
|
wrangler d1 🗄 Interact with a D1 database
|
|
106
|
+
wrangler constellation 🤖 Interact with Constellation AI models
|
|
102
107
|
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
|
|
103
108
|
wrangler mtls-certificate 🪪 Manage certificates used for mTLS connections
|
|
104
109
|
wrangler login 🔓 Login to Cloudflare
|
|
105
110
|
wrangler logout 🚪 Logout from Cloudflare
|
|
106
111
|
wrangler whoami 🕵️ Retrieve your user info and test your auth config
|
|
107
112
|
wrangler types 📝 Generate types from bindings & module rules in config
|
|
108
|
-
wrangler deployments 🚢
|
|
113
|
+
wrangler deployments 🚢 List and view details for deployments
|
|
114
|
+
wrangler rollback [deployment-id] 🔙 Rollback a deployment
|
|
109
115
|
|
|
110
116
|
Flags:
|
|
111
117
|
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
112
118
|
-c, --config Path to .toml configuration file [string]
|
|
113
119
|
-e, --env Environment to use for operations and .env files [string]
|
|
114
120
|
-h, --help Show help [boolean]
|
|
115
|
-
-v, --version Show version number [boolean]
|
|
121
|
+
-v, --version Show version number [boolean]
|
|
122
|
+
|
|
123
|
+
🚧\`wrangler rollback\` is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose"
|
|
116
124
|
`);
|
|
117
125
|
expect(std.err).toMatchInlineSnapshot(`
|
|
118
126
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown argument: invalid-command[0m
|