wrangler 0.0.0-fac199ba → 0.0.0-fac2f9dfa

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 (42) hide show
  1. package/README.md +30 -38
  2. package/bin/wrangler.js +8 -37
  3. package/config-schema.json +2487 -0
  4. package/package.json +179 -195
  5. package/templates/checked-fetch.js +1 -1
  6. package/templates/facade.d.ts +7 -5
  7. package/templates/gitignore +2 -4
  8. package/templates/init-tests/test-vitest-new-worker.js +1 -1
  9. package/templates/init-tests/test-vitest-new-worker.ts +3 -3
  10. package/templates/middleware/loader-modules.ts +92 -95
  11. package/templates/middleware/loader-sw.ts +4 -3
  12. package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  13. package/templates/middleware/middleware-patch-console-prefix.d.ts +3 -0
  14. package/templates/middleware/middleware-patch-console-prefix.ts +21 -0
  15. package/templates/middleware/middleware-scheduled.ts +15 -1
  16. package/templates/mixedMode/proxyServerWorker/index.ts +40 -0
  17. package/templates/mixedMode/proxyServerWorker/wrangler.jsonc +4 -0
  18. package/templates/modules-watch-stub.js +4 -0
  19. package/templates/pages-dev-pipeline.ts +5 -3
  20. package/templates/pages-template-plugin.ts +2 -2
  21. package/templates/pages-template-worker.ts +1 -1
  22. package/templates/startDevWorker/InspectorProxyWorker.ts +679 -0
  23. package/templates/startDevWorker/ProxyWorker.ts +336 -0
  24. package/templates/strip-cf-connecting-ip-header.js +13 -0
  25. package/templates/tsconfig.init.json +4 -87
  26. package/templates/tsconfig.json +8 -1
  27. package/templates/tsconfig.tsbuildinfo +1 -0
  28. package/wrangler-dist/InspectorProxyWorker.js +471 -0
  29. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  30. package/wrangler-dist/ProxyWorker.js +238 -0
  31. package/wrangler-dist/ProxyWorker.js.map +6 -0
  32. package/wrangler-dist/cli.d.ts +1888 -1185
  33. package/wrangler-dist/cli.js +173198 -146364
  34. package/wrangler-dist/cli.js.map +1 -0
  35. package/wrangler-dist/metafile-cjs.json +1 -0
  36. package/Cloudflare_CA.pem +0 -18
  37. package/templates/middleware/middleware-d1-beta.d.ts +0 -3
  38. package/templates/middleware/middleware-multiworker-dev.d.ts +0 -4
  39. package/templates/middleware/middleware-multiworker-dev.ts +0 -59
  40. package/templates/middleware/middleware-serve-static-assets.d.ts +0 -6
  41. package/templates/middleware/middleware-serve-static-assets.ts +0 -56
  42. package/wrangler-dist/wasm-sync.wasm +0 -0
package/README.md CHANGED
@@ -3,49 +3,47 @@
3
3
  <a href="https://www.npmjs.com/package/wrangler"><img alt="npm" src="https://img.shields.io/npm/dw/wrangler?style=flat-square"></a>
4
4
  <img alt="GitHub contributors" src="https://img.shields.io/github/contributors/cloudflare/workers-sdk?style=flat-square">
5
5
  <img alt="GitHub commit activity (branch)" src="https://img.shields.io/github/commit-activity/w/cloudflare/workers-sdk/main?style=flat-square">
6
- <a href="https://discord.gg/CloudflareDev"><img alt="Discord" src="https://img.shields.io/discord/595317990191398933?color=%23F48120&style=flat-square"></a>
6
+ <a href="https://discord.cloudflare.com"><img alt="Discord" src="https://img.shields.io/discord/595317990191398933?color=%23F48120&style=flat-square"></a>
7
7
  </section>
8
8
 
