wrangler 2.0.6 → 2.0.9
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 +132 -60
- package/src/__tests__/dev.test.tsx +168 -67
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +25 -10
- package/src/__tests__/init.test.ts +252 -131
- package/src/__tests__/kv.test.ts +16 -16
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +442 -38
- package/src/__tests__/parse.test.ts +5 -1
- package/src/__tests__/publish.test.ts +377 -84
- package/src/__tests__/secret.test.ts +4 -4
- package/src/__tests__/whoami.test.tsx +34 -0
- package/src/abort.d.ts +3 -0
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +20 -18
- package/src/config/config.ts +1 -1
- package/src/config/index.ts +162 -0
- package/src/config/validation.ts +77 -29
- package/src/create-worker-preview.ts +32 -22
- package/src/dev/dev.tsx +6 -16
- package/src/dev/remote.tsx +40 -16
- package/src/dialogs.tsx +48 -0
- package/src/durable.ts +102 -0
- package/src/index.tsx +291 -207
- package/src/inspect.ts +39 -0
- package/src/kv.ts +74 -25
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +218 -61
- package/src/parse.ts +21 -4
- package/src/proxy.ts +38 -22
- package/src/publish.ts +166 -108
- package/src/sites.tsx +8 -8
- package/src/user.tsx +12 -1
- package/src/whoami.tsx +3 -2
- package/src/worker.ts +2 -1
- package/src/zones.ts +73 -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 +33066 -20052
package/src/__tests__/kv.test.ts
CHANGED
|
@@ -663,7 +663,7 @@ describe("wrangler", () => {
|
|
|
663
663
|
|
|
664
664
|
expect(std.out).toMatchInlineSnapshot(`
|
|
665
665
|
"
|
|
666
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
666
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
667
667
|
`);
|
|
668
668
|
expect(std.err).toMatchInlineSnapshot(`
|
|
669
669
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mA namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".[0m
|
|
@@ -685,7 +685,7 @@ describe("wrangler", () => {
|
|
|
685
685
|
);
|
|
686
686
|
expect(std.out).toMatchInlineSnapshot(`
|
|
687
687
|
"
|
|
688
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
688
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
689
689
|
`);
|
|
690
690
|
expect(std.err).toMatchInlineSnapshot(`
|
|
691
691
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1msomeBinding has both a namespace ID and a preview ID. Specify \\"--preview\\" or \\"--preview false\\" to avoid writing data to the wrong namespace.[0m
|
|
@@ -856,7 +856,7 @@ describe("wrangler", () => {
|
|
|
856
856
|
`);
|
|
857
857
|
expect(std.out).toMatchInlineSnapshot(`
|
|
858
858
|
"
|
|
859
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
859
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
860
860
|
`);
|
|
861
861
|
});
|
|
862
862
|
});
|
|
@@ -1044,7 +1044,7 @@ describe("wrangler", () => {
|
|
|
1044
1044
|
);
|
|
1045
1045
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1046
1046
|
"
|
|
1047
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1047
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1048
1048
|
`);
|
|
1049
1049
|
expect(std.err).toMatchInlineSnapshot(`
|
|
1050
1050
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mA namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".[0m
|
|
@@ -1205,10 +1205,10 @@ describe("wrangler", () => {
|
|
|
1205
1205
|
);
|
|
1206
1206
|
expect(requests.count).toEqual(3);
|
|
1207
1207
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1208
|
-
"Uploaded 0 of
|
|
1209
|
-
Uploaded
|
|
1210
|
-
Uploaded
|
|
1211
|
-
Uploaded
|
|
1208
|
+
"Uploaded 0% (0 out of 12,000)
|
|
1209
|
+
Uploaded 41% (5,000 out of 12,000)
|
|
1210
|
+
Uploaded 83% (10,000 out of 12,000)
|
|
1211
|
+
Uploaded 100% (12,000 out of 12,000)
|
|
1212
1212
|
Success!"
|
|
1213
1213
|
`);
|
|
1214
1214
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -1226,7 +1226,7 @@ describe("wrangler", () => {
|
|
|
1226
1226
|
`);
|
|
1227
1227
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1228
1228
|
"
|
|
1229
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1229
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1230
1230
|
`);
|
|
1231
1231
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1232
1232
|
});
|
|
@@ -1288,7 +1288,7 @@ describe("wrangler", () => {
|
|
|
1288
1288
|
|
|
1289
1289
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1290
1290
|
"
|
|
1291
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1291
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1292
1292
|
`);
|
|
1293
1293
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
1294
1294
|
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mUnexpected key-value properties in \\"keys.json\\".[0m
|
|
@@ -1358,10 +1358,10 @@ describe("wrangler", () => {
|
|
|
1358
1358
|
);
|
|
1359
1359
|
expect(requests.count).toEqual(3);
|
|
1360
1360
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1361
|
-
"Deleted 0 of
|
|
1362
|
-
Deleted
|
|
1363
|
-
Deleted
|
|
1364
|
-
Deleted
|
|
1361
|
+
"Deleted 0% (0 out of 12,000)
|
|
1362
|
+
Deleted 41% (5,000 out of 12,000)
|
|
1363
|
+
Deleted 83% (10,000 out of 12,000)
|
|
1364
|
+
Deleted 100% (12,000 out of 12,000)
|
|
1365
1365
|
Success!"
|
|
1366
1366
|
`);
|
|
1367
1367
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -1429,7 +1429,7 @@ describe("wrangler", () => {
|
|
|
1429
1429
|
`);
|
|
1430
1430
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1431
1431
|
"
|
|
1432
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1432
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1433
1433
|
`);
|
|
1434
1434
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1435
1435
|
});
|
|
@@ -1454,7 +1454,7 @@ describe("wrangler", () => {
|
|
|
1454
1454
|
`);
|
|
1455
1455
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1456
1456
|
"
|
|
1457
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1457
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1458
1458
|
`);
|
|
1459
1459
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1460
1460
|
});
|
|
@@ -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
|
}
|