adhdev 0.1.9 → 0.1.11
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 +119 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -810,16 +810,16 @@ async function injectTokenToIDE(ide, connectionToken) {
|
|
|
810
810
|
try {
|
|
811
811
|
const os2 = await import("os");
|
|
812
812
|
const fs = await import("fs");
|
|
813
|
-
const
|
|
813
|
+
const path2 = await import("path");
|
|
814
814
|
const platform3 = os2.platform();
|
|
815
815
|
const home = os2.homedir();
|
|
816
816
|
const getSettingsPath = (appName2) => {
|
|
817
817
|
if (platform3 === "darwin") {
|
|
818
|
-
return
|
|
818
|
+
return path2.join(home, "Library", "Application Support", appName2, "User", "settings.json");
|
|
819
819
|
} else if (platform3 === "win32") {
|
|
820
|
-
return
|
|
820
|
+
return path2.join(process.env.APPDATA || path2.join(home, "AppData", "Roaming"), appName2, "User", "settings.json");
|
|
821
821
|
} else {
|
|
822
|
-
return
|
|
822
|
+
return path2.join(home, ".config", appName2, "User", "settings.json");
|
|
823
823
|
}
|
|
824
824
|
};
|
|
825
825
|
const appNameMap = {
|
|
@@ -841,7 +841,7 @@ async function injectTokenToIDE(ide, connectionToken) {
|
|
|
841
841
|
settings = {};
|
|
842
842
|
}
|
|
843
843
|
} else {
|
|
844
|
-
fs.mkdirSync(
|
|
844
|
+
fs.mkdirSync(path2.dirname(settingsPath), { recursive: true });
|
|
845
845
|
}
|
|
846
846
|
settings["adhdev.connectionToken"] = connectionToken;
|
|
847
847
|
settings["adhdev.autoConnect"] = true;
|
|
@@ -892,12 +892,13 @@ async function suggestGlobalInstall() {
|
|
|
892
892
|
const { execSync: execSyncLocal } = await import("child_process");
|
|
893
893
|
let isGloballyInstalled = false;
|
|
894
894
|
try {
|
|
895
|
-
const result = execSyncLocal("adhdev --
|
|
895
|
+
const result = execSyncLocal("npm list -g adhdev --json 2>/dev/null || npm list -g adhdev --json 2>nul", {
|
|
896
896
|
encoding: "utf-8",
|
|
897
|
-
timeout:
|
|
897
|
+
timeout: 1e4,
|
|
898
898
|
stdio: ["pipe", "pipe", "pipe"]
|
|
899
899
|
});
|
|
900
|
-
|
|
900
|
+
const parsed = JSON.parse(result);
|
|
901
|
+
isGloballyInstalled = !!parsed.dependencies?.adhdev;
|
|
901
902
|
} catch {
|
|
902
903
|
isGloballyInstalled = false;
|
|
903
904
|
}
|
|
@@ -947,6 +948,7 @@ async function suggestGlobalInstall() {
|
|
|
947
948
|
var import_child_process3 = require("child_process");
|
|
948
949
|
var net = __toESM(require("net"));
|
|
949
950
|
var os = __toESM(require("os"));
|
|
951
|
+
var path = __toESM(require("path"));
|
|
950
952
|
var CDP_PORTS = {
|
|
951
953
|
cursor: [9333, 9334],
|
|
952
954
|
antigravity: [9335, 9336],
|
|
@@ -964,12 +966,12 @@ var MAC_APP_IDENTIFIERS = {
|
|
|
964
966
|
vscodium: "VSCodium"
|
|
965
967
|
};
|
|
966
968
|
var WIN_PROCESS_NAMES = {
|
|
967
|
-
cursor: "Cursor.exe",
|
|
968
|
-
antigravity: "Antigravity.exe",
|
|
969
|
-
vscode: "Code.exe",
|
|
970
|
-
windsurf: "Windsurf.exe",
|
|
971
|
-
"vscode-insiders": "Code - Insiders.exe",
|
|
972
|
-
vscodium: "VSCodium.exe"
|
|
969
|
+
cursor: ["Cursor.exe"],
|
|
970
|
+
antigravity: ["Antigravity.exe"],
|
|
971
|
+
vscode: ["Code.exe"],
|
|
972
|
+
windsurf: ["Windsurf.exe"],
|
|
973
|
+
"vscode-insiders": ["Code - Insiders.exe"],
|
|
974
|
+
vscodium: ["VSCodium.exe"]
|
|
973
975
|
};
|
|
974
976
|
async function findFreePort(ports) {
|
|
975
977
|
for (const port2 of ports) {
|
|
@@ -1017,11 +1019,11 @@ async function isCdpActive(port) {
|
|
|
1017
1019
|
});
|
|
1018
1020
|
}
|
|
1019
1021
|
async function killIdeProcess(ideId) {
|
|
1020
|
-
const
|
|
1022
|
+
const plat = os.platform();
|
|
1021
1023
|
const appName = MAC_APP_IDENTIFIERS[ideId];
|
|
1022
|
-
const
|
|
1024
|
+
const winProcesses = WIN_PROCESS_NAMES[ideId];
|
|
1023
1025
|
try {
|
|
1024
|
-
if (
|
|
1026
|
+
if (plat === "darwin" && appName) {
|
|
1025
1027
|
try {
|
|
1026
1028
|
(0, import_child_process3.execSync)(`osascript -e 'tell application "${appName}" to quit' 2>/dev/null`, {
|
|
1027
1029
|
timeout: 5e3
|
|
@@ -1032,9 +1034,18 @@ async function killIdeProcess(ideId) {
|
|
|
1032
1034
|
} catch {
|
|
1033
1035
|
}
|
|
1034
1036
|
}
|
|
1035
|
-
} else if (
|
|
1037
|
+
} else if (plat === "win32" && winProcesses) {
|
|
1038
|
+
for (const proc of winProcesses) {
|
|
1039
|
+
try {
|
|
1040
|
+
(0, import_child_process3.execSync)(`taskkill /IM "${proc}" /F 2>nul`, { timeout: 5e3 });
|
|
1041
|
+
} catch {
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1036
1044
|
try {
|
|
1037
|
-
|
|
1045
|
+
const exeName = winProcesses[0].replace(".exe", "");
|
|
1046
|
+
(0, import_child_process3.execSync)(`powershell -Command "Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue | Stop-Process -Force"`, {
|
|
1047
|
+
timeout: 1e4
|
|
1048
|
+
});
|
|
1038
1049
|
} catch {
|
|
1039
1050
|
}
|
|
1040
1051
|
} else {
|
|
@@ -1047,15 +1058,17 @@ async function killIdeProcess(ideId) {
|
|
|
1047
1058
|
await new Promise((r) => setTimeout(r, 500));
|
|
1048
1059
|
if (!isIdeRunning(ideId)) return true;
|
|
1049
1060
|
}
|
|
1050
|
-
if (
|
|
1061
|
+
if (plat === "darwin" && appName) {
|
|
1051
1062
|
try {
|
|
1052
1063
|
(0, import_child_process3.execSync)(`pkill -9 -f "${appName}" 2>/dev/null`);
|
|
1053
1064
|
} catch {
|
|
1054
1065
|
}
|
|
1055
|
-
} else if (
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1066
|
+
} else if (plat === "win32" && winProcesses) {
|
|
1067
|
+
for (const proc of winProcesses) {
|
|
1068
|
+
try {
|
|
1069
|
+
(0, import_child_process3.execSync)(`taskkill /IM "${proc}" /F 2>nul`);
|
|
1070
|
+
} catch {
|
|
1071
|
+
}
|
|
1059
1072
|
}
|
|
1060
1073
|
}
|
|
1061
1074
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
@@ -1065,18 +1078,33 @@ async function killIdeProcess(ideId) {
|
|
|
1065
1078
|
}
|
|
1066
1079
|
}
|
|
1067
1080
|
function isIdeRunning(ideId) {
|
|
1068
|
-
const
|
|
1081
|
+
const plat = os.platform();
|
|
1069
1082
|
try {
|
|
1070
|
-
if (
|
|
1083
|
+
if (plat === "darwin") {
|
|
1071
1084
|
const appName = MAC_APP_IDENTIFIERS[ideId];
|
|
1072
1085
|
if (!appName) return false;
|
|
1073
1086
|
const result = (0, import_child_process3.execSync)(`pgrep -f "${appName}" 2>/dev/null`, { encoding: "utf-8" });
|
|
1074
1087
|
return result.trim().length > 0;
|
|
1075
|
-
} else if (
|
|
1076
|
-
const
|
|
1077
|
-
if (!
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1088
|
+
} else if (plat === "win32") {
|
|
1089
|
+
const winProcesses = WIN_PROCESS_NAMES[ideId];
|
|
1090
|
+
if (!winProcesses) return false;
|
|
1091
|
+
for (const proc of winProcesses) {
|
|
1092
|
+
try {
|
|
1093
|
+
const result = (0, import_child_process3.execSync)(`tasklist /FI "IMAGENAME eq ${proc}" /NH 2>nul`, { encoding: "utf-8" });
|
|
1094
|
+
if (result.includes(proc)) return true;
|
|
1095
|
+
} catch {
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
try {
|
|
1099
|
+
const exeName = winProcesses[0].replace(".exe", "");
|
|
1100
|
+
const result = (0, import_child_process3.execSync)(
|
|
1101
|
+
`powershell -Command "(Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue).Count"`,
|
|
1102
|
+
{ encoding: "utf-8", timeout: 5e3 }
|
|
1103
|
+
);
|
|
1104
|
+
return parseInt(result.trim()) > 0;
|
|
1105
|
+
} catch {
|
|
1106
|
+
}
|
|
1107
|
+
return false;
|
|
1080
1108
|
} else {
|
|
1081
1109
|
const result = (0, import_child_process3.execSync)(`pgrep -f "${ideId}" 2>/dev/null`, { encoding: "utf-8" });
|
|
1082
1110
|
return result.trim().length > 0;
|
|
@@ -1086,18 +1114,50 @@ function isIdeRunning(ideId) {
|
|
|
1086
1114
|
}
|
|
1087
1115
|
}
|
|
1088
1116
|
function detectCurrentWorkspace(ideId) {
|
|
1089
|
-
const
|
|
1090
|
-
if (
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1117
|
+
const plat = os.platform();
|
|
1118
|
+
if (plat === "darwin") {
|
|
1119
|
+
try {
|
|
1120
|
+
const appName = MAC_APP_IDENTIFIERS[ideId];
|
|
1121
|
+
if (!appName) return void 0;
|
|
1122
|
+
const result = (0, import_child_process3.execSync)(
|
|
1123
|
+
`lsof -c "${appName}" 2>/dev/null | grep cwd | head -1 | awk '{print $NF}'`,
|
|
1124
|
+
{ encoding: "utf-8", timeout: 3e3 }
|
|
1125
|
+
);
|
|
1126
|
+
const dir = result.trim();
|
|
1127
|
+
if (dir && dir !== "/") return dir;
|
|
1128
|
+
} catch {
|
|
1129
|
+
}
|
|
1130
|
+
} else if (plat === "win32") {
|
|
1131
|
+
try {
|
|
1132
|
+
const fs = require("fs");
|
|
1133
|
+
const appNameMap = {
|
|
1134
|
+
vscode: "Code",
|
|
1135
|
+
cursor: "Cursor",
|
|
1136
|
+
antigravity: "Antigravity",
|
|
1137
|
+
windsurf: "Windsurf",
|
|
1138
|
+
vscodium: "VSCodium"
|
|
1139
|
+
};
|
|
1140
|
+
const appName = appNameMap[ideId];
|
|
1141
|
+
if (appName) {
|
|
1142
|
+
const storagePath = path.join(
|
|
1143
|
+
process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"),
|
|
1144
|
+
appName,
|
|
1145
|
+
"storage.json"
|
|
1146
|
+
);
|
|
1147
|
+
if (fs.existsSync(storagePath)) {
|
|
1148
|
+
const data = JSON.parse(fs.readFileSync(storagePath, "utf-8"));
|
|
1149
|
+
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
1150
|
+
if (workspaces.length > 0) {
|
|
1151
|
+
const recent = workspaces[0];
|
|
1152
|
+
const uri = typeof recent === "string" ? recent : recent?.folderUri;
|
|
1153
|
+
if (uri?.startsWith("file:///")) {
|
|
1154
|
+
return decodeURIComponent(uri.replace("file:///", ""));
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
} catch {
|
|
1160
|
+
}
|
|
1101
1161
|
}
|
|
1102
1162
|
return void 0;
|
|
1103
1163
|
}
|
|
@@ -1226,12 +1286,22 @@ async function launchWindows(ide, port, workspace, newWindow) {
|
|
|
1226
1286
|
}
|
|
1227
1287
|
const args = ["--remote-debugging-port=" + port];
|
|
1228
1288
|
if (newWindow) args.push("--new-window");
|
|
1229
|
-
if (workspace) args.push(workspace);
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1289
|
+
if (workspace) args.push(`"${workspace}"`);
|
|
1290
|
+
const isCmd = cli.endsWith(".cmd") || cli.endsWith(".bat");
|
|
1291
|
+
if (isCmd) {
|
|
1292
|
+
const cmdLine = `start "" /b "${cli}" ${args.join(" ")}`;
|
|
1293
|
+
(0, import_child_process3.spawn)("cmd", ["/c", cmdLine], {
|
|
1294
|
+
detached: true,
|
|
1295
|
+
stdio: "ignore",
|
|
1296
|
+
windowsHide: true
|
|
1297
|
+
}).unref();
|
|
1298
|
+
} else {
|
|
1299
|
+
(0, import_child_process3.spawn)(cli, args, {
|
|
1300
|
+
detached: true,
|
|
1301
|
+
stdio: "ignore",
|
|
1302
|
+
shell: false
|
|
1303
|
+
}).unref();
|
|
1304
|
+
}
|
|
1235
1305
|
}
|
|
1236
1306
|
async function launchLinux(ide, port, workspace, newWindow) {
|
|
1237
1307
|
const cli = ide.cliCommand;
|