wrangler 0.0.0-fb53fda → 0.0.0-fd3517a

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.
Files changed (80) hide show
  1. package/README.md +24 -13
  2. package/bin/wrangler.js +3 -0
  3. package/miniflare-dist/index.mjs +18 -18
  4. package/miniflare-dist/index.mjs.map +3 -3
  5. package/package.json +25 -18
  6. package/pages/functions/buildPlugin.ts +55 -0
  7. package/pages/functions/filepath-routing.test.ts +11 -0
  8. package/pages/functions/filepath-routing.ts +8 -0
  9. package/pages/functions/routes.ts +6 -1
  10. package/pages/functions/template-plugin.ts +146 -0
  11. package/pages/functions/template-worker.ts +21 -8
  12. package/src/__tests__/config-cache.test.ts +31 -0
  13. package/src/__tests__/configuration.test.ts +383 -71
  14. package/src/__tests__/dev.test.tsx +113 -14
  15. package/src/__tests__/guess-worker-format.test.ts +18 -1
  16. package/src/__tests__/helpers/mock-cfetch.ts +5 -1
  17. package/src/__tests__/helpers/mock-console.ts +18 -3
  18. package/src/__tests__/helpers/mock-http-server.ts +46 -0
  19. package/src/__tests__/helpers/mock-istty.ts +23 -0
  20. package/src/__tests__/helpers/mock-oauth-flow.ts +231 -0
  21. package/src/__tests__/helpers/run-in-tmp.ts +7 -0
  22. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  23. package/src/__tests__/https-options.test.ts +4 -2
  24. package/src/__tests__/index.test.ts +13 -757
  25. package/src/__tests__/init.test.ts +833 -0
  26. package/src/__tests__/jest.setup.ts +4 -0
  27. package/src/__tests__/kv.test.ts +82 -44
  28. package/src/__tests__/logger.test.ts +115 -0
  29. package/src/__tests__/pages.test.ts +315 -43
  30. package/src/__tests__/publish.test.ts +1588 -342
  31. package/src/__tests__/r2.test.ts +8 -4
  32. package/src/__tests__/route.test.ts +4 -4
  33. package/src/__tests__/secret.test.ts +22 -10
  34. package/src/__tests__/tail.test.ts +100 -2
  35. package/src/__tests__/user.test.ts +126 -0
  36. package/src/__tests__/whoami.test.tsx +5 -8
  37. package/src/bundle.ts +30 -3
  38. package/src/cli.ts +4 -2
  39. package/src/config/README.md +1 -1
  40. package/src/config/config.ts +20 -4
  41. package/src/config/environment.ts +31 -3
  42. package/src/config/index.ts +2 -1
  43. package/src/config/validation-helpers.ts +24 -5
  44. package/src/config/validation.ts +271 -39
  45. package/src/config-cache.ts +43 -0
  46. package/src/create-worker-preview.ts +14 -7
  47. package/src/create-worker-upload-form.ts +32 -9
  48. package/src/dev/dev.tsx +62 -32
  49. package/src/dev/local.tsx +101 -21
  50. package/src/dev/remote.tsx +23 -13
  51. package/src/dev/use-esbuild.ts +23 -5
  52. package/src/dialogs.tsx +2 -1
  53. package/src/entry.ts +43 -13
  54. package/src/environment-variables.ts +3 -1
  55. package/src/errors.ts +11 -0
  56. package/src/https-options.ts +3 -2
  57. package/src/index.tsx +389 -310
  58. package/src/inspect.ts +17 -11
  59. package/src/logger.ts +56 -0
  60. package/src/miniflare-cli/index.ts +4 -0
  61. package/src/miniflare-cli/request-context.ts +40 -0
  62. package/src/module-collection.ts +7 -7
  63. package/src/open-in-browser.ts +5 -4
  64. package/src/package-manager.ts +9 -8
  65. package/src/pages.tsx +652 -55
  66. package/src/parse.ts +1 -1
  67. package/src/proxy.ts +25 -9
  68. package/src/publish.ts +261 -140
  69. package/src/reporting.ts +19 -3
  70. package/src/sites.tsx +27 -14
  71. package/src/tail/index.ts +1 -1
  72. package/src/tail/printing.ts +5 -4
  73. package/src/update-check.ts +19 -0
  74. package/src/user.tsx +83 -37
  75. package/src/whoami.tsx +2 -1
  76. package/src/worker.ts +15 -6
  77. package/templates/static-asset-facade.js +1 -1
  78. package/wrangler-dist/cli.js +14641 -10836
  79. package/wrangler-dist/cli.js.map +3 -3
  80. package/src/__tests__/logout.test.ts +0 -52
