aid-installer 0.7.5

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/aid.cmd ADDED
@@ -0,0 +1,24 @@
1
+ @echo off
2
+ :: aid.cmd - CMD entry point for the aid CLI.
3
+ :: Tries pwsh (PowerShell 7+) first, falls back to powershell (Windows PowerShell 5.1).
4
+ :: Installed at %AID_HOME%\bin\aid.cmd so that `aid` resolves in cmd.exe AND pwsh.
5
+ setlocal
6
+
7
+ set "AID_CMD_DIR=%~dp0"
8
+ set "AID_CMD_DIR=%AID_CMD_DIR:~0,-1%"
9
+ set "AID_PS1=%AID_CMD_DIR%\aid.ps1"
10
+
11
+ where pwsh >nul 2>nul
12
+ if %errorlevel%==0 (
13
+ pwsh -NoLogo -NonInteractive -File "%AID_PS1%" %*
14
+ exit /b %errorlevel%
15
+ )
16
+
17
+ where powershell >nul 2>nul
18
+ if %errorlevel%==0 (
19
+ powershell -NoLogo -NonInteractive -File "%AID_PS1%" %*
20
+ exit /b %errorlevel%
21
+ )
22
+
23
+ echo ERROR: aid: neither pwsh nor powershell found on PATH. Install PowerShell to use the aid CLI. >&2
24
+ exit /b 1
package/bin/aid.js ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ // aid.js - npm channel shim for the AID CLI.
3
+ //
4
+ // Purpose:
5
+ // Installed as the `aid` bin entry when the user runs `npm i -g aid-installer`.
6
+ // Spawns the vendored bin/aid (bash) or bin/aid.ps1 (pwsh/powershell) with
7
+ // AID_INSTALL_CHANNEL=npm injected into the child environment so that
8
+ // `aid update self` prints the npm upgrade hint instead of re-bootstrapping.
9
+ //
10
+ // Runtime selection:
11
+ // Windows -> try pwsh first, then powershell (with -NoLogo -NonInteractive -File)
12
+ // All else -> bash bin/aid
13
+ //
14
+ // argv forwarding: process.argv.slice(2) is spread as an array into spawnSync args
15
+ // (no shell:true) so spaces and shell metacharacters in arguments are safe.
16
+
17
+ 'use strict';
18
+
19
+ var spawnSync = require('child_process').spawnSync;
20
+ var path = require('path');
21
+ var os = require('os');
22
+ var process = require('process');
23
+ var fs = require('fs');
24
+
25
+ // packages/npm/bin/aid.js lives one level below the package root.
26
+ var pkgRoot = path.join(__dirname, '..');
27
+
28
+ var env = Object.assign({}, process.env, { AID_INSTALL_CHANNEL: 'npm' });
29
+
30
+ var userArgs = process.argv.slice(2);
31
+ var res;
32
+
33
+ if (process.platform === 'win32') {
34
+ var ps1 = path.join(pkgRoot, 'bin', 'aid.ps1');
35
+ var fixedFlagsPwsh = ['-NoLogo', '-NonInteractive', '-File', ps1];
36
+
37
+ // Try pwsh (PowerShell 7+) first.
38
+ res = spawnSync('pwsh', fixedFlagsPwsh.concat(userArgs), { stdio: 'inherit', env: env });
39
+
40
+ if (res.error && res.error.code === 'ENOENT') {
41
+ // Fallback to Windows PowerShell 5.1.
42
+ res = spawnSync('powershell', fixedFlagsPwsh.concat(userArgs), { stdio: 'inherit', env: env });
43
+
44
+ if (res.error && res.error.code === 'ENOENT') {
45
+ process.stderr.write(
46
+ 'ERROR: aid: neither pwsh nor powershell found on PATH.' +
47
+ ' Install PowerShell to use the aid CLI.\n'
48
+ );
49
+ process.exit(1);
50
+ }
51
+ }
52
+ } else {
53
+ var aidSh = path.join(pkgRoot, 'bin', 'aid');
54
+ res = spawnSync('bash', [aidSh].concat(userArgs), { stdio: 'inherit', env: env });
55
+
56
+ if (res.error && res.error.code === 'ENOENT') {
57
+ process.stderr.write(
58
+ 'ERROR: aid: bash not found on PATH.' +
59
+ ' Install bash to use the aid CLI.\n'
60
+ );
61
+ process.exit(1);
62
+ }
63
+ }
64
+
65
+ // Relay exit code (null when killed by signal).
66
+ if (res.status == null) {
67
+ process.exit(res.signal ? 1 : 0);
68
+ } else {
69
+ process.exit(res.status);
70
+ }