wrangler 0.0.0-e928f94 → 0.0.0-e93063e9
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/Cloudflare_CA.pem +18 -0
- package/README.md +47 -14
- package/bin/wrangler.js +180 -28
- package/kv-asset-handler.js +1 -0
- package/miniflare-dist/index.mjs +6364 -0
- package/package.json +194 -113
- package/src/__tests__/access.test.ts +25 -0
- package/src/__tests__/api-dev.test.ts +238 -0
- package/src/__tests__/api-devregistry.test.js +64 -0
- package/src/__tests__/api.test.ts +80 -0
- package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
- package/src/__tests__/config-cache.test.ts +42 -0
- package/src/__tests__/configuration.test.ts +4163 -0
- package/src/__tests__/d1/d1.test.ts +123 -0
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +266 -0
- package/src/__tests__/deployments.test.ts +105 -0
- package/src/__tests__/dev.test.tsx +1586 -0
- package/src/__tests__/generate.test.ts +238 -0
- package/src/__tests__/get-host-from-url.test.ts +16 -0
- package/src/__tests__/guess-worker-format.test.ts +85 -0
- package/src/__tests__/{clipboardy-mock.js → helpers/clipboardy-mock.js} +0 -0
- package/src/__tests__/helpers/cmd-shim.d.ts +11 -0
- package/src/__tests__/helpers/mock-account-id.ts +48 -0
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-bin.ts +36 -0
- package/src/__tests__/helpers/mock-cfetch.ts +278 -0
- package/src/__tests__/helpers/mock-console.ts +106 -0
- package/src/__tests__/helpers/mock-dialogs.ts +137 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
- package/src/__tests__/helpers/mock-http-server.ts +46 -0
- package/src/__tests__/helpers/mock-istty.ts +74 -0
- package/src/__tests__/helpers/mock-known-routes.ts +7 -0
- package/src/__tests__/helpers/mock-kv.ts +33 -0
- package/src/__tests__/helpers/mock-oauth-flow.ts +271 -0
- package/src/__tests__/helpers/mock-process.ts +34 -0
- package/src/__tests__/helpers/mock-stdin.ts +108 -0
- package/src/__tests__/helpers/mock-web-socket.ts +29 -0
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +59 -0
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +104 -0
- package/src/__tests__/helpers/msw/handlers/oauth.ts +31 -0
- package/src/__tests__/helpers/msw/handlers/r2.ts +80 -0
- package/src/__tests__/helpers/msw/handlers/script.ts +75 -0
- package/src/__tests__/helpers/msw/handlers/user.ts +63 -0
- package/src/__tests__/helpers/msw/handlers/zones.ts +22 -0
- package/src/__tests__/helpers/msw/index.ts +21 -0
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/helpers/run-in-tmp.ts +38 -0
- package/src/__tests__/helpers/run-wrangler.ts +16 -0
- package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +5 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +8 -0
- package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +5 -0
- package/src/__tests__/helpers/write-worker-source.ts +31 -0
- package/src/__tests__/helpers/write-wrangler-toml.ts +17 -0
- package/src/__tests__/https-options.test.ts +163 -0
- package/src/__tests__/index.test.ts +264 -149
- package/src/__tests__/init.test.ts +3147 -0
- package/src/__tests__/jest.setup.ts +198 -0
- package/src/__tests__/kv.test.ts +1788 -0
- package/src/__tests__/logger.test.ts +141 -0
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +493 -0
- package/src/__tests__/middleware.scheduled.test.ts +145 -0
- package/src/__tests__/middleware.test.ts +750 -0
- package/src/__tests__/package-manager.test.ts +353 -0
- package/src/__tests__/pages-deployment-tail.test.ts +884 -0
- package/src/__tests__/pages.test.ts +2899 -0
- package/src/__tests__/parse.test.ts +330 -0
- package/src/__tests__/paths.test.ts +39 -0
- package/src/__tests__/publish.test.ts +7769 -0
- package/src/__tests__/pubsub.test.ts +490 -0
- package/src/__tests__/queues.test.ts +522 -0
- package/src/__tests__/r2.test.ts +393 -0
- package/src/__tests__/route.test.ts +45 -0
- package/src/__tests__/secret.test.ts +701 -0
- package/src/__tests__/tail.test.ts +905 -0
- package/src/__tests__/test-old-node-version.js +31 -0
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/type-generation.test.ts +233 -0
- package/src/__tests__/user.test.ts +129 -0
- package/src/__tests__/utils-collectKeyValues.test.ts +47 -0
- package/src/__tests__/validate-dev-props.test.ts +56 -0
- package/src/__tests__/version.test.ts +35 -0
- package/src/__tests__/whoami.test.tsx +183 -0
- package/src/__tests__/worker-namespace.test.ts +326 -0
- package/src/abort.d.ts +3 -0
- package/src/api/dev.ts +247 -0
- package/src/api/index.ts +2 -0
- package/src/bundle-reporter.ts +68 -0
- package/src/bundle.ts +823 -0
- package/src/cfetch/index.ts +158 -0
- package/src/cfetch/internal.ts +261 -0
- package/src/cli.ts +26 -8
- package/src/config/README.md +107 -0
- package/src/config/config.ts +275 -0
- package/src/config/diagnostics.ts +80 -0
- package/src/config/environment.ts +577 -0
- package/src/config/index.ts +358 -0
- package/src/config/validation-helpers.ts +597 -0
- package/src/config/validation.ts +2151 -0
- package/src/config-cache.ts +85 -0
- package/src/create-worker-preview.ts +282 -0
- package/src/create-worker-upload-form.ts +325 -0
- package/src/d1/backups.tsx +223 -0
- package/src/d1/constants.ts +2 -0
- package/src/d1/create.tsx +63 -0
- package/src/d1/delete.ts +56 -0
- package/src/d1/execute.tsx +323 -0
- package/src/d1/formatTimeAgo.ts +14 -0
- package/src/d1/index.ts +101 -0
- package/src/d1/list.tsx +48 -0
- package/src/d1/migrations/apply.tsx +197 -0
- package/src/d1/migrations/create.tsx +77 -0
- package/src/d1/migrations/helpers.ts +147 -0
- package/src/d1/migrations/index.ts +3 -0
- package/src/d1/migrations/list.tsx +79 -0
- package/src/d1/migrations/options.ts +18 -0
- package/src/d1/options.ts +22 -0
- package/src/d1/splitter.ts +161 -0
- package/src/d1/types.ts +24 -0
- package/src/d1/utils.ts +48 -0
- package/src/delete.ts +103 -0
- package/src/deployments.ts +83 -0
- package/src/deprecated/index.ts +145 -0
- package/src/dev/dev-vars.ts +39 -0
- package/src/dev/dev.tsx +614 -0
- package/src/dev/get-local-persistence-path.ts +31 -0
- package/src/dev/local.tsx +932 -0
- package/src/dev/remote.tsx +630 -0
- package/src/dev/start-server.ts +543 -0
- package/src/dev/use-esbuild.ts +204 -0
- package/src/dev/validate-dev-props.ts +31 -0
- package/src/dev-registry.ts +201 -0
- package/src/dev.tsx +929 -704
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +207 -0
- package/src/docs/index.ts +97 -0
- package/src/durable.ts +102 -0
- package/src/entry.ts +329 -0
- package/src/environment-variables/factory.ts +88 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/errors.ts +11 -0
- package/src/generate/index.ts +300 -0
- package/src/git-client.ts +135 -0
- package/src/global-wrangler-config-path.ts +26 -0
- package/src/https-options.ts +127 -0
- package/src/index.ts +694 -0
- package/src/init.ts +1023 -0
- package/src/inspect.ts +767 -0
- package/src/intl-polyfill.d.ts +139 -0
- package/src/is-ci.ts +14 -0
- package/src/is-interactive.ts +16 -0
- package/src/jest.d.ts +4 -0
- package/src/kv/helpers.ts +430 -0
- package/src/kv/index.ts +596 -0
- package/src/logger.ts +104 -0
- package/src/metrics/index.ts +5 -0
- package/src/metrics/metrics-config.ts +239 -0
- package/src/metrics/metrics-dispatcher.ts +96 -0
- package/src/metrics/metrics-usage-headers.ts +24 -0
- package/src/metrics/send-event.ts +97 -0
- package/src/miniflare-cli/README.md +30 -0
- package/src/miniflare-cli/assets.ts +250 -0
- package/src/miniflare-cli/index.ts +210 -0
- package/src/miniflare-cli/request-context.ts +40 -0
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/module-collection.ts +256 -53
- package/src/open-in-browser.ts +17 -0
- package/src/package-manager.ts +219 -0
- package/src/pages/build.ts +270 -0
- package/src/pages/constants.ts +18 -0
- package/src/pages/deployment-tails.ts +284 -0
- package/src/pages/deployments.tsx +84 -0
- package/src/pages/dev.ts +711 -0
- package/src/pages/errors.ts +66 -0
- package/src/pages/functions/buildPlugin.ts +107 -0
- package/src/pages/functions/buildWorker.ts +166 -0
- package/src/pages/functions/filepath-routing.test.ts +234 -0
- package/src/pages/functions/filepath-routing.ts +189 -0
- package/src/pages/functions/identifiers.ts +78 -0
- package/src/pages/functions/routes-consolidation.test.ts +250 -0
- package/src/pages/functions/routes-consolidation.ts +73 -0
- package/src/pages/functions/routes-transformation.test.ts +282 -0
- package/src/pages/functions/routes-transformation.ts +115 -0
- package/src/pages/functions/routes-validation.test.ts +403 -0
- package/src/pages/functions/routes-validation.ts +202 -0
- package/src/pages/functions/routes.ts +151 -0
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/functions.ts +82 -0
- package/src/pages/hash.ts +13 -0
- package/src/pages/index.ts +102 -0
- package/src/pages/projects.tsx +167 -0
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +462 -0
- package/src/pages/types.ts +41 -0
- package/src/pages/upload.tsx +447 -0
- package/src/pages/utils.ts +23 -0
- package/src/parse.ts +286 -0
- package/src/paths.ts +71 -0
- package/src/proxy.ts +694 -0
- package/src/publish/index.ts +270 -0
- package/src/publish/publish.ts +1038 -0
- package/src/pubsub/index.ts +286 -0
- package/src/pubsub/pubsub-commands.ts +624 -0
- package/src/queues/cli/commands/consumer/add.ts +71 -0
- package/src/queues/cli/commands/consumer/index.ts +22 -0
- package/src/queues/cli/commands/consumer/remove.ts +38 -0
- package/src/queues/cli/commands/create.ts +25 -0
- package/src/queues/cli/commands/delete.ts +26 -0
- package/src/queues/cli/commands/index.ts +36 -0
- package/src/queues/cli/commands/list.ts +25 -0
- package/src/queues/client.ts +135 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +131 -0
- package/src/r2/index.ts +289 -0
- package/src/routes.ts +140 -0
- package/src/secret/index.ts +379 -0
- package/src/selfsigned.d.ts +29 -0
- package/src/sites.ts +372 -0
- package/src/tail/createTail.ts +379 -0
- package/src/tail/filters.ts +277 -0
- package/src/tail/index.ts +213 -0
- package/src/tail/printing.ts +107 -0
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +181 -0
- package/src/update-check.ts +19 -0
- package/src/user/access.ts +68 -0
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +39 -0
- package/src/user/generate-auth-url.ts +33 -0
- package/src/user/generate-random-state.ts +16 -0
- package/src/user/index.ts +2 -0
- package/src/user/user.ts +1232 -0
- package/src/utils/collectKeyValues.ts +14 -0
- package/src/whoami.ts +135 -0
- package/src/worker.ts +251 -0
- package/src/yargs-types.ts +24 -0
- package/src/zones.ts +191 -0
- package/templates/__tests__/pages-dev-util.test.ts +128 -0
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/checked-fetch.js +17 -0
- package/templates/d1-beta-facade.js +241 -0
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +19 -0
- package/templates/format-dev-errors.ts +33 -0
- package/templates/gitignore +171 -0
- package/templates/init-tests/test-jest-new-worker.js +23 -0
- package/templates/init-tests/test-vitest-new-worker.js +24 -0
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/common.ts +62 -0
- package/templates/middleware/loader-modules.ts +82 -0
- package/templates/middleware/loader-sw.ts +233 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +20 -0
- package/templates/middleware/middleware-pretty-error.ts +40 -0
- package/templates/middleware/middleware-scheduled.ts +15 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.js +15 -0
- package/templates/new-worker.ts +30 -0
- package/templates/no-op-worker.js +10 -0
- package/templates/pages-dev-pipeline.ts +31 -0
- package/templates/pages-dev-util.ts +52 -0
- package/templates/pages-shim.ts +12 -0
- package/templates/pages-template-plugin.ts +176 -0
- package/templates/pages-template-worker.ts +189 -0
- package/templates/serve-static-assets.ts +65 -0
- package/templates/service-bindings-module-facade.js +54 -0
- package/templates/service-bindings-sw-facade.js +42 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +106 -0
- package/templates/tsconfig.json +8 -0
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +906 -0
- package/wrangler-dist/cli.js +133533 -113146
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/src/__tests__/fixtures/init/.gitkeep +0 -0
- package/src/__tests__/mock-cfetch.js +0 -46
- package/src/api/form_data.ts +0 -141
- package/src/api/inspect.ts +0 -441
- package/src/api/preview.ts +0 -128
- package/src/api/worker.ts +0 -161
- package/src/cfetch.ts +0 -72
- package/src/config.ts +0 -122
- package/src/dialogs.tsx +0 -85
- package/src/index.tsx +0 -1858
- package/src/kv.tsx +0 -211
- package/src/pages.tsx +0 -843
- package/src/publish.ts +0 -346
- package/src/sites.tsx +0 -115
- package/src/tail.tsx +0 -71
- package/src/user.tsx +0 -1029
- package/static-asset-facade.js +0 -47
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
- package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
- package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
- package/vendor/wrangler-mime/CHANGELOG.md +0 -289
- package/vendor/wrangler-mime/LICENSE +0 -21
- package/vendor/wrangler-mime/Mime.js +0 -97
- package/vendor/wrangler-mime/README.md +0 -187
- package/vendor/wrangler-mime/cli.js +0 -46
- package/vendor/wrangler-mime/index.js +0 -4
- package/vendor/wrangler-mime/lite.js +0 -4
- package/vendor/wrangler-mime/package.json +0 -52
- package/vendor/wrangler-mime/types/other.js +0 -1
- package/vendor/wrangler-mime/types/standard.js +0 -1
- package/wrangler-dist/cli.js.map +0 -7
package/package.json
CHANGED
|
@@ -1,114 +1,195 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
2
|
+
"name": "wrangler",
|
|
3
|
+
"version": "0.0.0-e93063e9",
|
|
4
|
+
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wrangler",
|
|
7
|
+
"cloudflare",
|
|
8
|
+
"workers",
|
|
9
|
+
"cloudflare workers",
|
|
10
|
+
"edge",
|
|
11
|
+
"compute",
|
|
12
|
+
"serverless",
|
|
13
|
+
"serverless application",
|
|
14
|
+
"serverless module",
|
|
15
|
+
"wasm",
|
|
16
|
+
"web",
|
|
17
|
+
"assembly",
|
|
18
|
+
"webassembly",
|
|
19
|
+
"rust",
|
|
20
|
+
"emscripten",
|
|
21
|
+
"typescript",
|
|
22
|
+
"graphql",
|
|
23
|
+
"router",
|
|
24
|
+
"http",
|
|
25
|
+
"cli"
|
|
26
|
+
],
|
|
27
|
+
"homepage": "https://github.com/cloudflare/wrangler2#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/cloudflare/wrangler2/issues"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/cloudflare/wrangler2.git",
|
|
34
|
+
"directory": "packages/wrangler"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT OR Apache-2.0",
|
|
37
|
+
"author": "wrangler@cloudflare.com",
|
|
38
|
+
"main": "wrangler-dist/cli.js",
|
|
39
|
+
"types": "wrangler-dist/cli.d.ts",
|
|
40
|
+
"bin": {
|
|
41
|
+
"wrangler": "./bin/wrangler.js",
|
|
42
|
+
"wrangler2": "./bin/wrangler.js"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"src",
|
|
46
|
+
"bin",
|
|
47
|
+
"miniflare-config-stubs",
|
|
48
|
+
"miniflare-dist",
|
|
49
|
+
"wrangler-dist",
|
|
50
|
+
"templates",
|
|
51
|
+
"vendor",
|
|
52
|
+
"import_meta_url.js",
|
|
53
|
+
"kv-asset-handler.js",
|
|
54
|
+
"Cloudflare_CA.pem"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"assert-git-version": "node -r esbuild-register scripts/assert-git-version.ts",
|
|
58
|
+
"build": "npm run clean && npm run bundle && npm run emit-types",
|
|
59
|
+
"bundle": "node -r esbuild-register scripts/bundle.ts",
|
|
60
|
+
"check:type": "node -r esbuild-register scripts/tsc-all.ts",
|
|
61
|
+
"clean": "rimraf wrangler-dist miniflare-dist emitted-types",
|
|
62
|
+
"dev": "npm run clean && concurrently -c black,blue --kill-others-on-fail false 'npm run bundle -- --watch' 'npm run check:type -- --watch --preserveWatchOutput'",
|
|
63
|
+
"emit-types": "tsc -p tsconfig.emit.json && node -r esbuild-register scripts/emit-types.ts",
|
|
64
|
+
"prepublishOnly": "SOURCEMAPS=false npm run build",
|
|
65
|
+
"start": "npm run bundle && cross-env NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
66
|
+
"test": "npm run assert-git-version && jest --silent=false --verbose=true",
|
|
67
|
+
"test-watch": "npm run test -- --runInBand --testTimeout=50000 --watch",
|
|
68
|
+
"test:ci": "npm run test -- --verbose=true --coverage"
|
|
69
|
+
},
|
|
70
|
+
"jest": {
|
|
71
|
+
"coverageReporters": [
|
|
72
|
+
"json",
|
|
73
|
+
"html",
|
|
74
|
+
"text",
|
|
75
|
+
"cobertura"
|
|
76
|
+
],
|
|
77
|
+
"moduleNameMapper": {
|
|
78
|
+
"clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js",
|
|
79
|
+
"miniflare/cli": "<rootDir>/../../node_modules/miniflare/dist/src/cli.js"
|
|
80
|
+
},
|
|
81
|
+
"restoreMocks": true,
|
|
82
|
+
"setupFilesAfterEnv": [
|
|
83
|
+
"<rootDir>/src/__tests__/jest.setup.ts"
|
|
84
|
+
],
|
|
85
|
+
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
86
|
+
"testTimeout": 30000,
|
|
87
|
+
"transform": {
|
|
88
|
+
"^.+\\.c?(t|j)sx?$": [
|
|
89
|
+
"esbuild-jest",
|
|
90
|
+
{
|
|
91
|
+
"sourcemap": true
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"transformIgnorePatterns": [
|
|
96
|
+
"node_modules/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes|npx-import)"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"dependencies": {
|
|
100
|
+
"@cloudflare/kv-asset-handler": "^0.2.0",
|
|
101
|
+
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
102
|
+
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
|
103
|
+
"@miniflare/core": "2.11.0",
|
|
104
|
+
"@miniflare/d1": "2.11.0",
|
|
105
|
+
"@miniflare/durable-objects": "2.11.0",
|
|
106
|
+
"blake3-wasm": "^2.1.5",
|
|
107
|
+
"chokidar": "^3.5.3",
|
|
108
|
+
"esbuild": "0.14.51",
|
|
109
|
+
"miniflare": "2.11.0",
|
|
110
|
+
"nanoid": "^3.3.3",
|
|
111
|
+
"path-to-regexp": "^6.2.0",
|
|
112
|
+
"selfsigned": "^2.0.1",
|
|
113
|
+
"source-map": "^0.7.4",
|
|
114
|
+
"xxhash-wasm": "^1.0.1"
|
|
115
|
+
},
|
|
116
|
+
"devDependencies": {
|
|
117
|
+
"@cloudflare/types": "^6.18.4",
|
|
118
|
+
"@cloudflare/workers-types": "^4.20221111.1",
|
|
119
|
+
"@iarna/toml": "^3.0.0",
|
|
120
|
+
"@microsoft/api-extractor": "^7.28.3",
|
|
121
|
+
"@miniflare/tre": "^3.0.0-next.8",
|
|
122
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
123
|
+
"@types/busboy": "^1.5.0",
|
|
124
|
+
"@types/command-exists": "^1.2.0",
|
|
125
|
+
"@types/express": "^4.17.13",
|
|
126
|
+
"@types/glob-to-regexp": "0.4.1",
|
|
127
|
+
"@types/javascript-time-ago": "^2.0.3",
|
|
128
|
+
"@types/mime": "^2.0.3",
|
|
129
|
+
"@types/prompts": "^2.0.14",
|
|
130
|
+
"@types/react": "^17.0.37",
|
|
131
|
+
"@types/serve-static": "^1.13.10",
|
|
132
|
+
"@types/signal-exit": "^3.0.1",
|
|
133
|
+
"@types/supports-color": "^8.1.1",
|
|
134
|
+
"@types/ws": "^8.5.3",
|
|
135
|
+
"@types/yargs": "^17.0.10",
|
|
136
|
+
"@webcontainer/env": "^1.0.1",
|
|
137
|
+
"body-parser": "^1.20.0",
|
|
138
|
+
"chalk": "^2.4.2",
|
|
139
|
+
"cli-table3": "^0.6.3",
|
|
140
|
+
"clipboardy": "^3.0.0",
|
|
141
|
+
"cmd-shim": "^4.1.0",
|
|
142
|
+
"command-exists": "^1.2.9",
|
|
143
|
+
"concurrently": "^7.2.2",
|
|
144
|
+
"devtools-protocol": "^0.0.955664",
|
|
145
|
+
"dotenv": "^16.0.0",
|
|
146
|
+
"execa": "^6.1.0",
|
|
147
|
+
"express": "^4.18.1",
|
|
148
|
+
"finalhandler": "^1.2.0",
|
|
149
|
+
"find-up": "^6.3.0",
|
|
150
|
+
"get-port": "^6.1.2",
|
|
151
|
+
"glob-to-regexp": "0.4.1",
|
|
152
|
+
"http-terminator": "^3.2.0",
|
|
153
|
+
"ignore": "^5.2.0",
|
|
154
|
+
"ink": "^3.2.0",
|
|
155
|
+
"ink-select-input": "^4.2.1",
|
|
156
|
+
"ink-spinner": "^4.0.3",
|
|
157
|
+
"ink-table": "^3.0.0",
|
|
158
|
+
"ink-testing-library": "^2.1.0",
|
|
159
|
+
"ink-text-input": "^4.0.3",
|
|
160
|
+
"is-ci": "^3.0.1",
|
|
161
|
+
"javascript-time-ago": "^2.5.4",
|
|
162
|
+
"jest-fetch-mock": "^3.0.3",
|
|
163
|
+
"jest-websocket-mock": "^2.3.0",
|
|
164
|
+
"mime": "^3.0.0",
|
|
165
|
+
"minimatch": "^5.1.0",
|
|
166
|
+
"msw": "^0.49.1",
|
|
167
|
+
"npx-import": "^1.1.3",
|
|
168
|
+
"open": "^8.4.0",
|
|
169
|
+
"p-queue": "^7.2.0",
|
|
170
|
+
"pretty-bytes": "^6.0.0",
|
|
171
|
+
"prompts": "^2.4.2",
|
|
172
|
+
"react": "^17.0.2",
|
|
173
|
+
"react-error-boundary": "^3.1.4",
|
|
174
|
+
"remove-accents-esm": "^0.0.1",
|
|
175
|
+
"semiver": "^1.1.0",
|
|
176
|
+
"serve-static": "^1.15.0",
|
|
177
|
+
"signal-exit": "^3.0.7",
|
|
178
|
+
"supports-color": "^9.2.2",
|
|
179
|
+
"timeago.js": "^4.0.2",
|
|
180
|
+
"tmp-promise": "^3.0.3",
|
|
181
|
+
"ts-dedent": "^2.2.0",
|
|
182
|
+
"undici": "5.11.0",
|
|
183
|
+
"update-check": "^1.5.4",
|
|
184
|
+
"ws": "^8.5.0",
|
|
185
|
+
"xdg-app-paths": "^7.3.0",
|
|
186
|
+
"yargs": "^17.4.1",
|
|
187
|
+
"yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz"
|
|
188
|
+
},
|
|
189
|
+
"optionalDependencies": {
|
|
190
|
+
"fsevents": "~2.3.2"
|
|
191
|
+
},
|
|
192
|
+
"engines": {
|
|
193
|
+
"node": ">=16.13.0"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { domainUsesAccess, getAccessToken } from "../user/access";
|
|
2
|
+
import { msw, mswAccessHandlers } from "./helpers/msw";
|
|
3
|
+
|
|
4
|
+
describe("access", () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
msw.use(...mswAccessHandlers);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe("basic", () => {
|
|
10
|
+
it("should correctly detect an access protected domain", async () => {
|
|
11
|
+
expect(await domainUsesAccess("access-protected.com")).toBeTruthy();
|
|
12
|
+
expect(await domainUsesAccess("not-access-protected.com")).toBeFalsy();
|
|
13
|
+
});
|
|
14
|
+
it("should not fail without cloudflared installed", async () => {
|
|
15
|
+
expect(await getAccessToken("not-access-protected.com")).toBeFalsy();
|
|
16
|
+
});
|
|
17
|
+
it("should error without cloudflared installed on an access protected domain", async () => {
|
|
18
|
+
await expect(getAccessToken("access-protected.com")).rejects.toEqual(
|
|
19
|
+
new Error(
|
|
20
|
+
"To use Wrangler with Cloudflare Access, please install `cloudflared` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation"
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import { Request } from "undici";
|
|
3
|
+
import { unstable_dev } from "../api";
|
|
4
|
+
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
5
|
+
|
|
6
|
+
jest.unmock("undici");
|
|
7
|
+
|
|
8
|
+
describe("unstable_dev", () => {
|
|
9
|
+
it("should return Hello World", async () => {
|
|
10
|
+
const worker = await unstable_dev(
|
|
11
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
12
|
+
{
|
|
13
|
+
experimental: {
|
|
14
|
+
disableExperimentalWarning: true,
|
|
15
|
+
disableDevRegistry: true,
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
const resp = await worker.fetch();
|
|
20
|
+
if (resp) {
|
|
21
|
+
const text = await resp.text();
|
|
22
|
+
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
|
|
23
|
+
}
|
|
24
|
+
await worker.stop();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should return the port that the server started on (1)", async () => {
|
|
28
|
+
const worker = await unstable_dev(
|
|
29
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
30
|
+
{
|
|
31
|
+
experimental: {
|
|
32
|
+
disableExperimentalWarning: true,
|
|
33
|
+
disableDevRegistry: true,
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
expect(worker.port).toBeGreaterThan(0);
|
|
38
|
+
await worker.stop();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should return the port that the server started on (2)", async () => {
|
|
42
|
+
const worker = await unstable_dev(
|
|
43
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
44
|
+
{
|
|
45
|
+
port: 9191,
|
|
46
|
+
experimental: {
|
|
47
|
+
disableExperimentalWarning: true,
|
|
48
|
+
disableDevRegistry: true,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
expect(worker.port).toBe(9191);
|
|
53
|
+
await worker.stop();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("unstable dev fetch input protocol", () => {
|
|
58
|
+
it("should use http localProtocol", async () => {
|
|
59
|
+
const worker = await unstable_dev(
|
|
60
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
61
|
+
{
|
|
62
|
+
localProtocol: "http",
|
|
63
|
+
experimental: {
|
|
64
|
+
disableExperimentalWarning: true,
|
|
65
|
+
disableDevRegistry: true,
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
const res = await worker.fetch();
|
|
70
|
+
if (res) {
|
|
71
|
+
const text = await res.text();
|
|
72
|
+
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
|
|
73
|
+
}
|
|
74
|
+
await worker.stop();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should use undefined localProtocol", async () => {
|
|
78
|
+
const worker = await unstable_dev(
|
|
79
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
80
|
+
{
|
|
81
|
+
localProtocol: undefined,
|
|
82
|
+
experimental: {
|
|
83
|
+
disableExperimentalWarning: true,
|
|
84
|
+
disableDevRegistry: true,
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
const res = await worker.fetch();
|
|
89
|
+
if (res) {
|
|
90
|
+
const text = await res.text();
|
|
91
|
+
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
|
|
92
|
+
}
|
|
93
|
+
await worker.stop();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("unstable dev fetch input parsing", () => {
|
|
98
|
+
runInTempDir();
|
|
99
|
+
|
|
100
|
+
it("should pass in a request object unchanged", async () => {
|
|
101
|
+
const scriptContent = `
|
|
102
|
+
export default {
|
|
103
|
+
fetch(request, env, ctx) {
|
|
104
|
+
const url = new URL(request.url);
|
|
105
|
+
if (url.pathname === "/test") {
|
|
106
|
+
if (request.method === "POST") {
|
|
107
|
+
return new Response("requestPOST");
|
|
108
|
+
}
|
|
109
|
+
return new Response("requestGET");
|
|
110
|
+
}
|
|
111
|
+
return new Response('Hello world');
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
`;
|
|
115
|
+
fs.writeFileSync("index.js", scriptContent);
|
|
116
|
+
const port = 21213;
|
|
117
|
+
const worker = await unstable_dev("index.js", {
|
|
118
|
+
port,
|
|
119
|
+
experimental: {
|
|
120
|
+
disableExperimentalWarning: true,
|
|
121
|
+
disableDevRegistry: true,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
const req = new Request("http://0.0.0.0:21213/test", {
|
|
125
|
+
method: "POST",
|
|
126
|
+
});
|
|
127
|
+
const resp = await worker.fetch(req);
|
|
128
|
+
let text;
|
|
129
|
+
if (resp) text = await resp.text();
|
|
130
|
+
expect(text).toMatchInlineSnapshot(`"requestPOST"`);
|
|
131
|
+
await worker.stop();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("should strip back to pathname for URL objects", async () => {
|
|
135
|
+
const scriptContent = `
|
|
136
|
+
export default {
|
|
137
|
+
fetch(request, env, ctx) {
|
|
138
|
+
const url = new URL(request.url);
|
|
139
|
+
if (url.pathname === "/test") {
|
|
140
|
+
return new Response("request");
|
|
141
|
+
}
|
|
142
|
+
return new Response('Hello world');
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
`;
|
|
146
|
+
fs.writeFileSync("index.js", scriptContent);
|
|
147
|
+
const worker = await unstable_dev("index.js", {
|
|
148
|
+
experimental: {
|
|
149
|
+
disableExperimentalWarning: true,
|
|
150
|
+
disableDevRegistry: true,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
const url = new URL("http://localhost:80/test");
|
|
154
|
+
const resp = await worker.fetch(url);
|
|
155
|
+
let text;
|
|
156
|
+
if (resp) text = await resp.text();
|
|
157
|
+
expect(text).toMatchInlineSnapshot(`"request"`);
|
|
158
|
+
await worker.stop();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("should allow full url passed in string, and stripped back to pathname", async () => {
|
|
162
|
+
const scriptContent = `
|
|
163
|
+
export default {
|
|
164
|
+
fetch(request, env, ctx) {
|
|
165
|
+
const url = new URL(request.url);
|
|
166
|
+
if (url.pathname === "/test") {
|
|
167
|
+
return new Response("request");
|
|
168
|
+
}
|
|
169
|
+
return new Response('Hello world');
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
`;
|
|
173
|
+
fs.writeFileSync("index.js", scriptContent);
|
|
174
|
+
const worker = await unstable_dev("index.js", {
|
|
175
|
+
experimental: {
|
|
176
|
+
disableExperimentalWarning: true,
|
|
177
|
+
disableDevRegistry: true,
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
const resp = await worker.fetch("http://example.com/test");
|
|
181
|
+
let text;
|
|
182
|
+
if (resp) text = await resp.text();
|
|
183
|
+
expect(text).toMatchInlineSnapshot(`"request"`);
|
|
184
|
+
await worker.stop();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("should allow pathname to be passed in", async () => {
|
|
188
|
+
const scriptContent = `
|
|
189
|
+
export default {
|
|
190
|
+
fetch(request, env, ctx) {
|
|
191
|
+
const url = new URL(request.url);
|
|
192
|
+
if (url.pathname === "/test") {
|
|
193
|
+
return new Response("request");
|
|
194
|
+
}
|
|
195
|
+
return new Response('Hello world');
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
`;
|
|
199
|
+
fs.writeFileSync("index.js", scriptContent);
|
|
200
|
+
const worker = await unstable_dev("index.js", {
|
|
201
|
+
experimental: {
|
|
202
|
+
disableExperimentalWarning: true,
|
|
203
|
+
disableDevRegistry: true,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
const resp = await worker.fetch("/test");
|
|
207
|
+
let text;
|
|
208
|
+
if (resp) text = await resp.text();
|
|
209
|
+
expect(text).toMatchInlineSnapshot(`"request"`);
|
|
210
|
+
await worker.stop();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("should allow no input be passed in", async () => {
|
|
214
|
+
const scriptContent = `
|
|
215
|
+
export default {
|
|
216
|
+
fetch(request, env, ctx) {
|
|
217
|
+
const url = new URL(request.url);
|
|
218
|
+
if (url.pathname === "/test") {
|
|
219
|
+
return new Response("request");
|
|
220
|
+
}
|
|
221
|
+
return new Response('Hello world');
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
`;
|
|
225
|
+
fs.writeFileSync("index.js", scriptContent);
|
|
226
|
+
const worker = await unstable_dev("index.js", {
|
|
227
|
+
experimental: {
|
|
228
|
+
disableExperimentalWarning: true,
|
|
229
|
+
disableDevRegistry: true,
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
const resp = await worker.fetch("");
|
|
233
|
+
let text;
|
|
234
|
+
if (resp) text = await resp.text();
|
|
235
|
+
expect(text).toMatchInlineSnapshot(`"Hello world"`);
|
|
236
|
+
await worker.stop();
|
|
237
|
+
});
|
|
238
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { unstable_dev } from "../api";
|
|
2
|
+
import { fetch } from "undici";
|
|
3
|
+
|
|
4
|
+
jest.unmock("undici");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* a huge caveat to how testing multi-worker scripts works:
|
|
8
|
+
* you can't shutdown the first worker you spun up, or it'll kill the devRegistry
|
|
9
|
+
*/
|
|
10
|
+
describe("multi-worker testing", () => {
|
|
11
|
+
let childWorker;
|
|
12
|
+
let parentWorker;
|
|
13
|
+
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
childWorker = await unstable_dev(
|
|
16
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
17
|
+
{
|
|
18
|
+
config: "src/__tests__/helpers/worker-scripts/child-wrangler.toml",
|
|
19
|
+
experimental: {
|
|
20
|
+
disableExperimentalWarning: true,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
parentWorker = await unstable_dev(
|
|
25
|
+
"src/__tests__/helpers/worker-scripts/parent-worker.js",
|
|
26
|
+
{
|
|
27
|
+
config: "src/__tests__/helpers/worker-scripts/parent-wrangler.toml",
|
|
28
|
+
experimental: {
|
|
29
|
+
disableExperimentalWarning: true,
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterAll(async () => {
|
|
36
|
+
await childWorker.stop();
|
|
37
|
+
await parentWorker.stop();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("parentWorker and childWorker should be added devRegistry", async () => {
|
|
41
|
+
const resp = await fetch("http://localhost:6284/workers");
|
|
42
|
+
if (resp) {
|
|
43
|
+
const parsedResp = await resp.json();
|
|
44
|
+
expect(parsedResp.parent).toBeTruthy();
|
|
45
|
+
expect(parsedResp.child).toBeTruthy();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("childWorker should return Hello World itself", async () => {
|
|
50
|
+
const resp = await childWorker.fetch();
|
|
51
|
+
if (resp) {
|
|
52
|
+
const text = await resp.text();
|
|
53
|
+
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("parentWorker should return Hello World by invoking the child worker", async () => {
|
|
58
|
+
const resp = await parentWorker.fetch();
|
|
59
|
+
if (resp) {
|
|
60
|
+
const parsedResp = await resp.text();
|
|
61
|
+
expect(parsedResp).toEqual("Parent worker sees: Hello World!");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|