wrangler 0.0.0-e3cab74 → 0.0.0-e492c10

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 (97) 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 -27
  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 +1295 -355
  14. package/src/__tests__/dev.test.tsx +798 -84
  15. package/src/__tests__/guess-worker-format.test.ts +37 -18
  16. package/src/__tests__/helpers/mock-account-id.ts +22 -4
  17. package/src/__tests__/helpers/mock-cfetch.ts +8 -4
  18. package/src/__tests__/helpers/mock-console.ts +35 -10
  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/mock-stdin.ts +103 -0
  25. package/src/__tests__/helpers/run-in-tmp.ts +10 -0
  26. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  27. package/src/__tests__/https-options.test.ts +130 -0
  28. package/src/__tests__/index.test.ts +129 -753
  29. package/src/__tests__/init.test.ts +1516 -0
  30. package/src/__tests__/jest.setup.ts +28 -8
  31. package/src/__tests__/kv.test.ts +517 -216
  32. package/src/__tests__/logger.test.ts +115 -0
  33. package/src/__tests__/pages.test.ts +327 -0
  34. package/src/__tests__/parse.test.ts +4 -0
  35. package/src/__tests__/publish.test.ts +3400 -858
  36. package/src/__tests__/r2.test.ts +38 -26
  37. package/src/__tests__/route.test.ts +45 -0
  38. package/src/__tests__/secret.test.ts +193 -73
  39. package/src/__tests__/tail.test.ts +146 -20
  40. package/src/__tests__/user.test.ts +131 -0
  41. package/src/__tests__/whoami.test.tsx +26 -7
  42. package/src/bundle.ts +43 -7
  43. package/src/cfetch/internal.ts +9 -5
  44. package/src/cli.ts +5 -11
  45. package/src/config/README.md +7 -7
  46. package/src/config/config.ts +69 -100
  47. package/src/config/environment.ts +93 -4
  48. package/src/config/index.ts +15 -4
  49. package/src/config/validation-helpers.ts +228 -23
  50. package/src/config/validation.ts +562 -155
  51. package/src/config-cache.ts +45 -0
  52. package/src/{api/preview.ts → create-worker-preview.ts} +57 -29
  53. package/src/{api/form_data.ts → create-worker-upload-form.ts} +33 -10
  54. package/src/dev/dev-vars.ts +36 -0
  55. package/src/dev/dev.tsx +418 -0
  56. package/src/dev/local.tsx +312 -0
  57. package/src/dev/remote.tsx +213 -0
  58. package/src/dev/use-esbuild.ts +118 -0
  59. package/src/dialogs.tsx +16 -6
  60. package/src/entry.ts +222 -12
  61. package/src/environment-variables.ts +3 -1
  62. package/src/errors.ts +11 -0
  63. package/src/https-options.ts +123 -0
  64. package/src/index.tsx +1137 -766
  65. package/src/inspect.ts +25 -11
  66. package/src/intl-polyfill.d.ts +139 -0
  67. package/src/{kv.tsx → kv.ts} +97 -53
  68. package/src/logger.ts +66 -0
  69. package/src/miniflare-cli/README.md +30 -0
  70. package/src/miniflare-cli/enum-keys.ts +17 -0
  71. package/src/miniflare-cli/index.ts +41 -0
  72. package/src/miniflare-cli/request-context.ts +40 -0
  73. package/src/module-collection.ts +94 -6
  74. package/src/open-in-browser.ts +18 -5
  75. package/src/package-manager.ts +9 -8
  76. package/src/pages.tsx +892 -62
  77. package/src/parse.ts +4 -2
  78. package/src/proxy.ts +128 -55
  79. package/src/publish.ts +305 -204
  80. package/src/selfsigned.d.ts +29 -0
  81. package/src/sites.tsx +89 -37
  82. package/src/tail/index.ts +2 -2
  83. package/src/tail/printing.ts +13 -8
  84. package/src/update-check.ts +19 -0
  85. package/src/user.tsx +263 -109
  86. package/src/whoami.tsx +2 -1
  87. package/src/{api/worker.ts → worker.ts} +16 -30
  88. package/templates/gitignore +171 -0
  89. package/templates/static-asset-facade.js +1 -1
  90. package/wrangler-dist/cli.js +23800 -50736
  91. package/src/__tests__/helpers/mock-user.ts +0 -27
  92. package/src/__tests__/logout.test.ts +0 -50
  93. package/src/__tests__/sentry.test.ts +0 -146
  94. package/src/dev.tsx +0 -961
  95. package/src/guess-worker-format.ts +0 -68
  96. package/src/reporting.ts +0 -115
  97. package/wrangler-dist/cli.js.map +0 -7
