acadex-cli 1.0.3 → 1.0.4
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/acadex.js +41 -21
- package/package.json +1 -1
package/bin/acadex.js
CHANGED
|
@@ -6,56 +6,64 @@ const os = require('os');
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
|
|
8
8
|
const platform = os.platform();
|
|
9
|
-
// Use parent directory to access the scripts
|
|
10
9
|
const scriptDir = path.join(__dirname, '..');
|
|
11
10
|
|
|
12
11
|
let scriptPath;
|
|
13
12
|
let shell;
|
|
14
13
|
let shellArgs;
|
|
15
14
|
|
|
15
|
+
// Detect platform and select appropriate script
|
|
16
16
|
if (platform === 'win32') {
|
|
17
17
|
// Windows - use PowerShell script
|
|
18
18
|
scriptPath = path.join(scriptDir, 'acadex.ps1');
|
|
19
19
|
|
|
20
|
-
// Check if script exists
|
|
21
20
|
if (!fs.existsSync(scriptPath)) {
|
|
22
|
-
console.error(
|
|
23
|
-
console.error(
|
|
21
|
+
console.error('Error: ACADEX CLI is not properly installed for Windows.');
|
|
22
|
+
console.error(`Missing: ${scriptPath}`);
|
|
23
|
+
console.error('Please reinstall: npm install -g acadex-cli');
|
|
24
24
|
process.exit(1);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
shell = 'powershell.exe';
|
|
28
|
-
shellArgs = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
shellArgs = [
|
|
29
|
+
'-NoProfile',
|
|
30
|
+
'-ExecutionPolicy', 'Bypass',
|
|
31
|
+
'-File', scriptPath,
|
|
32
|
+
...process.argv.slice(2)
|
|
33
|
+
];
|
|
34
|
+
} else if (platform === 'darwin' || platform === 'linux') {
|
|
35
|
+
// macOS and Linux - use bash script
|
|
33
36
|
scriptPath = path.join(scriptDir, 'acadex');
|
|
34
37
|
|
|
35
|
-
// Check if script exists
|
|
36
38
|
if (!fs.existsSync(scriptPath)) {
|
|
37
|
-
console.error(
|
|
38
|
-
console.error(
|
|
39
|
+
console.error('Error: ACADEX CLI is not properly installed for Unix systems.');
|
|
40
|
+
console.error(`Missing: ${scriptPath}`);
|
|
41
|
+
console.error('Please reinstall: npm install -g acadex-cli');
|
|
39
42
|
process.exit(1);
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
//
|
|
45
|
+
// Ensure script is executable
|
|
43
46
|
try {
|
|
44
|
-
fs.chmodSync(scriptPath,
|
|
47
|
+
fs.chmodSync(scriptPath, 0o755);
|
|
45
48
|
} catch (err) {
|
|
46
|
-
//
|
|
49
|
+
// Silent fail - may not have permissions or already executable
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
shell = 'bash';
|
|
50
53
|
shellArgs = [scriptPath, ...process.argv.slice(2)];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
console.
|
|
54
|
+
} else {
|
|
55
|
+
// Unsupported platform
|
|
56
|
+
console.error(`Error: Unsupported platform: ${platform}`);
|
|
57
|
+
console.error('ACADEX CLI supports: Windows (win32), macOS (darwin), Linux (linux)');
|
|
58
|
+
console.error('Please report this issue if you believe this is an error.');
|
|
59
|
+
process.exit(1);
|
|
54
60
|
}
|
|
55
61
|
|
|
62
|
+
// Spawn the platform-specific script
|
|
56
63
|
const child = spawn(shell, shellArgs, {
|
|
57
64
|
stdio: 'inherit',
|
|
58
|
-
shell: false
|
|
65
|
+
shell: false,
|
|
66
|
+
windowsHide: true // Hide console window on Windows for cleaner experience
|
|
59
67
|
});
|
|
60
68
|
|
|
61
69
|
child.on('exit', (code) => {
|
|
@@ -63,8 +71,20 @@ child.on('exit', (code) => {
|
|
|
63
71
|
});
|
|
64
72
|
|
|
65
73
|
child.on('error', (err) => {
|
|
66
|
-
console.error('Failed to
|
|
74
|
+
console.error('\nError: Failed to execute ACADEX CLI');
|
|
75
|
+
console.error(`Reason: ${err.message}`);
|
|
67
76
|
console.error(`Platform: ${platform}`);
|
|
68
|
-
console.error(`Script
|
|
77
|
+
console.error(`Script: ${scriptPath}`);
|
|
78
|
+
console.error('\nTroubleshooting:');
|
|
79
|
+
|
|
80
|
+
if (platform === 'win32') {
|
|
81
|
+
console.error(' - Ensure PowerShell is installed and in PATH');
|
|
82
|
+
console.error(' - Try running PowerShell as Administrator');
|
|
83
|
+
} else {
|
|
84
|
+
console.error(' - Ensure bash is installed: which bash');
|
|
85
|
+
console.error(' - Check script permissions: ls -la $(which acadex)');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.error('\nReinstall: npm uninstall -g acadex-cli && npm install -g acadex-cli');
|
|
69
89
|
process.exit(1);
|
|
70
90
|
});
|