wrangler 0.0.0-e5d3690 → 0.0.0-e600f029

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 (118) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +47 -16
  3. package/bin/wrangler.js +117 -31
  4. package/kv-asset-handler.js +1 -0
  5. package/package.json +194 -127
  6. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  7. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  8. package/templates/__tests__/tsconfig.json +8 -0
  9. package/templates/checked-fetch.js +30 -0
  10. package/templates/facade.d.ts +17 -0
  11. package/templates/gitignore +172 -0
  12. package/templates/init-tests/test-jest-new-worker.js +23 -0
  13. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  14. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  15. package/templates/middleware/common.ts +67 -0
  16. package/templates/middleware/loader-modules.ts +137 -0
  17. package/templates/middleware/loader-sw.ts +228 -0
  18. package/templates/middleware/middleware-d1-beta.d.ts +3 -0
  19. package/templates/middleware/middleware-d1-beta.ts +244 -0
  20. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  21. package/templates/middleware/middleware-multiworker-dev.d.ts +4 -0
  22. package/templates/middleware/middleware-multiworker-dev.ts +59 -0
  23. package/templates/middleware/middleware-pretty-error.ts +40 -0
  24. package/templates/middleware/middleware-scheduled.ts +15 -0
  25. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  26. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  27. package/templates/new-worker-scheduled.js +17 -0
  28. package/templates/new-worker-scheduled.ts +32 -0
  29. package/templates/new-worker.js +15 -0
  30. package/templates/new-worker.ts +33 -0
  31. package/templates/no-op-worker.js +10 -0
  32. package/templates/pages-dev-pipeline.ts +31 -0
  33. package/templates/pages-dev-util.ts +55 -0
  34. package/templates/pages-shim.ts +9 -0
  35. package/templates/pages-template-plugin.ts +190 -0
  36. package/templates/pages-template-worker.ts +198 -0
  37. package/templates/tsconfig-sanity.ts +11 -0
  38. package/templates/tsconfig.init.json +105 -0
  39. package/templates/tsconfig.json +8 -0
  40. package/wrangler-dist/cli.d.ts +1732 -0
  41. package/wrangler-dist/cli.js +139889 -113990
  42. package/wrangler-dist/wasm-sync.wasm +0 -0
  43. package/import_meta_url.js +0 -3
  44. package/miniflare-config-stubs/.env.empty +0 -0
  45. package/miniflare-config-stubs/package.empty.json +0 -1
  46. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  47. package/pages/functions/buildWorker.ts +0 -62
  48. package/pages/functions/filepath-routing.test.ts +0 -39
  49. package/pages/functions/filepath-routing.ts +0 -228
  50. package/pages/functions/identifiers.ts +0 -78
  51. package/pages/functions/routes.ts +0 -158
  52. package/pages/functions/template-worker.ts +0 -136
  53. package/src/__tests__/clipboardy-mock.js +0 -4
  54. package/src/__tests__/dev.test.tsx +0 -67
  55. package/src/__tests__/index.test.ts +0 -289
  56. package/src/__tests__/jest.setup.ts +0 -22
  57. package/src/__tests__/kv.test.ts +0 -1199
  58. package/src/__tests__/mock-cfetch.ts +0 -173
  59. package/src/__tests__/mock-dialogs.ts +0 -65
  60. package/src/__tests__/publish.test.ts +0 -672
  61. package/src/__tests__/run-in-tmp.ts +0 -19
  62. package/src/__tests__/run-wrangler.ts +0 -32
  63. package/src/__tests__/whoami.test.tsx +0 -130
  64. package/src/api/form_data.ts +0 -131
  65. package/src/api/preview.ts +0 -128
  66. package/src/api/worker.ts +0 -155
  67. package/src/cfetch/index.ts +0 -110
  68. package/src/cfetch/internal.ts +0 -71
  69. package/src/cli.ts +0 -9
  70. package/src/config.ts +0 -646
  71. package/src/dev.tsx +0 -779
  72. package/src/dialogs.tsx +0 -77
  73. package/src/index.tsx +0 -1975
  74. package/src/inspect.ts +0 -543
  75. package/src/kv.tsx +0 -276
  76. package/src/module-collection.ts +0 -64
  77. package/src/pages.tsx +0 -1040
  78. package/src/proxy.ts +0 -302
  79. package/src/publish.ts +0 -382
  80. package/src/sites.tsx +0 -243
  81. package/src/tail.tsx +0 -73
  82. package/src/user.tsx +0 -1019
  83. package/src/whoami.tsx +0 -69
  84. package/static-asset-facade.js +0 -47
  85. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  86. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  87. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  88. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  89. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  90. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  91. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  92. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  93. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  94. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  95. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  96. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  97. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  98. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  99. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  100. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  101. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  102. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  103. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  104. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  105. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  106. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  107. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  108. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  109. package/vendor/wrangler-mime/LICENSE +0 -21
  110. package/vendor/wrangler-mime/Mime.js +0 -97
  111. package/vendor/wrangler-mime/README.md +0 -187
  112. package/vendor/wrangler-mime/cli.js +0 -46
  113. package/vendor/wrangler-mime/index.js +0 -4
  114. package/vendor/wrangler-mime/lite.js +0 -4
  115. package/vendor/wrangler-mime/package.json +0 -52
  116. package/vendor/wrangler-mime/types/other.js +0 -1
  117. package/vendor/wrangler-mime/types/standard.js +0 -1
  118. package/wrangler-dist/cli.js.map +0 -7