9
9
  `wrangler` is a command line tool for building [Cloudflare Workers](https://workers.cloudflare.com/).
10
10
 
11
11
  ## Quick Start
12
12
 
13
+ To get started quickly with a Hello World worker, run the command below:
14
+
13
15
  ```bash
14
- # Make a javascript file
15
- echo "export default { fetch() { return new Response('hello world') } }" > index.js
16
- # try it out
17
- npx wrangler dev index.js
18
- # and then deploy it
19
- npx wrangler deploy index.js --name my-worker
20
- # visit https://my-worker.<your workers subdomain>.workers.dev
16
+ npx wrangler init my-worker -y
21
17
  ```
22
18
 
23
- ## Create a Project
19
+ For more info, visit our [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/) guide.
24
20
 
25
- ```bash
26
- # Generate a new project
27
- npx wrangler init my-worker --no-delegate-c3
28
- # try it out
29
- cd my-worker && npm run start
30
- # and then deploy it
31
- npm run deploy
32
- ```
21
+ <details><summary>Wrangler System Requirements</summary>
33
22
 
34
- ## Installation:
23
+ We support running the Wrangler CLI with the [Current, Active, and Maintenance](https://nodejs.org/en/about/previous-releases) versions of Node.js. Your Worker will always be executed in `workerd`, the open source Cloudflare Workers runtime.
35
24
 
36
- ```bash
37
- $ npm install wrangler --save-dev
38
- ```
25
+ Wrangler is only supported on macOS 13.5+, Windows 11, and Linux distros that support glib 2.35. This follows [`workerd`'s OS support policy](https://github.com/cloudflare/workerd?tab=readme-ov-file#running-workerd).
26
+
27
+ </details>
28
+
29
+ ## Documentation
39
30
 
40
- ## Configuration:
31
+ For the latest Wrangler documentation, [click here](https://developers.cloudflare.com/workers/wrangler/).
32
+
33
+ To read more about Workers in general:
41
34
 
42
- Wrangler is configured via a `wrangler.toml` file in the project root. When utilizing the `wrangler init` command, a `wrangler.toml` file will be created for you.
35
+ - [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/)
36
+ - [How Workers works](https://developers.cloudflare.com/workers/reference/how-workers-works/)
37
+ - [Observability](https://developers.cloudflare.com/workers/observability/)
38
+ - [Platform](https://developers.cloudflare.com/workers/platform/)
43
39
 
44
- Example:
40
+ ## Configuration
41
+
42
+ Wrangler is configured via a `wrangler.toml` or `wrangler.json` file in the project root. An example configuration generated by `npx wrangler init` or `npx create cloudflare` is as follows:
45
43
 
46
44
  ```toml
47
45
  name = "my-worker"
48
- main = "./src/index.ts" # init w/ TypeScript
46
+ main = "./src/index.ts"
49
47
  compatibility_date = "YYYY-MM-DD"
50
48
  ```
51
49
 
@@ -53,30 +51,24 @@ For more detailed information about configuration, refer to the [documentation](
53
51
 
54
52
  ## Commands
55
53
 
56
- ### `wrangler init [name]`
57
-
58
- Creates a Worker project. For details on configuration keys and values, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/commands/#init).
54
+ ### Workers
59
55
 
60
- ### `wrangler dev`
56
+ #### `wrangler dev`
61
57
 
62
58
  Start a local development server, with live reloading and devtools.
63
59
 
64
- ### `wrangler deploy`
60
+ #### `wrangler deploy`
65
61
 
66
- Publish the given script to the worldwide Cloudflare network.
62
+ Publish the given script to Cloudflare's global network.
67
63
 
68
64
  For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/commands/).
69
65
 
70
- ## Pages
66
+ ### Pages
71
67
 
72
- ### `wrangler pages dev [directory] [-- command]`
68
+ #### `wrangler pages dev [directory]`
73
69
 
74
- Either serves a static build asset directory, or proxies itself in front of a command.
70
+ Serves a static build asset directory.
75
71
 
76
72
  Builds and runs functions from a `./functions` directory or uses a `_worker.js` file inside the static build asset directory.
77
73
 
78
74
  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`.
79
-
80
- ## Documentation
81
-
82
- For the latest Wrangler documentation, [click here](https://developers.cloudflare.com/workers/wrangler/).
package/bin/wrangler.js CHANGED
@@ -1,22 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  const { spawn } = require("child_process");
3
3
  const path = require("path");
4
- const fs = require("fs");
5
- const os = require("os");
6
-
7
- const MIN_NODE_VERSION = "16.13.0";
8
- const debug =
9
- process.env["WRANGLER_LOG"] === "debug"
10
- ? (...args) => console.log(...args)
11
- : () => {};
12
4
 
5
+ const ERR_NODE_VERSION = "20.0.0";
6
+ const MIN_NODE_VERSION = "20.0.0";
13
7
  let wranglerProcess;
14
8
 
15
9
  /**
16
10
  * Executes ../wrangler-dist/cli.js
17
11
  */
18
12
  function runWrangler() {
19
- if (semiver(process.versions.node, MIN_NODE_VERSION) < 0) {
13
+ if (semiver(process.versions.node, ERR_NODE_VERSION) < 0) {
20
14
  // Note Volta and nvm are also recommended in the official docs:
21
15
  // https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
22
16
  console.error(
@@ -28,30 +22,6 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
28
22
  return;
29
23
  }
30
24
 
31
- let pathToCACerts = process.env.NODE_EXTRA_CA_CERTS;
32
- if (pathToCACerts) {
33
- // TODO:
34
- // - should we log a warning here?
35
- // - maybe we can generate a certificate that concatenates with ours?
36
- //
37
- // I do think it'll be rare that someone wants to add a cert AND
38
- // use Cloudflare WARP, but let's wait till the situation actually
39
- // arises before we do anything about it
40
- } else {
41
- const osTempDir = os.tmpdir();
42
- const certDir = path.join(osTempDir, "wrangler-cert");
43
- const certPath = path.join(certDir, "Cloudflare_CA.pem");
44
- // copy cert to the system temp dir if needed
45
- if (!fs.existsSync(certPath)) {
46
- fs.mkdirSync(certDir, { recursive: true });
47
- fs.writeFileSync(
48
- certPath,
49
- fs.readFileSync(path.join(__dirname, "../Cloudflare_CA.pem"), "utf-8")
50
- );
51
- }
52
- pathToCACerts = certPath;
53
- }
54
-
55
25
  return spawn(
56
26
  process.execPath,
57
27
  [
@@ -63,10 +33,6 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
63
33
  ],
64
34
  {
65
35
  stdio: ["inherit", "inherit", "inherit", "ipc"],
66
- env: {
67
- ...process.env,
68
- NODE_EXTRA_CA_CERTS: pathToCACerts,
69
- },
70
36
  }
71
37
  )
72
38
  .on("exit", (code) =>
@@ -76,6 +42,11 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
76
42
  if (process.send) {
77
43
  process.send(message);
78
44
  }
45
+ })
46
+ .on("disconnect", () => {
47
+ if (process.disconnect) {
48
+ process.disconnect();
49
+ }
79
50
  });
80
51
  }
81
52