switchly 1.0.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/README.md +116 -0
- package/dist/commands/add.d.ts +11 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +211 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/keys.d.ts +2 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +40 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +38 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/remove.d.ts +7 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +85 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +92 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/switch.d.ts +2 -0
- package/dist/commands/switch.d.ts.map +1 -0
- package/dist/commands/switch.js +108 -0
- package/dist/commands/switch.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/services/gh.d.ts +15 -0
- package/dist/services/gh.d.ts.map +1 -0
- package/dist/services/gh.js +89 -0
- package/dist/services/gh.js.map +1 -0
- package/dist/services/git.d.ts +23 -0
- package/dist/services/git.d.ts.map +1 -0
- package/dist/services/git.js +130 -0
- package/dist/services/git.js.map +1 -0
- package/dist/services/ssh.d.ts +16 -0
- package/dist/services/ssh.d.ts.map +1 -0
- package/dist/services/ssh.js +180 -0
- package/dist/services/ssh.js.map +1 -0
- package/dist/services/store.d.ts +12 -0
- package/dist/services/store.d.ts.map +1 -0
- package/dist/services/store.js +58 -0
- package/dist/services/store.js.map +1 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/logger.d.ts +18 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +23 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import { log } from "../utils/logger.js";
|
|
4
|
+
import { getActiveProfile, getProfiles, getConfigPath } from "../services/store.js";
|
|
5
|
+
import { getCurrentGitUser, getSigningConfig } from "../services/git.js";
|
|
6
|
+
import { isGhInstalled, getGhAuthStatus } from "../services/gh.js";
|
|
7
|
+
import { testSSHConnection } from "../services/ssh.js";
|
|
8
|
+
export async function statusCommand(options = {}) {
|
|
9
|
+
const activeProfile = getActiveProfile();
|
|
10
|
+
const profiles = getProfiles();
|
|
11
|
+
log.title("GitHub Account Status");
|
|
12
|
+
// Active profile
|
|
13
|
+
if (activeProfile) {
|
|
14
|
+
console.log(chalk.green("● Active Profile:"), chalk.bold(activeProfile.name));
|
|
15
|
+
console.log(chalk.dim(` Git Name: ${activeProfile.gitName}`));
|
|
16
|
+
console.log(chalk.dim(` Git Email: ${activeProfile.gitEmail}`));
|
|
17
|
+
if (activeProfile.sshHost) {
|
|
18
|
+
console.log(chalk.dim(` SSH Host: ${activeProfile.sshHost}`));
|
|
19
|
+
}
|
|
20
|
+
if (activeProfile.signCommits && activeProfile.signingKey) {
|
|
21
|
+
const keyName = activeProfile.signingKey.split("/").pop();
|
|
22
|
+
console.log(chalk.dim(` Signing: ${activeProfile.signingFormat?.toUpperCase()} (${keyName})`));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
console.log(chalk.yellow("○ No active profile"));
|
|
27
|
+
}
|
|
28
|
+
console.log();
|
|
29
|
+
// Current Git config (actual values)
|
|
30
|
+
const gitUser = await getCurrentGitUser();
|
|
31
|
+
console.log(chalk.cyan("Git Configuration (Global):"));
|
|
32
|
+
console.log(chalk.dim(` user.name: ${gitUser.name || "(not set)"}`));
|
|
33
|
+
console.log(chalk.dim(` user.email: ${gitUser.email || "(not set)"}`));
|
|
34
|
+
// Check if Git config matches active profile
|
|
35
|
+
if (activeProfile) {
|
|
36
|
+
const nameMatches = gitUser.name === activeProfile.gitName;
|
|
37
|
+
const emailMatches = gitUser.email === activeProfile.gitEmail;
|
|
38
|
+
if (!nameMatches || !emailMatches) {
|
|
39
|
+
console.log(chalk.yellow("\n⚠ Git config doesn't match active profile!"));
|
|
40
|
+
console.log(chalk.dim(" Run `switchly use " + activeProfile.name + "` to sync."));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
console.log();
|
|
44
|
+
// Commit signing status
|
|
45
|
+
const signingConfig = await getSigningConfig();
|
|
46
|
+
console.log(chalk.cyan("Commit Signing:"));
|
|
47
|
+
if (signingConfig.signCommits) {
|
|
48
|
+
const keyName = signingConfig.signingKey?.split("/").pop() || signingConfig.signingKey;
|
|
49
|
+
console.log(chalk.green(` ✓ Enabled (${signingConfig.signingFormat || "gpg"})`));
|
|
50
|
+
console.log(chalk.dim(` Key: ${keyName || "(not set)"}`));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log(chalk.dim(" Disabled"));
|
|
54
|
+
}
|
|
55
|
+
console.log();
|
|
56
|
+
// GitHub CLI status
|
|
57
|
+
const ghInstalled = await isGhInstalled();
|
|
58
|
+
console.log(chalk.cyan("GitHub CLI (gh):"));
|
|
59
|
+
if (ghInstalled) {
|
|
60
|
+
const ghStatus = await getGhAuthStatus();
|
|
61
|
+
if (ghStatus.authenticated) {
|
|
62
|
+
console.log(chalk.green(` ✓ Authenticated as ${ghStatus.user}`));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.log(chalk.yellow(" ○ Not authenticated"));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.log(chalk.dim(" Not installed"));
|
|
70
|
+
}
|
|
71
|
+
// SSH connection test (if verbose or active profile has SSH)
|
|
72
|
+
if (options.verbose && activeProfile?.sshHost) {
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(chalk.cyan("SSH Connection Test:"));
|
|
75
|
+
const spinner = ora(`Testing ${activeProfile.sshHost}...`).start();
|
|
76
|
+
const sshWorks = await testSSHConnection(activeProfile.sshHost);
|
|
77
|
+
if (sshWorks) {
|
|
78
|
+
spinner.succeed(chalk.green(`SSH connection to ${activeProfile.sshHost} working`));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
spinner.fail(chalk.red(`SSH connection to ${activeProfile.sshHost} failed`));
|
|
82
|
+
console.log(chalk.dim(" Make sure you've added the public key to GitHub."));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Profile count
|
|
86
|
+
console.log();
|
|
87
|
+
console.log(chalk.dim(`${profiles.length} profile(s) configured`));
|
|
88
|
+
if (options.verbose) {
|
|
89
|
+
console.log(chalk.dim(`Config file: ${getConfigPath()}`));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAMvD,MAAM,CAAC,KAAK,UAAU,aAAa,C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AAO,CAAC,CAAC;QAChE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,aAAa,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;QACrF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,aAAa,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;YAC7E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IAED,gBAAgB;IAChB,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,wBAAwB,CAAC,CAAC,CAAC;IAEnE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/commands/switch.ts"],"names":[],"mappings":"AAaA,wBAAsB,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4GvE"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import ora from "ora";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import { log } from "../utils/logger.js";
|
|
5
|
+
import { getProfiles, getProfile, setActiveProfile, getActiveProfileName, } from "../services/store.js";
|
|
6
|
+
import { setGitUser, setSigningConfig, disableSigning } from "../services/git.js";
|
|
7
|
+
import { switchGhAuth, isGhInstalled } from "../services/gh.js";
|
|
8
|
+
export async function switchCommand(profileName) {
|
|
9
|
+
const profiles = getProfiles();
|
|
10
|
+
if (profiles.length === 0) {
|
|
11
|
+
log.error("No profiles configured. Run `switchly add` first.");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// If no profile specified, prompt for selection
|
|
15
|
+
if (!profileName) {
|
|
16
|
+
const activeProfile = getActiveProfileName();
|
|
17
|
+
const choices = profiles.map((p) => ({
|
|
18
|
+
name: p.name === activeProfile ? `${p.name} (current)` : p.name,
|
|
19
|
+
value: p.name,
|
|
20
|
+
}));
|
|
21
|
+
const answer = await inquirer.prompt([
|
|
22
|
+
{
|
|
23
|
+
type: "list",
|
|
24
|
+
name: "profile",
|
|
25
|
+
message: "Select a profile to switch to:",
|
|
26
|
+
choices,
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
profileName = answer.profile;
|
|
30
|
+
}
|
|
31
|
+
const profile = getProfile(profileName);
|
|
32
|
+
if (!profile) {
|
|
33
|
+
log.error(`Profile "${profileName}" not found.`);
|
|
34
|
+
console.log(chalk.dim("\nAvailable profiles:"));
|
|
35
|
+
profiles.forEach((p) => console.log(chalk.dim(` - ${p.name}`)));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const currentProfile = getActiveProfileName();
|
|
39
|
+
if (currentProfile === profileName) {
|
|
40
|
+
log.info(`Already using profile "${profileName}"`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
log.title(`Switching to "${profileName}"`);
|
|
44
|
+
// Switch Git config
|
|
45
|
+
const gitSpinner = ora("Updating Git config...").start();
|
|
46
|
+
try {
|
|
47
|
+
await setGitUser(profile.gitName, profile.gitEmail);
|
|
48
|
+
gitSpinner.succeed(`Git config: ${profile.gitName} <${profile.gitEmail}>`);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
gitSpinner.fail("Failed to update Git config");
|
|
52
|
+
log.error(error.message);
|
|
53
|
+
}
|
|
54
|
+
// Switch commit signing
|
|
55
|
+
if (profile.signCommits && profile.signingKey) {
|
|
56
|
+
const signingSpinner = ora("Configuring commit signing...").start();
|
|
57
|
+
try {
|
|
58
|
+
await setSigningConfig(profile.signingKey, profile.signingFormat, true);
|
|
59
|
+
signingSpinner.succeed(`Signing: ${profile.signingFormat?.toUpperCase()} (${profile.signingKey.split("/").pop()})`);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
signingSpinner.fail("Failed to configure signing");
|
|
63
|
+
log.error(error.message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Disable signing if not configured for this profile
|
|
68
|
+
try {
|
|
69
|
+
await disableSigning();
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Ignore errors
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Switch GitHub CLI auth if token exists
|
|
76
|
+
if (profile.ghToken) {
|
|
77
|
+
const ghInstalled = await isGhInstalled();
|
|
78
|
+
if (ghInstalled) {
|
|
79
|
+
const ghSpinner = ora("Switching GitHub CLI auth...").start();
|
|
80
|
+
try {
|
|
81
|
+
const success = await switchGhAuth(profile.ghToken);
|
|
82
|
+
if (success) {
|
|
83
|
+
ghSpinner.succeed("GitHub CLI authenticated");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
ghSpinner.warn("GitHub CLI auth switch failed");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
ghSpinner.fail("Failed to switch GitHub CLI auth");
|
|
91
|
+
log.error(error.message);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
log.dim("GitHub CLI (gh) not installed, skipping auth switch");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Update active profile
|
|
99
|
+
setActiveProfile(profileName);
|
|
100
|
+
console.log();
|
|
101
|
+
log.success(`Switched to profile "${profileName}"`);
|
|
102
|
+
// Show SSH clone hint
|
|
103
|
+
if (profile.sshHost) {
|
|
104
|
+
console.log(chalk.dim("\nFor repos with this profile, use:"));
|
|
105
|
+
console.log(chalk.cyan(` git clone git@${profile.sshHost}:username/repo.git`));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/commands/switch.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EACL,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAoB;IACtD,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAE/B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,GAAG,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;QAC/D,OAAO;IACT,CAAC;IAED,gDAAgD;IAChD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,aAAa,GAAG,oBAAoB,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;YAC/D,KAAK,EAAE,CAAC,CAAC,IAAI;SACd,CAAC,CAAC,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D,CAAC;qBAAM,CAAC;oBACN,SAAS,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,SAAS,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;gBACnD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,gBAAgB,CAAC,WAAY,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,GAAG,CAAC,OAAO,CAAC,wBAAwB,WAAW,GAAG,CAAC,CAAC;IAEpD,sBAAsB;IACtB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,OAAO,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;IAClF,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { addCommand } from "./commands/add.js";
|
|
4
|
+
import { listCommand } from "./commands/list.js";
|
|
5
|
+
import { switchCommand } from "./commands/switch.js";
|
|
6
|
+
import { removeCommand } from "./commands/remove.js";
|
|
7
|
+
import { statusCommand } from "./commands/status.js";
|
|
8
|
+
import { keysCommand } from "./commands/keys.js";
|
|
9
|
+
const program = new Command();
|
|
10
|
+
program
|
|
11
|
+
.name("switchly")
|
|
12
|
+
.description("Switch between multiple GitHub accounts easily")
|
|
13
|
+
.version("1.0.0");
|
|
14
|
+
program
|
|
15
|
+
.command("add")
|
|
16
|
+
.description("Add a new GitHub profile")
|
|
17
|
+
.option("-n, --name <name>", "Profile name")
|
|
18
|
+
.option("-e, --email <email>", "Git email")
|
|
19
|
+
.option("-u, --git-name <name>", "Git username")
|
|
20
|
+
.option("--skip-ssh", "Skip SSH key generation")
|
|
21
|
+
.option("--skip-gh", "Skip GitHub CLI token setup")
|
|
22
|
+
.action(addCommand);
|
|
23
|
+
program
|
|
24
|
+
.command("list")
|
|
25
|
+
.alias("ls")
|
|
26
|
+
.description("List all configured profiles")
|
|
27
|
+
.action(listCommand);
|
|
28
|
+
program
|
|
29
|
+
.command("use [profile]")
|
|
30
|
+
.alias("switch")
|
|
31
|
+
.description("Switch to a GitHub profile")
|
|
32
|
+
.action(switchCommand);
|
|
33
|
+
program
|
|
34
|
+
.command("remove [profile]")
|
|
35
|
+
.alias("rm")
|
|
36
|
+
.description("Remove a GitHub profile")
|
|
37
|
+
.option("-f, --force", "Skip confirmation prompt")
|
|
38
|
+
.option("--keep-ssh", "Keep SSH keys when removing profile")
|
|
39
|
+
.action(removeCommand);
|
|
40
|
+
program
|
|
41
|
+
.command("status")
|
|
42
|
+
.description("Show current profile and configuration status")
|
|
43
|
+
.option("-v, --verbose", "Show detailed information including SSH test")
|
|
44
|
+
.action(statusCommand);
|
|
45
|
+
program
|
|
46
|
+
.command("keys")
|
|
47
|
+
.description("List all SSH keys on this machine")
|
|
48
|
+
.action(keysCommand);
|
|
49
|
+
// Default to status if no command given
|
|
50
|
+
program
|
|
51
|
+
.action(() => {
|
|
52
|
+
statusCommand();
|
|
53
|
+
});
|
|
54
|
+
program.parse();
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":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BAAyB,CAAC;KACtC,MAAM,CAAC,aAAa,EAAE,0BAA0B,CAAC;KACjD,MAAM,CAAC,YAAY,EAAE,qCAAqC,CAAC;KAC3D,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,+CAA+C,CAAC;KAC5D,MAAM,CAAC,eAAe,EAAE,8CAA8C,CAAC;KACvE,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,mCAAmC,CAAC;KAChD,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,wCAAwC;AACxC,OAAO;KACJ,MAAM,CAAC,GAAG,EAAE;IACX,aAAa,EAAE,CAAC;AAClB,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function isGhInstalled(): Promise<boolean>;
|
|
2
|
+
export declare function getGhAuthStatus(): Promise<{
|
|
3
|
+
authenticated: boolean;
|
|
4
|
+
user: string | null;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function loginWithToken(token: string): Promise<boolean>;
|
|
7
|
+
export declare function logout(): Promise<void>;
|
|
8
|
+
export declare function readGhHosts(): Promise<string>;
|
|
9
|
+
export declare function validateToken(token: string): Promise<{
|
|
10
|
+
valid: boolean;
|
|
11
|
+
user: string | null;
|
|
12
|
+
scopes: string[];
|
|
13
|
+
}>;
|
|
14
|
+
export declare function switchGhAuth(token: string | undefined): Promise<boolean>;
|
|
15
|
+
//# sourceMappingURL=gh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gh.d.ts","sourceRoot":"","sources":["../../src/services/gh.ts"],"names":[],"mappings":"AAWA,wBAAsB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAOtD;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC;IAC/C,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC,CAYD;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWpE;AAED,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAM5C;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAMnD;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1D,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC,CAiBD;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAe9E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { readFile } from "fs/promises";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
const execAsync = promisify(exec);
|
|
7
|
+
const GH_CONFIG_DIR = join(homedir(), ".config", "gh");
|
|
8
|
+
const GH_HOSTS_PATH = join(GH_CONFIG_DIR, "hosts.yml");
|
|
9
|
+
export async function isGhInstalled() {
|
|
10
|
+
try {
|
|
11
|
+
await execAsync("gh --version");
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function getGhAuthStatus() {
|
|
19
|
+
try {
|
|
20
|
+
const { stdout } = await execAsync("gh auth status 2>&1");
|
|
21
|
+
const userMatch = stdout.match(/Logged in to github\.com account (\S+)/i);
|
|
22
|
+
return {
|
|
23
|
+
authenticated: true,
|
|
24
|
+
user: userMatch ? userMatch[1] : null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// gh auth status returns exit code 1 when not authenticated
|
|
29
|
+
return { authenticated: false, user: null };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function loginWithToken(token) {
|
|
33
|
+
try {
|
|
34
|
+
// Write token to stdin of gh auth login
|
|
35
|
+
const { stdout, stderr } = await execAsync(`echo "${token}" | gh auth login --with-token`);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error("GitHub CLI login failed:", error.message);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export async function logout() {
|
|
44
|
+
try {
|
|
45
|
+
await execAsync("gh auth logout --hostname github.com -y");
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Ignore errors if not logged in
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function readGhHosts() {
|
|
52
|
+
try {
|
|
53
|
+
return await readFile(GH_HOSTS_PATH, "utf-8");
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export async function validateToken(token) {
|
|
60
|
+
try {
|
|
61
|
+
const { stdout } = await execAsync(`curl -sS -H "Authorization: Bearer ${token}" https://api.github.com/user`);
|
|
62
|
+
const data = JSON.parse(stdout);
|
|
63
|
+
if (data.login) {
|
|
64
|
+
return {
|
|
65
|
+
valid: true,
|
|
66
|
+
user: data.login,
|
|
67
|
+
scopes: [], // Would need to parse headers for scopes
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return { valid: false, user: null, scopes: [] };
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return { valid: false, user: null, scopes: [] };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export async function switchGhAuth(token) {
|
|
77
|
+
if (!token) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const isInstalled = await isGhInstalled();
|
|
81
|
+
if (!isInstalled) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
// Logout current user
|
|
85
|
+
await logout();
|
|
86
|
+
// Login with new token
|
|
87
|
+
return await loginWithToken(token);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=gh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gh.js","sourceRoot":"","sources":["../../src/services/gh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACvD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,cAAc,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe;IAInC,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,qBAAqB,CAAC,CAAC;QAC1D,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC1E,OAAO;YACL,aAAa,EAAE,IAAI;YACnB,IAAI,EAAE,SAAS,CAAC,CAAC,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I;gBACX,IAAI,EAAE,IAAI,CAAC,KAAK;gBAChB,MAAM,EAAE,EAAE,EAAE,yCAAyC;aACtD,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAClD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAyB;IAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,aAAa,EAAE,CAAC;IAC1C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,sBAAsB;IACtB,MAAM,MAAM,EAAE,CAAC;IAEf,uBAAuB;IACvB,OAAO,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function getGitConfig(key: string, global?: boolean): Promise<string | null>;
|
|
2
|
+
export declare function setGitConfig(key: string, value: string, global?: boolean): Promise<void>;
|
|
3
|
+
export declare function unsetGitConfig(key: string, global?: boolean): Promise<void>;
|
|
4
|
+
export declare function getCurrentGitUser(): Promise<{
|
|
5
|
+
name: string | null;
|
|
6
|
+
email: string | null;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function setGitUser(name: string, email: string): Promise<void>;
|
|
9
|
+
export declare function isGitRepo(): Promise<boolean>;
|
|
10
|
+
export declare function getRepoRemoteUrl(): Promise<string | null>;
|
|
11
|
+
export declare function setRepoRemoteUrl(url: string): Promise<void>;
|
|
12
|
+
export declare function updateRemoteForProfile(profileName: string): Promise<boolean>;
|
|
13
|
+
export interface SigningConfig {
|
|
14
|
+
signingKey: string | null;
|
|
15
|
+
signingFormat: string | null;
|
|
16
|
+
signCommits: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function getSigningConfig(): Promise<SigningConfig>;
|
|
19
|
+
export declare function setSigningConfig(signingKey: string | undefined, signingFormat: "gpg" | "ssh" | undefined, signCommits: boolean | undefined): Promise<void>;
|
|
20
|
+
export declare function disableSigning(): Promise<void>;
|
|
21
|
+
export declare function listGPGKeys(): Promise<string[]>;
|
|
22
|
+
export declare function listSSHKeys(): Promise<string[]>;
|
|
23
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/services/git.ts"],"names":[],"mappings":"AAKA,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,UAAO,GACZ,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,UAAO,GACZ,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAO9E;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC;IACjD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC,CAMD;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3E;AAED,wBAAsB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAOlD;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO/D;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;AAED,wBAAsB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAclF;AAMD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAY/D;AAED,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,EACxC,WAAW,EAAE,OAAO,GAAG,SAAS,GAC/B,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAQrD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAOrD"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
const execAsync = promisify(exec);
|
|
4
|
+
export async function getGitConfig(key, global = true) {
|
|
5
|
+
try {
|
|
6
|
+
const flag = global ? "--global" : "--local";
|
|
7
|
+
const { stdout } = await execAsync(`git config ${flag} ${key}`);
|
|
8
|
+
return stdout.trim() || null;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function setGitConfig(key, value, global = true) {
|
|
15
|
+
const flag = global ? "--global" : "--local";
|
|
16
|
+
await execAsync(`git config ${flag} ${key} "${value}"`);
|
|
17
|
+
}
|
|
18
|
+
export async function unsetGitConfig(key, global = true) {
|
|
19
|
+
try {
|
|
20
|
+
const flag = global ? "--global" : "--local";
|
|
21
|
+
await execAsync(`git config ${flag} --unset ${key}`);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Ignore errors if key doesn't exist
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function getCurrentGitUser() {
|
|
28
|
+
const [name, email] = await Promise.all([
|
|
29
|
+
getGitConfig("user.name"),
|
|
30
|
+
getGitConfig("user.email"),
|
|
31
|
+
]);
|
|
32
|
+
return { name, email };
|
|
33
|
+
}
|
|
34
|
+
export async function setGitUser(name, email) {
|
|
35
|
+
// Run sequentially to avoid git config lock conflicts
|
|
36
|
+
await setGitConfig("user.name", name);
|
|
37
|
+
await setGitConfig("user.email", email);
|
|
38
|
+
}
|
|
39
|
+
export async function isGitRepo() {
|
|
40
|
+
try {
|
|
41
|
+
await execAsync("git rev-parse --git-dir");
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function getRepoRemoteUrl() {
|
|
49
|
+
try {
|
|
50
|
+
const { stdout } = await execAsync("git remote get-url origin");
|
|
51
|
+
return stdout.trim() || null;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function setRepoRemoteUrl(url) {
|
|
58
|
+
await execAsync(`git remote set-url origin "${url}"`);
|
|
59
|
+
}
|
|
60
|
+
export async function updateRemoteForProfile(profileName) {
|
|
61
|
+
const currentUrl = await getRepoRemoteUrl();
|
|
62
|
+
if (!currentUrl)
|
|
63
|
+
return false;
|
|
64
|
+
// Check if it's a GitHub SSH URL
|
|
65
|
+
const sshMatch = currentUrl.match(/^git@github\.com[^:]*:(.+)$/);
|
|
66
|
+
if (sshMatch) {
|
|
67
|
+
const repoPath = sshMatch[1];
|
|
68
|
+
const newUrl = `git@github.com-${profileName}:${repoPath}`;
|
|
69
|
+
await setRepoRemoteUrl(newUrl);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
export async function getSigningConfig() {
|
|
75
|
+
const [signingKey, signingFormat, gpgSign] = await Promise.all([
|
|
76
|
+
getGitConfig("user.signingkey"),
|
|
77
|
+
getGitConfig("gpg.format"),
|
|
78
|
+
getGitConfig("commit.gpgsign"),
|
|
79
|
+
]);
|
|
80
|
+
return {
|
|
81
|
+
signingKey,
|
|
82
|
+
signingFormat,
|
|
83
|
+
signCommits: gpgSign === "true",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export async function setSigningConfig(signingKey, signingFormat, signCommits) {
|
|
87
|
+
// Run sequentially to avoid git config lock conflicts
|
|
88
|
+
if (signingKey) {
|
|
89
|
+
await setGitConfig("user.signingkey", signingKey);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
await unsetGitConfig("user.signingkey");
|
|
93
|
+
}
|
|
94
|
+
if (signingFormat) {
|
|
95
|
+
await setGitConfig("gpg.format", signingFormat);
|
|
96
|
+
// For SSH signing, also set the allowed signers file path
|
|
97
|
+
if (signingFormat === "ssh") {
|
|
98
|
+
await setGitConfig("gpg.ssh.allowedSignersFile", "~/.ssh/allowed_signers");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
await unsetGitConfig("gpg.format");
|
|
103
|
+
}
|
|
104
|
+
if (signCommits !== undefined) {
|
|
105
|
+
await setGitConfig("commit.gpgsign", signCommits ? "true" : "false");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export async function disableSigning() {
|
|
109
|
+
await setGitConfig("commit.gpgsign", "false");
|
|
110
|
+
}
|
|
111
|
+
export async function listGPGKeys() {
|
|
112
|
+
try {
|
|
113
|
+
const { stdout } = await execAsync("gpg --list-secret-keys --keyid-format=long 2>/dev/null");
|
|
114
|
+
const matches = stdout.match(/sec\s+\w+\/([A-F0-9]+)/gi) || [];
|
|
115
|
+
return matches.map((m) => m.split("/")[1]);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export async function listSSHKeys() {
|
|
122
|
+
try {
|
|
123
|
+
const { stdout } = await execAsync("ls ~/.ssh/*.pub 2>/dev/null");
|
|
124
|
+
return stdout.trim().split("\n").filter(Boolean);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/services/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAW,EACX,MAAM,GAAG,IAAI;IAEb,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,cAAc,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAW,EACX,KAAa,EACb,MAAM,GAAG,IAAI;IAEb,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7C,MAAM,SAAS,CAAC,cAAc,IAAI,IAAI,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC;AAC1D,CAAC;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AC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SSHConfig } from "../types/index.js";
|
|
2
|
+
export declare function ensureSSHDir(): Promise<void>;
|
|
3
|
+
export declare function generateSSHKey(email: string, profileName: string): Promise<{
|
|
4
|
+
privateKey: string;
|
|
5
|
+
publicKey: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function readSSHConfig(): Promise<string>;
|
|
8
|
+
export declare function writeSSHConfig(content: string): Promise<void>;
|
|
9
|
+
export declare function parseSSHConfig(content: string): Map<string, SSHConfig>;
|
|
10
|
+
export declare function formatSSHConfig(config: SSHConfig): string;
|
|
11
|
+
export declare function addSSHHostConfig(profileName: string, privateKeyPath: string): Promise<string>;
|
|
12
|
+
export declare function removeSSHHostConfig(profileName: string): Promise<void>;
|
|
13
|
+
export declare function testSSHConnection(host: string): Promise<boolean>;
|
|
14
|
+
export declare function getSSHKeyPath(profileName: string): string;
|
|
15
|
+
export declare function sshKeyExists(profileName: string): Promise<boolean>;
|
|
16
|
+
//# sourceMappingURL=ssh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh.d.ts","sourceRoot":"","sources":["../../src/services/ssh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOnD,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAMlD;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBpD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAMrD;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CA+CtE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAazD;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CA6CjB;AAED,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB5E;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUtE;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOxE"}
|