4runr-os 2.1.30 → 2.1.32
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/package.json +1 -1
- package/scripts/setup.js +71 -7
package/package.json
CHANGED
package/scripts/setup.js
CHANGED
|
@@ -9,6 +9,7 @@ import * as fs from 'fs';
|
|
|
9
9
|
import * as path from 'path';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
11
11
|
import { dirname } from 'path';
|
|
12
|
+
import * as readline from 'readline';
|
|
12
13
|
|
|
13
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
15
|
const __dirname = dirname(__filename);
|
|
@@ -148,14 +149,77 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
148
149
|
installed = true;
|
|
149
150
|
console.log(` ✅ Installed via winget: ${pkg}`);
|
|
150
151
|
|
|
151
|
-
// If MSYS2 was installed,
|
|
152
|
+
// If MSYS2 was installed, automatically install MinGW toolchain
|
|
152
153
|
if (pkg === 'msys2.msys2') {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
|
|
155
|
+
const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
|
|
156
|
+
|
|
157
|
+
// Check if MinGW is already installed
|
|
158
|
+
if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
|
|
159
|
+
console.log(`\n ✅ MinGW already installed in MSYS2`);
|
|
160
|
+
mingwInstalled = true;
|
|
161
|
+
mingwPath = msys2MingwPath;
|
|
162
|
+
} else {
|
|
163
|
+
// Automatically install MinGW toolchain via MSYS2
|
|
164
|
+
console.log('\n 🔨 Installing MinGW toolchain in MSYS2 (this may take a few minutes)...');
|
|
165
|
+
try {
|
|
166
|
+
execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
|
|
167
|
+
stdio: 'inherit',
|
|
168
|
+
timeout: 300000 // 5 minutes for installation
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Verify installation
|
|
172
|
+
if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
|
|
173
|
+
console.log(' ✅ MinGW toolchain installed successfully');
|
|
174
|
+
mingwInstalled = true;
|
|
175
|
+
mingwPath = msys2MingwPath;
|
|
176
|
+
} else {
|
|
177
|
+
console.warn(' ⚠️ Installation completed but MinGW not found. Please restart terminal and run 4runr-setup again.');
|
|
178
|
+
process.exit(0);
|
|
179
|
+
}
|
|
180
|
+
} catch (installError) {
|
|
181
|
+
console.error(' ❌ Failed to install MinGW automatically');
|
|
182
|
+
console.error(' Please install manually:');
|
|
183
|
+
console.error(' 1. Open MSYS2 terminal');
|
|
184
|
+
console.error(' 2. Run: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
|
|
185
|
+
console.error(' 3. Restart terminal and run: 4runr-setup\n');
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Add to PATH for current session
|
|
191
|
+
if (mingwInstalled && mingwPath) {
|
|
192
|
+
console.log(` ✅ Adding ${mingwPath} to PATH for this session...`);
|
|
193
|
+
process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
|
|
194
|
+
|
|
195
|
+
// Try to add to permanent PATH (may require admin)
|
|
196
|
+
try {
|
|
197
|
+
const currentPath = execSync('powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"', { encoding: 'utf-8' }).trim();
|
|
198
|
+
if (!currentPath.includes(mingwPath)) {
|
|
199
|
+
// Use synchronous readline for simpler flow
|
|
200
|
+
process.stdout.write('\n Add MinGW to PATH permanently? (recommended) [Y/n]: ');
|
|
201
|
+
const rl = readline.createInterface({
|
|
202
|
+
input: process.stdin,
|
|
203
|
+
output: process.stdout
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
rl.on('line', (answer) => {
|
|
207
|
+
rl.close();
|
|
208
|
+
if (!answer || answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
209
|
+
try {
|
|
210
|
+
execSync(`powershell -Command "[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + ';${mingwPath}', 'User')"`, { stdio: 'pipe' });
|
|
211
|
+
console.log(' ✅ Added to PATH permanently');
|
|
212
|
+
} catch {
|
|
213
|
+
console.log(' ⚠️ Could not add to PATH permanently. Please add manually:');
|
|
214
|
+
console.log(` ${mingwPath}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
} catch {
|
|
220
|
+
// Ignore - PATH update failed, user can add manually
|
|
221
|
+
}
|
|
222
|
+
}
|
|
159
223
|
}
|
|
160
224
|
break;
|
|
161
225
|
} catch (err) {
|