@buildinternet/uploads 0.32.0 → 0.33.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/dist/client.d.ts
CHANGED
|
@@ -437,6 +437,7 @@ export interface MintWorkspaceSummary {
|
|
|
437
437
|
/** GET /v1/tokens — workspaces the signed-in user can mint tokens for. */
|
|
438
438
|
export declare function listMintWorkspaces(apiUrl: string, accessToken: string): Promise<{
|
|
439
439
|
workspaces: MintWorkspaceSummary[];
|
|
440
|
+
suggestedWorkspace?: string;
|
|
440
441
|
}>;
|
|
441
442
|
export interface CreateWorkspaceResult {
|
|
442
443
|
name: string;
|
package/dist/commands/config.js
CHANGED
|
@@ -149,9 +149,13 @@ Examples:
|
|
|
149
149
|
keys.UPLOADS_WORKSPACE = workspace;
|
|
150
150
|
if (token)
|
|
151
151
|
keys.UPLOADS_TOKEN = token;
|
|
152
|
+
// Seed only the API URL. A `UPLOADS_WORKSPACE` written here outranks the
|
|
153
|
+
// workspace encoded in the token itself (see `resolveConfig`'s precedence),
|
|
154
|
+
// so seeding one would pin every later `uploads login` to whatever this
|
|
155
|
+
// wrote — historically `default` — no matter which workspace the user's
|
|
156
|
+
// token was actually minted for.
|
|
152
157
|
if (Object.keys(keys).length === 0) {
|
|
153
158
|
keys.UPLOADS_API_URL = DEFAULT_API_URL;
|
|
154
|
-
keys.UPLOADS_WORKSPACE = DEFAULT_WORKSPACE;
|
|
155
159
|
}
|
|
156
160
|
try {
|
|
157
161
|
const result = writeConfigKeys(path, keys, { force });
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -30,8 +30,13 @@ export interface DeviceLoginIo {
|
|
|
30
30
|
write: (text: string) => void;
|
|
31
31
|
/** Whether the CLI can prompt the user (a real TTY, not a script/CI pipe). */
|
|
32
32
|
isTTY: boolean;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Prompt for a new workspace name when the account has zero. `suggestion`
|
|
35
|
+
* is a server-derived default (the user's GitHub login, when it makes a
|
|
36
|
+
* valid and available slug) offered as a bracketed default that Enter
|
|
37
|
+
* accepts; it is always overridable and never auto-submitted.
|
|
38
|
+
*/
|
|
39
|
+
promptWorkspaceName: (suggestion?: string) => Promise<string>;
|
|
35
40
|
}
|
|
36
41
|
export declare const defaultDeviceIo: DeviceLoginIo;
|
|
37
42
|
/** A completed device authorization: the session bearer plus the (possibly rewritten) scope. */
|
package/dist/commands/login.js
CHANGED
|
@@ -185,10 +185,14 @@ function openUrl(url) {
|
|
|
185
185
|
// ignore — the URL is printed for manual navigation.
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
async function promptWorkspaceName() {
|
|
188
|
+
async function promptWorkspaceName(suggestion) {
|
|
189
189
|
const rl = createInterface({ input: stdin, output: process.stderr });
|
|
190
|
+
const hint = suggestion ? ` [${suggestion}]` : "";
|
|
190
191
|
try {
|
|
191
|
-
|
|
192
|
+
const answer = (await rl.question(`no workspaces yet — enter a name to create one (lowercase, hyphens)${hint}: `)).trim();
|
|
193
|
+
// Empty input accepts the offered default; with no suggestion it stays
|
|
194
|
+
// empty and the caller's "cancelled" guard fires as before.
|
|
195
|
+
return answer || (suggestion ?? "");
|
|
192
196
|
}
|
|
193
197
|
finally {
|
|
194
198
|
rl.close();
|
|
@@ -347,14 +351,14 @@ async function resolveMintWorkspace(apiUrl, accessToken, requested, io, create =
|
|
|
347
351
|
io.write(`created workspace "${created.name}" — files will get public URLs under ${created.publicBaseUrl}/\n`);
|
|
348
352
|
return created.name;
|
|
349
353
|
}
|
|
350
|
-
const { workspaces } = await listMintWorkspaces(apiUrl, accessToken);
|
|
354
|
+
const { workspaces, suggestedWorkspace } = await listMintWorkspaces(apiUrl, accessToken);
|
|
351
355
|
if (workspaces.length === 1)
|
|
352
356
|
return workspaces[0].workspace;
|
|
353
357
|
if (workspaces.length === 0) {
|
|
354
358
|
if (!io.isTTY) {
|
|
355
359
|
throw new UsageError("your account has no workspace access yet — pass `--workspace <name> --create` to provision one, run `uploads login` interactively, or ask an administrator for an invitation");
|
|
356
360
|
}
|
|
357
|
-
const name = (await io.promptWorkspaceName()).trim();
|
|
361
|
+
const name = (await io.promptWorkspaceName(suggestedWorkspace)).trim();
|
|
358
362
|
if (!name)
|
|
359
363
|
throw new UsageError("workspace creation cancelled");
|
|
360
364
|
const created = await createWorkspaceRequest(apiUrl, accessToken, name);
|