@trigguard/cli 0.1.1 → 0.1.2
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.
|
@@ -3,6 +3,7 @@ import { hasFlag } from "../tg/args.js";
|
|
|
3
3
|
import { loadConfig, saveConfig } from "../cp/config.js";
|
|
4
4
|
import { defaultMachineLabel, ensureCliApiKey, } from "../cp/provisionCliKey.js";
|
|
5
5
|
import { startCliDeviceAuth, waitForCliDeviceAuth, } from "../cp/cliDeviceAuth.js";
|
|
6
|
+
import { formatNextAuthorizeCommand, printActivationEstablished, } from "../tg/activationCopy.js";
|
|
6
7
|
async function openBrowser(url) {
|
|
7
8
|
const platform = process.platform;
|
|
8
9
|
let cmd;
|
|
@@ -75,6 +76,5 @@ export async function runLoginWeb(args) {
|
|
|
75
76
|
console.log(`Signed in as ${complete.user.email}`);
|
|
76
77
|
console.log(`Workspace: ${complete.orgName ?? orgId}`);
|
|
77
78
|
console.log("API key configured for this machine.");
|
|
78
|
-
|
|
79
|
-
console.log("Next: tg authorize --surface deploy.release --actor demo --intent \"test deploy\"");
|
|
79
|
+
printActivationEstablished(formatNextAuthorizeCommand());
|
|
80
80
|
}
|
package/dist/commands/session.js
CHANGED
|
@@ -5,6 +5,7 @@ import { loadConfig, saveConfig, clearSession } from "../cp/config.js";
|
|
|
5
5
|
import { resolveApiKeySource, storedCliApiKeyForSession } from "../cp/credentials.js";
|
|
6
6
|
import { defaultMachineLabel, ensureCliApiKey } from "../cp/provisionCliKey.js";
|
|
7
7
|
import { runLoginWeb } from "./login-web.js";
|
|
8
|
+
import { formatNextAuthorizeCommand, printActivationEstablished, } from "../tg/activationCopy.js";
|
|
8
9
|
function flagValue(args, name) {
|
|
9
10
|
const i = args.indexOf(name);
|
|
10
11
|
if (i === -1)
|
|
@@ -188,8 +189,10 @@ export async function runLogin(args) {
|
|
|
188
189
|
console.log(`Workspace: ${activeOrgId}`);
|
|
189
190
|
else
|
|
190
191
|
console.log("Workspace: (verify email to list organizations)");
|
|
191
|
-
if (apiKey)
|
|
192
|
+
if (apiKey) {
|
|
192
193
|
console.log("API key configured for this machine.");
|
|
194
|
+
printActivationEstablished(formatNextAuthorizeCommand());
|
|
195
|
+
}
|
|
193
196
|
}
|
|
194
197
|
export async function runLogout(args) {
|
|
195
198
|
const json = hasFlag(args, "--json");
|
|
@@ -5,6 +5,7 @@ import { resolveSessionSnapshot } from "./session.js";
|
|
|
5
5
|
import { runLoginWeb } from "./login-web.js";
|
|
6
6
|
import { loadExecutionSurfaces } from "./tg-surfaces.js";
|
|
7
7
|
import { shellQuoteArg } from "../tg/shellQuote.js";
|
|
8
|
+
import { printActivationEstablished } from "../tg/activationCopy.js";
|
|
8
9
|
import os from "node:os";
|
|
9
10
|
export async function runTgSetup(args) {
|
|
10
11
|
const json = hasFlag(args, "--json");
|
|
@@ -16,6 +17,9 @@ export async function runTgSetup(args) {
|
|
|
16
17
|
console.log("Step 1/3 — Sign in (browser)");
|
|
17
18
|
await runLoginWeb(json ? ["--json"] : []);
|
|
18
19
|
}
|
|
20
|
+
else if (!json) {
|
|
21
|
+
printActivationEstablished(`tg authorize --surface deploy.release --actor ${shellQuoteArg(snap.activeOrg?.name ?? os.userInfo().username ?? "demo")} --intent "setup test"`);
|
|
22
|
+
}
|
|
19
23
|
const refreshed = loadConfig();
|
|
20
24
|
const snap2 = await resolveSessionSnapshot();
|
|
21
25
|
if (!snap2.authenticated || !resolveApiKey(refreshed)) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ACTIVATION_HEADLINE = "Execution Authority Established";
|
|
2
|
+
export declare const ACTIVATION_STATUS = "Authority Status: Verified";
|
|
3
|
+
export type NextAuthorizeOptions = {
|
|
4
|
+
surface?: string;
|
|
5
|
+
actor?: string;
|
|
6
|
+
intent?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function formatNextAuthorizeCommand(opts?: NextAuthorizeOptions): string;
|
|
9
|
+
export declare function printActivationEstablished(nextCommand: string): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
export const ACTIVATION_HEADLINE = "Execution Authority Established";
|
|
3
|
+
export const ACTIVATION_STATUS = "Authority Status: Verified";
|
|
4
|
+
export function formatNextAuthorizeCommand(opts = {}) {
|
|
5
|
+
const surface = opts.surface ?? "deploy.release";
|
|
6
|
+
const actor = opts.actor ?? "demo";
|
|
7
|
+
const intent = opts.intent ?? "test deployment";
|
|
8
|
+
return `tg authorize --surface ${surface} --actor ${actor} --intent "${intent}"`;
|
|
9
|
+
}
|
|
10
|
+
function tryCopyToClipboard(text) {
|
|
11
|
+
if (!process.stdout.isTTY)
|
|
12
|
+
return false;
|
|
13
|
+
const platform = process.platform;
|
|
14
|
+
if (platform === "darwin") {
|
|
15
|
+
const r = spawnSync("pbcopy", [], { input: text, stdio: ["pipe", "ignore", "ignore"] });
|
|
16
|
+
return r.status === 0;
|
|
17
|
+
}
|
|
18
|
+
if (platform === "win32") {
|
|
19
|
+
const r = spawnSync("clip", [], { input: text, stdio: ["pipe", "ignore", "ignore"], shell: true });
|
|
20
|
+
return r.status === 0;
|
|
21
|
+
}
|
|
22
|
+
for (const [cmd, args] of [
|
|
23
|
+
["xclip", ["-selection", "clipboard"]],
|
|
24
|
+
["xsel", ["--clipboard", "--input"]],
|
|
25
|
+
]) {
|
|
26
|
+
const r = spawnSync(cmd, [...args], { input: text, stdio: ["pipe", "ignore", "ignore"] });
|
|
27
|
+
if (r.status === 0)
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
export function printActivationEstablished(nextCommand) {
|
|
33
|
+
console.log("");
|
|
34
|
+
console.log(ACTIVATION_HEADLINE);
|
|
35
|
+
console.log(ACTIVATION_STATUS);
|
|
36
|
+
console.log("");
|
|
37
|
+
console.log("Next step:");
|
|
38
|
+
console.log(` ${nextCommand}`);
|
|
39
|
+
if (tryCopyToClipboard(nextCommand)) {
|
|
40
|
+
console.log("");
|
|
41
|
+
console.log("(Command copied to clipboard)");
|
|
42
|
+
}
|
|
43
|
+
}
|