package/README.md CHANGED
@@ -2,46 +2,53 @@
2
2
 
3
3
  `wrangler` is a command line tool for building [Cloudflare Workers](https://workers.cloudflare.com/).
4
4
 
5
- [(Read the full stack week launch blog post.)](https://blog.cloudflare.com/wrangler-v2-beta/)
6
-
7
- **DISCLAIMER**: This is a work in progress, and is NOT recommended for use in production. We are opening this preview for feedback from the community, and to openly share our [roadmap](https://github.com/cloudflare/wrangler2/issues/12) for the future. As such, expect APIs and documentation to change before the end of the preview.
8
-
9
- Further, we will NOT do a general release until we are both feature complete, and have a full backward compatibility and incremental migration plan in place. For more details, follow the [parent roadmap issue](https://github.com/cloudflare/wrangler2/issues/12).
10
-
11
5
  ## Quick Start
12
6
 
13
7
  ```bash
14
8
  # Make a javascript file
15
- $ echo "export default { fetch() { return new Response('hello world') } }" > index.js
9
+ echo "export default { fetch() { return new Response('hello world') } }" > index.js
16
10
  # try it out
17
- $ npx wrangler@beta dev index.js
11
+ npx wrangler dev index.js
18
12
  # and then publish it
19
- $ npx wrangler@beta publish index.js --name my-worker
13
+ npx wrangler publish index.js --name my-worker
20
14
  # visit https://my-worker.<your workers subdomain>.workers.dev
21
15
  ```
22
16
 
17
+ ## Create a Project
18
+
19
+ ```bash
20
+ # Generate a new project
21
+ npx wrangler init my-worker
22
+ # try it out
23
+ cd my-worker && npm run start
24
+ # and then publish it
25
+ npx wrangler publish
26
+ ```
27
+
23
28
  ## Installation:
24
29
 
25
30
  ```bash
26
- $ npm install wrangler@beta
31
+ $ npm install wrangler --save-dev
27
32
  ```
28
33
 
29
34
  ## Commands
30
35
 
31
36
  ### `wrangler init [name]`
32
37
 
33
- Creates a `wrangler.toml` configuration file. For more details on the configuration keys and values, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration).
38
+ Creates a Worker project. For details on configuration keys and values, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration).
34
39
 
35
- ### `wrangler dev [script]`
40
+ ### `wrangler dev`
36
41
 
37
42
  Start a local development server, with live reloading and devtools.
38
43
 
39
- ### `wrangler publish [script] --name [name]`
44
+ ### `wrangler publish`
40
45
 
41
46
  Publish the given script to the worldwide Cloudflare network.
42
47
 
43
48
  For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/commands).
44
49
 
50
+ ## Pages
51
+
45
52
  ### `wrangler pages dev [directory] [-- command]`
46
53
 
47
54
  Either serves a static build asset directory, or proxies itself in front of a command.
@@ -49,3 +56,7 @@ Either serves a static build asset directory, or proxies itself in front of a co
49
56
  Builds and runs functions from a `./functions` directory or uses a `_worker.js` file inside the static build asset directory.
50
57
 
51
58
  For more commands and options, refer to the [documentation](https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally) or run `wrangler pages dev --help`.
59
+
60
+ ## Documentation
61
+
62
+ For the latest Wrangler documentation, [click here](https://6b05b6e1.cloudflare-docs-7ou.pages.dev/workers/wrangler/).
package/bin/wrangler.js CHANGED
@@ -23,6 +23,9 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
23
23
  wranglerProcess = spawn(
24
24
  process.execPath,
25
25
  [
26
+ ...(semiver(process.versions.node, "18.0.0") >= 0
27
+ ? ["--no-experimental-fetch"] // TODO: remove this when https://github.com/cloudflare/wrangler2/issues/834 is properly fixed
28
+ : []),
26
29
  "--no-warnings",
27
30
  "--experimental-vm-modules",
28
31
  ...process.execArgv,