theclawbay 0.3.21 → 0.3.22
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/commands/setup.js +37 -1
- package/package.json +1 -1
package/dist/commands/setup.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
6
7
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
7
8
|
const node_os_1 = __importDefault(require("node:os"));
|
|
8
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -95,10 +96,45 @@ function localAppDataDir() {
|
|
|
95
96
|
return process.env.LOCALAPPDATA;
|
|
96
97
|
return node_path_1.default.join(node_os_1.default.homedir(), "AppData", "Local");
|
|
97
98
|
}
|
|
99
|
+
const TRAE_BUNDLE_RELATIVE_PATH = node_path_1.default.join("resources", "app", "node_modules", "@byted-icube", "ai-modules-chat", "dist", "index.js");
|
|
100
|
+
function appendTraeBundlePath(basePath) {
|
|
101
|
+
if (basePath.toLowerCase().endsWith(node_path_1.default.normalize(TRAE_BUNDLE_RELATIVE_PATH).toLowerCase())) {
|
|
102
|
+
return basePath;
|
|
103
|
+
}
|
|
104
|
+
return node_path_1.default.join(basePath, TRAE_BUNDLE_RELATIVE_PATH);
|
|
105
|
+
}
|
|
106
|
+
function traeBundleCandidateRoots() {
|
|
107
|
+
const candidates = new Set();
|
|
108
|
+
if (process.env.THECLAWBAY_TRAE_PATH?.trim()) {
|
|
109
|
+
candidates.add(process.env.THECLAWBAY_TRAE_PATH.trim());
|
|
110
|
+
}
|
|
111
|
+
const localPrograms = node_path_1.default.join(localAppDataDir(), "Programs");
|
|
112
|
+
candidates.add(node_path_1.default.join(localPrograms, "Trae"));
|
|
113
|
+
for (const envKey of ["ProgramFiles", "ProgramFiles(x86)"]) {
|
|
114
|
+
const root = process.env[envKey]?.trim();
|
|
115
|
+
if (root)
|
|
116
|
+
candidates.add(node_path_1.default.join(root, "Trae"));
|
|
117
|
+
}
|
|
118
|
+
if ((0, node_fs_1.existsSync)(localPrograms)) {
|
|
119
|
+
for (const entry of (0, node_fs_1.readdirSync)(localPrograms, { withFileTypes: true })) {
|
|
120
|
+
if (!entry.isDirectory())
|
|
121
|
+
continue;
|
|
122
|
+
if (!entry.name.toLowerCase().includes("trae"))
|
|
123
|
+
continue;
|
|
124
|
+
candidates.add(node_path_1.default.join(localPrograms, entry.name));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return Array.from(candidates);
|
|
128
|
+
}
|
|
98
129
|
function traeBundlePath() {
|
|
99
130
|
if (node_os_1.default.platform() !== "win32")
|
|
100
131
|
return null;
|
|
101
|
-
|
|
132
|
+
for (const candidateRoot of traeBundleCandidateRoots()) {
|
|
133
|
+
const bundlePath = appendTraeBundlePath(candidateRoot);
|
|
134
|
+
if ((0, node_fs_1.existsSync)(bundlePath))
|
|
135
|
+
return bundlePath;
|
|
136
|
+
}
|
|
137
|
+
return appendTraeBundlePath(node_path_1.default.join(localAppDataDir(), "Programs", "Trae"));
|
|
102
138
|
}
|
|
103
139
|
function traeBundleBackupPath(bundlePath) {
|
|
104
140
|
return `${bundlePath}${TRAE_BUNDLE_BACKUP_SUFFIX}`;
|