wrangler 0.0.0-e043479 → 0.0.0-e0a0509

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 (96) hide show
  1. package/README.md +27 -14
  2. package/bin/wrangler.js +13 -1
  3. package/miniflare-dist/index.mjs +4886 -0
  4. package/package.json +38 -25
  5. package/pages/functions/buildPlugin.ts +92 -0
  6. package/pages/functions/buildWorker.ts +80 -4
  7. package/pages/functions/filepath-routing.test.ts +136 -25
  8. package/pages/functions/filepath-routing.ts +14 -3
  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 +36 -0
  13. package/src/__tests__/configuration.test.ts +1294 -355
  14. package/src/__tests__/dev.test.tsx +592 -12
  15. package/src/__tests__/guess-worker-format.test.ts +37 -18
  16. package/src/__tests__/helpers/mock-account-id.ts +4 -0
  17. package/src/__tests__/helpers/mock-cfetch.ts +8 -4
  18. package/src/__tests__/helpers/mock-console.ts +20 -3
  19. package/src/__tests__/helpers/mock-dialogs.ts +26 -1
  20. package/src/__tests__/helpers/mock-http-server.ts +46 -0
  21. package/src/__tests__/helpers/mock-istty.ts +27 -0
  22. package/src/__tests__/helpers/mock-kv.ts +9 -16
  23. package/src/__tests__/helpers/mock-oauth-flow.ts +255 -0
  24. package/src/__tests__/helpers/run-in-tmp.ts +10 -0
  25. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  26. package/src/__tests__/https-options.test.ts +130 -0
  27. package/src/__tests__/index.test.ts +129 -753
  28. package/src/__tests__/init.test.ts +1516 -0
  29. package/src/__tests__/jest.setup.ts +13 -5
  30. package/src/__tests__/kv.test.ts +208 -174
  31. package/src/__tests__/logger.test.ts +115 -0
  32. package/src/__tests__/pages.test.ts +327 -0
  33. package/src/__tests__/parse.test.ts +4 -0
  34. package/src/__tests__/publish.test.ts +3313 -505
  35. package/src/__tests__/r2.test.ts +38 -26
  36. package/src/__tests__/route.test.ts +45 -0
  37. package/src/__tests__/secret.test.ts +55 -34
  38. package/src/__tests__/tail.test.ts +146 -20
  39. package/src/__tests__/user.test.ts +131 -0
  40. package/src/__tests__/whoami.test.tsx +26 -7
  41. package/src/bundle.ts +43 -7
  42. package/src/cfetch/internal.ts +9 -5
  43. package/src/cli.ts +5 -11
  44. package/src/config/README.md +7 -7
  45. package/src/config/config.ts +69 -105
  46. package/src/config/environment.ts +93 -4
  47. package/src/config/index.ts +15 -4
  48. package/src/config/validation-helpers.ts +228 -23
  49. package/src/config/validation.ts +559 -154
  50. package/src/config-cache.ts +45 -0
  51. package/src/{api/preview.ts → create-worker-preview.ts} +41 -13
  52. package/src/{api/form_data.ts → create-worker-upload-form.ts} +33 -10
  53. package/src/dev/dev-vars.ts +36 -0
  54. package/src/dev/dev.tsx +418 -0
  55. package/src/dev/local.tsx +312 -0
  56. package/src/dev/remote.tsx +213 -0
  57. package/src/dev/use-esbuild.ts +118 -0
  58. package/src/dialogs.tsx +16 -6
  59. package/src/entry.ts +222 -12
  60. package/src/environment-variables.ts +3 -1
  61. package/src/errors.ts +11 -0
  62. package/src/https-options.ts +123 -0
  63. package/src/index.tsx +878 -482
  64. package/src/inspect.ts +25 -11
  65. package/src/intl-polyfill.d.ts +139 -0
  66. package/src/{kv.tsx → kv.ts} +7 -27
  67. package/src/logger.ts +66 -0
  68. package/src/miniflare-cli/README.md +30 -0
  69. package/src/miniflare-cli/enum-keys.ts +17 -0
  70. package/src/miniflare-cli/index.ts +41 -0
  71. package/src/miniflare-cli/request-context.ts +40 -0
  72. package/src/module-collection.ts +94 -6
  73. package/src/open-in-browser.ts +18 -5
  74. package/src/package-manager.ts +9 -8
  75. package/src/pages.tsx +892 -62
  76. package/src/parse.ts +4 -2
  77. package/src/proxy.ts +128 -55
  78. package/src/publish.ts +305 -199
  79. package/src/selfsigned.d.ts +29 -0
  80. package/src/sites.tsx +88 -33
  81. package/src/tail/index.ts +2 -2
  82. package/src/tail/printing.ts +13 -8
  83. package/src/update-check.ts +19 -0
  84. package/src/user.tsx +244 -104
  85. package/src/whoami.tsx +2 -1
  86. package/src/{api/worker.ts → worker.ts} +15 -29
  87. package/templates/gitignore +171 -0
  88. package/templates/static-asset-facade.js +1 -1
  89. package/wrangler-dist/cli.js +23568 -50489
  90. package/src/__tests__/helpers/mock-user.ts +0 -27
  91. package/src/__tests__/logout.test.ts +0 -50
  92. package/src/__tests__/sentry.test.ts +0 -146
  93. package/src/dev.tsx +0 -960
  94. package/src/guess-worker-format.ts +0 -68
  95. package/src/reporting.ts +0 -115
  96. package/wrangler-dist/cli.js.map +0 -7
