wrangler 0.0.0-e9a1820 → 0.0.0-e9ab55a
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/package.json +12 -5
- package/pages/functions/buildWorker.ts +62 -0
- package/pages/functions/filepath-routing.test.ts +39 -0
- package/pages/functions/filepath-routing.ts +228 -0
- package/pages/functions/identifiers.ts +78 -0
- package/pages/functions/routes.ts +158 -0
- package/pages/functions/template-worker.ts +136 -0
- package/src/__tests__/dev.test.tsx +67 -0
- package/src/__tests__/jest.setup.ts +5 -1
- package/src/__tests__/kv.test.ts +849 -45
- package/src/__tests__/mock-cfetch.ts +137 -29
- package/src/__tests__/publish.test.ts +102 -0
- package/src/api/form_data.ts +1 -1
- package/src/api/preview.ts +4 -4
- package/src/api/worker.ts +6 -6
- package/src/cfetch/index.ts +102 -0
- package/src/cfetch/internal.ts +69 -0
- package/src/config.ts +633 -118
- package/src/dev.tsx +114 -209
- package/src/index.tsx +265 -239
- package/src/inspect.ts +543 -0
- package/src/kv.tsx +49 -30
- package/src/pages.tsx +431 -242
- package/src/proxy.ts +275 -76
- package/src/publish.ts +79 -47
- package/src/sites.tsx +10 -7
- package/src/tail.tsx +5 -3
- package/src/user.tsx +22 -17
- package/wrangler-dist/cli.js +42319 -36190
- package/wrangler-dist/cli.js.map +3 -3
- package/src/api/inspect.ts +0 -430
- package/src/cfetch.ts +0 -72
package/src/tail.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from "ws";
|
|
2
|
-
import cfetch from "./cfetch";
|
|
3
2
|
import { version as packageVersion } from "../package.json";
|
|
3
|
+
import { fetchResult } from "./cfetch";
|
|
4
4
|
|
|
5
5
|
export type TailApiResponse = {
|
|
6
6
|
id: string;
|
|
@@ -27,7 +27,9 @@ async function createTailButDontConnect(
|
|
|
27
27
|
): Promise<TailApiResponse> {
|
|
28
28
|
const createTailUrl = makeCreateTailUrl(accountId, workerName);
|
|
29
29
|
/// https://api.cloudflare.com/#worker-tail-logs-start-tail
|
|
30
|
-
return await
|
|
30
|
+
return await fetchResult<TailApiResponse>(createTailUrl, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
});
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export async function createTail(
|
|
@@ -48,7 +50,7 @@ export async function createTail(
|
|
|
48
50
|
|
|
49
51
|
// deletes the tail
|
|
50
52
|
async function deleteTail() {
|
|
51
|
-
await
|
|
53
|
+
await fetchResult(deleteUrl, { method: "DELETE" });
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
const tail = new WebSocket(websocketUrl, "trace-v1", {
|
package/src/user.tsx
CHANGED
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
*/
|
|
207
207
|
|
|
208
208
|
import React from "react";
|
|
209
|
-
import { render } from "ink";
|
|
209
|
+
import { render, Text } from "ink";
|
|
210
210
|
import Table from "ink-table";
|
|
211
211
|
import SelectInput from "ink-select-input";
|
|
212
212
|
import fetch from "node-fetch";
|
|
@@ -298,9 +298,9 @@ let initialised = false;
|
|
|
298
298
|
|
|
299
299
|
// we do this because we have some async stuff
|
|
300
300
|
// TODO: this should just happen in the top level
|
|
301
|
-
//
|
|
301
|
+
// and we should figure out how to do top level await
|
|
302
302
|
export async function initialise(): Promise<void> {
|
|
303
|
-
// get
|
|
303
|
+
// get refreshToken/accessToken from fs if exists
|
|
304
304
|
try {
|
|
305
305
|
// if CF_API_TOKEN available, use that
|
|
306
306
|
if (process.env.CF_API_TOKEN) {
|
|
@@ -350,7 +350,9 @@ export function getAPIToken(): string {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
throwIfNotInitialised();
|
|
353
|
-
|
|
353
|
+
// `throwIfNotInitialised()` ensures that the accessToken is guaranteed to be defined.
|
|
354
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
355
|
+
return LocalState.accessToken!.value;
|
|
354
356
|
}
|
|
355
357
|
|
|
356
358
|
interface AccessContext {
|
|
@@ -971,14 +973,14 @@ export async function getAccountId() {
|
|
|
971
973
|
});
|
|
972
974
|
} catch (err) {
|
|
973
975
|
// probably offline
|
|
976
|
+
return;
|
|
974
977
|
}
|
|
975
|
-
|
|
976
|
-
let accountId: string;
|
|
977
|
-
|
|
978
|
-
const responseJSON: {
|
|
978
|
+
|
|
979
|
+
let accountId: string | undefined;
|
|
980
|
+
const responseJSON = (await response.json()) as {
|
|
979
981
|
success: boolean;
|
|
980
982
|
result: { id: string; account: { id: string; name: string } }[];
|
|
981
|
-
}
|
|
983
|
+
};
|
|
982
984
|
|
|
983
985
|
if (responseJSON.success === true) {
|
|
984
986
|
if (responseJSON.result.length === 1) {
|
|
@@ -1010,13 +1012,16 @@ export function ChooseAccount(props: {
|
|
|
1010
1012
|
onSelect: (item) => void;
|
|
1011
1013
|
}) {
|
|
1012
1014
|
return (
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1015
|
+
<>
|
|
1016
|
+
<Text bold>Select an account from below:</Text>
|
|
1017
|
+
<SelectInput
|
|
1018
|
+
items={props.accounts.map((item) => ({
|
|
1019
|
+
key: item.id,
|
|
1020
|
+
label: item.name,
|
|
1021
|
+
value: item,
|
|
1022
|
+
}))}
|
|
1023
|
+
onSelect={props.onSelect}
|
|
1024
|
+
/>
|
|
1025
|
+
</>
|
|
1021
1026
|
);
|
|
1022
1027
|
}
|