package-version-info 0.2.2 → 0.2.3
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/README.md +4 -0
- package/bin/native/darwin-arm64/version_info +0 -0
- package/bin/native/darwin-x64/version_info +0 -0
- package/bin/native/linux-arm64/version_info +0 -0
- package/bin/native/linux-x64/version_info +0 -0
- package/bin/native/win32-x64/version_info.exe +0 -0
- package/bin/package-version-info.js +62 -0
- package/package.json +2 -2
- package/bin/version_info +0 -0
package/README.md
CHANGED
|
@@ -44,6 +44,10 @@ npm install package-version-info --save-dev
|
|
|
44
44
|
yarn add package-version-info --dev
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
The npm package includes native executables for macOS arm64/x64, Linux arm64/x64, and Windows
|
|
48
|
+
x64. A small Node.js launcher selects the matching executable at runtime; no platform-specific
|
|
49
|
+
packages are installed separately.
|
|
50
|
+
|
|
47
51
|
### 2. Generate the file
|
|
48
52
|
|
|
49
53
|
```bash
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { existsSync } = require('node:fs');
|
|
5
|
+
const { join } = require('node:path');
|
|
6
|
+
const { spawnSync } = require('node:child_process');
|
|
7
|
+
|
|
8
|
+
const supportedPlatforms = new Map([
|
|
9
|
+
['darwin-arm64', 'version_info'],
|
|
10
|
+
['darwin-x64', 'version_info'],
|
|
11
|
+
['linux-arm64', 'version_info'],
|
|
12
|
+
['linux-x64', 'version_info'],
|
|
13
|
+
['win32-x64', 'version_info.exe'],
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
function getBinaryPath(platform = process.platform, arch = process.arch, baseDir = __dirname) {
|
|
17
|
+
const id = `${platform}-${arch}`;
|
|
18
|
+
const binary = supportedPlatforms.get(id);
|
|
19
|
+
|
|
20
|
+
if (!binary) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Unsupported platform ${id}. Supported platforms: ${[...supportedPlatforms.keys()].join(', ')}.`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return join(baseDir, 'native', id, binary);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function resolveBinary(platform = process.platform, arch = process.arch) {
|
|
30
|
+
const id = `${platform}-${arch}`;
|
|
31
|
+
const binaryPath = getBinaryPath(platform, arch);
|
|
32
|
+
if (!existsSync(binaryPath)) {
|
|
33
|
+
throw new Error(`The package is missing its ${id} executable at ${binaryPath}.`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return binaryPath;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function run(args = process.argv.slice(2)) {
|
|
40
|
+
const binaryPath = resolveBinary();
|
|
41
|
+
const result = spawnSync(binaryPath, args, { stdio: 'inherit' });
|
|
42
|
+
|
|
43
|
+
if (result.error) throw result.error;
|
|
44
|
+
if (result.signal) {
|
|
45
|
+
process.kill(process.pid, result.signal);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process.exitCode = result.status ?? 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (require.main === module) {
|
|
53
|
+
try {
|
|
54
|
+
run();
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
console.error(`package-version-info: ${message}`);
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { getBinaryPath, resolveBinary, run };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "package-version-info",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Dominik Hladík",
|
|
6
6
|
"email": "dominik.hladik@seznam.cz",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"private": false,
|
|
11
11
|
"description": "Generate version info from package.json for TypeScript projects",
|
|
12
12
|
"bin": {
|
|
13
|
-
"package-version-info": "bin/
|
|
13
|
+
"package-version-info": "bin/package-version-info.js"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/Celtian/package-version-info",
|
|
16
16
|
"repository": {
|
package/bin/version_info
DELETED
|
Binary file
|