4runr-os 2.1.32 ā 2.1.34
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 +108 -74
package/package.json
CHANGED
package/scripts/setup.js
CHANGED
|
@@ -17,6 +17,8 @@ const __dirname = dirname(__filename);
|
|
|
17
17
|
const platform = process.platform;
|
|
18
18
|
const isWindows = platform === 'win32';
|
|
19
19
|
|
|
20
|
+
// Main setup function (async for delays)
|
|
21
|
+
async function runSetup() {
|
|
20
22
|
console.log('š Checking 4runr-os setup...\n');
|
|
21
23
|
|
|
22
24
|
// Check Node.js
|
|
@@ -97,48 +99,94 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
97
99
|
let mingwInstalled = false;
|
|
98
100
|
let mingwPath = '';
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
'
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
102
|
+
// PRIORITY 1: Check if MSYS2 exists FIRST (most reliable)
|
|
103
|
+
const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
|
|
104
|
+
const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
|
|
105
|
+
|
|
106
|
+
if (fs.existsSync(msys2Bash)) {
|
|
107
|
+
console.log(' ā
MSYS2 found - checking for MinGW...');
|
|
108
|
+
if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
|
|
109
|
+
mingwInstalled = true;
|
|
110
|
+
mingwPath = msys2MingwPath;
|
|
111
|
+
console.log(' ā
MinGW found in MSYS2');
|
|
112
|
+
} else {
|
|
113
|
+
// MSYS2 exists but MinGW not installed - install it automatically
|
|
114
|
+
console.log(' šØ Installing MinGW toolchain in MSYS2 (this may take 2-3 minutes)...');
|
|
115
|
+
try {
|
|
116
|
+
execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
|
|
117
|
+
stdio: 'inherit',
|
|
118
|
+
timeout: 300000 // 5 minutes
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
|
|
122
|
+
mingwInstalled = true;
|
|
123
|
+
mingwPath = msys2MingwPath;
|
|
124
|
+
console.log(' ā
MinGW toolchain installed successfully');
|
|
125
|
+
} else {
|
|
126
|
+
console.warn(' ā ļø Installation completed but MinGW not found');
|
|
127
|
+
console.warn(' Please restart terminal and run 4runr-setup again');
|
|
128
|
+
process.exit(0);
|
|
129
|
+
}
|
|
130
|
+
} catch (installError) {
|
|
131
|
+
console.error(' ā Failed to install MinGW automatically');
|
|
132
|
+
console.error(' Quick fix - run this command:');
|
|
133
|
+
console.error(` "${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`);
|
|
134
|
+
console.error(' Then restart terminal and run: 4runr-setup\n');
|
|
135
|
+
process.exit(1);
|
|
126
136
|
}
|
|
127
137
|
}
|
|
128
138
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
// Add to PATH for current session
|
|
140
|
+
if (mingwInstalled && mingwPath) {
|
|
141
|
+
console.log(` ā
Adding ${mingwPath} to PATH for this session...`);
|
|
142
|
+
process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// PRIORITY 2: Check PATH if MSYS2 didn't work
|
|
147
|
+
if (!mingwInstalled) {
|
|
148
|
+
try {
|
|
149
|
+
const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
150
|
+
mingwInstalled = true;
|
|
151
|
+
mingwPath = path.dirname(dlltoolPath);
|
|
152
|
+
console.log(' ā
MinGW found in PATH at:', mingwPath);
|
|
153
|
+
} catch {
|
|
154
|
+
// Check other common paths
|
|
155
|
+
console.log(' Checking common installation locations...');
|
|
156
|
+
const commonPaths = [
|
|
157
|
+
'C:\\mingw64\\bin',
|
|
158
|
+
'C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin',
|
|
140
159
|
];
|
|
141
160
|
|
|
161
|
+
for (const testPath of commonPaths) {
|
|
162
|
+
if (fs.existsSync(testPath)) {
|
|
163
|
+
const dlltoolPath = path.join(testPath, 'dlltool.exe');
|
|
164
|
+
if (fs.existsSync(dlltoolPath)) {
|
|
165
|
+
mingwInstalled = true;
|
|
166
|
+
mingwPath = testPath;
|
|
167
|
+
console.log(' ā
MinGW found at:', mingwPath);
|
|
168
|
+
process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// PRIORITY 3: Only if still not found, try winget installation
|
|
177
|
+
if (!mingwInstalled) {
|
|
178
|
+
console.log(' Installing MinGW-w64 via winget...');
|
|
179
|
+
|
|
180
|
+
// Try multiple installation methods
|
|
181
|
+
let installed = false;
|
|
182
|
+
|
|
183
|
+
// Try winget - MSYS2 is more reliable and includes MinGW
|
|
184
|
+
const wingetPackages = [
|
|
185
|
+
'msys2.msys2', // MSYS2 (includes MinGW, most reliable)
|
|
186
|
+
'mingw-w64.mingw-w64', // Direct MinGW package
|
|
187
|
+
'mingw-w64', // Alternative MinGW package name
|
|
188
|
+
];
|
|
189
|
+
|
|
142
190
|
for (const pkg of wingetPackages) {
|
|
143
191
|
try {
|
|
144
192
|
console.log(` Trying: winget install ${pkg}...`);
|
|
@@ -149,19 +197,21 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
149
197
|
installed = true;
|
|
150
198
|
console.log(` ā
Installed via winget: ${pkg}`);
|
|
151
199
|
|
|
152
|
-
// If MSYS2 was installed,
|
|
200
|
+
// If MSYS2 was just installed via winget, install MinGW inside it
|
|
153
201
|
if (pkg === 'msys2.msys2') {
|
|
154
|
-
|
|
155
|
-
|
|
202
|
+
// Wait a moment for MSYS2 installation to complete
|
|
203
|
+
console.log(' Waiting for MSYS2 installation to complete...');
|
|
204
|
+
const { setTimeout } = await import('timers/promises');
|
|
205
|
+
await setTimeout(5000);
|
|
156
206
|
|
|
157
207
|
// Check if MinGW is already installed
|
|
158
208
|
if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
|
|
159
|
-
console.log(
|
|
209
|
+
console.log(` ā
MinGW already installed in MSYS2`);
|
|
160
210
|
mingwInstalled = true;
|
|
161
211
|
mingwPath = msys2MingwPath;
|
|
162
212
|
} else {
|
|
163
213
|
// Automatically install MinGW toolchain via MSYS2
|
|
164
|
-
console.log('
|
|
214
|
+
console.log(' šØ Installing MinGW toolchain in MSYS2 (this may take 2-3 minutes)...');
|
|
165
215
|
try {
|
|
166
216
|
execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
|
|
167
217
|
stdio: 'inherit',
|
|
@@ -179,10 +229,9 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
179
229
|
}
|
|
180
230
|
} catch (installError) {
|
|
181
231
|
console.error(' ā Failed to install MinGW automatically');
|
|
182
|
-
console.error('
|
|
183
|
-
console.error(
|
|
184
|
-
console.error('
|
|
185
|
-
console.error(' 3. Restart terminal and run: 4runr-setup\n');
|
|
232
|
+
console.error(' Quick fix - run this command:');
|
|
233
|
+
console.error(` "${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`);
|
|
234
|
+
console.error(' Then restart terminal and run: 4runr-setup\n');
|
|
186
235
|
process.exit(1);
|
|
187
236
|
}
|
|
188
237
|
}
|
|
@@ -191,34 +240,18 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
191
240
|
if (mingwInstalled && mingwPath) {
|
|
192
241
|
console.log(` ā
Adding ${mingwPath} to PATH for this session...`);
|
|
193
242
|
process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
}
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
// Direct MinGW package - wait and check PATH
|
|
246
|
+
const { setTimeout } = await import('timers/promises');
|
|
247
|
+
await setTimeout(2000);
|
|
248
|
+
try {
|
|
249
|
+
const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
250
|
+
mingwInstalled = true;
|
|
251
|
+
mingwPath = path.dirname(dlltoolPath);
|
|
252
|
+
} catch {
|
|
253
|
+
// Not in PATH yet - user will need to restart terminal
|
|
254
|
+
console.warn(' ā ļø Installed but not in PATH - please restart terminal');
|
|
222
255
|
}
|
|
223
256
|
}
|
|
224
257
|
break;
|
|
@@ -340,4 +373,5 @@ if (mk3Dir && fs.existsSync(mk3Dir)) {
|
|
|
340
373
|
}
|
|
341
374
|
|
|
342
375
|
console.log('\nā
Setup complete! You can now run: 4r\n');
|
|
376
|
+
})();
|
|
343
377
|
|