editor-profile-sync 1.0.2 → 1.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/README.md +13 -2
- package/index.js +21 -6
- package/lib/editor-cli.js +75 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,16 @@ You can sync:
|
|
|
14
14
|
|
|
15
15
|
- **Node.js** 18 or newer
|
|
16
16
|
- **npm** (comes with Node.js)
|
|
17
|
-
- At least one [supported editor](#supported-editors) installed
|
|
17
|
+
- At least one [supported editor](#supported-editors) installed
|
|
18
|
+
- **macOS**: Choose one of the following options:
|
|
19
|
+
- **Option 1 (Recommended)**: Install terminal command:
|
|
20
|
+
1. Open your editor
|
|
21
|
+
2. Press `Cmd + Shift + P` to open the Command Palette
|
|
22
|
+
3. Type: `shell command`
|
|
23
|
+
4. Select: **Shell Command: Install '[command]' command in PATH**
|
|
24
|
+
5. Restart your terminal
|
|
25
|
+
- **Option 2**: Have the editor installed in `/Applications/` (e.g., `/Applications/Visual Studio Code.app`). The CLI will be auto-detected from the app bundle.
|
|
26
|
+
- **Windows/Linux**: Editor CLI must be on your PATH (e.g., `code`, `cursor`)
|
|
18
27
|
|
|
19
28
|
## Install
|
|
20
29
|
|
|
@@ -127,7 +136,9 @@ These editors are currently supported:
|
|
|
127
136
|
| VS Code | `code` |
|
|
128
137
|
| Windsurf | `windsurf` |
|
|
129
138
|
|
|
130
|
-
|
|
139
|
+
**macOS**: Editors work with either option: install terminal command (recommended) or auto-detect from `/Applications/` if installed as `.app` bundles.
|
|
140
|
+
|
|
141
|
+
**Windows/Linux**: Each editor must be installed and its CLI available in your terminal (e.g. `code`, `cursor`).
|
|
131
142
|
|
|
132
143
|
## Generated files
|
|
133
144
|
|
package/index.js
CHANGED
|
@@ -71,12 +71,27 @@ async function main() {
|
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
if (availableEditors.length === 0) {
|
|
74
|
-
detectSpinner.fail("No supported editors found
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
detectSpinner.fail("No supported editors found.");
|
|
75
|
+
if (process.platform === "darwin") {
|
|
76
|
+
console.log(
|
|
77
|
+
chalk.yellow(
|
|
78
|
+
"\n On macOS, you have two options:\n" +
|
|
79
|
+
" 1. Install terminal command (recommended):\n" +
|
|
80
|
+
" • Open your editor\n" +
|
|
81
|
+
" • Press Cmd + Shift + P\n" +
|
|
82
|
+
" • Type: shell command\n" +
|
|
83
|
+
" • Select: Shell Command: Install '[command]' command in PATH\n" +
|
|
84
|
+
" • Restart your terminal\n" +
|
|
85
|
+
" 2. Or make sure the editor is installed in /Applications/[EditorName].app\n",
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
} else {
|
|
89
|
+
console.log(
|
|
90
|
+
chalk.yellow(
|
|
91
|
+
"\n Install at least one supported editor and make sure its CLI is on your PATH.\n",
|
|
92
|
+
),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
80
95
|
process.exit(1);
|
|
81
96
|
}
|
|
82
97
|
|
package/lib/editor-cli.js
CHANGED
|
@@ -1,15 +1,80 @@
|
|
|
1
1
|
import { execSync, spawn } from "child_process";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
|
|
5
|
+
// macOS app bundle names for each editor
|
|
6
|
+
const MACOS_APP_BUNDLES = {
|
|
7
|
+
antigravity: "Antigravity.app",
|
|
8
|
+
cursor: "Cursor.app",
|
|
9
|
+
kiro: "Kiro.app",
|
|
10
|
+
trae: "Trae.app",
|
|
11
|
+
code: "Visual Studio Code.app",
|
|
12
|
+
windsurf: "Windsurf.app",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function findMacOSCliPath(editor) {
|
|
16
|
+
if (process.platform !== "darwin") return null;
|
|
17
|
+
|
|
18
|
+
const appName = MACOS_APP_BUNDLES[editor.id];
|
|
19
|
+
if (!appName) return null;
|
|
20
|
+
|
|
21
|
+
const appPath = join("/Applications", appName);
|
|
22
|
+
if (!existsSync(appPath)) return null;
|
|
23
|
+
|
|
24
|
+
// VS Code-based editors typically have CLI at:
|
|
25
|
+
// /Applications/AppName.app/Contents/Resources/app/bin/command
|
|
26
|
+
const cliPath = join(
|
|
27
|
+
appPath,
|
|
28
|
+
"Contents",
|
|
29
|
+
"Resources",
|
|
30
|
+
"app",
|
|
31
|
+
"bin",
|
|
32
|
+
editor.cmd,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (existsSync(cliPath)) {
|
|
36
|
+
return cliPath;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
2
41
|
|
|
3
42
|
export function isEditorInstalled(editor) {
|
|
43
|
+
// First check PATH
|
|
4
44
|
const cmd = process.platform === "win32" ? "where" : "which";
|
|
5
45
|
try {
|
|
6
46
|
execSync(`${cmd} ${editor.cmd}`, { stdio: "ignore" });
|
|
7
47
|
return true;
|
|
8
48
|
} catch {
|
|
49
|
+
// On macOS, also check app bundles
|
|
50
|
+
if (process.platform === "darwin") {
|
|
51
|
+
return findMacOSCliPath(editor) !== null;
|
|
52
|
+
}
|
|
9
53
|
return false;
|
|
10
54
|
}
|
|
11
55
|
}
|
|
12
56
|
|
|
57
|
+
export function getEditorCliPath(editor) {
|
|
58
|
+
// First check PATH
|
|
59
|
+
const cmd = process.platform === "win32" ? "where" : "which";
|
|
60
|
+
try {
|
|
61
|
+
const result = execSync(`${cmd} ${editor.cmd}`, { encoding: "utf-8" });
|
|
62
|
+
const path = result.trim().split("\n")[0];
|
|
63
|
+
if (path) return path;
|
|
64
|
+
} catch {
|
|
65
|
+
// Fall through to fallback options
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// On macOS, fall back to app bundle path
|
|
69
|
+
if (process.platform === "darwin") {
|
|
70
|
+
const macPath = findMacOSCliPath(editor);
|
|
71
|
+
if (macPath) return macPath;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Final fallback: use command name (should work if in PATH)
|
|
75
|
+
return editor.cmd;
|
|
76
|
+
}
|
|
77
|
+
|
|
13
78
|
function escapeShellArg(arg) {
|
|
14
79
|
const s = String(arg);
|
|
15
80
|
return s.includes(" ") || s.includes('"') ? `"${s.replace(/"/g, '""')}"` : s;
|
|
@@ -17,7 +82,10 @@ function escapeShellArg(arg) {
|
|
|
17
82
|
|
|
18
83
|
function runEditorCmdAsync(editor, args, options = {}) {
|
|
19
84
|
const { ignoreError = false } = options;
|
|
20
|
-
const
|
|
85
|
+
const cliPath = getEditorCliPath(editor);
|
|
86
|
+
const cmdString = [escapeShellArg(cliPath), ...args.map(escapeShellArg)].join(
|
|
87
|
+
" ",
|
|
88
|
+
);
|
|
21
89
|
|
|
22
90
|
return new Promise((resolve, reject) => {
|
|
23
91
|
const child = spawn(cmdString, [], {
|
|
@@ -73,6 +141,11 @@ export async function installExtension(editor, extensionId) {
|
|
|
73
141
|
}
|
|
74
142
|
|
|
75
143
|
export function uninstallExtension(editor, extensionId) {
|
|
76
|
-
const
|
|
144
|
+
const cliPath = getEditorCliPath(editor);
|
|
145
|
+
const cmd = [
|
|
146
|
+
escapeShellArg(cliPath),
|
|
147
|
+
"--uninstall-extension",
|
|
148
|
+
escapeShellArg(extensionId),
|
|
149
|
+
].join(" ");
|
|
77
150
|
execSync(cmd, { stdio: "ignore" });
|
|
78
151
|
}
|