@codella-software/cli 2.2.4 → 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 +71 -43
- package/bin/codella +0 -0
- package/package.json +2 -2
package/bin/cli.js
CHANGED
|
@@ -1,50 +1,78 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// Wrapper script to run the Go CLI binary
|
|
4
|
-
// In production, this would download and execute the appropriate binary for the platform
|
|
5
|
-
|
|
6
|
-
const { spawn } = require('child_process');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const os = require('os');
|
|
9
|
-
|
|
10
|
-
// Map Node.js platform/arch to Go binary naming
|
|
11
|
-
const platformMap = {
|
|
12
|
-
'darwin': {
|
|
13
|
-
'x64': 'codella-darwin-x64',
|
|
14
|
-
'arm64': 'codella-darwin-arm64'
|
|
15
|
-
},
|
|
16
|
-
'linux': {
|
|
17
|
-
'x64': 'codella-linux-x64',
|
|
18
|
-
'arm64': 'codella-linux-arm64'
|
|
19
|
-
},
|
|
20
|
-
'win32': {
|
|
21
|
-
'x64': 'codella-win32-x64.exe'
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
4
|
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
import { spawn, execSync } from 'child_process';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
27
10
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const binaryPath = path.join(__dirname, 'codella');
|
|
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
|
+
}
|
|
32
43
|
}
|
|
33
44
|
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// Spawn the Go CLI binary with all arguments passed through
|
|
46
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
47
|
+
stdio: 'inherit',
|
|
48
|
+
shell: false
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Pass through exit code
|
|
52
|
+
child.on('exit', (code) => {
|
|
53
|
+
process.exit(code || 0);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Handle errors
|
|
57
|
+
child.on('error', (error) => {
|
|
58
|
+
if (error.code === 'ENOENT') {
|
|
59
|
+
console.error('Error: Codella CLI binary not found');
|
|
60
|
+
console.error(`Expected at: ${binaryPath}`);
|
|
61
|
+
console.error('\nPlease rebuild the CLI:');
|
|
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
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
console.error('Error running Codella CLI:', error.message);
|
|
76
|
+
}
|
|
77
|
+
process.exit(1);
|
|
78
|
+
});
|
package/bin/codella
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codella-software/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "CLI for scaffolding Codella components into React projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "
|
|
28
|
+
"build": "bash scripts/build.sh",
|
|
29
29
|
"postinstall": "node scripts/postinstall.js",
|
|
30
30
|
"test": "echo 'CLI package: no tests to run'",
|
|
31
31
|
"test:run": "echo 'CLI package: no tests to run'",
|