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.
Files changed (2) hide show
  1. package/bin/acadex.js +41 -21
  2. 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(`Error: PowerShell script not found at ${scriptPath}`);
23
- console.error('Please ensure acadex.ps1 is installed correctly.');
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 = ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptPath, ...process.argv.slice(2)];
29
-
30
- console.log('Running on Windows - Using PowerShell');
31
- } else {
32
- // Unix-like systems (Linux, macOS) - use bash script
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(`Error: Bash script not found at ${scriptPath}`);
38
- console.error('Please ensure acadex bash script is installed correctly.');
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
- // Make sure the script is executable
45
+ // Ensure script is executable
43
46
  try {
44
- fs.chmodSync(scriptPath, '755');
47
+ fs.chmodSync(scriptPath, 0o755);
45
48
  } catch (err) {
46
- // Ignore if we can't change permissions
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
- const platformName = platform === 'darwin' ? 'macOS' : 'Linux';
53
- console.log(`Running on ${platformName} - Using Bash`);
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 start subprocess:', err.message);
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 path: ${scriptPath}`);
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acadex-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A global CLI tool for managing Acadex projects with easy setup and automation",
5
5
  "main": "bin/acadex.js",
6
6
  "bin": {