@package-pal/cli 0.0.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/package.json +48 -0
- package/src/link-binary.js +84 -0
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@package-pal/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "CLI tool exposing core PackagePal functionality.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"package",
|
|
7
|
+
"pal",
|
|
8
|
+
"monorepo",
|
|
9
|
+
"dependencies",
|
|
10
|
+
"deps",
|
|
11
|
+
"cli"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@clack/prompts": "^0.11.0",
|
|
17
|
+
"@package-pal/core": "^0.0.2",
|
|
18
|
+
"@package-pal/util": "^0.0.4",
|
|
19
|
+
"@stricli/core": "^1.2.0",
|
|
20
|
+
"yoctocolors": "^2.1.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.8.3",
|
|
24
|
+
"@types/bun": "^1.2.19"
|
|
25
|
+
},
|
|
26
|
+
"optionalDependencies": {
|
|
27
|
+
"@package-pal/cli-linux-x64": "0.0.1",
|
|
28
|
+
"@package-pal/linux-x64-musl": "0.0.1",
|
|
29
|
+
"@package-pal/cli-linux-arm64": "0.0.1",
|
|
30
|
+
"@package-pal/linux-arm64-musl": "0.0.1",
|
|
31
|
+
"@package-pal/cli-darwin-arm64": "0.0.1",
|
|
32
|
+
"@package-pal/cli-darwin-x64": "0.0.1",
|
|
33
|
+
"@package-pal/cli-windows-x64": "0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"bun": ">=1.2.0"
|
|
37
|
+
},
|
|
38
|
+
"bin": {
|
|
39
|
+
"ppal": "bin/ppal",
|
|
40
|
+
"dppal": "./src/index.ts"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"./src/link-binary.js"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"postinstall": "node ./scripts/link-binary.js"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
copyFileSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync,
|
|
3
|
+
} from 'fs';
|
|
4
|
+
import {
|
|
5
|
+
arch, platform,
|
|
6
|
+
} from 'os';
|
|
7
|
+
import {
|
|
8
|
+
resolve, dirname,
|
|
9
|
+
} from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
import packageJson from '../package.json';
|
|
12
|
+
|
|
13
|
+
const usePlatform = platform();
|
|
14
|
+
const useArch = arch();
|
|
15
|
+
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const rawBinName = Object.keys(packageJson.bin)[0];
|
|
18
|
+
if (!rawBinName) {
|
|
19
|
+
throw new Error('Expected bin name.');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const binName = usePlatform === 'win32' ? `${rawBinName}.exe` : rawBinName;
|
|
23
|
+
const binDir = resolve(
|
|
24
|
+
__dirname, '..', 'bin',
|
|
25
|
+
);
|
|
26
|
+
const binTarget = resolve(binDir, binName);
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
rmSync(binTarget, { force: true });
|
|
30
|
+
rmSync(`${binTarget}.exe`, { force: true });
|
|
31
|
+
rmSync(`${binTarget}.cmd`, { force: true });
|
|
32
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
33
|
+
} catch (_) { /* empty */ }
|
|
34
|
+
|
|
35
|
+
let platformPackage = '';
|
|
36
|
+
switch (usePlatform) {
|
|
37
|
+
case 'darwin':
|
|
38
|
+
platformPackage = useArch === 'arm64' ? 'cli-darwin-arm64' : 'cli-darwin-x64';
|
|
39
|
+
break;
|
|
40
|
+
|
|
41
|
+
case 'win32':
|
|
42
|
+
platformPackage = 'cli-windows-x64';
|
|
43
|
+
break;
|
|
44
|
+
|
|
45
|
+
case 'linux':
|
|
46
|
+
let isMusl = false;
|
|
47
|
+
try {
|
|
48
|
+
// @ts-expect-error unknown type
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
50
|
+
isMusl = !process.report.getReport().header?.glibcVersionRuntime;
|
|
51
|
+
} catch {
|
|
52
|
+
isMusl = true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
platformPackage
|
|
56
|
+
= useArch === 'arm64'
|
|
57
|
+
? isMusl
|
|
58
|
+
? 'cli-linux-arm64-musl'
|
|
59
|
+
: 'cli-linux-arm64'
|
|
60
|
+
: isMusl
|
|
61
|
+
? 'cli-linux-x64-musl'
|
|
62
|
+
: 'cli-linux-x64';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!platformPackage) {
|
|
66
|
+
throw new Error(`Unsupported platform: ${usePlatform} ${useArch}.`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const binPath = resolve(
|
|
70
|
+
__dirname, '..', '..', platformPackage, binName,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (!existsSync(binPath)) {
|
|
74
|
+
throw new Error(`Expected binary not found: ${binPath}.`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
mkdirSync(binDir, { recursive: true });
|
|
78
|
+
|
|
79
|
+
if (usePlatform === 'win32') {
|
|
80
|
+
copyFileSync(binPath, `${binTarget}.exe`);
|
|
81
|
+
writeFileSync(`${binTarget}.cmd`, `@echo off\r\n"%~dp0\\{binName}.exe" %*\r\n`);
|
|
82
|
+
} else {
|
|
83
|
+
symlinkSync(binPath, binTarget);
|
|
84
|
+
}
|