wrangler 2.0.5 → 2.0.8
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.
- package/README.md +1 -1
- package/bin/wrangler.js +16 -4
- package/package.json +6 -4
- package/pages/functions/buildPlugin.ts +13 -0
- package/pages/functions/buildWorker.ts +13 -0
- package/src/__tests__/configuration.test.ts +335 -86
- package/src/__tests__/dev.test.tsx +166 -15
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +30 -16
- package/src/__tests__/init.test.ts +249 -131
- package/src/__tests__/kv.test.ts +101 -101
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +369 -39
- package/src/__tests__/parse.test.ts +5 -1
- package/src/__tests__/publish.test.ts +556 -84
- package/src/__tests__/r2.test.ts +47 -24
- package/src/__tests__/secret.test.ts +39 -4
- package/src/abort.d.ts +3 -0
- package/src/bundle.ts +32 -1
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +14 -9
- package/src/config/environment.ts +40 -14
- package/src/config/index.ts +162 -0
- package/src/config/validation.ts +179 -64
- package/src/create-worker-preview.ts +17 -7
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/dev.tsx +2 -4
- package/src/dev/local.tsx +6 -0
- package/src/dev/remote.tsx +15 -1
- package/src/dialogs.tsx +48 -0
- package/src/durable.ts +102 -0
- package/src/index.tsx +314 -144
- package/src/inspect.ts +39 -0
- package/src/kv.ts +77 -13
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +210 -65
- package/src/parse.ts +21 -4
- package/src/proxy.ts +38 -22
- package/src/publish.ts +227 -113
- package/src/sites.tsx +11 -9
- package/src/worker.ts +8 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.ts +16 -1
- package/wrangler-dist/cli.js +35466 -22362
|
@@ -7,100 +7,210 @@ const { getPackageManager, getPackageManagerName } =
|
|
|
7
7
|
jest.requireActual("../package-manager");
|
|
8
8
|
interface TestCase {
|
|
9
9
|
npm: boolean;
|
|
10
|
+
pnpm: boolean;
|
|
10
11
|
yarn: boolean;
|
|
11
12
|
npmLockFile: boolean;
|
|
12
13
|
yarnLockFile: boolean;
|
|
14
|
+
pnpmLockFile: boolean;
|
|
13
15
|
expectedPackageManager: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const testCases: TestCase[] = [
|
|
17
|
-
// npm binary
|
|
19
|
+
// npm binary only
|
|
18
20
|
{
|
|
19
21
|
npm: true,
|
|
20
22
|
yarn: false,
|
|
23
|
+
pnpm: false,
|
|
21
24
|
npmLockFile: false,
|
|
22
25
|
yarnLockFile: false,
|
|
26
|
+
pnpmLockFile: false,
|
|
23
27
|
expectedPackageManager: "npm",
|
|
24
28
|
},
|
|
25
29
|
{
|
|
26
30
|
npm: true,
|
|
27
31
|
yarn: false,
|
|
32
|
+
pnpm: false,
|
|
28
33
|
npmLockFile: true,
|
|
29
34
|
yarnLockFile: false,
|
|
35
|
+
pnpmLockFile: false,
|
|
30
36
|
expectedPackageManager: "npm",
|
|
31
37
|
},
|
|
32
38
|
{
|
|
33
39
|
npm: true,
|
|
34
40
|
yarn: false,
|
|
41
|
+
pnpm: false,
|
|
35
42
|
npmLockFile: false,
|
|
36
43
|
yarnLockFile: true,
|
|
44
|
+
pnpmLockFile: false,
|
|
37
45
|
expectedPackageManager: "npm",
|
|
38
46
|
},
|
|
39
47
|
{
|
|
40
48
|
npm: true,
|
|
41
49
|
yarn: false,
|
|
50
|
+
pnpm: false,
|
|
42
51
|
npmLockFile: true,
|
|
43
52
|
yarnLockFile: true,
|
|
53
|
+
pnpmLockFile: false,
|
|
44
54
|
expectedPackageManager: "npm",
|
|
45
55
|
},
|
|
46
56
|
|
|
47
|
-
// yarn binary
|
|
57
|
+
// yarn binary only
|
|
48
58
|
{
|
|
49
59
|
npm: false,
|
|
50
60
|
yarn: true,
|
|
61
|
+
pnpm: false,
|
|
51
62
|
npmLockFile: false,
|
|
52
63
|
yarnLockFile: false,
|
|
64
|
+
pnpmLockFile: false,
|
|
53
65
|
expectedPackageManager: "yarn",
|
|
54
66
|
},
|
|
55
67
|
{
|
|
56
68
|
npm: false,
|
|
57
69
|
yarn: true,
|
|
70
|
+
pnpm: false,
|
|
58
71
|
npmLockFile: true,
|
|
59
72
|
yarnLockFile: false,
|
|
73
|
+
pnpmLockFile: false,
|
|
60
74
|
expectedPackageManager: "yarn",
|
|
61
75
|
},
|
|
62
76
|
{
|
|
63
77
|
npm: false,
|
|
64
78
|
yarn: true,
|
|
79
|
+
pnpm: false,
|
|
65
80
|
npmLockFile: false,
|
|
66
81
|
yarnLockFile: true,
|
|
82
|
+
pnpmLockFile: false,
|
|
67
83
|
expectedPackageManager: "yarn",
|
|
68
84
|
},
|
|
69
85
|
{
|
|
70
86
|
npm: false,
|
|
71
87
|
yarn: true,
|
|
88
|
+
pnpm: false,
|
|
72
89
|
npmLockFile: true,
|
|
73
90
|
yarnLockFile: true,
|
|
91
|
+
pnpmLockFile: false,
|
|
74
92
|
expectedPackageManager: "yarn",
|
|
75
93
|
},
|
|
76
94
|
|
|
95
|
+
// pnpm binary only
|
|
96
|
+
{
|
|
97
|
+
npm: false,
|
|
98
|
+
yarn: false,
|
|
99
|
+
pnpm: true,
|
|
100
|
+
npmLockFile: false,
|
|
101
|
+
yarnLockFile: false,
|
|
102
|
+
pnpmLockFile: true,
|
|
103
|
+
expectedPackageManager: "pnpm",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
npm: false,
|
|
107
|
+
yarn: false,
|
|
108
|
+
pnpm: true,
|
|
109
|
+
npmLockFile: true,
|
|
110
|
+
yarnLockFile: false,
|
|
111
|
+
pnpmLockFile: false,
|
|
112
|
+
expectedPackageManager: "pnpm",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
npm: false,
|
|
116
|
+
yarn: false,
|
|
117
|
+
pnpm: true,
|
|
118
|
+
npmLockFile: false,
|
|
119
|
+
yarnLockFile: true,
|
|
120
|
+
pnpmLockFile: false,
|
|
121
|
+
expectedPackageManager: "pnpm",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
npm: false,
|
|
125
|
+
yarn: false,
|
|
126
|
+
pnpm: true,
|
|
127
|
+
npmLockFile: true,
|
|
128
|
+
yarnLockFile: true,
|
|
129
|
+
pnpmLockFile: true,
|
|
130
|
+
expectedPackageManager: "pnpm",
|
|
131
|
+
},
|
|
132
|
+
|
|
77
133
|
// npm and yarn binaries
|
|
78
134
|
{
|
|
79
135
|
npm: true,
|
|
80
136
|
yarn: true,
|
|
137
|
+
pnpm: false,
|
|
81
138
|
npmLockFile: false,
|
|
82
139
|
yarnLockFile: false,
|
|
140
|
+
pnpmLockFile: false,
|
|
83
141
|
expectedPackageManager: "npm",
|
|
84
142
|
},
|
|
85
143
|
{
|
|
86
144
|
npm: true,
|
|
87
145
|
yarn: true,
|
|
146
|
+
pnpm: false,
|
|
88
147
|
npmLockFile: true,
|
|
89
148
|
yarnLockFile: false,
|
|
149
|
+
pnpmLockFile: false,
|
|
90
150
|
expectedPackageManager: "npm",
|
|
91
151
|
},
|
|
92
152
|
{
|
|
93
153
|
npm: true,
|
|
94
154
|
yarn: true,
|
|
155
|
+
pnpm: false,
|
|
95
156
|
npmLockFile: false,
|
|
96
157
|
yarnLockFile: true,
|
|
158
|
+
pnpmLockFile: false,
|
|
97
159
|
expectedPackageManager: "yarn",
|
|
98
160
|
},
|
|
99
161
|
{
|
|
100
162
|
npm: true,
|
|
101
163
|
yarn: true,
|
|
164
|
+
pnpm: false,
|
|
102
165
|
npmLockFile: true,
|
|
103
166
|
yarnLockFile: true,
|
|
167
|
+
pnpmLockFile: false,
|
|
168
|
+
expectedPackageManager: "npm",
|
|
169
|
+
},
|
|
170
|
+
// npm, yarn and pnpm binaries
|
|
171
|
+
{
|
|
172
|
+
npm: true,
|
|
173
|
+
yarn: true,
|
|
174
|
+
pnpm: true,
|
|
175
|
+
npmLockFile: false,
|
|
176
|
+
yarnLockFile: false,
|
|
177
|
+
pnpmLockFile: false,
|
|
178
|
+
expectedPackageManager: "npm",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
npm: true,
|
|
182
|
+
yarn: true,
|
|
183
|
+
pnpm: true,
|
|
184
|
+
npmLockFile: true,
|
|
185
|
+
yarnLockFile: false,
|
|
186
|
+
pnpmLockFile: false,
|
|
187
|
+
expectedPackageManager: "npm",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
npm: true,
|
|
191
|
+
yarn: true,
|
|
192
|
+
pnpm: true,
|
|
193
|
+
npmLockFile: false,
|
|
194
|
+
yarnLockFile: true,
|
|
195
|
+
pnpmLockFile: false,
|
|
196
|
+
expectedPackageManager: "yarn",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
npm: true,
|
|
200
|
+
yarn: true,
|
|
201
|
+
pnpm: true,
|
|
202
|
+
npmLockFile: false,
|
|
203
|
+
yarnLockFile: false,
|
|
204
|
+
pnpmLockFile: true,
|
|
205
|
+
expectedPackageManager: "pnpm",
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
npm: true,
|
|
209
|
+
yarn: true,
|
|
210
|
+
pnpm: true,
|
|
211
|
+
npmLockFile: true,
|
|
212
|
+
yarnLockFile: true,
|
|
213
|
+
pnpmLockFile: true,
|
|
104
214
|
expectedPackageManager: "npm",
|
|
105
215
|
},
|
|
106
216
|
];
|
|
@@ -112,12 +222,13 @@ describe("getPackageManager()", () => {
|
|
|
112
222
|
describe("no supported package manager", () => {
|
|
113
223
|
mockYarn(false);
|
|
114
224
|
mockNpm(false);
|
|
225
|
+
mockPnpm(false);
|
|
115
226
|
|
|
116
227
|
it("should throw an error", async () => {
|
|
117
228
|
await expect(() =>
|
|
118
229
|
getPackageManager(process.cwd())
|
|
119
230
|
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
120
|
-
`"Unable to find a package manager. Supported managers are: npm and
|
|
231
|
+
`"Unable to find a package manager. Supported managers are: npm, yarn, and pnpm."`
|
|
121
232
|
);
|
|
122
233
|
});
|
|
123
234
|
});
|
|
@@ -125,16 +236,26 @@ describe("getPackageManager()", () => {
|
|
|
125
236
|
for (const {
|
|
126
237
|
npm,
|
|
127
238
|
yarn,
|
|
239
|
+
pnpm,
|
|
128
240
|
npmLockFile,
|
|
129
241
|
yarnLockFile,
|
|
242
|
+
pnpmLockFile,
|
|
130
243
|
expectedPackageManager,
|
|
131
244
|
} of testCases) {
|
|
132
245
|
describe(
|
|
133
|
-
getTestCaseDescription(
|
|
246
|
+
getTestCaseDescription(
|
|
247
|
+
npm,
|
|
248
|
+
yarn,
|
|
249
|
+
pnpm,
|
|
250
|
+
npmLockFile,
|
|
251
|
+
yarnLockFile,
|
|
252
|
+
pnpmLockFile
|
|
253
|
+
),
|
|
134
254
|
() => {
|
|
135
255
|
mockYarn(yarn);
|
|
136
256
|
mockNpm(npm);
|
|
137
|
-
|
|
257
|
+
mockPnpm(pnpm);
|
|
258
|
+
mockLockFiles(npmLockFile, yarnLockFile, pnpmLockFile);
|
|
138
259
|
|
|
139
260
|
it(`should return the ${expectedPackageManager} package manager`, async () => {
|
|
140
261
|
const actualPackageManager = await getPackageManager(process.cwd());
|
|
@@ -169,10 +290,25 @@ function mockNpm(succeed: boolean): void {
|
|
|
169
290
|
afterEach(() => unMock());
|
|
170
291
|
}
|
|
171
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Create a fake pnpm binary
|
|
295
|
+
*/
|
|
296
|
+
function mockPnpm(succeed: boolean): void {
|
|
297
|
+
let unMock: () => void;
|
|
298
|
+
beforeEach(async () => {
|
|
299
|
+
unMock = await mockBinary("pnpm", `process.exit(${succeed ? 0 : 1})`);
|
|
300
|
+
});
|
|
301
|
+
afterEach(() => unMock());
|
|
302
|
+
}
|
|
303
|
+
|
|
172
304
|
/**
|
|
173
305
|
* Create a fake lock files.
|
|
174
306
|
*/
|
|
175
|
-
function mockLockFiles(
|
|
307
|
+
function mockLockFiles(
|
|
308
|
+
npmLockFile: boolean,
|
|
309
|
+
yarnLockFile: boolean,
|
|
310
|
+
pnpmLockFile: boolean
|
|
311
|
+
) {
|
|
176
312
|
beforeEach(() => {
|
|
177
313
|
if (npmLockFile) {
|
|
178
314
|
writeFileSync("package-lock.json", "");
|
|
@@ -180,14 +316,19 @@ function mockLockFiles(npmLockFile: boolean, yarnLockFile: boolean) {
|
|
|
180
316
|
if (yarnLockFile) {
|
|
181
317
|
writeFileSync("yarn.lock", "");
|
|
182
318
|
}
|
|
319
|
+
if (pnpmLockFile) {
|
|
320
|
+
writeFileSync("pnpm-lock.yaml", "");
|
|
321
|
+
}
|
|
183
322
|
});
|
|
184
323
|
}
|
|
185
324
|
|
|
186
325
|
function getTestCaseDescription(
|
|
187
326
|
npm: boolean,
|
|
188
327
|
yarn: boolean,
|
|
328
|
+
pnpm: boolean,
|
|
189
329
|
npmLockFile: boolean,
|
|
190
|
-
yarnLockFile: boolean
|
|
330
|
+
yarnLockFile: boolean,
|
|
331
|
+
pnpmLockFile: boolean
|
|
191
332
|
): string {
|
|
192
333
|
const criteria: string[] = [];
|
|
193
334
|
if (npm) {
|
|
@@ -202,5 +343,11 @@ function getTestCaseDescription(
|
|
|
202
343
|
if (yarnLockFile) {
|
|
203
344
|
criteria.push("yarn.lock");
|
|
204
345
|
}
|
|
346
|
+
if (pnpm) {
|
|
347
|
+
criteria.push("pnpm");
|
|
348
|
+
}
|
|
349
|
+
if (pnpmLockFile) {
|
|
350
|
+
criteria.push("pnpm-lock.yaml");
|
|
351
|
+
}
|
|
205
352
|
return "using " + criteria.join("; ");
|
|
206
353
|
}
|