wrangler 2.4.4 → 2.6.0
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/bin/wrangler.js +20 -8
- package/miniflare-dist/index.mjs +90 -41
- package/package.json +3 -3
- package/src/__tests__/configuration.test.ts +211 -0
- package/src/__tests__/delete.test.ts +81 -48
- package/src/__tests__/dev.test.tsx +25 -8
- package/src/__tests__/helpers/mock-oauth-flow.ts +5 -1
- package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
- package/src/__tests__/init.test.ts +18 -3
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +88 -43
- package/src/__tests__/pages-deployment-tail.test.ts +165 -101
- package/src/__tests__/publish.test.ts +94 -7
- package/src/__tests__/pubsub.test.ts +208 -88
- package/src/__tests__/queues.test.ts +155 -67
- package/src/__tests__/tail.test.ts +207 -108
- package/src/__tests__/type-generation.test.ts +7 -0
- package/src/__tests__/user.test.ts +43 -69
- package/src/config/environment.ts +16 -0
- package/src/config/index.ts +31 -8
- package/src/config/validation.ts +49 -0
- package/src/create-worker-upload-form.ts +9 -0
- package/src/d1/backups.tsx +7 -2
- package/src/d1/delete.tsx +4 -4
- package/src/d1/index.ts +2 -0
- package/src/d1/migrations/apply.tsx +6 -5
- package/src/d1/migrations/helpers.ts +4 -2
- package/src/d1/migrations/list.tsx +2 -2
- package/src/d1/migrations/options.ts +18 -0
- package/src/dev/dev.tsx +46 -22
- package/src/dev/local.tsx +63 -29
- package/src/dev/start-server.ts +18 -21
- package/src/dev.tsx +33 -13
- package/src/git-client.ts +15 -4
- package/src/index.tsx +1 -0
- package/src/init.ts +8 -0
- package/src/miniflare-cli/assets.ts +55 -28
- package/src/miniflare-cli/index.ts +2 -1
- package/src/pages/dev.tsx +7 -0
- package/src/proxy.ts +5 -0
- package/src/publish/publish.ts +1 -0
- package/src/secret/index.ts +1 -0
- package/src/type-generation.ts +10 -2
- package/src/worker.ts +6 -0
- package/wrangler-dist/cli.d.ts +15 -0
- package/wrangler-dist/cli.js +2045 -636
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { rest } from "msw";
|
|
1
2
|
import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
2
|
-
import { setMockResponse, unsetAllMocks } from "./helpers/mock-cfetch";
|
|
3
3
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
4
|
+
import { msw } from "./helpers/msw";
|
|
4
5
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
5
6
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
6
7
|
import type {
|
|
@@ -16,10 +17,6 @@ describe("wrangler", () => {
|
|
|
16
17
|
runInTempDir();
|
|
17
18
|
const std = mockConsoleMethods();
|
|
18
19
|
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
unsetAllMocks();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
20
|
describe("pubsub", () => {
|
|
24
21
|
describe("help menu", () => {
|
|
25
22
|
it("shows usage details", async () => {
|
|
@@ -83,15 +80,30 @@ describe("wrangler", () => {
|
|
|
83
80
|
describe("create", () => {
|
|
84
81
|
function mockCreateRequest(expectedNamespaceName: string) {
|
|
85
82
|
const requests = { count: 0 };
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
83
|
+
msw.use(
|
|
84
|
+
rest.post(
|
|
85
|
+
"*/accounts/:accountId/pubsub/namespaces",
|
|
86
|
+
async (req, res, ctx) => {
|
|
87
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
88
|
+
const namespace = await req.json();
|
|
89
|
+
expect(namespace.name).toEqual(expectedNamespaceName);
|
|
90
|
+
requests.count++;
|
|
91
|
+
return res.once(
|
|
92
|
+
ctx.status(200),
|
|
93
|
+
ctx.json({
|
|
94
|
+
success: true,
|
|
95
|
+
errors: [],
|
|
96
|
+
messages: [],
|
|
97
|
+
result: {
|
|
98
|
+
id: "some-namespace-id",
|
|
99
|
+
name: namespace.name,
|
|
100
|
+
created_at: "3005-01-01T00:00:00.000000Z",
|
|
101
|
+
updated_at: "3005-01-01T00:00:00.000000Z",
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
)
|
|
95
107
|
);
|
|
96
108
|
return requests;
|
|
97
109
|
}
|
|
@@ -107,14 +119,24 @@ describe("wrangler", () => {
|
|
|
107
119
|
describe("list", () => {
|
|
108
120
|
function mockListRequest(namespaces: PubSubNamespace[]) {
|
|
109
121
|
const requests = { count: 0 };
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
msw.use(
|
|
123
|
+
rest.get(
|
|
124
|
+
"*/accounts/:accountId/pubsub/namespaces",
|
|
125
|
+
async (req, res, ctx) => {
|
|
126
|
+
requests.count++;
|
|
127
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
128
|
+
|
|
129
|
+
return res.once(
|
|
130
|
+
ctx.status(200),
|
|
131
|
+
ctx.json({
|
|
132
|
+
success: true,
|
|
133
|
+
errors: [],
|
|
134
|
+
messages: [],
|
|
135
|
+
result: namespaces,
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
)
|
|
118
140
|
);
|
|
119
141
|
return requests;
|
|
120
142
|
}
|
|
@@ -128,7 +150,12 @@ describe("wrangler", () => {
|
|
|
128
150
|
await runWrangler("pubsub namespace list");
|
|
129
151
|
|
|
130
152
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
131
|
-
|
|
153
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
154
|
+
"[
|
|
155
|
+
{ name: 'namespace-1', created_on: '01-01-2001' },
|
|
156
|
+
{ name: 'namespace-2', created_on: '01-01-2001' }
|
|
157
|
+
]"
|
|
158
|
+
`);
|
|
132
159
|
expect(requests.count).toEqual(1);
|
|
133
160
|
});
|
|
134
161
|
});
|
|
@@ -174,16 +201,29 @@ describe("wrangler", () => {
|
|
|
174
201
|
describe("create", () => {
|
|
175
202
|
function mockCreateRequest(expectedBrokerName: string) {
|
|
176
203
|
const requests = { count: 0 };
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
204
|
+
msw.use(
|
|
205
|
+
rest.post(
|
|
206
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers",
|
|
207
|
+
async (req, res, ctx) => {
|
|
208
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
209
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
210
|
+
const broker = await req.json();
|
|
211
|
+
expect(broker.name).toEqual(expectedBrokerName);
|
|
212
|
+
requests.count++;
|
|
213
|
+
return res.once(
|
|
214
|
+
ctx.status(200),
|
|
215
|
+
ctx.json({
|
|
216
|
+
success: true,
|
|
217
|
+
errors: [],
|
|
218
|
+
messages: [],
|
|
219
|
+
result: {
|
|
220
|
+
name: expectedBrokerName,
|
|
221
|
+
created_on: "01-01-2001",
|
|
222
|
+
},
|
|
223
|
+
})
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
)
|
|
187
227
|
);
|
|
188
228
|
return requests;
|
|
189
229
|
}
|
|
@@ -194,7 +234,10 @@ describe("wrangler", () => {
|
|
|
194
234
|
"pubsub broker create my-broker --namespace=some-namespace"
|
|
195
235
|
);
|
|
196
236
|
|
|
197
|
-
|
|
237
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
238
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
239
|
+
`"{ name: 'my-broker', created_on: '01-01-2001' }"`
|
|
240
|
+
);
|
|
198
241
|
expect(requests.count).toEqual(1);
|
|
199
242
|
});
|
|
200
243
|
|
|
@@ -215,21 +258,34 @@ describe("wrangler", () => {
|
|
|
215
258
|
expectedOnPublishConfig: PubSubBrokerOnPublish
|
|
216
259
|
) {
|
|
217
260
|
const requests = { count: 0 };
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
261
|
+
msw.use(
|
|
262
|
+
rest.patch(
|
|
263
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName",
|
|
264
|
+
async (req, res, cxt) => {
|
|
265
|
+
requests.count += 1;
|
|
266
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
267
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
268
|
+
expect(req.params.brokerName).toEqual(expectedBrokerName);
|
|
269
|
+
|
|
270
|
+
const patchBody: PubSubBrokerUpdate = await req.json();
|
|
271
|
+
|
|
272
|
+
expect(patchBody.expiration).toEqual(expectedExpiration);
|
|
273
|
+
expect(patchBody.description).toEqual(expectedDescription);
|
|
274
|
+
expect(patchBody.on_publish).toEqual(expectedOnPublishConfig);
|
|
275
|
+
return res.once(
|
|
276
|
+
cxt.status(200),
|
|
277
|
+
cxt.json({
|
|
278
|
+
success: true,
|
|
279
|
+
errors: [],
|
|
280
|
+
messages: [],
|
|
281
|
+
result: {
|
|
282
|
+
name: expectedBrokerName,
|
|
283
|
+
created_on: "01-01-2001",
|
|
284
|
+
},
|
|
285
|
+
})
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
)
|
|
233
289
|
);
|
|
234
290
|
return requests;
|
|
235
291
|
}
|
|
@@ -249,7 +305,10 @@ describe("wrangler", () => {
|
|
|
249
305
|
);
|
|
250
306
|
|
|
251
307
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
252
|
-
|
|
308
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
309
|
+
"{ name: 'my-broker', created_on: '01-01-2001' }
|
|
310
|
+
Successfully updated Pub/Sub Broker my-broker"
|
|
311
|
+
`);
|
|
253
312
|
expect(requests.count).toEqual(1);
|
|
254
313
|
});
|
|
255
314
|
});
|
|
@@ -257,15 +316,24 @@ describe("wrangler", () => {
|
|
|
257
316
|
describe("list", () => {
|
|
258
317
|
function mockListRequest(brokers: PubSubBroker[]) {
|
|
259
318
|
const requests = { count: 0 };
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
319
|
+
msw.use(
|
|
320
|
+
rest.get(
|
|
321
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers",
|
|
322
|
+
async (req, res, cxt) => {
|
|
323
|
+
requests.count++;
|
|
324
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
325
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
326
|
+
return res.once(
|
|
327
|
+
cxt.status(200),
|
|
328
|
+
cxt.json({
|
|
329
|
+
success: true,
|
|
330
|
+
errors: [],
|
|
331
|
+
messages: [],
|
|
332
|
+
result: brokers,
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
)
|
|
269
337
|
);
|
|
270
338
|
return requests;
|
|
271
339
|
}
|
|
@@ -279,7 +347,12 @@ describe("wrangler", () => {
|
|
|
279
347
|
await runWrangler("pubsub broker list --namespace=some-namespace");
|
|
280
348
|
|
|
281
349
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
282
|
-
|
|
350
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
351
|
+
"[
|
|
352
|
+
{ name: 'broker-1', created_on: '01-01-2001' },
|
|
353
|
+
{ name: 'broker-2', created_on: '01-01-2001' }
|
|
354
|
+
]"
|
|
355
|
+
`);
|
|
283
356
|
expect(requests.count).toEqual(1);
|
|
284
357
|
});
|
|
285
358
|
});
|
|
@@ -287,15 +360,25 @@ describe("wrangler", () => {
|
|
|
287
360
|
describe("describe", () => {
|
|
288
361
|
function mockGetRequest(broker: PubSubBroker) {
|
|
289
362
|
const requests = { count: 0 };
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
363
|
+
msw.use(
|
|
364
|
+
rest.get(
|
|
365
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName",
|
|
366
|
+
(req, res, cxt) => {
|
|
367
|
+
requests.count++;
|
|
368
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
369
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
370
|
+
expect(req.params.brokerName).toEqual(broker.name);
|
|
371
|
+
return res.once(
|
|
372
|
+
cxt.status(200),
|
|
373
|
+
cxt.json({
|
|
374
|
+
success: true,
|
|
375
|
+
errors: [],
|
|
376
|
+
messages: [],
|
|
377
|
+
result: broker,
|
|
378
|
+
})
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
)
|
|
299
382
|
);
|
|
300
383
|
return requests;
|
|
301
384
|
}
|
|
@@ -307,7 +390,9 @@ describe("wrangler", () => {
|
|
|
307
390
|
);
|
|
308
391
|
|
|
309
392
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
310
|
-
|
|
393
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
394
|
+
`"{ id: '1234', name: 'my-broker' }"`
|
|
395
|
+
);
|
|
311
396
|
expect(requests.count).toEqual(1);
|
|
312
397
|
});
|
|
313
398
|
});
|
|
@@ -315,14 +400,28 @@ describe("wrangler", () => {
|
|
|
315
400
|
describe("issue", () => {
|
|
316
401
|
function mockIssueRequest(expectedBrokerName: string) {
|
|
317
402
|
const requests = { count: 0 };
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
403
|
+
msw.use(
|
|
404
|
+
rest.get(
|
|
405
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName/credentials",
|
|
406
|
+
(req, res, cxt) => {
|
|
407
|
+
requests.count++;
|
|
408
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
409
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
410
|
+
expect(req.params.brokerName).toEqual(expectedBrokerName);
|
|
411
|
+
return res.once(
|
|
412
|
+
cxt.status(200),
|
|
413
|
+
cxt.json({
|
|
414
|
+
success: true,
|
|
415
|
+
errors: [],
|
|
416
|
+
messages: [],
|
|
417
|
+
result: {
|
|
418
|
+
"MOCK-89T6DXG3SVG1WQRA": `<base-64-encoded-JWT>`,
|
|
419
|
+
"MOCK-393REE4WRRE4NHAV96": `<base-64-encoded-JWT>`,
|
|
420
|
+
},
|
|
421
|
+
})
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
)
|
|
326
425
|
);
|
|
327
426
|
return requests;
|
|
328
427
|
}
|
|
@@ -334,7 +433,13 @@ describe("wrangler", () => {
|
|
|
334
433
|
);
|
|
335
434
|
|
|
336
435
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
337
|
-
|
|
436
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
437
|
+
"🔑 Issuing credential(s) for my-broker.some-namespace...
|
|
438
|
+
{
|
|
439
|
+
'MOCK-89T6DXG3SVG1WQRA': '<base-64-encoded-JWT>',
|
|
440
|
+
'MOCK-393REE4WRRE4NHAV96': '<base-64-encoded-JWT>'
|
|
441
|
+
}"
|
|
442
|
+
`);
|
|
338
443
|
expect(requests.count).toEqual(1);
|
|
339
444
|
});
|
|
340
445
|
});
|
|
@@ -342,14 +447,27 @@ describe("wrangler", () => {
|
|
|
342
447
|
describe("public-keys", () => {
|
|
343
448
|
function mockIssueRequest(expectedBrokerName: string) {
|
|
344
449
|
const requests = { count: 0 };
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
450
|
+
msw.use(
|
|
451
|
+
rest.get(
|
|
452
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName/publickeys",
|
|
453
|
+
(req, res, cxt) => {
|
|
454
|
+
requests.count++;
|
|
455
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
456
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
457
|
+
expect(req.params.brokerName).toEqual(expectedBrokerName);
|
|
458
|
+
return res.once(
|
|
459
|
+
cxt.status(200),
|
|
460
|
+
cxt.json({
|
|
461
|
+
success: true,
|
|
462
|
+
errors: [],
|
|
463
|
+
messages: [],
|
|
464
|
+
result: {
|
|
465
|
+
public_keys: "Mock-Public-Key",
|
|
466
|
+
},
|
|
467
|
+
})
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
)
|
|
353
471
|
);
|
|
354
472
|
return requests;
|
|
355
473
|
}
|
|
@@ -361,7 +479,9 @@ describe("wrangler", () => {
|
|
|
361
479
|
);
|
|
362
480
|
|
|
363
481
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
364
|
-
|
|
482
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
483
|
+
`"{ public_keys: 'Mock-Public-Key' }"`
|
|
484
|
+
);
|
|
365
485
|
expect(requests.count).toEqual(1);
|
|
366
486
|
});
|
|
367
487
|
});
|