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/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 cfetch<TailApiResponse>(createTailUrl, { method: "POST" });
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 cfetch(deleteUrl, { method: "DELETE" });
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
- // abd we should fiure out how to do top level await
301
+ // and we should figure out how to do top level await
302
302
  export async function initialise(): Promise<void> {
303
- // get refreshtoken/accesstoken from fs if exists
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
- return LocalState.accessToken?.value;
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
- if (!response) return;
976
- let accountId: string;
977
- // @ts-expect-error need to type this response
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
- } = await response.json();
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
- <SelectInput
1014
- items={props.accounts.map((item) => ({
1015
- key: item.id,
1016
- label: item.name,
1017
- value: item,
1018
- }))}
1019
- onSelect={props.onSelect}
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
  }