@@ -1,7 +1,3 @@
1
- import { fetch } from "undici";
2
- import { previewToken } from "./preview";
3
- import type { CfPreviewToken } from "./preview";
4
-
5
1
  /**
6
2
  * A Cloudflare account.
7
3
  */
@@ -79,7 +75,7 @@ interface CfKvNamespace {
79
75
  }
80
76
 
81
77
  /**
82
- * A binding to a wasm module (in service worker format)
78
+ * A binding to a wasm module (in service-worker format)
83
79
  */
84
80
 
85
81
  interface CfWasmModuleBindings {
@@ -87,13 +83,21 @@ interface CfWasmModuleBindings {
87
83
  }
88
84
 
89
85
  /**
90
- * A binding to a text blob (in service worker format)
86
+ * A binding to a text blob (in service-worker format)
91
87
  */
92
88
 
93
89
  interface CfTextBlobBindings {
94
90
  [key: string]: string;
95
91
  }
96
92
 
93
+ /**
94
+ * A binding to a data blob (in service-worker format)
95
+ */
96
+
97
+ interface CfDataBlobBindings {
98
+ [key: string]: string;
99
+ }
100
+
97
101
  /**
98
102
  * A Durable Object.
99
103
  */
@@ -141,7 +145,7 @@ export interface CfWorkerInit {
141
145
  /**
142
146
  * The list of additional modules.
143
147
  */
144
- modules: undefined | CfModule[];
148
+ modules: CfModule[] | undefined;
145
149
  /**
146
150
  * All the bindings
147
151
  */
@@ -150,37 +154,19 @@ export interface CfWorkerInit {
150
154
  kv_namespaces: CfKvNamespace[] | undefined;
151
155
  wasm_modules: CfWasmModuleBindings | undefined;
152
156
  text_blobs: CfTextBlobBindings | undefined;
157
+ data_blobs: CfDataBlobBindings | undefined;
153
158
  durable_objects: { bindings: CfDurableObject[] } | undefined;
154
159
  r2_buckets: CfR2Bucket[] | undefined;
155
160
  unsafe: CfUnsafeBinding[] | undefined;
156
161
  };
157
- migrations: undefined | CfDurableObjectMigrations;
162
+ migrations: CfDurableObjectMigrations | undefined;
158
163
  compatibility_date: string | undefined;
159
- compatibility_flags: undefined | string[];
160
- usage_model: undefined | "bundled" | "unbound";
164
+ compatibility_flags: string[] | undefined;
165
+ usage_model: "bundled" | "unbound" | undefined;
161
166
  }
162
167
 
163
168
  export interface CfWorkerContext {
164
169
  env: string | undefined;
165
170
  legacyEnv: boolean | undefined;
166
- zone: string | undefined;
167
- }
168
-
169
- /**
170
- * A stub to create a Cloudflare Worker preview.
171
- *
172
- * @example
173
- * const {value, host} = await createWorker(init, acct);
174
- */
175
- export async function createWorker(
176
- init: CfWorkerInit,
177
- account: CfAccount,
178
- ctx: CfWorkerContext
179
- ): Promise<CfPreviewToken> {
180
- const token = await previewToken(account, init, ctx);
181
- const response = await fetch(token.prewarmUrl.href, { method: "POST" });
182
- if (!response.ok) {
183
- // console.error("worker failed to prewarm: ", response.statusText);
184
- }
185
- return token;
171
+ zone: { id: string; host: string } | undefined;
186
172
  }
@@ -0,0 +1,171 @@
1
+ # Logs
2
+
3
+ logs
4
+ _.log
5
+ npm-debug.log_
6
+ yarn-debug.log*
7
+ yarn-error.log*
8
+ lerna-debug.log*
9
+ .pnpm-debug.log*
10
+
11
+ # Diagnostic reports (https://nodejs.org/api/report.html)
12
+
13
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
14
+
15
+ # Runtime data
16
+
17
+ pids
18
+ _.pid
19
+ _.seed
20
+ \*.pid.lock
21
+
22
+ # Directory for instrumented libs generated by jscoverage/JSCover
23
+
24
+ lib-cov
25
+
26
+ # Coverage directory used by tools like istanbul
27
+
28
+ coverage
29
+ \*.lcov
30
+
31
+ # nyc test coverage
32
+
33
+ .nyc_output
34
+
35
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36
+
37
+ .grunt
38
+
39
+ # Bower dependency directory (https://bower.io/)
40
+
41
+ bower_components
42
+
43
+ # node-waf configuration
44
+
45
+ .lock-wscript
46
+
47
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
48
+
49
+ build/Release
50
+
51
+ # Dependency directories
52
+
53
+ node_modules/
54
+ jspm_packages/
55
+
56
+ # Snowpack dependency directory (https://snowpack.dev/)
57
+
58
+ web_modules/
59
+
60
+ # TypeScript cache
61
+
62
+ \*.tsbuildinfo
63
+
64
+ # Optional npm cache directory
65
+
66
+ .npm
67
+
68
+ # Optional eslint cache
69
+
70
+ .eslintcache
71
+
72
+ # Optional stylelint cache
73
+
74
+ .stylelintcache
75
+
76
+ # Microbundle cache
77
+
78
+ .rpt2_cache/
79
+ .rts2_cache_cjs/
80
+ .rts2_cache_es/
81
+ .rts2_cache_umd/
82
+
83
+ # Optional REPL history
84
+
85
+ .node_repl_history
86
+
87
+ # Output of 'npm pack'
88
+
89
+ \*.tgz
90
+
91
+ # Yarn Integrity file
92
+
93
+ .yarn-integrity
94
+
95
+ # dotenv environment variable files
96
+
97
+ .env
98
+ .env.development.local
99
+ .env.test.local
100
+ .env.production.local
101
+ .env.local
102
+
103
+ # parcel-bundler cache (https://parceljs.org/)
104
+
105
+ .cache
106
+ .parcel-cache
107
+
108
+ # Next.js build output
109
+
110
+ .next
111
+ out
112
+
113
+ # Nuxt.js build / generate output
114
+
115
+ .nuxt
116
+ dist
117
+
118
+ # Gatsby files
119
+
120
+ .cache/
121
+
122
+ # Comment in the public line in if your project uses Gatsby and not Next.js
123
+
124
+ # https://nextjs.org/blog/next-9-1#public-directory-support
125
+
126
+ # public
127
+
128
+ # vuepress build output
129
+
130
+ .vuepress/dist
131
+
132
+ # vuepress v2.x temp and cache directory
133
+
134
+ .temp
135
+ .cache
136
+
137
+ # Docusaurus cache and generated files
138
+
139
+ .docusaurus
140
+
141
+ # Serverless directories
142
+
143
+ .serverless/
144
+
145
+ # FuseBox cache
146
+
147
+ .fusebox/
148
+
149
+ # DynamoDB Local files
150
+
151
+ .dynamodb/
152
+
153
+ # TernJS port file
154
+
155
+ .tern-port
156
+
157
+ # Stores VSCode versions used for testing VSCode extensions
158
+
159
+ .vscode-test
160
+
161
+ # yarn v2
162
+
163
+ .yarn/cache
164
+ .yarn/unplugged
165
+ .yarn/build-state.yml
166
+ .yarn/install-state.gz
167
+ .pnp.\*
168
+
169
+ # wrangler project
170
+
171
+ .dev.vars
@@ -41,7 +41,7 @@ export default {
41
41
  // if an error is thrown then serve from actual worker
42
42
  return worker.fetch(request);
43
43
  // TODO: throw here if worker is not available
44
- // (which implies it may be a service worker)
44
+ // (which implies it may be a service-worker)
45
45
  }
46
46
  },
47
47
  };