@@ -1,13 +1,26 @@
1
1
  import open from "open";
2
+ import { logger } from "./logger";
3
+
2
4
  /**
3
5
  * An extremely simple wrapper around the open command.
4
6
  * Specifically, it adds an 'error' event handler so that when this function
5
- * is called in environments where we can't open the browser (e.g. github codespaces,
6
- * stackblitz, remote servers), it doesn't just crash the process.
7
+ * is called in environments where we can't open the browser (e.g. GitHub Codespaces,
8
+ * StackBlitz, remote servers), it doesn't just crash the process.
9
+ *
10
+ * @param url the URL to point the browser at
11
+ * @param options open a Chromium-based browser instead of the default
7
12
  */
8
- export default async function openInBrowser(url: string): Promise<void> {
9
- const childProcess = await open(url);
13
+ export default async function openInBrowser(
14
+ url: string,
15
+ { forceChromium }: { forceChromium: boolean } = { forceChromium: false }
16
+ ): Promise<void> {
17
+ const options: open.Options | undefined = forceChromium
18
+ ? {
19
+ app: [{ name: open.apps.chrome }, { name: open.apps.edge }],
20
+ }
21
+ : undefined;
22
+ const childProcess = await open(url, options);
10
23
  childProcess.on("error", () => {
11
- console.warn(`Failed to open ${url} in a browser`);
24
+ logger.warn(`Failed to open ${url} in a browser.`);
12
25
  });
13
26
  }
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { execa, execaCommandSync } from "execa";
4
+ import { logger } from "./logger";
4
5
 
5
6
  export interface PackageManager {
6
7
  cwd: string;
@@ -16,26 +17,26 @@ export async function getPackageManager(cwd: string): Promise<PackageManager> {
16
17
 
17
18
  if (hasNpmLock) {
18
19
  if (hasNpm) {
19
- console.log(
20
+ logger.log(
20
21
  "Using npm as package manager, as there is already a package-lock.json file."
21
22
  );
22
23
  return { ...NpmPackageManager, cwd };
23
24
  } else if (hasYarn) {
24
- console.log("Using yarn as package manager.");
25
- console.warn(
25
+ logger.log("Using yarn as package manager.");
26
+ logger.warn(
26
27
  "There is already a package-lock.json file but could not find npm on the PATH."
27
28
  );
28
29
  return { ...YarnPackageManager, cwd };
29
30
  }
30
31
  } else if (hasYarnLock) {
31
32
  if (hasYarn) {
32
- console.log(
33
+ logger.log(
33
34
  "Using yarn as package manager, as there is already a yarn.lock file."
34
35
  );
35
36
  return { ...YarnPackageManager, cwd };
36
37
  } else if (hasNpm) {
37
- console.log("Using npm as package manager.");
38
- console.warn(
38
+ logger.log("Using npm as package manager.");
39
+ logger.warn(
39
40
  "There is already a yarn.lock file but could not find yarn on the PATH."
40
41
  );
41
42
  return { ...NpmPackageManager, cwd };
@@ -43,10 +44,10 @@ export async function getPackageManager(cwd: string): Promise<PackageManager> {
43
44
  }
44
45
 
45
46
  if (hasNpm) {
46
- console.log("Using npm as package manager.");
47
+ logger.log("Using npm as package manager.");
47
48
  return { ...NpmPackageManager, cwd };
48
49
  } else if (hasYarn) {
49
- console.log("Using yarn as package manager.");
50
+ logger.log("Using yarn as package manager.");
50
51
  return { ...YarnPackageManager, cwd };
51
52
  } else {
52
53
  throw new Error(