wrangler 0.0.0-ea7ee45 → 0.0.0-ea968c81

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 (86) hide show
  1. package/bin/wrangler.js +42 -8
  2. package/miniflare-dist/index.mjs +465 -4
  3. package/package.json +80 -64
  4. package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
  5. package/src/__tests__/config-cache.test.ts +6 -0
  6. package/src/__tests__/configuration.test.ts +151 -29
  7. package/src/__tests__/dev.test.tsx +137 -7
  8. package/src/__tests__/helpers/mock-cfetch.ts +54 -2
  9. package/src/__tests__/helpers/mock-istty.ts +1 -1
  10. package/src/__tests__/helpers/run-in-tmp.ts +22 -23
  11. package/src/__tests__/https-options.test.ts +51 -18
  12. package/src/__tests__/index.test.ts +25 -22
  13. package/src/__tests__/jest.setup.ts +20 -1
  14. package/src/__tests__/kv.test.ts +115 -63
  15. package/src/__tests__/metrics.test.ts +445 -0
  16. package/src/__tests__/pages.test.ts +15 -8
  17. package/src/__tests__/publish.test.ts +483 -207
  18. package/src/__tests__/pubsub.test.ts +91 -0
  19. package/src/__tests__/r2.test.ts +155 -71
  20. package/src/__tests__/secret.test.ts +84 -78
  21. package/src/__tests__/tail.test.ts +8 -0
  22. package/src/__tests__/test-old-node-version.js +31 -0
  23. package/src/__tests__/user.test.ts +11 -11
  24. package/src/__tests__/version.test.ts +35 -0
  25. package/src/__tests__/whoami.test.tsx +11 -3
  26. package/src/api/dev.ts +60 -12
  27. package/src/bundle.ts +195 -37
  28. package/src/cfetch/internal.ts +67 -21
  29. package/src/cli.ts +2 -2
  30. package/src/config/config.ts +15 -0
  31. package/src/config/environment.ts +43 -0
  32. package/src/config/index.ts +29 -0
  33. package/src/config/validation.ts +123 -1
  34. package/src/config-cache.ts +71 -31
  35. package/src/create-worker-preview.ts +3 -1
  36. package/src/create-worker-upload-form.ts +18 -0
  37. package/src/d1/backups.tsx +196 -0
  38. package/src/d1/create.tsx +49 -0
  39. package/src/d1/delete.tsx +49 -0
  40. package/src/d1/execute.tsx +134 -0
  41. package/src/d1/index.ts +72 -0
  42. package/src/d1/list.tsx +57 -0
  43. package/src/d1/types.tsx +14 -0
  44. package/src/dev/dev.tsx +81 -23
  45. package/src/dev/local.tsx +53 -25
  46. package/src/dev/remote.tsx +25 -10
  47. package/src/dev/use-esbuild.ts +14 -7
  48. package/src/dev.tsx +115 -41
  49. package/src/entry.ts +1 -1
  50. package/src/{__tests__/helpers/faye-websocket.d.ts → faye-websocket.d.ts} +0 -0
  51. package/src/formatTimeAgo.ts +14 -0
  52. package/src/global-wrangler-config-path.ts +26 -0
  53. package/src/https-options.ts +8 -4
  54. package/src/index.tsx +357 -49
  55. package/src/is-interactive.ts +12 -0
  56. package/src/kv.ts +23 -1
  57. package/src/metrics/index.ts +4 -0
  58. package/src/metrics/is-ci.ts +14 -0
  59. package/src/metrics/metrics-config.ts +239 -0
  60. package/src/metrics/metrics-dispatcher.ts +95 -0
  61. package/src/metrics/send-event.ts +92 -0
  62. package/src/miniflare-cli/assets.ts +543 -0
  63. package/src/miniflare-cli/index.ts +37 -4
  64. package/src/package-manager.ts +45 -0
  65. package/src/pages/build.tsx +2 -0
  66. package/src/pages/deployments.tsx +6 -1
  67. package/src/pages/dev.tsx +90 -637
  68. package/src/pages/projects.tsx +7 -1
  69. package/src/pages/publish.tsx +3 -0
  70. package/src/pages/upload.tsx +26 -14
  71. package/src/publish.ts +153 -123
  72. package/src/pubsub/pubsub-commands.tsx +434 -405
  73. package/src/r2.ts +68 -0
  74. package/src/user/choose-account.tsx +22 -13
  75. package/src/user/user.tsx +85 -43
  76. package/src/whoami.tsx +2 -1
  77. package/src/worker-namespace.ts +16 -0
  78. package/src/worker.ts +29 -0
  79. package/templates/d1-beta-facade.js +170 -0
  80. package/templates/format-dev-errors.ts +32 -0
  81. package/templates/pages-shim.ts +9 -0
  82. package/templates/serve-static-assets.ts +61 -0
  83. package/templates/tsconfig.json +2 -2
  84. package/wrangler-dist/cli.d.ts +328 -0
  85. package/wrangler-dist/cli.js +30103 -30814
  86. package/templates/static-asset-facade.js +0 -43
