@codella-software/cli 2.2.5 → 2.2.6
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/cli.js +44 -1
- package/bin/codella +0 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -2,14 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
// Wrapper script to run the Go CLI binary
|
|
4
4
|
|
|
5
|
-
import { spawn } from 'child_process';
|
|
5
|
+
import { spawn, execSync } from 'child_process';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import os from 'os';
|
|
8
|
+
import fs from 'fs';
|
|
8
9
|
import { fileURLToPath } from 'url';
|
|
9
10
|
|
|
10
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
12
|
const binaryPath = path.join(__dirname, 'codella');
|
|
12
13
|
|
|
14
|
+
// Ensure binary is executable
|
|
15
|
+
if (os.platform() !== 'win32') {
|
|
16
|
+
try {
|
|
17
|
+
// Check if binary exists
|
|
18
|
+
if (!fs.existsSync(binaryPath)) {
|
|
19
|
+
console.error('Error: Codella CLI binary not found');
|
|
20
|
+
console.error(`Expected at: ${binaryPath}`);
|
|
21
|
+
console.error('\nPlease reinstall the CLI:');
|
|
22
|
+
console.error(' npm install -g @codella-software/cli@latest');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Make sure it's executable
|
|
27
|
+
const stats = fs.statSync(binaryPath);
|
|
28
|
+
const isExecutable = (stats.mode & parseInt('0111', 8)) !== 0;
|
|
29
|
+
|
|
30
|
+
if (!isExecutable) {
|
|
31
|
+
try {
|
|
32
|
+
fs.chmodSync(binaryPath, '0755');
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error('Error: Could not make CLI binary executable');
|
|
35
|
+
console.error('Please try running: chmod +x ' + binaryPath);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error checking CLI binary:', error.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
13
45
|
// Spawn the Go CLI binary with all arguments passed through
|
|
14
46
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
15
47
|
stdio: 'inherit',
|
|
@@ -28,6 +60,17 @@ child.on('error', (error) => {
|
|
|
28
60
|
console.error(`Expected at: ${binaryPath}`);
|
|
29
61
|
console.error('\nPlease rebuild the CLI:');
|
|
30
62
|
console.error(' npm run build -w packages/cli-npm');
|
|
63
|
+
} else if (error.code === 'ENOEXEC') {
|
|
64
|
+
console.error('Error: Codella CLI binary is not executable');
|
|
65
|
+
console.error(`Expected at: ${binaryPath}`);
|
|
66
|
+
console.error('\nTrying to fix permissions...');
|
|
67
|
+
try {
|
|
68
|
+
fs.chmodSync(binaryPath, '0755');
|
|
69
|
+
console.error('✓ Permissions fixed, please try again');
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.error('Could not fix permissions. Please try:');
|
|
72
|
+
console.error(' chmod +x ' + binaryPath);
|
|
73
|
+
}
|
|
31
74
|
} else {
|
|
32
75
|
console.error('Error running Codella CLI:', error.message);
|
|
33
76
|
}
|
package/bin/codella
CHANGED
|
Binary file
|