tally-cli 0.3.0 → 0.4.1
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 +131 -0
- package/package.json +19 -17
- package/bin/index.js +0 -22
- package/get-exe.js +0 -18
- package/postinstall.js +0 -4
package/bin/cli.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require('child_process');
|
|
4
|
+
const { existsSync } = require('fs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get the platform-specific package name for the current system
|
|
8
|
+
* @returns {string} the npm package name for this platform
|
|
9
|
+
*/
|
|
10
|
+
function getPlatformPackageName() {
|
|
11
|
+
const platform = process.platform;
|
|
12
|
+
const arch = process.arch;
|
|
13
|
+
|
|
14
|
+
// Map Node.js platform/arch to our package naming convention
|
|
15
|
+
let pkgPlatform;
|
|
16
|
+
let pkgArch;
|
|
17
|
+
|
|
18
|
+
switch (platform) {
|
|
19
|
+
case 'linux':
|
|
20
|
+
pkgPlatform = 'linux';
|
|
21
|
+
break;
|
|
22
|
+
case 'darwin':
|
|
23
|
+
pkgPlatform = 'darwin';
|
|
24
|
+
break;
|
|
25
|
+
case 'win32':
|
|
26
|
+
case 'cygwin':
|
|
27
|
+
pkgPlatform = 'windows';
|
|
28
|
+
break;
|
|
29
|
+
case 'freebsd':
|
|
30
|
+
pkgPlatform = 'freebsd';
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
switch (arch) {
|
|
37
|
+
case 'x64':
|
|
38
|
+
pkgArch = 'x64';
|
|
39
|
+
break;
|
|
40
|
+
case 'arm64':
|
|
41
|
+
pkgArch = 'arm64';
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`Unsupported architecture: ${arch}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// FreeBSD only supports x64
|
|
48
|
+
if (pkgPlatform === 'freebsd' && pkgArch !== 'x64') {
|
|
49
|
+
throw new Error(`FreeBSD only supports x64 architecture, not ${arch}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return `@contino/tally-${pkgPlatform}-${pkgArch}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Find and execute the platform-specific tally binary
|
|
57
|
+
*/
|
|
58
|
+
function main() {
|
|
59
|
+
try {
|
|
60
|
+
const pkgName = getPlatformPackageName();
|
|
61
|
+
const binName = process.platform === 'win32' || process.platform === 'cygwin'
|
|
62
|
+
? 'tally.exe'
|
|
63
|
+
: 'tally';
|
|
64
|
+
|
|
65
|
+
// Try to resolve the binary path from the platform package
|
|
66
|
+
let binPath;
|
|
67
|
+
try {
|
|
68
|
+
binPath = require.resolve(`${pkgName}/bin/${binName}`);
|
|
69
|
+
} catch (resolveError) {
|
|
70
|
+
// Platform package not found or binary missing
|
|
71
|
+
console.error(`Error: Could not find tally binary for your platform (${pkgName}).`);
|
|
72
|
+
console.error('');
|
|
73
|
+
console.error('This usually means:');
|
|
74
|
+
console.error('1. Optional dependencies were disabled during installation');
|
|
75
|
+
console.error('2. Your platform is not supported');
|
|
76
|
+
console.error('');
|
|
77
|
+
console.error('To fix this:');
|
|
78
|
+
console.error('1. Reinstall with optional dependencies enabled:');
|
|
79
|
+
console.error(' npm install tally-cli');
|
|
80
|
+
console.error(' # or');
|
|
81
|
+
console.error(' yarn add tally-cli');
|
|
82
|
+
console.error(' # or');
|
|
83
|
+
console.error(' bun add tally-cli');
|
|
84
|
+
console.error('');
|
|
85
|
+
console.error('2. If you disabled optional dependencies, re-enable them:');
|
|
86
|
+
console.error(' npm install --include=optional');
|
|
87
|
+
console.error('');
|
|
88
|
+
console.error(`Expected package: ${pkgName}`);
|
|
89
|
+
console.error(`Platform: ${process.platform} ${process.arch}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Verify the binary exists and is executable
|
|
94
|
+
if (!existsSync(binPath)) {
|
|
95
|
+
console.error(`Error: Binary not found at ${binPath}`);
|
|
96
|
+
console.error('The platform package was installed but the binary is missing.');
|
|
97
|
+
console.error('Please try reinstalling tally-cli.');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Execute the binary with the same arguments passed to this script
|
|
102
|
+
// Skip the first two arguments (node and script path)
|
|
103
|
+
const args = process.argv.slice(2);
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
execFileSync(binPath, args, {
|
|
107
|
+
stdio: 'inherit', // Forward stdin/stdout/stderr to the user
|
|
108
|
+
windowsHide: false // On Windows, don't hide the console window
|
|
109
|
+
});
|
|
110
|
+
} catch (execError) {
|
|
111
|
+
// If the binary exits with a non-zero code, preserve that exit code
|
|
112
|
+
if (execError.status !== undefined) {
|
|
113
|
+
process.exit(execError.status);
|
|
114
|
+
}
|
|
115
|
+
// If there was an execution error (e.g., binary corrupted), report it
|
|
116
|
+
console.error(`Error executing tally binary: ${execError.message}`);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error(`Error: ${error.message}`);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Only run if this script is executed directly (not required as a module)
|
|
127
|
+
if (require.main === module) {
|
|
128
|
+
main();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = { getPlatformPackageName };
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tally-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A fast, configurable linter for Dockerfiles and Containerfiles",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/tinovyatkin/tally.git"
|
|
8
8
|
},
|
|
9
|
-
"main": "bin/index.js",
|
|
10
|
-
"files": [
|
|
11
|
-
"postinstall.js",
|
|
12
|
-
"get-exe.js"
|
|
13
|
-
],
|
|
14
9
|
"bin": {
|
|
15
|
-
"tally": "bin/
|
|
10
|
+
"tally": "./bin/cli.js"
|
|
16
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
17
16
|
"keywords": [
|
|
18
17
|
"docker",
|
|
19
18
|
"dockerfile",
|
|
@@ -28,16 +27,19 @@
|
|
|
28
27
|
"url": "https://github.com/tinovyatkin/tally/issues"
|
|
29
28
|
},
|
|
30
29
|
"homepage": "https://github.com/tinovyatkin/tally#readme",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18.0.0"
|
|
32
|
+
},
|
|
31
33
|
"optionalDependencies": {
|
|
32
|
-
"@contino/tally-darwin-arm64": "0.
|
|
33
|
-
"@contino/tally-darwin-x64": "0.
|
|
34
|
-
"@contino/tally-linux-arm64": "0.
|
|
35
|
-
"@contino/tally-linux-x64": "0.
|
|
36
|
-
"@contino/tally-windows-arm64": "0.
|
|
37
|
-
"@contino/tally-windows-x64": "0.
|
|
38
|
-
"@contino/tally-freebsd-x64": "0.
|
|
34
|
+
"@contino/tally-darwin-arm64": "0.4.1",
|
|
35
|
+
"@contino/tally-darwin-x64": "0.4.1",
|
|
36
|
+
"@contino/tally-linux-arm64": "0.4.1",
|
|
37
|
+
"@contino/tally-linux-x64": "0.4.1",
|
|
38
|
+
"@contino/tally-windows-arm64": "0.4.1",
|
|
39
|
+
"@contino/tally-windows-x64": "0.4.1",
|
|
40
|
+
"@contino/tally-freebsd-x64": "0.4.1"
|
|
39
41
|
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
42
44
|
}
|
|
43
|
-
}
|
|
45
|
+
}
|
package/bin/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawn } = require('child_process');
|
|
4
|
-
const { getExePath } = require('../get-exe');
|
|
5
|
-
|
|
6
|
-
const command_args = process.argv.slice(2);
|
|
7
|
-
|
|
8
|
-
const child = spawn(
|
|
9
|
-
getExePath(),
|
|
10
|
-
command_args,
|
|
11
|
-
{ stdio: "inherit" });
|
|
12
|
-
|
|
13
|
-
child.on('error', function (err) {
|
|
14
|
-
console.error(`Failed to execute binary: ${err.message}`);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
child.on('close', function (code) {
|
|
19
|
-
if (code !== 0) {
|
|
20
|
-
process.exit(code);
|
|
21
|
-
}
|
|
22
|
-
});
|
package/get-exe.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
function getExePath() {
|
|
2
|
-
// Detect OS
|
|
3
|
-
// https://nodejs.org/api/process.html#process_process_platform
|
|
4
|
-
let os = process.platform;
|
|
5
|
-
let extension = "";
|
|
6
|
-
if (["win32", "cygwin"].includes(process.platform)) {
|
|
7
|
-
os = "windows";
|
|
8
|
-
extension = ".exe";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Detect architecture
|
|
12
|
-
// https://nodejs.org/api/process.html#process_process_arch
|
|
13
|
-
let arch = process.arch;
|
|
14
|
-
|
|
15
|
-
return require.resolve(`@contino/tally-${os}-${arch}/bin/tally${extension}`);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
exports.getExePath = getExePath;
|
package/postinstall.js
DELETED