@@ -1,136 +0,0 @@
1
- import { match } from "path-to-regexp";
2
- import type { HTTPMethod } from "./routes";
3
-
4
- /* TODO: Grab these from @cloudflare/workers-types instead */
5
- type Params<P extends string = string> = Record<P, string | string[]>;
6
-
7
- type EventContext<Env, P extends string, Data> = {
8
- request: Request;
9
- waitUntil: (promise: Promise<unknown>) => void;
10
- next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
11
- env: Env & { ASSETS: { fetch: typeof fetch } };
12
- params: Params<P>;
13
- data: Data;
14
- };
15
-
16
- declare type PagesFunction<
17
- Env = unknown,
18
- P extends string = string,
19
- Data extends Record<string, unknown> = Record<string, unknown>
20
- > = (context: EventContext<Env, P, Data>) => Response | Promise<Response>;
21
- /* end @cloudflare/workers-types */
22
-
23
- type RouteHandler = {
24
- routePath: string;
25
- methods: HTTPMethod[];
26
- modules: PagesFunction[];
27
- middlewares: PagesFunction[];
28
- };
29
-
30
- // inject `routes` via ESBuild
31
- declare const routes: RouteHandler[];
32
- // define `__FALLBACK_SERVICE__` via ESBuild
33
- declare const __FALLBACK_SERVICE__: string;
34
-
35
- // expect an ASSETS fetcher binding pointing to the asset-server stage
36
- type FetchEnv = {
37
- [name: string]: { fetch: typeof fetch };
38
- ASSETS: { fetch: typeof fetch };
39
- };
40
-
41
- type WorkerContext = {
42
- waitUntil: (promise: Promise<unknown>) => void;
43
- };
44
-
45
- function* executeRequest(request: Request, _env: FetchEnv) {
46
- const requestPath = new URL(request.url).pathname;
47
-
48
- // First, iterate through the routes (backwards) and execute "middlewares" on partial route matches
49
- for (const route of [...routes].reverse()) {
50
- if (
51
- route.methods.length &&
52
- !route.methods.includes(request.method as HTTPMethod)
53
- ) {
54
- continue;
55
- }
56
-
57
- const routeMatcher = match(route.routePath, { end: false });
58
- const matchResult = routeMatcher(requestPath);
59
- if (matchResult) {
60
- for (const handler of route.middlewares.flat()) {
61
- yield {
62
- handler,
63
- params: matchResult.params as Params,
64
- };
65
- }
66
- }
67
- }
68
-
69
- // Then look for the first exact route match and execute its "modules"
70
- for (const route of routes) {
71
- if (
72
- route.methods.length &&
73
- !route.methods.includes(request.method as HTTPMethod)
74
- ) {
75
- continue;
76
- }
77
-
78
- const routeMatcher = match(route.routePath, { end: true });
79
- const matchResult = routeMatcher(requestPath);
80
- if (matchResult && route.modules.length) {
81
- for (const handler of route.modules.flat()) {
82
- yield {
83
- handler,
84
- params: matchResult.params as Params,
85
- };
86
- }
87
- break;
88
- }
89
- }
90
- }
91
-
92
- export default {
93
- async fetch(request: Request, env: FetchEnv, workerContext: WorkerContext) {
94
- const handlerIterator = executeRequest(request, env);
95
- const data = {}; // arbitrary data the user can set between functions
96
- const next = async (input?: RequestInfo, init?: RequestInit) => {
97
- if (input !== undefined) {
98
- request = new Request(input, init);
99
- }
100
-
101
- const result = handlerIterator.next();
102
- // Note we can't use `!result.done` because this doesn't narrow to the correct type
103
- if (result.done == false) {
104
- const { handler, params } = result.value;
105
- const context = {
106
- request: new Request(request.clone()),
107
- next,
108
- params,
109
- data,
110
- env,
111
- waitUntil: workerContext.waitUntil.bind(workerContext),
112
- };
113
-
114
- const response = await handler(context);
115
-
116
- // https://fetch.spec.whatwg.org/#null-body-status
117
- return new Response(
118
- [101, 204, 205, 304].includes(response.status) ? null : response.body,
119
- response
120
- );
121
- } else if (__FALLBACK_SERVICE__) {
122
- // There are no more handlers so finish with the fallback service (`env.ASSETS.fetch` in Pages' case)
123
- return env[__FALLBACK_SERVICE__].fetch(request);
124
- } else {
125
- // There was not fallback service so actually make the request to the origin.
126
- return fetch(request);
127
- }
128
- };
129
-
130
- try {
131
- return next();
132
- } catch (err) {
133
- return new Response("Internal Error", { status: 500 });
134
- }
135
- },
136
- };
@@ -1,4 +0,0 @@
1
- // We use this mock during tests because we're having trouble
2
- // properly compiling clipboardy for jest
3
- // We can revisit this if and when we write tests that test
4
- // the copying part of `dev`
@@ -1,67 +0,0 @@
1
- import { render } from "ink-testing-library";
2
- import patchConsole from "patch-console";
3
- import React from "react";
4
- import Dev from "../dev";
5
- import type { DevProps } from "../dev";
6
-
7
- describe("Dev component", () => {
8
- let restoreConsole;
9
- beforeEach(() => (restoreConsole = patchConsole(() => {})));
10
- afterEach(() => restoreConsole());
11
-
12
- it("should throw if format is service-worker and there is a public directory", () => {
13
- const { lastFrame } = renderDev({
14
- format: "service-worker",
15
- accountId: "some-account-id",
16
- public: "some/public/path",
17
- });
18
- expect(lastFrame()?.split("\n").slice(0, 2).join("\n"))
19
- .toMatchInlineSnapshot(`
20
- "Something went wrong:
21
- Error: You cannot use the service worker format with a \`public\` directory."
22
- `);
23
- });
24
- });
25
-
26
- /**
27
- * Helper function to make it easier to setup and render the `Dev` component.
28
- *
29
- * All the `Dev` props are optional here, with sensible defaults for testing.
30
- */
31
- function renderDev({
32
- name,
33
- entry = "some/entry.ts",
34
- port,
35
- format,
36
- accountId,
37
- initialMode = "remote",
38
- jsxFactory,
39
- jsxFragment,
40
- bindings = {},
41
- public: publicDir,
42
- assetPaths,
43
- compatibilityDate,
44
- compatibilityFlags,
45
- usageModel,
46
- buildCommand = {},
47
- }: Partial<DevProps>) {
48
- return render(
49
- <Dev
50
- name={name}
51
- entry={entry}
52
- port={port}
53
- buildCommand={buildCommand}
54
- format={format}
55
- initialMode={initialMode}
56
- jsxFactory={jsxFactory}
57
- jsxFragment={jsxFragment}
58
- accountId={accountId}
59
- assetPaths={assetPaths}
60
- public={publicDir}
61
- compatibilityDate={compatibilityDate}
62
- compatibilityFlags={compatibilityFlags}
63
- usageModel={usageModel}
64
- bindings={bindings}
65
- />
66
- );
67
- }
@@ -1,289 +0,0 @@
1
- import * as fsp from "node:fs/promises";
2
- import * as TOML from "@iarna/toml";
3
- import { mockConfirm } from "./mock-dialogs";
4
- import { runWrangler } from "./run-wrangler";
5
- import { runInTempDir } from "./run-in-tmp";
6
- import * as fs from "node:fs";
7
-
8
- describe("wrangler", () => {
9
- runInTempDir();
10
-
11
- describe("no command", () => {
12
- it("should display a list of available commands", async () => {
13
- const { stdout, stderr } = await runWrangler();
14
-
15
- expect(stdout).toMatchInlineSnapshot(`
16
- "wrangler
17
-
18
- Commands:
19
- wrangler init [name] 📥 Create a wrangler.toml configuration file
20
- wrangler whoami 🕵️ Retrieve your user info and test your auth config
21
- wrangler dev <filename> 👂 Start a local server for developing your worker
22
- wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
23
- wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker.
24
- wrangler secret 🤫 Generate a secret that can be referenced in the worker script
25
- wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
26
- wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
27
- wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
28
- wrangler pages ⚡️ Configure Cloudflare Pages
29
-
30
- Flags:
31
- -c, --config Path to .toml configuration file [string]
32
- -h, --help Show help [boolean]
33
- -v, --version Show version number [boolean]
34
-
35
- Options:
36
- -l, --local Run on my machine [boolean] [default: false]"
37
- `);
38
-
39
- expect(stderr).toMatchInlineSnapshot(`""`);
40
- });
41
- });
42
-
43
- describe("invalid command", () => {
44
- it("should display an error", async () => {
45
- const { error, stdout, stderr } = await runWrangler("invalid-command");
46
-
47
- expect(stdout).toMatchInlineSnapshot(`""`);
48
- expect(stderr).toMatchInlineSnapshot(`
49
- "wrangler
50
-
51
- Commands:
52
- wrangler init [name] 📥 Create a wrangler.toml configuration file
53
- wrangler whoami 🕵️ Retrieve your user info and test your auth config
54
- wrangler dev <filename> 👂 Start a local server for developing your worker
55
- wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
56
- wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker.
57
- wrangler secret 🤫 Generate a secret that can be referenced in the worker script
58
- wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
59
- wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
60
- wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
61
- wrangler pages ⚡️ Configure Cloudflare Pages
62
-
63
- Flags:
64
- -c, --config Path to .toml configuration file [string]
65
- -h, --help Show help [boolean]
66
- -v, --version Show version number [boolean]
67
-
68
- Options:
69
- -l, --local Run on my machine [boolean] [default: false]
70
-
71
- Unknown command: invalid-command."
72
- `);
73
- expect(error).toMatchInlineSnapshot(
74
- `[Error: Unknown command: invalid-command.]`
75
- );
76
- });
77
- });
78
-
79
- describe("init", () => {
80
- it("should create a wrangler.toml", async () => {
81
- mockConfirm({
82
- text: "No package.json found. Would you like to create one?",
83
- result: false,
84
- });
85
- await runWrangler("init");
86
- const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
87
- expect(typeof parsed.compatibility_date).toBe("string");
88
- expect(fs.existsSync("./package.json")).toBe(false);
89
- expect(fs.existsSync("./tsconfig.json")).toBe(false);
90
- });
91
-
92
- it("should display warning when wrangler.toml already exists, and exit if user does not want to carry on", async () => {
93
- fs.writeFileSync("./wrangler.toml", "", "utf-8");
94
- mockConfirm({
95
- text: "Do you want to continue initializing this project?",
96
- result: false,
97
- });
98
- const { warnings } = await runWrangler("init");
99
- expect(warnings).toContain("wrangler.toml file already exists!");
100
- const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
101
- expect(typeof parsed.compatibility_date).toBe("undefined");
102
- });
103
-
104
- it("should display warning when wrangler.toml already exists, but continue if user does want to carry on", async () => {
105
- fs.writeFileSync("./wrangler.toml", "", "utf-8");
106
- mockConfirm(
107
- {
108
- text: "Do you want to continue initializing this project?",
109
- result: true,
110
- },
111
- {
112
- text: "No package.json found. Would you like to create one?",
113
- result: false,
114
- }
115
- );
116
- const { warnings } = await runWrangler("init");
117
- expect(warnings).toContain("wrangler.toml file already exists!");
118
- const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
119
- expect(typeof parsed.compatibility_date).toBe("string");
120
- });
121
-
122
- it("should create a package.json if none is found and user confirms", async () => {
123
- mockConfirm(
124
- {
125
- text: "No package.json found. Would you like to create one?",
126
- result: true,
127
- },
128
- {
129
- text: "Would you like to use typescript?",
130
- result: false,
131
- }
132
- );
133
- await runWrangler("init");
134
- expect(fs.existsSync("./package.json")).toBe(true);
135
- const packageJson = JSON.parse(
136
- fs.readFileSync("./package.json", "utf-8")
137
- );
138
- expect(packageJson.name).toEqual("worker"); // TODO: should we infer the name from the directory?
139
- expect(packageJson.version).toEqual("0.0.1");
140
- expect(fs.existsSync("./tsconfig.json")).toBe(false);
141
- });
142
-
143
- it("should not touch an existing package.json in the same directory", async () => {
144
- mockConfirm({
145
- text: "Would you like to use typescript?",
146
- result: false,
147
- });
148
-
149
- fs.writeFileSync(
150
- "./package.json",
151
- JSON.stringify({ name: "test", version: "1.0.0" }),
152
- "utf-8"
153
- );
154
-
155
- await runWrangler("init");
156
- const packageJson = JSON.parse(
157
- fs.readFileSync("./package.json", "utf-8")
158
- );
159
- expect(packageJson.name).toEqual("test");
160
- expect(packageJson.version).toEqual("1.0.0");
161
- });
162
-
163
- it("should not touch an existing package.json in an ancestor directory", async () => {
164
- mockConfirm({
165
- text: "Would you like to use typescript?",
166
- result: false,
167
- });
168
-
169
- fs.writeFileSync(
170
- "./package.json",
171
- JSON.stringify({ name: "test", version: "1.0.0" }),
172
- "utf-8"
173
- );
174
-
175
- fs.mkdirSync("./sub-1/sub-2", { recursive: true });
176
- process.chdir("./sub-1/sub-2");
177
-
178
- await runWrangler("init");
179
- expect(fs.existsSync("./package.json")).toBe(false);
180
- expect(fs.existsSync("../../package.json")).toBe(true);
181
-
182
- const packageJson = JSON.parse(
183
- fs.readFileSync("../../package.json", "utf-8")
184
- );
185
- expect(packageJson.name).toEqual("test");
186
- expect(packageJson.version).toEqual("1.0.0");
187
- });
188
-
189
- it("should create a tsconfig.json and install `workers-types` if none is found and user confirms", async () => {
190
- mockConfirm(
191
- {
192
- text: "No package.json found. Would you like to create one?",
193
- result: true,
194
- },
195
- {
196
- text: "Would you like to use typescript?",
197
- result: true,
198
- }
199
- );
200
- await runWrangler("init");
201
- expect(fs.existsSync("./tsconfig.json")).toBe(true);
202
- const tsconfigJson = JSON.parse(
203
- fs.readFileSync("./tsconfig.json", "utf-8")
204
- );
205
- expect(tsconfigJson.compilerOptions.types).toEqual([
206
- "@cloudflare/workers-types",
207
- ]);
208
- const packageJson = JSON.parse(
209
- fs.readFileSync("./package.json", "utf-8")
210
- );
211
- expect(packageJson.devDependencies).toEqual({
212
- "@cloudflare/workers-types": expect.any(String),
213
- });
214
- });
215
-
216
- it("should not touch an existing tsconfig.json in the same directory", async () => {
217
- fs.writeFileSync(
218
- "./package.json",
219
- JSON.stringify({ name: "test", version: "1.0.0" }),
220
- "utf-8"
221
- );
222
- fs.writeFileSync(
223
- "./tsconfig.json",
224
- JSON.stringify({ compilerOptions: {} }),
225
- "utf-8"
226
- );
227
-
228
- await runWrangler("init");
229
- const tsconfigJson = JSON.parse(
230
- fs.readFileSync("./tsconfig.json", "utf-8")
231
- );
232
- expect(tsconfigJson.compilerOptions).toEqual({});
233
- });
234
-
235
- it("should not touch an existing package.json in an ancestor directory", async () => {
236
- fs.writeFileSync(
237
- "./package.json",
238
- JSON.stringify({ name: "test", version: "1.0.0" }),
239
- "utf-8"
240
- );
241
- fs.writeFileSync(
242
- "./tsconfig.json",
243
- JSON.stringify({ compilerOptions: {} }),
244
- "utf-8"
245
- );
246
-
247
- fs.mkdirSync("./sub-1/sub-2", { recursive: true });
248
- process.chdir("./sub-1/sub-2");
249
-
250
- await runWrangler("init");
251
- expect(fs.existsSync("./tsconfig.json")).toBe(false);
252
- expect(fs.existsSync("../../tsconfig.json")).toBe(true);
253
-
254
- const tsconfigJson = JSON.parse(
255
- fs.readFileSync("../../tsconfig.json", "utf-8")
256
- );
257
- expect(tsconfigJson.compilerOptions).toEqual({});
258
- });
259
-
260
- it("should error if `--type` is used", async () => {
261
- const { error } = await runWrangler("init --type");
262
- expect(error).toMatchInlineSnapshot(
263
- `[Error: The --type option is no longer supported.]`
264
- );
265
- });
266
-
267
- it("should error if `--type javascript` is used", async () => {
268
- const { error } = await runWrangler("init --type javascript");
269
- expect(error).toMatchInlineSnapshot(
270
- `[Error: The --type option is no longer supported.]`
271
- );
272
- });
273
-
274
- it("should error if `--type rust` is used", async () => {
275
- const { error } = await runWrangler("init --type rust");
276
- expect(error).toMatchInlineSnapshot(
277
- `[Error: The --type option is no longer supported.]`
278
- );
279
- });
280
-
281
- it("should error if `--type webpack` is used", async () => {
282
- const { error } = await runWrangler("init --type webpack");
283
- expect(error).toMatchInlineSnapshot(`
284
- [Error: The --type option is no longer supported.
285
- If you wish to use webpack then you will need to create a custom build.]
286
- `);
287
- });
288
- });
289
- });
@@ -1,22 +0,0 @@
1
- import { mockFetchInternal } from "./mock-cfetch";
2
- import { confirm, prompt } from "../dialogs";
3
- import { fetchInternal } from "../cfetch/internal";
4
-
5
- jest.mock("../cfetch/internal");
6
- (fetchInternal as jest.Mock).mockImplementation(mockFetchInternal);
7
-
8
- jest.mock("../dialogs");
9
-
10
- // By default (if not configured by mockConfirm()) calls to `confirm()` should throw.
11
- (confirm as jest.Mock).mockImplementation(() => {
12
- throw new Error(
13
- "Unexpected call to `confirm()`. You should use `mockConfirm()` to mock calls to `confirm()` with expectations. Search the codebase for `mockConfirm` to learn more."
14
- );
15
- });
16
-
17
- // By default (if not configured by mockPrompt()) calls to `prompt()` should throw.
18
- (prompt as jest.Mock).mockImplementation(() => {
19
- throw new Error(
20
- "Unexpected call to `prompt()`. You should use `mockPrompt()` to mock calls to `prompt()` with expectations. Search the codebase for `mockPrompt` to learn more."
21
- );
22
- });