@temps-sdk/cli 0.1.21 → 0.1.23
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/index.js +404 -293
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74447,15 +74447,79 @@ function getErrorMessage(error3) {
|
|
|
74447
74447
|
|
|
74448
74448
|
// src/commands/auth/login.ts
|
|
74449
74449
|
init_sdk_gen();
|
|
74450
|
-
import { hostname } from "node:os";
|
|
74451
|
-
|
|
74452
|
-
|
|
74450
|
+
import { hostname, platform } from "node:os";
|
|
74451
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
74452
|
+
function debugEnabled(opts = {}) {
|
|
74453
|
+
if (opts.debug)
|
|
74454
|
+
return true;
|
|
74455
|
+
const env3 = process.env.TEMPS_DEBUG;
|
|
74456
|
+
return env3 === "1" || env3 === "true" || env3 === "yes";
|
|
74457
|
+
}
|
|
74458
|
+
function debugLog(message, payload) {
|
|
74459
|
+
if (payload === undefined) {
|
|
74460
|
+
process.stderr.write(`[temps-cli debug] ${message}
|
|
74461
|
+
`);
|
|
74462
|
+
return;
|
|
74463
|
+
}
|
|
74464
|
+
let rendered;
|
|
74465
|
+
try {
|
|
74466
|
+
rendered = typeof payload === "string" ? payload : JSON.stringify(payload, null, 2);
|
|
74467
|
+
} catch {
|
|
74468
|
+
rendered = String(payload);
|
|
74469
|
+
}
|
|
74470
|
+
process.stderr.write(`[temps-cli debug] ${message} ${rendered}
|
|
74471
|
+
`);
|
|
74453
74472
|
}
|
|
74454
|
-
function
|
|
74455
|
-
|
|
74473
|
+
async function debugFetch(url, init, debug) {
|
|
74474
|
+
if (debug) {
|
|
74475
|
+
debugLog(`-> ${init.method ?? "GET"} ${url}`);
|
|
74476
|
+
if (init.body)
|
|
74477
|
+
debugLog(" request body:", init.body);
|
|
74478
|
+
}
|
|
74479
|
+
let res;
|
|
74480
|
+
try {
|
|
74481
|
+
res = await fetch(url, init);
|
|
74482
|
+
} catch (err) {
|
|
74483
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
74484
|
+
if (debug)
|
|
74485
|
+
debugLog(` fetch failed: ${reason}`);
|
|
74486
|
+
throw new AuthenticationError(`Unable to connect to ${url}: ${reason}. Is the server reachable from this machine?`);
|
|
74487
|
+
}
|
|
74488
|
+
const rawBody = await res.text();
|
|
74489
|
+
if (debug) {
|
|
74490
|
+
debugLog(`<- ${res.status} ${res.statusText} (${url})`);
|
|
74491
|
+
const headers = {};
|
|
74492
|
+
res.headers.forEach((value, key) => {
|
|
74493
|
+
headers[key] = value;
|
|
74494
|
+
});
|
|
74495
|
+
debugLog(" response headers:", headers);
|
|
74496
|
+
const preview = rawBody.length > 2000 ? `${rawBody.slice(0, 2000)}…[truncated]` : rawBody;
|
|
74497
|
+
debugLog(" response body:", preview || "(empty)");
|
|
74498
|
+
}
|
|
74499
|
+
let json2 = null;
|
|
74500
|
+
if (rawBody.length > 0) {
|
|
74501
|
+
try {
|
|
74502
|
+
json2 = JSON.parse(rawBody);
|
|
74503
|
+
} catch {
|
|
74504
|
+
json2 = null;
|
|
74505
|
+
}
|
|
74506
|
+
}
|
|
74507
|
+
return { res, rawBody, json: json2 };
|
|
74508
|
+
}
|
|
74509
|
+
function serverBaseUrl(rawApiUrl) {
|
|
74510
|
+
const trimmed = rawApiUrl.replace(/\/+$/, "");
|
|
74511
|
+
return /\/api$/.test(trimmed) ? trimmed : `${trimmed}/api`;
|
|
74456
74512
|
}
|
|
74457
74513
|
async function login2(options) {
|
|
74458
74514
|
newline();
|
|
74515
|
+
const debug = debugEnabled(options);
|
|
74516
|
+
if (debug) {
|
|
74517
|
+
debugLog("login invoked with options:", {
|
|
74518
|
+
url: options.url,
|
|
74519
|
+
context: options.context,
|
|
74520
|
+
hasApiKey: !!options.apiKey
|
|
74521
|
+
});
|
|
74522
|
+
}
|
|
74459
74523
|
const switchingContext = !!(options.url || options.context);
|
|
74460
74524
|
if (!switchingContext && await credentials.isAuthenticated()) {
|
|
74461
74525
|
const existingEmail = await credentials.get("email");
|
|
@@ -74463,53 +74527,152 @@ async function login2(options) {
|
|
|
74463
74527
|
info('Run "temps logout" first to switch accounts, or pass --url / --context to add another.');
|
|
74464
74528
|
return;
|
|
74465
74529
|
}
|
|
74466
|
-
if (options.magic) {
|
|
74467
|
-
await loginWithMagicLink(typeof options.magic === "string" ? options.magic : undefined);
|
|
74468
|
-
return;
|
|
74469
|
-
}
|
|
74470
|
-
if (options.email) {
|
|
74471
|
-
await loginWithEmail(typeof options.email === "string" ? options.email : undefined, {
|
|
74472
|
-
url: options.url,
|
|
74473
|
-
context: options.context,
|
|
74474
|
-
mfa: options.mfa
|
|
74475
|
-
});
|
|
74476
|
-
return;
|
|
74477
|
-
}
|
|
74478
74530
|
if (options.apiKey) {
|
|
74479
74531
|
await loginWithApiKey(options.apiKey);
|
|
74480
74532
|
return;
|
|
74481
74533
|
}
|
|
74482
|
-
|
|
74483
|
-
|
|
74484
|
-
|
|
74485
|
-
|
|
74486
|
-
|
|
74487
|
-
|
|
74488
|
-
|
|
74534
|
+
await loginWithDevice({ url: options.url, context: options.context, debug });
|
|
74535
|
+
}
|
|
74536
|
+
async function loginWithDevice(opts = {}) {
|
|
74537
|
+
const debug = debugEnabled(opts);
|
|
74538
|
+
const apiBaseUrl = opts.url ? serverBaseUrl(opts.url) : serverBaseUrl(config.get("apiUrl"));
|
|
74539
|
+
const webBaseUrl = apiBaseUrl.replace(/\/api$/, "");
|
|
74540
|
+
if (opts.url) {
|
|
74541
|
+
config.set("apiUrl", apiBaseUrl);
|
|
74489
74542
|
}
|
|
74490
|
-
|
|
74491
|
-
|
|
74492
|
-
|
|
74493
|
-
|
|
74494
|
-
|
|
74495
|
-
|
|
74496
|
-
|
|
74543
|
+
if (debug) {
|
|
74544
|
+
debugLog(`resolved apiBaseUrl: ${apiBaseUrl}`);
|
|
74545
|
+
debugLog(`resolved webBaseUrl: ${webBaseUrl}`);
|
|
74546
|
+
debugLog(`raw url arg: ${opts.url ?? "(none, using config apiUrl)"}`);
|
|
74547
|
+
}
|
|
74548
|
+
const deviceName = (() => {
|
|
74549
|
+
try {
|
|
74550
|
+
return hostname() || "cli";
|
|
74551
|
+
} catch {
|
|
74552
|
+
return "cli";
|
|
74553
|
+
}
|
|
74554
|
+
})();
|
|
74555
|
+
const startUrl = `${apiBaseUrl}/auth/cli/device/start`;
|
|
74556
|
+
const start = await withSpinner("Requesting device authorization...", async () => {
|
|
74557
|
+
const { res, rawBody, json: json2 } = await debugFetch(startUrl, {
|
|
74558
|
+
method: "POST",
|
|
74559
|
+
headers: { "Content-Type": "application/json" },
|
|
74560
|
+
body: JSON.stringify({ client_name: deviceName })
|
|
74561
|
+
}, debug);
|
|
74562
|
+
if (!res.ok) {
|
|
74563
|
+
const problem = json2 ?? null;
|
|
74564
|
+
throw new AuthenticationError(problem?.detail || problem?.title || `Device authorization start failed at ${startUrl} (status ${res.status}). ` + `Response body: ${rawBody.slice(0, 200) || "(empty)"}`);
|
|
74565
|
+
}
|
|
74566
|
+
if (json2 === null) {
|
|
74567
|
+
throw new AuthenticationError(`Server at ${startUrl} returned a non-JSON response (status ${res.status}, ` + `content-type ${res.headers.get("content-type") ?? "unknown"}). ` + `First 200 chars: ${rawBody.slice(0, 200) || "(empty)"}. ` + `Re-run with --debug for the full response.`);
|
|
74568
|
+
}
|
|
74569
|
+
return json2;
|
|
74570
|
+
}, { successText: "Device authorization ready" });
|
|
74571
|
+
const fullUrl = absoluteVerificationUri(webBaseUrl, start);
|
|
74572
|
+
newline();
|
|
74573
|
+
box([
|
|
74574
|
+
`Open this URL to authorize:`,
|
|
74575
|
+
` ${colors.primary(fullUrl)}`,
|
|
74576
|
+
``,
|
|
74577
|
+
`If your browser doesn't open automatically, paste the code:`,
|
|
74578
|
+
` ${colors.bold(start.user_code)}`,
|
|
74579
|
+
`at ${colors.muted(`${webBaseUrl}/cli-login`)}`
|
|
74580
|
+
].join(`
|
|
74581
|
+
`), `${icons.sparkles} Authorize the Temps CLI`);
|
|
74582
|
+
await tryOpenBrowser(fullUrl);
|
|
74583
|
+
const intervalMs = Math.max(500, (start.interval ?? 2) * 1000);
|
|
74584
|
+
const deadline = Date.now() + (start.expires_in ?? 900) * 1000;
|
|
74585
|
+
const success3 = await withSpinner(`Waiting for browser approval (code ${colors.bold(start.user_code)})...`, async () => {
|
|
74586
|
+
let pollDelay = intervalMs;
|
|
74587
|
+
const pollUrl = `${apiBaseUrl}/auth/cli/device/poll`;
|
|
74588
|
+
while (Date.now() < deadline) {
|
|
74589
|
+
await sleep(pollDelay);
|
|
74590
|
+
const { res, rawBody, json: json2 } = await debugFetch(pollUrl, {
|
|
74591
|
+
method: "POST",
|
|
74592
|
+
headers: { "Content-Type": "application/json" },
|
|
74593
|
+
body: JSON.stringify({ device_code: start.device_code })
|
|
74594
|
+
}, debug);
|
|
74595
|
+
if (!res.ok) {
|
|
74596
|
+
const problem = json2 ?? null;
|
|
74597
|
+
throw new AuthenticationError(problem?.detail || problem?.title || `Polling failed at ${pollUrl} (status ${res.status}). ` + `Response body: ${rawBody.slice(0, 200) || "(empty)"}`);
|
|
74598
|
+
}
|
|
74599
|
+
if (json2 === null) {
|
|
74600
|
+
throw new AuthenticationError(`Server at ${pollUrl} returned a non-JSON response (status ${res.status}). ` + `First 200 chars: ${rawBody.slice(0, 200) || "(empty)"}`);
|
|
74601
|
+
}
|
|
74602
|
+
const body = json2;
|
|
74603
|
+
switch (body.status) {
|
|
74604
|
+
case "authorization_pending":
|
|
74605
|
+
pollDelay = intervalMs;
|
|
74606
|
+
continue;
|
|
74607
|
+
case "slow_down":
|
|
74608
|
+
pollDelay = Math.min(pollDelay * 2, 1e4);
|
|
74609
|
+
continue;
|
|
74610
|
+
case "access_denied":
|
|
74611
|
+
throw new AuthenticationError("Authorization denied in the browser.");
|
|
74612
|
+
case "expired_token":
|
|
74613
|
+
throw new AuthenticationError("Authorization code expired before approval. Run `temps login` again.");
|
|
74614
|
+
case "approved":
|
|
74615
|
+
return body;
|
|
74616
|
+
}
|
|
74617
|
+
}
|
|
74618
|
+
throw new AuthenticationError("Timed out waiting for browser approval. Run `temps login` again.");
|
|
74619
|
+
}, { successText: "Browser approval received" });
|
|
74620
|
+
const contextName = opts.context ?? defaultContextName(apiBaseUrl);
|
|
74621
|
+
await upsertContext({
|
|
74622
|
+
name: contextName,
|
|
74623
|
+
url: apiBaseUrl,
|
|
74624
|
+
apiKey: success3.api_key,
|
|
74625
|
+
email: success3.email,
|
|
74626
|
+
keyPrefix: success3.key_prefix,
|
|
74627
|
+
expiresAt: success3.expires_at ?? undefined
|
|
74497
74628
|
});
|
|
74498
|
-
|
|
74499
|
-
|
|
74500
|
-
|
|
74501
|
-
|
|
74502
|
-
|
|
74503
|
-
|
|
74504
|
-
|
|
74505
|
-
|
|
74506
|
-
|
|
74507
|
-
|
|
74508
|
-
|
|
74509
|
-
|
|
74510
|
-
|
|
74511
|
-
|
|
74629
|
+
config.set("apiUrl", apiBaseUrl);
|
|
74630
|
+
await credentials.setAll({
|
|
74631
|
+
apiKey: success3.api_key,
|
|
74632
|
+
userId: success3.user_id,
|
|
74633
|
+
email: success3.email
|
|
74634
|
+
});
|
|
74635
|
+
displayWelcome(success3.email, contextName, apiBaseUrl, {
|
|
74636
|
+
role: success3.role,
|
|
74637
|
+
key_prefix: success3.key_prefix,
|
|
74638
|
+
expires_at: success3.expires_at
|
|
74639
|
+
});
|
|
74640
|
+
}
|
|
74641
|
+
function absoluteVerificationUri(baseUrl, start) {
|
|
74642
|
+
if (/^https?:\/\//i.test(start.verification_uri_complete)) {
|
|
74643
|
+
return start.verification_uri_complete;
|
|
74644
|
+
}
|
|
74645
|
+
const path6 = start.verification_uri_complete.startsWith("/") ? start.verification_uri_complete : `/${start.verification_uri_complete}`;
|
|
74646
|
+
return `${baseUrl.replace(/\/+$/, "")}${path6}`;
|
|
74647
|
+
}
|
|
74648
|
+
async function tryOpenBrowser(url) {
|
|
74649
|
+
if (process.env.CI || process.env.TEMPS_NO_BROWSER || !process.stdout.isTTY) {
|
|
74650
|
+
return;
|
|
74512
74651
|
}
|
|
74652
|
+
const plat = platform();
|
|
74653
|
+
let cmd2;
|
|
74654
|
+
let args;
|
|
74655
|
+
if (plat === "darwin") {
|
|
74656
|
+
cmd2 = "open";
|
|
74657
|
+
args = [url];
|
|
74658
|
+
} else if (plat === "win32") {
|
|
74659
|
+
cmd2 = "cmd";
|
|
74660
|
+
args = ["/c", "start", '""', url];
|
|
74661
|
+
} else {
|
|
74662
|
+
cmd2 = "xdg-open";
|
|
74663
|
+
args = [url];
|
|
74664
|
+
}
|
|
74665
|
+
try {
|
|
74666
|
+
const child = spawn2(cmd2, args, {
|
|
74667
|
+
stdio: "ignore",
|
|
74668
|
+
detached: true
|
|
74669
|
+
});
|
|
74670
|
+
child.on("error", () => {});
|
|
74671
|
+
child.unref();
|
|
74672
|
+
} catch {}
|
|
74673
|
+
}
|
|
74674
|
+
function sleep(ms) {
|
|
74675
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
74513
74676
|
}
|
|
74514
74677
|
async function loginWithApiKey(apiKey) {
|
|
74515
74678
|
const key = apiKey ?? await promptPassword({
|
|
@@ -74549,233 +74712,11 @@ async function loginWithApiKey(apiKey) {
|
|
|
74549
74712
|
keyPrefix: key.slice(0, 8)
|
|
74550
74713
|
});
|
|
74551
74714
|
displayWelcome(result.email, ctxName, baseUrl);
|
|
74552
|
-
} catch
|
|
74715
|
+
} catch {
|
|
74553
74716
|
await credentials.clear();
|
|
74554
74717
|
throw new AuthenticationError("Invalid API key");
|
|
74555
74718
|
}
|
|
74556
74719
|
}
|
|
74557
|
-
async function loginWithEmail(emailArg, opts = {}) {
|
|
74558
|
-
const baseUrl = opts.url ? serverBaseUrl(opts.url) : serverBaseUrl(config.get("apiUrl"));
|
|
74559
|
-
if (opts.url) {
|
|
74560
|
-
config.set("apiUrl", baseUrl);
|
|
74561
|
-
}
|
|
74562
|
-
const email = emailArg ?? await promptEmail("Email");
|
|
74563
|
-
const password = await promptPassword({
|
|
74564
|
-
message: "Password",
|
|
74565
|
-
validate: (value) => {
|
|
74566
|
-
if (!value || value.trim().length === 0) {
|
|
74567
|
-
return "Password is required";
|
|
74568
|
-
}
|
|
74569
|
-
return true;
|
|
74570
|
-
}
|
|
74571
|
-
});
|
|
74572
|
-
const deviceName = (() => {
|
|
74573
|
-
try {
|
|
74574
|
-
return hostname() || "cli";
|
|
74575
|
-
} catch {
|
|
74576
|
-
return "cli";
|
|
74577
|
-
}
|
|
74578
|
-
})();
|
|
74579
|
-
const firstResponse = await withSpinner("Logging in...", async () => {
|
|
74580
|
-
return cliLoginRequest(baseUrl, {
|
|
74581
|
-
email,
|
|
74582
|
-
password,
|
|
74583
|
-
mfa_code: opts.mfa,
|
|
74584
|
-
device_name: deviceName
|
|
74585
|
-
});
|
|
74586
|
-
}, { successText: "Authenticated" });
|
|
74587
|
-
let success3;
|
|
74588
|
-
if (isMfaChallenge(firstResponse)) {
|
|
74589
|
-
const mfaCode = opts.mfa ?? await promptText({
|
|
74590
|
-
message: "MFA Code",
|
|
74591
|
-
required: true,
|
|
74592
|
-
validate: (value) => /^\d{6}$/.test(value) || "Enter a 6-digit code"
|
|
74593
|
-
});
|
|
74594
|
-
success3 = await withSpinner("Verifying MFA...", async () => {
|
|
74595
|
-
const r = await cliLoginRequest(baseUrl, {
|
|
74596
|
-
email,
|
|
74597
|
-
password,
|
|
74598
|
-
mfa_code: mfaCode,
|
|
74599
|
-
mfa_session_token: firstResponse.mfa_session_token,
|
|
74600
|
-
device_name: deviceName
|
|
74601
|
-
});
|
|
74602
|
-
if (isMfaChallenge(r)) {
|
|
74603
|
-
throw new AuthenticationError("Server requested MFA again after we supplied a code");
|
|
74604
|
-
}
|
|
74605
|
-
return r;
|
|
74606
|
-
}, { successText: "MFA verified" });
|
|
74607
|
-
} else {
|
|
74608
|
-
success3 = firstResponse;
|
|
74609
|
-
}
|
|
74610
|
-
const contextName = opts.context ?? defaultContextName(baseUrl);
|
|
74611
|
-
await upsertContext({
|
|
74612
|
-
name: contextName,
|
|
74613
|
-
url: baseUrl,
|
|
74614
|
-
apiKey: success3.api_key,
|
|
74615
|
-
email: success3.email || email,
|
|
74616
|
-
keyPrefix: success3.key_prefix,
|
|
74617
|
-
expiresAt: success3.expires_at ?? undefined
|
|
74618
|
-
});
|
|
74619
|
-
config.set("apiUrl", baseUrl);
|
|
74620
|
-
await credentials.setAll({
|
|
74621
|
-
apiKey: success3.api_key,
|
|
74622
|
-
userId: success3.user_id,
|
|
74623
|
-
email: success3.email || email
|
|
74624
|
-
});
|
|
74625
|
-
displayWelcome(success3.email || email, contextName, baseUrl, success3);
|
|
74626
|
-
}
|
|
74627
|
-
async function cliLoginRequest(baseUrl, body) {
|
|
74628
|
-
const url = `${baseUrl}/auth/cli/login`;
|
|
74629
|
-
const response = await fetch(url, {
|
|
74630
|
-
method: "POST",
|
|
74631
|
-
headers: { "Content-Type": "application/json" },
|
|
74632
|
-
body: JSON.stringify(body)
|
|
74633
|
-
});
|
|
74634
|
-
if (!response.ok) {
|
|
74635
|
-
let detail = "";
|
|
74636
|
-
try {
|
|
74637
|
-
const problem = await response.json();
|
|
74638
|
-
detail = problem.detail || problem.title || "";
|
|
74639
|
-
} catch {}
|
|
74640
|
-
if (response.status === 401) {
|
|
74641
|
-
throw new AuthenticationError(detail || "Invalid email or password");
|
|
74642
|
-
}
|
|
74643
|
-
if (response.status === 403) {
|
|
74644
|
-
throw new AuthenticationError(detail || "Access denied");
|
|
74645
|
-
}
|
|
74646
|
-
throw new AuthenticationError(detail ? `Login failed (${response.status}): ${detail}` : `Login failed (status ${response.status})`);
|
|
74647
|
-
}
|
|
74648
|
-
return await response.json();
|
|
74649
|
-
}
|
|
74650
|
-
async function loginWithMagicLink(emailArg) {
|
|
74651
|
-
const email = emailArg ?? await promptEmail("Email");
|
|
74652
|
-
const apiUrl = normalizeApiUrl(config.get("apiUrl"));
|
|
74653
|
-
await withSpinner("Sending magic link...", async () => {
|
|
74654
|
-
const response = await fetch(`${apiUrl}/auth/magic-link/request`, {
|
|
74655
|
-
method: "POST",
|
|
74656
|
-
headers: { "Content-Type": "application/json" },
|
|
74657
|
-
body: JSON.stringify({ email })
|
|
74658
|
-
});
|
|
74659
|
-
if (!response.ok && response.status !== 200) {
|
|
74660
|
-
if (response.status === 503) {
|
|
74661
|
-
throw new Error("Email service is not configured on this server");
|
|
74662
|
-
}
|
|
74663
|
-
throw new Error("Failed to send magic link");
|
|
74664
|
-
}
|
|
74665
|
-
}, { successText: "Magic link sent" });
|
|
74666
|
-
newline();
|
|
74667
|
-
info("Check your email for a magic link.");
|
|
74668
|
-
info("After clicking the link, paste the token from the URL below.");
|
|
74669
|
-
newline();
|
|
74670
|
-
const tokenInput = await promptText({
|
|
74671
|
-
message: "Magic link token (from URL or email)",
|
|
74672
|
-
required: true
|
|
74673
|
-
});
|
|
74674
|
-
const token = extractTokenFromInput(tokenInput);
|
|
74675
|
-
const verifyResult = await withSpinner("Verifying token...", async () => {
|
|
74676
|
-
const response = await fetch(`${apiUrl}/auth/magic-link/verify?token=${encodeURIComponent(token)}`, {
|
|
74677
|
-
method: "GET",
|
|
74678
|
-
headers: { "Content-Type": "application/json" }
|
|
74679
|
-
});
|
|
74680
|
-
if (!response.ok) {
|
|
74681
|
-
if (response.status === 400) {
|
|
74682
|
-
throw new AuthenticationError("Invalid or expired token");
|
|
74683
|
-
}
|
|
74684
|
-
throw new AuthenticationError("Verification failed");
|
|
74685
|
-
}
|
|
74686
|
-
const data = await response.json();
|
|
74687
|
-
const setCookie = response.headers.get("set-cookie");
|
|
74688
|
-
return { data, setCookie };
|
|
74689
|
-
}, { successText: "Token verified" });
|
|
74690
|
-
const sessionCookie = extractSessionCookie(verifyResult.setCookie);
|
|
74691
|
-
if (!sessionCookie) {
|
|
74692
|
-
warning("Could not extract session. Please create an API key from the dashboard.");
|
|
74693
|
-
info(`Dashboard: ${colors.primary(`${apiUrl}/dashboard/settings/api-keys`)}`);
|
|
74694
|
-
newline();
|
|
74695
|
-
info("Then run: temps login --api-key <your-key>");
|
|
74696
|
-
return;
|
|
74697
|
-
}
|
|
74698
|
-
const apiKey = await withSpinner("Creating API token...", async () => {
|
|
74699
|
-
const response = await fetch(`${apiUrl}/api/tokens`, {
|
|
74700
|
-
method: "POST",
|
|
74701
|
-
headers: {
|
|
74702
|
-
"Content-Type": "application/json",
|
|
74703
|
-
Cookie: sessionCookie
|
|
74704
|
-
},
|
|
74705
|
-
body: JSON.stringify({
|
|
74706
|
-
name: `temps-cli-${new Date().toISOString().split("T")[0]}`,
|
|
74707
|
-
permissions: ["*"]
|
|
74708
|
-
})
|
|
74709
|
-
});
|
|
74710
|
-
if (!response.ok) {
|
|
74711
|
-
throw new Error("Could not create API token from session");
|
|
74712
|
-
}
|
|
74713
|
-
const tokenData = await response.json();
|
|
74714
|
-
return tokenData.token ?? tokenData.api_key;
|
|
74715
|
-
}, { successText: "API token created" });
|
|
74716
|
-
if (!apiKey) {
|
|
74717
|
-
warning("Could not create API token. Please generate one from the dashboard.");
|
|
74718
|
-
return;
|
|
74719
|
-
}
|
|
74720
|
-
await credentials.set("apiKey", apiKey);
|
|
74721
|
-
await setupClient();
|
|
74722
|
-
const user = await withSpinner("Validating...", async () => {
|
|
74723
|
-
const { data, error: error3 } = await getCurrentUser({ client });
|
|
74724
|
-
if (error3 || !data)
|
|
74725
|
-
throw new AuthenticationError("Token validation failed");
|
|
74726
|
-
return data;
|
|
74727
|
-
}, { successText: "Validated" });
|
|
74728
|
-
await credentials.setAll({
|
|
74729
|
-
apiKey,
|
|
74730
|
-
userId: user.id,
|
|
74731
|
-
email: user.email ?? undefined
|
|
74732
|
-
});
|
|
74733
|
-
const baseUrl = serverBaseUrl(config.get("apiUrl"));
|
|
74734
|
-
const ctxName = defaultContextName(baseUrl);
|
|
74735
|
-
await upsertContext({
|
|
74736
|
-
name: ctxName,
|
|
74737
|
-
url: baseUrl,
|
|
74738
|
-
apiKey,
|
|
74739
|
-
email: user.email ?? "",
|
|
74740
|
-
keyPrefix: apiKey.slice(0, 8)
|
|
74741
|
-
});
|
|
74742
|
-
displayWelcome(user.email, ctxName, baseUrl);
|
|
74743
|
-
}
|
|
74744
|
-
function extractCookieValue(setCookie, name) {
|
|
74745
|
-
if (!setCookie)
|
|
74746
|
-
return null;
|
|
74747
|
-
const cookies = setCookie.split(/,(?=\s*\w+=)/);
|
|
74748
|
-
for (const cookie of cookies) {
|
|
74749
|
-
const match = cookie.match(new RegExp(`${name}=([^;]+)`));
|
|
74750
|
-
if (match)
|
|
74751
|
-
return `${name}=${match[1]}`;
|
|
74752
|
-
}
|
|
74753
|
-
return null;
|
|
74754
|
-
}
|
|
74755
|
-
function extractSessionCookie(setCookie) {
|
|
74756
|
-
if (!setCookie)
|
|
74757
|
-
return null;
|
|
74758
|
-
const cookieNames = ["session_token", "session", "id", "sid"];
|
|
74759
|
-
for (const name of cookieNames) {
|
|
74760
|
-
const cookie = extractCookieValue(setCookie, name);
|
|
74761
|
-
if (cookie)
|
|
74762
|
-
return cookie;
|
|
74763
|
-
}
|
|
74764
|
-
const match = setCookie.match(/^([^=]+=[^;]+)/);
|
|
74765
|
-
if (match?.[1])
|
|
74766
|
-
return match[1];
|
|
74767
|
-
return null;
|
|
74768
|
-
}
|
|
74769
|
-
function extractTokenFromInput(input) {
|
|
74770
|
-
const trimmed = input.trim();
|
|
74771
|
-
try {
|
|
74772
|
-
const url = new URL(trimmed);
|
|
74773
|
-
const token = url.searchParams.get("token");
|
|
74774
|
-
if (token)
|
|
74775
|
-
return token;
|
|
74776
|
-
} catch {}
|
|
74777
|
-
return trimmed;
|
|
74778
|
-
}
|
|
74779
74720
|
function displayWelcome(email, contextName, baseUrl, meta) {
|
|
74780
74721
|
newline();
|
|
74781
74722
|
const url = baseUrl ?? config.get("apiUrl");
|
|
@@ -74899,7 +74840,7 @@ async function whoami(options) {
|
|
|
74899
74840
|
|
|
74900
74841
|
// src/commands/auth/index.ts
|
|
74901
74842
|
function registerAuthCommands(program2) {
|
|
74902
|
-
program2.command("login [url]").description("Authenticate with a Temps server
|
|
74843
|
+
program2.command("login [url]").description("Authenticate with a Temps server. Opens the browser for interactive logins; use --api-key for headless / CI.").option("-k, --api-key <key>", "Use a pre-minted API key (Settings → API Keys) instead of opening the browser. Required for headless / CI.").option("--context <name>", "Save the credentials under this context name (defaults to URL host)").option("--debug", "Print every request/response (URL, status, headers, raw body) to stderr. Also enabled via TEMPS_DEBUG=1.").action(async (url, opts) => {
|
|
74903
74844
|
await login2({
|
|
74904
74845
|
...opts,
|
|
74905
74846
|
url: typeof url === "string" && url.length > 0 ? url : opts.url
|
|
@@ -76039,6 +75980,23 @@ async function createNewServiceOfType(serviceType) {
|
|
|
76039
75980
|
}
|
|
76040
75981
|
|
|
76041
75982
|
// src/commands/projects/create.ts
|
|
75983
|
+
var MANUAL_SOURCE_TYPES = [
|
|
75984
|
+
{
|
|
75985
|
+
value: "manual",
|
|
75986
|
+
name: "Flexible (Recommended)",
|
|
75987
|
+
description: "Deploy via Docker images, static files, or Git - switch anytime"
|
|
75988
|
+
},
|
|
75989
|
+
{
|
|
75990
|
+
value: "docker_image",
|
|
75991
|
+
name: "Docker Image Only",
|
|
75992
|
+
description: "Locked to Docker image deployments only"
|
|
75993
|
+
},
|
|
75994
|
+
{
|
|
75995
|
+
value: "static_files",
|
|
75996
|
+
name: "Static Files Only",
|
|
75997
|
+
description: "Locked to static file deployments only"
|
|
75998
|
+
}
|
|
75999
|
+
];
|
|
76042
76000
|
async function create(options) {
|
|
76043
76001
|
await requireAuth();
|
|
76044
76002
|
await setupClient();
|
|
@@ -76047,6 +76005,43 @@ async function create(options) {
|
|
|
76047
76005
|
console.log(colors.bold(`${icons.sparkles} Create New Project`));
|
|
76048
76006
|
console.log(colors.muted("─".repeat(40)));
|
|
76049
76007
|
newline();
|
|
76008
|
+
const manualRequested = options.manual === true || options.sourceType !== undefined || options.image !== undefined || options.port !== undefined;
|
|
76009
|
+
let manualSourceType;
|
|
76010
|
+
if (manualRequested) {
|
|
76011
|
+
if (options.sourceType) {
|
|
76012
|
+
const match = MANUAL_SOURCE_TYPES.find((t) => t.value === options.sourceType);
|
|
76013
|
+
if (!match) {
|
|
76014
|
+
error(`Invalid --source-type "${options.sourceType}". Use one of: ${MANUAL_SOURCE_TYPES.map((t) => t.value).join(", ")}`);
|
|
76015
|
+
return;
|
|
76016
|
+
}
|
|
76017
|
+
manualSourceType = match.value;
|
|
76018
|
+
} else {
|
|
76019
|
+
manualSourceType = "manual";
|
|
76020
|
+
}
|
|
76021
|
+
} else if (!skipPrompts && !options.repo && !options.connection) {
|
|
76022
|
+
const choice = await promptSelect({
|
|
76023
|
+
message: "How do you want to deploy this project?",
|
|
76024
|
+
choices: [
|
|
76025
|
+
{
|
|
76026
|
+
name: "Git Repository",
|
|
76027
|
+
value: "git",
|
|
76028
|
+
description: "Connect a repo - builds and deploys on every push"
|
|
76029
|
+
},
|
|
76030
|
+
...MANUAL_SOURCE_TYPES.map((t) => ({
|
|
76031
|
+
name: t.name,
|
|
76032
|
+
value: t.value,
|
|
76033
|
+
description: t.description
|
|
76034
|
+
}))
|
|
76035
|
+
]
|
|
76036
|
+
});
|
|
76037
|
+
if (choice !== "git") {
|
|
76038
|
+
manualSourceType = choice;
|
|
76039
|
+
}
|
|
76040
|
+
}
|
|
76041
|
+
if (manualSourceType) {
|
|
76042
|
+
await createManualProject(options, manualSourceType, skipPrompts);
|
|
76043
|
+
return;
|
|
76044
|
+
}
|
|
76050
76045
|
try {
|
|
76051
76046
|
let connection;
|
|
76052
76047
|
if (options.connection) {
|
|
@@ -76191,6 +76186,122 @@ async function create(options) {
|
|
|
76191
76186
|
error(getErrorMessage(err));
|
|
76192
76187
|
}
|
|
76193
76188
|
}
|
|
76189
|
+
async function createManualProject(options, sourceType, skipPrompts) {
|
|
76190
|
+
const methodMeta = MANUAL_SOURCE_TYPES.find((t) => t.value === sourceType);
|
|
76191
|
+
info(`Deployment method: ${methodMeta.name}`);
|
|
76192
|
+
try {
|
|
76193
|
+
let projectName;
|
|
76194
|
+
if (options.name) {
|
|
76195
|
+
projectName = options.name;
|
|
76196
|
+
info(`Using project name: ${projectName}`);
|
|
76197
|
+
} else if (skipPrompts) {
|
|
76198
|
+
error("Project name is required. Pass --name when using --yes.");
|
|
76199
|
+
return;
|
|
76200
|
+
} else {
|
|
76201
|
+
newline();
|
|
76202
|
+
projectName = await promptText({
|
|
76203
|
+
message: "Project name",
|
|
76204
|
+
required: true,
|
|
76205
|
+
validate: (v) => v.length >= 2 ? true : "Name must be at least 2 characters"
|
|
76206
|
+
});
|
|
76207
|
+
}
|
|
76208
|
+
let dockerImage;
|
|
76209
|
+
if (sourceType === "manual" || sourceType === "docker_image") {
|
|
76210
|
+
if (options.image) {
|
|
76211
|
+
dockerImage = options.image;
|
|
76212
|
+
info(`Using Docker image: ${dockerImage}`);
|
|
76213
|
+
} else if (!skipPrompts) {
|
|
76214
|
+
const entered = await promptText({
|
|
76215
|
+
message: "Docker image (optional, e.g. nginx:latest or ghcr.io/org/image:tag)",
|
|
76216
|
+
required: false
|
|
76217
|
+
});
|
|
76218
|
+
dockerImage = entered.trim() || undefined;
|
|
76219
|
+
}
|
|
76220
|
+
}
|
|
76221
|
+
let port;
|
|
76222
|
+
if (options.port) {
|
|
76223
|
+
const parsed = parseInt(options.port, 10);
|
|
76224
|
+
if (isNaN(parsed) || parsed < 1 || parsed > 65535) {
|
|
76225
|
+
error(`Invalid --port "${options.port}". Must be a number between 1 and 65535.`);
|
|
76226
|
+
return;
|
|
76227
|
+
}
|
|
76228
|
+
port = parsed;
|
|
76229
|
+
info(`Using port: ${port}`);
|
|
76230
|
+
} else if (skipPrompts) {
|
|
76231
|
+
port = 3000;
|
|
76232
|
+
} else {
|
|
76233
|
+
port = await promptNumber(sourceType === "docker_image" ? "Container port" : "Application port", { default: 3000, min: 1, max: 65535 });
|
|
76234
|
+
}
|
|
76235
|
+
const serviceIds = skipPrompts ? [] : await selectStorageServices();
|
|
76236
|
+
const envVars = skipPrompts ? [] : await configureEnvironmentVariables();
|
|
76237
|
+
const projectType = sourceType === "static_files" ? "static" : "docker";
|
|
76238
|
+
const project = await withSpinner("Creating project...", async () => {
|
|
76239
|
+
const { data, error: apiError } = await createProject({
|
|
76240
|
+
client,
|
|
76241
|
+
body: {
|
|
76242
|
+
name: projectName,
|
|
76243
|
+
preset: "dockerfile",
|
|
76244
|
+
directory: "./",
|
|
76245
|
+
main_branch: "main",
|
|
76246
|
+
source_type: sourceType,
|
|
76247
|
+
project_type: projectType,
|
|
76248
|
+
automatic_deploy: false,
|
|
76249
|
+
exposed_port: port,
|
|
76250
|
+
storage_service_ids: serviceIds,
|
|
76251
|
+
environment_variables: envVars.length > 0 ? envVars : undefined
|
|
76252
|
+
}
|
|
76253
|
+
});
|
|
76254
|
+
if (apiError || !data) {
|
|
76255
|
+
throw new Error(getErrorMessage(apiError) || "Failed to create project");
|
|
76256
|
+
}
|
|
76257
|
+
return data;
|
|
76258
|
+
});
|
|
76259
|
+
newline();
|
|
76260
|
+
header(`${icons.check} Project Created Successfully`);
|
|
76261
|
+
newline();
|
|
76262
|
+
keyValue("ID", project.id);
|
|
76263
|
+
keyValue("Name", project.name);
|
|
76264
|
+
keyValue("Slug", project.slug);
|
|
76265
|
+
keyValue("Deployment Method", methodMeta.name);
|
|
76266
|
+
if (dockerImage) {
|
|
76267
|
+
keyValue("Docker Image", `${dockerImage} ${colors.muted("(deploy with the command below)")}`);
|
|
76268
|
+
}
|
|
76269
|
+
keyValue("Port", port);
|
|
76270
|
+
if (serviceIds.length > 0) {
|
|
76271
|
+
keyValue("Services", `${serviceIds.length} linked`);
|
|
76272
|
+
}
|
|
76273
|
+
if (envVars.length > 0) {
|
|
76274
|
+
keyValue("Environment Variables", `${envVars.length} configured`);
|
|
76275
|
+
}
|
|
76276
|
+
newline();
|
|
76277
|
+
if (skipPrompts) {
|
|
76278
|
+
config.set("defaultProject", project.slug);
|
|
76279
|
+
success(`Default project set to "${project.slug}"`);
|
|
76280
|
+
} else {
|
|
76281
|
+
const setDefault = await promptConfirm({
|
|
76282
|
+
message: "Set as default project?",
|
|
76283
|
+
default: true
|
|
76284
|
+
});
|
|
76285
|
+
if (setDefault) {
|
|
76286
|
+
config.set("defaultProject", project.slug);
|
|
76287
|
+
success(`Default project set to "${project.slug}"`);
|
|
76288
|
+
}
|
|
76289
|
+
}
|
|
76290
|
+
newline();
|
|
76291
|
+
info(`View your project: temps projects show ${project.slug}`);
|
|
76292
|
+
if (sourceType === "static_files") {
|
|
76293
|
+
info(`Deploy static files: temps deploy:static -p ${project.slug} --path <path>`);
|
|
76294
|
+
} else {
|
|
76295
|
+
const imageHint = dockerImage ?? "<image>";
|
|
76296
|
+
info(`Deploy a Docker image: temps deploy:image -p ${project.slug} --image ${imageHint}`);
|
|
76297
|
+
if (sourceType === "manual") {
|
|
76298
|
+
info(`Or deploy static files: temps deploy:static -p ${project.slug} --path <path>`);
|
|
76299
|
+
}
|
|
76300
|
+
}
|
|
76301
|
+
} catch (err) {
|
|
76302
|
+
error(getErrorMessage(err));
|
|
76303
|
+
}
|
|
76304
|
+
}
|
|
76194
76305
|
async function configureProjectName(repository, directory) {
|
|
76195
76306
|
let defaultName = repository.name;
|
|
76196
76307
|
if (directory && directory !== "./" && directory !== "." && directory !== "root") {
|
|
@@ -76833,7 +76944,7 @@ async function updateConfigAction(options) {
|
|
|
76833
76944
|
function registerProjectsCommands(program2) {
|
|
76834
76945
|
const projects = program2.command("projects").alias("project").alias("p").description("Manage projects");
|
|
76835
76946
|
projects.command("list").alias("ls").description("List all projects").option("--json", "Output in JSON format").option("--page <n>", "Page number").option("--per-page <n>", "Items per page").action(list);
|
|
76836
|
-
projects.command("create").alias("new").description("Create a new project").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("--repo <repository>", "Repository in owner/name format").option("--branch <branch>", "Git branch").option("--directory <directory>", "Root directory (relative to repo)").option("--preset <preset>", "Build preset (e.g., nextjs, nodejs, static, docker)").option("--connection <id>", "Git connection ID").option("-y, --yes", "Skip optional prompts (services, env vars, set-default)").action(create);
|
|
76947
|
+
projects.command("create").alias("new").description("Create a new project (git-based or manual deployment)").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("--repo <repository>", "Repository in owner/name format").option("--branch <branch>", "Git branch").option("--directory <directory>", "Root directory (relative to repo)").option("--preset <preset>", "Build preset (e.g., nextjs, nodejs, static, docker)").option("--connection <id>", "Git connection ID").option("--manual", "Create a manual (non-git) project - deploy via Docker image or static files").option("--source-type <type>", "Manual deployment method: manual (flexible), docker_image, or static_files").option("--image <image>", "Docker image for the first deployment (manual mode)").option("--port <port>", "Application/container port (manual mode, default: 3000)").option("-y, --yes", "Skip optional prompts (services, env vars, set-default)").action(create);
|
|
76837
76948
|
projects.command("show").alias("get").description("Show project details").option("-p, --project <project>", "Project slug or ID").option("--json", "Output in JSON format").action(show);
|
|
76838
76949
|
projects.command("update").alias("edit").description("Update project name and description").option("-p, --project <project>", "Project slug or ID").option("-n, --name <name>", "New project name").option("-d, --description <description>", "New project description").option("--json", "Output in JSON format").option("-y, --yes", "Skip prompts, use provided values (for automation)").action(updateProjectAction);
|
|
76839
76950
|
projects.command("settings").description("Update project settings (slug, attack mode, preview environments)").option("-p, --project <project>", "Project slug or ID").option("--slug <slug>", "Project URL slug").option("--attack-mode", "Enable attack mode (CAPTCHA protection)").option("--no-attack-mode", "Disable attack mode").option("--preview-envs", "Enable preview environments").option("--no-preview-envs", "Disable preview environments").option("--json", "Output in JSON format").option("-y, --yes", "Skip prompts (for automation)").action(updateSettingsAction);
|
|
@@ -77024,12 +77135,12 @@ var isWebWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanc
|
|
|
77024
77135
|
var isDedicatedWorker = typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
77025
77136
|
var isSharedWorker = typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope;
|
|
77026
77137
|
var isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope;
|
|
77027
|
-
var
|
|
77028
|
-
var isMacOs =
|
|
77029
|
-
var isWindows =
|
|
77030
|
-
var isLinux =
|
|
77031
|
-
var isIos =
|
|
77032
|
-
var isAndroid =
|
|
77138
|
+
var platform2 = globalThis.navigator?.userAgentData?.platform;
|
|
77139
|
+
var isMacOs = platform2 === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin";
|
|
77140
|
+
var isWindows = platform2 === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32";
|
|
77141
|
+
var isLinux = platform2 === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux";
|
|
77142
|
+
var isIos = platform2 === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
|
|
77143
|
+
var isAndroid = platform2 === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android";
|
|
77033
77144
|
|
|
77034
77145
|
// node_modules/ansi-escapes/base.js
|
|
77035
77146
|
var ESC3 = "\x1B[";
|
|
@@ -82202,7 +82313,7 @@ async function watchDeployment(options) {
|
|
|
82202
82313
|
init_sdk_gen();
|
|
82203
82314
|
init_prompts();
|
|
82204
82315
|
init_output();
|
|
82205
|
-
import { spawn as
|
|
82316
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
82206
82317
|
import { existsSync as existsSync6, createWriteStream, writeFileSync as writeFileSync3, mkdirSync } from "node:fs";
|
|
82207
82318
|
import { unlink as unlink2 } from "node:fs/promises";
|
|
82208
82319
|
import { resolve as resolve2, basename, join as join3 } from "node:path";
|
|
@@ -82541,7 +82652,7 @@ async function dockerBuild(options) {
|
|
|
82541
82652
|
args.push("--build-arg", arg);
|
|
82542
82653
|
}
|
|
82543
82654
|
args.push(options.context);
|
|
82544
|
-
const docker =
|
|
82655
|
+
const docker = spawn3("docker", args, {
|
|
82545
82656
|
stdio: ["ignore", "pipe", "pipe"]
|
|
82546
82657
|
});
|
|
82547
82658
|
let stderr = "";
|
|
@@ -82579,7 +82690,7 @@ ${stderr}`));
|
|
|
82579
82690
|
}
|
|
82580
82691
|
async function checkImageExists(imageName) {
|
|
82581
82692
|
return new Promise((resolve3) => {
|
|
82582
|
-
const docker =
|
|
82693
|
+
const docker = spawn3("docker", ["image", "inspect", imageName], {
|
|
82583
82694
|
stdio: ["ignore", "pipe", "pipe"]
|
|
82584
82695
|
});
|
|
82585
82696
|
docker.on("close", (code) => {
|
|
@@ -82592,7 +82703,7 @@ async function checkImageExists(imageName) {
|
|
|
82592
82703
|
}
|
|
82593
82704
|
async function getImageSize(imageName) {
|
|
82594
82705
|
return new Promise((resolve3) => {
|
|
82595
|
-
const docker =
|
|
82706
|
+
const docker = spawn3("docker", ["image", "inspect", "--format", "{{.Size}}", imageName], {
|
|
82596
82707
|
stdio: ["ignore", "pipe", "pipe"]
|
|
82597
82708
|
});
|
|
82598
82709
|
let output = "";
|
|
@@ -82615,7 +82726,7 @@ async function getImageSize(imageName) {
|
|
|
82615
82726
|
async function dockerSaveToFile(imageName, outputPath, onProgress) {
|
|
82616
82727
|
return new Promise((resolve3, reject2) => {
|
|
82617
82728
|
let totalBytes = 0;
|
|
82618
|
-
const docker =
|
|
82729
|
+
const docker = spawn3("docker", ["save", imageName], {
|
|
82619
82730
|
stdio: ["ignore", "pipe", "pipe"]
|
|
82620
82731
|
});
|
|
82621
82732
|
const writeStream = createWriteStream(outputPath);
|
|
@@ -82752,7 +82863,7 @@ init_output();
|
|
|
82752
82863
|
import { existsSync as existsSync7, statSync } from "node:fs";
|
|
82753
82864
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
82754
82865
|
import { basename as basename2, extname, resolve as resolve3 } from "node:path";
|
|
82755
|
-
import { spawn as
|
|
82866
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
82756
82867
|
async function deployStatic(options) {
|
|
82757
82868
|
await requireAuth();
|
|
82758
82869
|
await setupClient();
|
|
@@ -83028,7 +83139,7 @@ async function createTarGzFromDirectory(dirPath) {
|
|
|
83028
83139
|
const filename = `${dirName}.tar.gz`;
|
|
83029
83140
|
return new Promise((resolve4, reject2) => {
|
|
83030
83141
|
const chunks = [];
|
|
83031
|
-
const tar =
|
|
83142
|
+
const tar = spawn4("tar", ["-czf", "-", "-C", dirPath, "."], {
|
|
83032
83143
|
stdio: ["ignore", "pipe", "pipe"]
|
|
83033
83144
|
});
|
|
83034
83145
|
tar.stdout.on("data", (chunk2) => {
|
|
@@ -99067,11 +99178,11 @@ async function listTemplatesAction(options) {
|
|
|
99067
99178
|
init_sdk_gen();
|
|
99068
99179
|
init_output();
|
|
99069
99180
|
function registerPlatformCommands(program2) {
|
|
99070
|
-
const
|
|
99071
|
-
|
|
99072
|
-
|
|
99073
|
-
|
|
99074
|
-
|
|
99181
|
+
const platform3 = program2.command("platform").alias("plat").description("View platform and server information");
|
|
99182
|
+
platform3.command("info").description("Get platform information").option("--json", "Output in JSON format").action(platformInfoAction);
|
|
99183
|
+
platform3.command("access").description("Get access and networking information").option("--json", "Output in JSON format").action(accessInfoAction);
|
|
99184
|
+
platform3.command("private-ip").description("Get the server private IP address").action(privateIpAction);
|
|
99185
|
+
platform3.command("public-ip").description("Get the server public IP address").action(publicIpAction);
|
|
99075
99186
|
}
|
|
99076
99187
|
async function platformInfoAction(options) {
|
|
99077
99188
|
await requireAuth();
|
|
@@ -104014,11 +104125,11 @@ init_sdk_gen();
|
|
|
104014
104125
|
init_prompts();
|
|
104015
104126
|
init_output();
|
|
104016
104127
|
function openUrl(url) {
|
|
104017
|
-
const
|
|
104128
|
+
const platform3 = process.platform;
|
|
104018
104129
|
try {
|
|
104019
|
-
if (
|
|
104130
|
+
if (platform3 === "darwin") {
|
|
104020
104131
|
execSync3(`open "${url}"`);
|
|
104021
|
-
} else if (
|
|
104132
|
+
} else if (platform3 === "win32") {
|
|
104022
104133
|
execSync3(`start "" "${url}"`);
|
|
104023
104134
|
} else {
|
|
104024
104135
|
execSync3(`xdg-open "${url}"`);
|
|
@@ -104633,7 +104744,7 @@ function openBrowser2(url) {
|
|
|
104633
104744
|
}
|
|
104634
104745
|
} catch {}
|
|
104635
104746
|
}
|
|
104636
|
-
function
|
|
104747
|
+
function sleep2(ms) {
|
|
104637
104748
|
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
104638
104749
|
}
|
|
104639
104750
|
async function cloudLogin() {
|
|
@@ -104673,7 +104784,7 @@ async function cloudLogin() {
|
|
|
104673
104784
|
const deadline = Date.now() + deviceCode.expires_in * 1000;
|
|
104674
104785
|
let accessToken = null;
|
|
104675
104786
|
while (Date.now() < deadline) {
|
|
104676
|
-
await
|
|
104787
|
+
await sleep2(interval);
|
|
104677
104788
|
try {
|
|
104678
104789
|
const response = await fetch(`${cloudUrl}/api/auth/device/token`, {
|
|
104679
104790
|
method: "POST",
|