wrangler 0.0.0-ea7ee45 → 0.0.0-eab9542
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 +6 -3
- package/miniflare-dist/index.mjs +1 -0
- package/package.json +1 -1
- package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
- package/src/__tests__/config-cache.test.ts +6 -0
- package/src/__tests__/configuration.test.ts +117 -0
- package/src/__tests__/dev.test.tsx +1 -1
- package/src/__tests__/publish.test.ts +59 -3
- package/src/__tests__/pubsub.test.ts +91 -0
- package/src/api/dev.ts +16 -3
- package/src/cli.ts +1 -1
- package/src/config/environment.ts +23 -0
- package/src/config/index.ts +13 -0
- package/src/config/validation.ts +52 -0
- package/src/config-cache.ts +70 -31
- package/src/create-worker-upload-form.ts +9 -0
- package/src/dev/dev.tsx +2 -2
- package/src/dev/local.tsx +24 -22
- package/src/dev/remote.tsx +20 -5
- package/src/dev/use-esbuild.ts +6 -6
- package/src/dev.tsx +23 -11
- package/src/index.tsx +7 -7
- package/src/is-interactive.ts +12 -0
- package/src/miniflare-cli/index.ts +1 -0
- package/src/publish.ts +4 -3
- package/src/pubsub/pubsub-commands.tsx +386 -403
- package/src/user/choose-account.tsx +2 -2
- package/src/user/user.tsx +53 -22
- package/src/worker.ts +6 -0
- package/wrangler-dist/cli.js +15146 -15048
|
@@ -15,7 +15,7 @@ export type ChooseAccountItem = {
|
|
|
15
15
|
*/
|
|
16
16
|
export function ChooseAccount(props: {
|
|
17
17
|
accounts: ChooseAccountItem[];
|
|
18
|
-
onSelect: (
|
|
18
|
+
onSelect: (account: { name: string; id: string }) => void;
|
|
19
19
|
onError: (error: Error) => void;
|
|
20
20
|
}) {
|
|
21
21
|
return (
|
|
@@ -29,7 +29,7 @@ export function ChooseAccount(props: {
|
|
|
29
29
|
}))}
|
|
30
30
|
onSelect={(item) => {
|
|
31
31
|
logger.log(`Using account: "${item.value.name} - ${item.value.id}"`);
|
|
32
|
-
props.onSelect(item.value.id);
|
|
32
|
+
props.onSelect({ id: item.value.id, name: item.value.name });
|
|
33
33
|
}}
|
|
34
34
|
/>
|
|
35
35
|
</>
|
package/src/user/user.tsx
CHANGED
|
@@ -219,7 +219,12 @@ import { render } from "ink";
|
|
|
219
219
|
import Table from "ink-table";
|
|
220
220
|
import React from "react";
|
|
221
221
|
import { fetch } from "undici";
|
|
222
|
-
import {
|
|
222
|
+
import {
|
|
223
|
+
getConfigCache,
|
|
224
|
+
purgeConfigCaches,
|
|
225
|
+
saveToConfigCache,
|
|
226
|
+
} from "../config-cache";
|
|
227
|
+
import isInteractive from "../is-interactive";
|
|
223
228
|
import { logger } from "../logger";
|
|
224
229
|
import openInBrowser from "../open-in-browser";
|
|
225
230
|
import { parseTOML, readFileSync } from "../parse";
|
|
@@ -1058,27 +1063,37 @@ export async function getAccountId(): Promise<string | undefined> {
|
|
|
1058
1063
|
const apiToken = getAPIToken();
|
|
1059
1064
|
if (!apiToken) return;
|
|
1060
1065
|
|
|
1066
|
+
// check if we have a cached value
|
|
1067
|
+
const cachedAccount = getAccountFromCache();
|
|
1068
|
+
if (cachedAccount) {
|
|
1069
|
+
return cachedAccount.id;
|
|
1070
|
+
}
|
|
1061
1071
|
const accounts = await getAccountChoices();
|
|
1062
1072
|
if (accounts.length === 1) {
|
|
1073
|
+
saveAccountToCache({ id: accounts[0].id, name: accounts[0].name });
|
|
1063
1074
|
return accounts[0].id;
|
|
1064
1075
|
}
|
|
1065
1076
|
|
|
1066
1077
|
if (isInteractive()) {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1078
|
+
const account = await new Promise<{ id: string; name: string }>(
|
|
1079
|
+
(resolve, reject) => {
|
|
1080
|
+
const { unmount } = render(
|
|
1081
|
+
<ChooseAccount
|
|
1082
|
+
accounts={accounts}
|
|
1083
|
+
onSelect={async (selected) => {
|
|
1084
|
+
saveAccountToCache(selected);
|
|
1085
|
+
resolve(selected);
|
|
1086
|
+
unmount();
|
|
1087
|
+
}}
|
|
1088
|
+
onError={(err) => {
|
|
1089
|
+
reject(err);
|
|
1090
|
+
unmount();
|
|
1091
|
+
}}
|
|
1092
|
+
/>
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
return account.id;
|
|
1082
1097
|
}
|
|
1083
1098
|
|
|
1084
1099
|
throw new Error(
|
|
@@ -1121,10 +1136,26 @@ export function requireApiToken(): ApiCredentials {
|
|
|
1121
1136
|
return credentials;
|
|
1122
1137
|
}
|
|
1123
1138
|
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1139
|
+
/**
|
|
1140
|
+
* Save the given account details to a cache
|
|
1141
|
+
*/
|
|
1142
|
+
export function saveAccountToCache(account: {
|
|
1143
|
+
id: string;
|
|
1144
|
+
name: string;
|
|
1145
|
+
}): void {
|
|
1146
|
+
saveToConfigCache<{ account: { id: string; name: string } }>(
|
|
1147
|
+
"wrangler-account.json",
|
|
1148
|
+
{ account }
|
|
1149
|
+
);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Fetch the given account details from a cache if available
|
|
1154
|
+
*/
|
|
1155
|
+
export function getAccountFromCache():
|
|
1156
|
+
| undefined
|
|
1157
|
+
| { id: string; name: string } {
|
|
1158
|
+
return getConfigCache<{ account: { id: string; name: string } }>(
|
|
1159
|
+
"wrangler-account.json"
|
|
1160
|
+
).account;
|
|
1130
1161
|
}
|
package/src/worker.ts
CHANGED
|
@@ -122,6 +122,11 @@ interface CfService {
|
|
|
122
122
|
environment?: string;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
interface CfWorkerNamespace {
|
|
126
|
+
binding: string;
|
|
127
|
+
namespace: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
125
130
|
interface CfUnsafeBinding {
|
|
126
131
|
name: string;
|
|
127
132
|
type: string;
|
|
@@ -168,6 +173,7 @@ export interface CfWorkerInit {
|
|
|
168
173
|
durable_objects: { bindings: CfDurableObject[] } | undefined;
|
|
169
174
|
r2_buckets: CfR2Bucket[] | undefined;
|
|
170
175
|
services: CfService[] | undefined;
|
|
176
|
+
worker_namespaces: CfWorkerNamespace[] | undefined;
|
|
171
177
|
unsafe: CfUnsafeBinding[] | undefined;
|
|
172
178
|
};
|
|
173
179
|
migrations: CfDurableObjectMigrations | undefined;
|