talos-deploy 0.0.3 → 0.0.4
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/api/client.js +2 -2
- package/dist/commands/auth.js +3 -3
- package/dist/commands/up.js +1 -1
- package/dist/config/index.js +4 -3
- package/dist/lib/ssh.js +4 -3
- package/package.json +1 -1
package/dist/api/client.js
CHANGED
|
@@ -6,7 +6,7 @@ import { loadConfig, getPortalUrl } from "../config/index.js";
|
|
|
6
6
|
export async function api(path, options = {}) {
|
|
7
7
|
const config = loadConfig();
|
|
8
8
|
if (!config) {
|
|
9
|
-
console.error("Not logged in. Run:
|
|
9
|
+
console.error("Not logged in. Run: talosd auth login");
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
const portalUrl = getPortalUrl();
|
|
@@ -21,7 +21,7 @@ export async function api(path, options = {}) {
|
|
|
21
21
|
headers,
|
|
22
22
|
});
|
|
23
23
|
if (resp.status === 401) {
|
|
24
|
-
console.error("Session expired. Run:
|
|
24
|
+
console.error("Session expired. Run: talosd auth login");
|
|
25
25
|
process.exit(1);
|
|
26
26
|
}
|
|
27
27
|
return resp;
|
package/dist/commands/auth.js
CHANGED
|
@@ -16,7 +16,7 @@ export async function authLoginCommand() {
|
|
|
16
16
|
const data = (await resp.json());
|
|
17
17
|
if (data.user?.email) {
|
|
18
18
|
console.log(`Already logged in as ${data.user.email}`);
|
|
19
|
-
console.log(`To switch accounts, run:
|
|
19
|
+
console.log(`To switch accounts, run: talosd auth login --force`);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -70,7 +70,7 @@ export async function authStatusCommand() {
|
|
|
70
70
|
const portalUrl = getPortalUrl();
|
|
71
71
|
if (!config?.token) {
|
|
72
72
|
console.log("Not logged in.");
|
|
73
|
-
console.log("Run:
|
|
73
|
+
console.log("Run: talosd auth login");
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
try {
|
|
@@ -83,7 +83,7 @@ export async function authStatusCommand() {
|
|
|
83
83
|
console.log(`Server: ${portalUrl}`);
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
console.log("Session expired. Run:
|
|
86
|
+
console.log("Session expired. Run: talosd auth login");
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
catch {
|
package/dist/commands/up.js
CHANGED
|
@@ -56,7 +56,7 @@ export async function upCommand(opts) {
|
|
|
56
56
|
// Step 4: Write SSH config with ProxyCommand
|
|
57
57
|
const binaryPath = resolveTalosBinaryPath();
|
|
58
58
|
updateSshConfig(opts.project, binaryPath);
|
|
59
|
-
process.stdout.write(`${CLEAR_LINE} ${GREEN}✓${RESET} SSH config updated (host:
|
|
59
|
+
process.stdout.write(`${CLEAR_LINE} ${GREEN}✓${RESET} SSH config updated (host: talosd-${opts.project})\n`);
|
|
60
60
|
// Step 5: SSH via host alias
|
|
61
61
|
console.log(`\n ${BOLD}Connecting via SSH...${RESET}\n`);
|
|
62
62
|
await sshIntoSandbox(opts.project);
|
package/dist/config/index.js
CHANGED
|
@@ -4,9 +4,10 @@ import os from "os";
|
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
export const CONFIG_DIR = path.join(os.homedir(), ".talos");
|
|
6
6
|
export const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
7
|
-
// Load .env from current directory or project root
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// Load .env from current directory or project root (quiet: suppresses banner
|
|
8
|
+
// that would corrupt SSH ProxyCommand binary protocol on stdout)
|
|
9
|
+
dotenv.config({ path: path.resolve(process.cwd(), ".env"), quiet: true }) ||
|
|
10
|
+
dotenv.config({ path: path.resolve(process.cwd(), "../..", ".env"), quiet: true });
|
|
10
11
|
// ── Config loading ─────────────────────────────────────
|
|
11
12
|
export function loadConfig() {
|
|
12
13
|
if (!fs.existsSync(CONFIG_FILE))
|
package/dist/lib/ssh.js
CHANGED
|
@@ -150,14 +150,15 @@ export function updateSshConfig(project, binaryPath, sshConfigPath = path.join(o
|
|
|
150
150
|
if (fs.existsSync(sshConfigPath)) {
|
|
151
151
|
content = fs.readFileSync(sshConfigPath, "utf-8");
|
|
152
152
|
}
|
|
153
|
-
const hostAlias = `
|
|
153
|
+
const hostAlias = `talosd-${project}`;
|
|
154
154
|
const block = `\nHost ${hostAlias}\n` +
|
|
155
155
|
` User coder\n` +
|
|
156
156
|
` StrictHostKeyChecking no\n` +
|
|
157
157
|
` UserKnownHostsFile /dev/null\n` +
|
|
158
158
|
` IdentityFile ~/.ssh/id_ed25519\n` +
|
|
159
159
|
` ProxyCommand ${binaryPath} ssh-proxy --project ${project}\n`;
|
|
160
|
-
|
|
160
|
+
// Replace existing block (new talosd- or legacy tt- naming)
|
|
161
|
+
const regex = new RegExp(`\n?Host (?:talosd|tt)-${project}\n(?: .*\n)*`);
|
|
161
162
|
if (regex.test(content)) {
|
|
162
163
|
content = content.replace(regex, block);
|
|
163
164
|
}
|
|
@@ -169,7 +170,7 @@ export function updateSshConfig(project, binaryPath, sshConfigPath = path.join(o
|
|
|
169
170
|
// ── SSH session ────────────────────────────────────────
|
|
170
171
|
export function sshIntoSandbox(project, spawnFn = spawn) {
|
|
171
172
|
return new Promise((resolve, reject) => {
|
|
172
|
-
const ssh = spawnFn("ssh", [`
|
|
173
|
+
const ssh = spawnFn("ssh", [`talosd-${project}`], { stdio: "inherit" });
|
|
173
174
|
ssh.on("close", (code) => {
|
|
174
175
|
if (code && code !== 0) {
|
|
175
176
|
reject(new Error(`SSH exited with code ${code}`));
|