4runr-os 2.1.33 ā 2.1.37
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 +147 -150
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,59 +99,65 @@ 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
|
-
|
|
126
|
-
|
|
127
|
-
} else {
|
|
128
|
-
// MSYS2 exists but MinGW not installed - install it automatically
|
|
129
|
-
console.log(' šØ Installing MinGW toolchain in MSYS2 (this may take a few minutes)...');
|
|
130
|
-
try {
|
|
131
|
-
execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
|
|
132
|
-
stdio: 'inherit',
|
|
133
|
-
timeout: 300000 // 5 minutes
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
|
|
137
|
-
mingwInstalled = true;
|
|
138
|
-
mingwPath = msys2MingwPath;
|
|
139
|
-
console.log(' ā
MinGW toolchain installed successfully');
|
|
140
|
-
} else {
|
|
141
|
-
console.warn(' ā ļø Installation completed but MinGW not found');
|
|
142
|
-
console.warn(' Please restart terminal and run 4runr-setup again');
|
|
143
|
-
}
|
|
144
|
-
} catch (installError) {
|
|
145
|
-
console.warn(' ā ļø Failed to install MinGW automatically');
|
|
146
|
-
console.warn(' Please run manually in MSYS2 terminal: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
|
|
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);
|
|
147
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);
|
|
148
136
|
}
|
|
149
137
|
}
|
|
150
138
|
|
|
151
|
-
//
|
|
152
|
-
if (
|
|
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',
|
|
159
|
+
];
|
|
160
|
+
|
|
153
161
|
for (const testPath of commonPaths) {
|
|
154
162
|
if (fs.existsSync(testPath)) {
|
|
155
163
|
const dlltoolPath = path.join(testPath, 'dlltool.exe');
|
|
@@ -157,29 +165,27 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
157
165
|
mingwInstalled = true;
|
|
158
166
|
mingwPath = testPath;
|
|
159
167
|
console.log(' ā
MinGW found at:', mingwPath);
|
|
168
|
+
process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
|
|
160
169
|
break;
|
|
161
170
|
}
|
|
162
171
|
}
|
|
163
172
|
}
|
|
164
173
|
}
|
|
174
|
+
}
|
|
165
175
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
176
|
+
// PRIORITY 3: Only if still not found, try winget installation
|
|
177
|
+
if (!mingwInstalled) {
|
|
178
|
+
console.log(' Installing MinGW-w64 via winget...');
|
|
170
179
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
'mingw-w64.mingw-w64', // Direct MinGW package
|
|
181
|
-
'mingw-w64', // Alternative MinGW package name
|
|
182
|
-
];
|
|
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
|
+
];
|
|
183
189
|
|
|
184
190
|
for (const pkg of wingetPackages) {
|
|
185
191
|
try {
|
|
@@ -191,19 +197,21 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
191
197
|
installed = true;
|
|
192
198
|
console.log(` ā
Installed via winget: ${pkg}`);
|
|
193
199
|
|
|
194
|
-
// If MSYS2 was installed,
|
|
200
|
+
// If MSYS2 was just installed via winget, install MinGW inside it
|
|
195
201
|
if (pkg === 'msys2.msys2') {
|
|
196
|
-
|
|
197
|
-
|
|
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);
|
|
198
206
|
|
|
199
207
|
// Check if MinGW is already installed
|
|
200
208
|
if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
|
|
201
|
-
console.log(
|
|
209
|
+
console.log(` ā
MinGW already installed in MSYS2`);
|
|
202
210
|
mingwInstalled = true;
|
|
203
211
|
mingwPath = msys2MingwPath;
|
|
204
212
|
} else {
|
|
205
213
|
// Automatically install MinGW toolchain via MSYS2
|
|
206
|
-
console.log('
|
|
214
|
+
console.log(' šØ Installing MinGW toolchain in MSYS2 (this may take 2-3 minutes)...');
|
|
207
215
|
try {
|
|
208
216
|
execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
|
|
209
217
|
stdio: 'inherit',
|
|
@@ -221,10 +229,9 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
221
229
|
}
|
|
222
230
|
} catch (installError) {
|
|
223
231
|
console.error(' ā Failed to install MinGW automatically');
|
|
224
|
-
console.error('
|
|
225
|
-
console.error(
|
|
226
|
-
console.error('
|
|
227
|
-
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');
|
|
228
235
|
process.exit(1);
|
|
229
236
|
}
|
|
230
237
|
}
|
|
@@ -233,34 +240,18 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
233
240
|
if (mingwInstalled && mingwPath) {
|
|
234
241
|
console.log(` ā
Adding ${mingwPath} to PATH for this session...`);
|
|
235
242
|
process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
rl.on('line', (answer) => {
|
|
249
|
-
rl.close();
|
|
250
|
-
if (!answer || answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
251
|
-
try {
|
|
252
|
-
execSync(`powershell -Command "[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + ';${mingwPath}', 'User')"`, { stdio: 'pipe' });
|
|
253
|
-
console.log(' ā
Added to PATH permanently');
|
|
254
|
-
} catch {
|
|
255
|
-
console.log(' ā ļø Could not add to PATH permanently. Please add manually:');
|
|
256
|
-
console.log(` ${mingwPath}`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
} catch {
|
|
262
|
-
// Ignore - PATH update failed, user can add manually
|
|
263
|
-
}
|
|
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');
|
|
264
255
|
}
|
|
265
256
|
}
|
|
266
257
|
break;
|
|
@@ -322,64 +313,70 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
|
|
|
322
313
|
console.warn(' rustup default stable-x86_64-pc-windows-gnu');
|
|
323
314
|
}
|
|
324
315
|
}
|
|
325
|
-
}
|
|
326
316
|
|
|
327
|
-
// Check if 4runr-os is installed
|
|
328
|
-
try {
|
|
329
|
-
execSync('4r --version', { stdio: 'ignore' });
|
|
330
|
-
console.log('ā
4runr-os is installed');
|
|
331
|
-
} catch {
|
|
332
|
-
console.log('ā ļø 4runr-os not found in PATH');
|
|
333
|
-
console.log(' Installing 4runr-os...');
|
|
317
|
+
// Check if 4runr-os is installed
|
|
334
318
|
try {
|
|
335
|
-
execSync('
|
|
336
|
-
console.log('ā
4runr-os installed');
|
|
319
|
+
execSync('4r --version', { stdio: 'ignore' });
|
|
320
|
+
console.log('ā
4runr-os is installed');
|
|
337
321
|
} catch {
|
|
338
|
-
console.
|
|
339
|
-
console.
|
|
340
|
-
|
|
322
|
+
console.log('ā ļø 4runr-os not found in PATH');
|
|
323
|
+
console.log(' Installing 4runr-os...');
|
|
324
|
+
try {
|
|
325
|
+
execSync('npm install -g 4runr-os@latest', { stdio: 'inherit' });
|
|
326
|
+
console.log('ā
4runr-os installed');
|
|
327
|
+
} catch {
|
|
328
|
+
console.error('ā Failed to install 4runr-os');
|
|
329
|
+
console.error(' Run manually: npm install -g 4runr-os@latest');
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
341
332
|
}
|
|
342
|
-
}
|
|
343
333
|
|
|
344
|
-
// Verify mk3-tui binary (check global install location)
|
|
345
|
-
let mk3Dir = null;
|
|
346
|
-
try {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
334
|
+
// Verify mk3-tui binary (check global install location)
|
|
335
|
+
let mk3Dir = null;
|
|
336
|
+
try {
|
|
337
|
+
// Try to find global install location
|
|
338
|
+
const npmPrefix = execSync('npm config get prefix', { encoding: 'utf-8' }).trim();
|
|
339
|
+
const globalPath = isWindows
|
|
340
|
+
? path.join(npmPrefix, 'node_modules', '4runr-os', 'mk3-tui')
|
|
341
|
+
: path.join(npmPrefix, 'lib', 'node_modules', '4runr-os', 'mk3-tui');
|
|
342
|
+
|
|
343
|
+
if (fs.existsSync(globalPath)) {
|
|
344
|
+
mk3Dir = globalPath;
|
|
345
|
+
}
|
|
346
|
+
} catch {
|
|
347
|
+
// Fallback to local
|
|
348
|
+
mk3Dir = path.join(__dirname, '..', 'mk3-tui');
|
|
355
349
|
}
|
|
356
|
-
} catch {
|
|
357
|
-
// Fallback to local
|
|
358
|
-
mk3Dir = path.join(__dirname, '..', 'mk3-tui');
|
|
359
|
-
}
|
|
360
350
|
|
|
361
|
-
if (mk3Dir && fs.existsSync(mk3Dir)) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
351
|
+
if (mk3Dir && fs.existsSync(mk3Dir)) {
|
|
352
|
+
const binaryName = isWindows ? 'mk3-tui.exe' : 'mk3-tui';
|
|
353
|
+
const binaryPath = path.join(mk3Dir, 'target', 'release', binaryName);
|
|
354
|
+
|
|
355
|
+
if (!fs.existsSync(binaryPath)) {
|
|
356
|
+
console.log('\nšØ Building mk3-tui binary...');
|
|
357
|
+
try {
|
|
358
|
+
execSync('cargo build --release', {
|
|
359
|
+
cwd: mk3Dir,
|
|
360
|
+
stdio: 'inherit',
|
|
361
|
+
});
|
|
362
|
+
console.log('ā
mk3-tui built successfully');
|
|
363
|
+
} catch (error) {
|
|
364
|
+
console.warn('ā ļø Failed to build mk3-tui');
|
|
365
|
+
console.warn(' The binary will be built automatically on first run of 4r');
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
console.log('ā
mk3-tui binary found');
|
|
376
369
|
}
|
|
377
370
|
} else {
|
|
378
|
-
console.log('
|
|
371
|
+
console.log('ā ļø mk3-tui source not found - will build on first run of 4r');
|
|
379
372
|
}
|
|
380
|
-
|
|
381
|
-
console.log('
|
|
373
|
+
|
|
374
|
+
console.log('\nā
Setup complete! You can now run: 4r\n');
|
|
382
375
|
}
|
|
383
376
|
|
|
384
|
-
|
|
377
|
+
// Run the setup
|
|
378
|
+
runSetup().catch((error) => {
|
|
379
|
+
console.error('\nā Setup failed:', error);
|
|
380
|
+
process.exit(1);
|
|
381
|
+
});
|
|
385
382
|
|