dank-ai 1.0.12 → 1.0.13
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/lib/docker/manager.js +63 -10
- package/package.json +1 -1
package/lib/docker/manager.js
CHANGED
|
@@ -132,16 +132,58 @@ class DockerManager {
|
|
|
132
132
|
async installDockerMacOS() {
|
|
133
133
|
this.logger.info('Installing Docker Desktop for macOS...');
|
|
134
134
|
|
|
135
|
-
// Check if Homebrew is available
|
|
135
|
+
// Check if Homebrew is available with multiple methods
|
|
136
|
+
let homebrewAvailable = false;
|
|
137
|
+
let homebrewPath = 'brew';
|
|
138
|
+
|
|
136
139
|
try {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await this.runCommand('brew install --cask docker', 'Installing Docker Desktop via Homebrew');
|
|
142
|
-
|
|
140
|
+
// Try different ways to detect Homebrew
|
|
141
|
+
await execAsync('brew --version');
|
|
142
|
+
homebrewAvailable = true;
|
|
143
|
+
homebrewPath = 'brew';
|
|
143
144
|
} catch (error) {
|
|
145
|
+
try {
|
|
146
|
+
// Try with full path (Apple Silicon Macs)
|
|
147
|
+
await execAsync('/opt/homebrew/bin/brew --version');
|
|
148
|
+
homebrewAvailable = true;
|
|
149
|
+
homebrewPath = '/opt/homebrew/bin/brew';
|
|
150
|
+
} catch (error2) {
|
|
151
|
+
try {
|
|
152
|
+
// Try with usr/local path (Intel Macs)
|
|
153
|
+
await execAsync('/usr/local/bin/brew --version');
|
|
154
|
+
homebrewAvailable = true;
|
|
155
|
+
homebrewPath = '/usr/local/bin/brew';
|
|
156
|
+
} catch (error3) {
|
|
157
|
+
// Try to find brew in PATH
|
|
158
|
+
try {
|
|
159
|
+
const { stdout } = await execAsync('which brew');
|
|
160
|
+
if (stdout.trim()) {
|
|
161
|
+
await execAsync(`${stdout.trim()} --version`);
|
|
162
|
+
homebrewAvailable = true;
|
|
163
|
+
homebrewPath = stdout.trim();
|
|
164
|
+
}
|
|
165
|
+
} catch (error4) {
|
|
166
|
+
// Homebrew not found
|
|
167
|
+
this.logger.debug('Homebrew detection failed:', error4.message);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (homebrewAvailable) {
|
|
174
|
+
this.logger.info(`Using Homebrew to install Docker Desktop (found at: ${homebrewPath})...`);
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
// Use the detected Homebrew path
|
|
178
|
+
await this.runCommand(`${homebrewPath} install --cask docker`, 'Installing Docker Desktop via Homebrew');
|
|
179
|
+
} catch (error) {
|
|
180
|
+
this.logger.warn('Homebrew found but installation failed. Please install Docker Desktop manually from https://www.docker.com/products/docker-desktop/');
|
|
181
|
+
this.logger.error(`Installation error: ${error.message}`);
|
|
182
|
+
throw new Error('Docker Desktop installation via Homebrew failed. Please install manually from https://www.docker.com/products/docker-desktop/');
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
144
185
|
this.logger.warn('Homebrew not found. Please install Docker Desktop manually from https://www.docker.com/products/docker-desktop/');
|
|
186
|
+
this.logger.info('You can install Homebrew by running: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"');
|
|
145
187
|
throw new Error('Docker Desktop installation requires manual intervention. Please install from https://www.docker.com/products/docker-desktop/');
|
|
146
188
|
}
|
|
147
189
|
}
|
|
@@ -171,7 +213,7 @@ class DockerManager {
|
|
|
171
213
|
// Install Docker
|
|
172
214
|
await this.runCommand('sudo apt-get install -y docker-ce docker-ce-cli containerd.io', 'Installing Docker');
|
|
173
215
|
|
|
174
|
-
// Add current user to docker
|
|
216
|
+
// Add current user to docker groupl
|
|
175
217
|
await this.runCommand('sudo usermod -aG docker $USER', 'Adding user to docker group');
|
|
176
218
|
|
|
177
219
|
this.logger.info('Docker installation completed. You may need to log out and back in for group changes to take effect.');
|
|
@@ -258,6 +300,7 @@ class DockerManager {
|
|
|
258
300
|
*/
|
|
259
301
|
async runCommand(command, description) {
|
|
260
302
|
this.logger.info(`${description}...`);
|
|
303
|
+
this.logger.debug(`Executing command: ${command}`);
|
|
261
304
|
|
|
262
305
|
return new Promise((resolve, reject) => {
|
|
263
306
|
const child = spawn('sh', ['-c', command], {
|
|
@@ -269,11 +312,17 @@ class DockerManager {
|
|
|
269
312
|
let stderr = '';
|
|
270
313
|
|
|
271
314
|
child.stdout.on('data', (data) => {
|
|
272
|
-
|
|
315
|
+
const output = data.toString();
|
|
316
|
+
stdout += output;
|
|
317
|
+
// Log output in debug mode
|
|
318
|
+
this.logger.debug(`STDOUT: ${output.trim()}`);
|
|
273
319
|
});
|
|
274
320
|
|
|
275
321
|
child.stderr.on('data', (data) => {
|
|
276
|
-
|
|
322
|
+
const output = data.toString();
|
|
323
|
+
stderr += output;
|
|
324
|
+
// Log stderr in debug mode
|
|
325
|
+
this.logger.debug(`STDERR: ${output.trim()}`);
|
|
277
326
|
});
|
|
278
327
|
|
|
279
328
|
child.on('close', (code) => {
|
|
@@ -283,12 +332,16 @@ class DockerManager {
|
|
|
283
332
|
} else {
|
|
284
333
|
const error = new Error(`Command failed with exit code ${code}: ${stderr}`);
|
|
285
334
|
this.logger.error(`${description} failed: ${error.message}`);
|
|
335
|
+
this.logger.error(`Command: ${command}`);
|
|
336
|
+
this.logger.error(`STDOUT: ${stdout}`);
|
|
337
|
+
this.logger.error(`STDERR: ${stderr}`);
|
|
286
338
|
reject(error);
|
|
287
339
|
}
|
|
288
340
|
});
|
|
289
341
|
|
|
290
342
|
child.on('error', (error) => {
|
|
291
343
|
this.logger.error(`${description} failed: ${error.message}`);
|
|
344
|
+
this.logger.error(`Command: ${command}`);
|
|
292
345
|
reject(error);
|
|
293
346
|
});
|
|
294
347
|
});
|