squad-station 0.8.18 → 0.8.19
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/bin/run.js +61 -17
- package/package.json +1 -1
package/bin/run.js
CHANGED
|
@@ -45,7 +45,7 @@ function install() {
|
|
|
45
45
|
|
|
46
46
|
function installBinary() {
|
|
47
47
|
// Binary version — may differ from npm package version
|
|
48
|
-
var VERSION = '0.8.
|
|
48
|
+
var VERSION = '0.8.19';
|
|
49
49
|
var REPO = 'thientranhung/squad-station';
|
|
50
50
|
|
|
51
51
|
var isWindows = process.platform === 'win32';
|
|
@@ -174,7 +174,7 @@ function findBestInstallDir() {
|
|
|
174
174
|
return squadBin;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
// Verify the installed binary is callable. If not,
|
|
177
|
+
// Verify the installed binary is callable. If not, auto-add to shell profile.
|
|
178
178
|
function verifyInPath(destPath, installDir) {
|
|
179
179
|
var isWindows = process.platform === 'win32';
|
|
180
180
|
var checkCmd = isWindows ? 'where' : 'which';
|
|
@@ -185,25 +185,62 @@ function verifyInPath(destPath, installDir) {
|
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
// Not in PATH — print instructions
|
|
189
|
-
console.log('');
|
|
190
|
-
console.log(' \x1b[33m⚠ squad-station is not in your PATH\x1b[0m');
|
|
191
|
-
console.log(' The binary was installed to: \x1b[36m' + installDir + '\x1b[0m');
|
|
192
|
-
console.log('');
|
|
193
|
-
|
|
194
188
|
if (isWindows) {
|
|
195
|
-
|
|
189
|
+
// Windows: print manual instructions (modifying registry is too invasive)
|
|
196
190
|
console.log('');
|
|
191
|
+
console.log(' \x1b[33m⚠ squad-station is not in your PATH\x1b[0m');
|
|
197
192
|
console.log(' \x1b[2m# Windows (PowerShell) — run as Administrator:\x1b[0m');
|
|
198
193
|
console.log(' \x1b[36m[Environment]::SetEnvironmentVariable("Path",\x1b[0m');
|
|
199
194
|
console.log(' \x1b[36m [Environment]::GetEnvironmentVariable("Path", "User") + ";' + installDir + '", "User")\x1b[0m');
|
|
200
|
-
console.log('');
|
|
201
195
|
console.log(' Then restart your terminal.');
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
console.log(' Add to your shell profile: \x1b[36mexport PATH="$HOME/.squad/bin:$PATH"\x1b[0m');
|
|
205
|
-
console.log(' Then restart your terminal or run: \x1b[36msource ' + shellProfile + '\x1b[0m');
|
|
196
|
+
console.log('');
|
|
197
|
+
return;
|
|
206
198
|
}
|
|
199
|
+
|
|
200
|
+
// macOS/Linux: auto-add to shell profile
|
|
201
|
+
var home = process.env.HOME || '';
|
|
202
|
+
var exportLine = 'export PATH="$HOME/.squad/bin:$PATH"';
|
|
203
|
+
var profileCandidates = process.platform === 'darwin'
|
|
204
|
+
? ['.zshrc', '.bash_profile', '.bashrc']
|
|
205
|
+
: ['.bashrc', '.zshrc', '.profile'];
|
|
206
|
+
|
|
207
|
+
// Find the first existing profile, or default to the platform's primary
|
|
208
|
+
var profileName = profileCandidates[0];
|
|
209
|
+
for (var i = 0; i < profileCandidates.length; i++) {
|
|
210
|
+
if (fs.existsSync(path.join(home, profileCandidates[i]))) {
|
|
211
|
+
profileName = profileCandidates[i];
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
var profilePath = path.join(home, profileName);
|
|
216
|
+
|
|
217
|
+
// Check if already added (idempotent)
|
|
218
|
+
var alreadyAdded = false;
|
|
219
|
+
try {
|
|
220
|
+
var content = fs.readFileSync(profilePath, 'utf8');
|
|
221
|
+
if (content.includes('.squad/bin')) {
|
|
222
|
+
alreadyAdded = true;
|
|
223
|
+
}
|
|
224
|
+
} catch (_) {
|
|
225
|
+
// File doesn't exist yet — we'll create it
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (!alreadyAdded) {
|
|
229
|
+
try {
|
|
230
|
+
var marker = '\n# Squad Station\n' + exportLine + '\n';
|
|
231
|
+
fs.appendFileSync(profilePath, marker);
|
|
232
|
+
console.log(' \x1b[32m✓\x1b[0m Added ~/.squad/bin to PATH in ~/' + profileName);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.log(' \x1b[33m⚠\x1b[0m Could not update ~/' + profileName + ': ' + e.message);
|
|
235
|
+
console.log(' Add manually: \x1b[36m' + exportLine + '\x1b[0m');
|
|
236
|
+
console.log('');
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Source the profile so it takes effect in the current npx process isn't needed,
|
|
242
|
+
// but we need the user's NEXT terminal to work. Print a note.
|
|
243
|
+
console.log(' \x1b[33m→\x1b[0m Run \x1b[36msource ~/' + profileName + '\x1b[0m or open a new terminal to activate.');
|
|
207
244
|
console.log('');
|
|
208
245
|
}
|
|
209
246
|
|
|
@@ -217,14 +254,21 @@ function checkDuplicateBinary(installedPath) {
|
|
|
217
254
|
return; // not in PATH at all — verifyInPath already warned
|
|
218
255
|
}
|
|
219
256
|
|
|
220
|
-
var
|
|
257
|
+
var whichPath = result.stdout.trim();
|
|
258
|
+
|
|
259
|
+
// Ignore npx cache / node_modules wrappers — these are not real installs
|
|
260
|
+
if (whichPath.includes('.npm/_npx') || whichPath.includes('node_modules/.bin') || whichPath.includes('node_modules\\.bin')) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
var resolvedWhich = fs.realpathSync(whichPath);
|
|
221
265
|
var resolvedInstalled = fs.realpathSync(installedPath);
|
|
222
266
|
|
|
223
267
|
if (resolvedWhich !== resolvedInstalled) {
|
|
224
268
|
console.log('');
|
|
225
|
-
console.log(' \x1b[33m⚠ Another squad-station found at: ' +
|
|
269
|
+
console.log(' \x1b[33m⚠ Another squad-station found at: ' + whichPath + '\x1b[0m');
|
|
226
270
|
console.log(' This version will be used instead of the one just installed.');
|
|
227
|
-
console.log(' Remove it to avoid conflicts: \x1b[36mrm ' +
|
|
271
|
+
console.log(' Remove it to avoid conflicts: \x1b[36mrm ' + whichPath + '\x1b[0m');
|
|
228
272
|
console.log('');
|
|
229
273
|
}
|
|
230
274
|
}
|