bluekiwi 0.3.7 → 0.3.8
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/commands/accept.js +26 -9
- package/package.json +1 -1
package/dist/commands/accept.js
CHANGED
|
@@ -14,24 +14,41 @@ export async function acceptCommand(token, opts) {
|
|
|
14
14
|
}
|
|
15
15
|
const invite = (await validateRes.json());
|
|
16
16
|
console.log(pc.green(`✓ Invited as ${invite.email} (${invite.role})`));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
// If account already exists (e.g. signed up via web), only need password to re-link
|
|
18
|
+
const answers = invite.already_accepted
|
|
19
|
+
? opts.password
|
|
20
|
+
? { username: "", password: opts.password }
|
|
21
|
+
: await prompts([
|
|
22
|
+
{
|
|
23
|
+
type: "password",
|
|
24
|
+
name: "password",
|
|
25
|
+
message: "Enter your existing password to link this CLI",
|
|
26
|
+
},
|
|
27
|
+
])
|
|
28
|
+
: opts.username && opts.password
|
|
29
|
+
? { username: opts.username, password: opts.password }
|
|
30
|
+
: await prompts([
|
|
31
|
+
{ type: "text", name: "username", message: "Choose a username" },
|
|
32
|
+
{ type: "password", name: "password", message: "Set a password" },
|
|
33
|
+
]);
|
|
34
|
+
console.log(pc.cyan(invite.already_accepted
|
|
35
|
+
? "→ Linking account..."
|
|
36
|
+
: "→ Creating account..."));
|
|
24
37
|
const acceptRes = await fetch(`${opts.server}/api/invites/accept/${token}`, {
|
|
25
38
|
method: "POST",
|
|
26
39
|
headers: { "Content-Type": "application/json" },
|
|
27
|
-
body: JSON.stringify(
|
|
40
|
+
body: JSON.stringify(invite.already_accepted
|
|
41
|
+
? { password: answers.password }
|
|
42
|
+
: answers),
|
|
28
43
|
});
|
|
29
44
|
if (!acceptRes.ok) {
|
|
30
45
|
console.error(pc.red(`Accept failed: ${await acceptRes.text()}`));
|
|
31
46
|
process.exit(1);
|
|
32
47
|
}
|
|
33
48
|
const result = (await acceptRes.json());
|
|
34
|
-
console.log(pc.green(
|
|
49
|
+
console.log(pc.green(invite.already_accepted
|
|
50
|
+
? `✓ Linked to account: ${result.user.username}`
|
|
51
|
+
: `✓ Account created: ${result.user.username}`));
|
|
35
52
|
const client = new BlueKiwiClient(opts.server, result.api_key);
|
|
36
53
|
await client.request("GET", "/api/workflows");
|
|
37
54
|
// Skip runtime installation in non-interactive (CI/script) mode
|