package/bin/wrangler.js CHANGED
@@ -3,9 +3,12 @@ const { spawn } = require("child_process");
3
3
  const path = require("path");
4
4
  const fs = require("fs");
5
5
  const os = require("os");
6
- const semiver = require("semiver");
7
6
 
8
7
  const MIN_NODE_VERSION = "16.7.0";
8
+ const debug =
9
+ process.env["WRANGLER_LOG"] === "debug"
10
+ ? (...args) => console.log(...args)
11
+ : () => {};
9
12
 
10
13
  let wranglerProcess;
11
14
 
@@ -17,8 +20,8 @@ function runWrangler() {
17
20
  // Note Volta and nvm are also recommended in the official docs:
18
21
  // https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
19
22
  console.error(
20
- `Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}.
21
- You should use the latest Node.js version if possible, as Cloudflare Workers use a very up-to-date version of V8.
23
+ `Wrangler requires at least node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of node.js.
24
+
22
25
  Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
23
26
  );
24
27
  process.exitCode = 1;
@@ -84,9 +87,8 @@ function runDelegatedWrangler() {
84
87
  } = JSON.parse(fs.readFileSync(packageJsonPath));
85
88
  const resolvedBinaryPath = path.resolve(packageJsonPath, "..", binaryPath);
86
89
 
87
- console.log(
88
- `Delegating to locally-installed version of wrangler @ v${version}`
89
- );
90
+ debug(`Delegating to locally-installed version of wrangler @ v${version}`);
91
+
90
92
  // this call to `spawn` is simpler because the delegated version will do all
91
93
  // of the other work.
92
94
  return spawn(
@@ -125,10 +127,42 @@ async function main() {
125
127
  }
126
128
 
127
129
  process.on("SIGINT", () => {
128
- wranglerProcess?.kill();
130
+ wranglerProcess && wranglerProcess.kill();
129
131
  });
130
132
  process.on("SIGTERM", () => {
131
- wranglerProcess?.kill();
133
+ wranglerProcess && wranglerProcess.kill();
132
134
  });
133
135
 
136
+ // semiver implementation via https://github.com/lukeed/semiver/blob/ae7eebe6053c96be63032b14fb0b68e2553fcac4/src/index.js
137
+
138
+ /**
139
+ MIT License
140
+
141
+ Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
142
+
143
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
144
+
145
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
146
+
147
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
148
+
149
+ */
150
+
151
+ var fn = new Intl.Collator(0, { numeric: 1 }).compare;
152
+
153
+ function semiver(a, b, bool) {
154
+ a = a.split(".");
155
+ b = b.split(".");
156
+
157
+ return (
158
+ fn(a[0], b[0]) ||
159
+ fn(a[1], b[1]) ||
160
+ ((b[2] = b.slice(2).join(".")),
161
+ (bool = /[.-]/.test((a[2] = a.slice(2).join(".")))),
162
+ bool == /[.-]/.test(b[2]) ? fn(a[2], b[2]) : bool ? -1 : 1)
163
+ );
164
+ }
165
+
166
+ // end semiver implementation
167
+
134
168
  void main();