periderm-cli 0.1.53 → 0.1.54
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 +4 -2
- package/scripts/postinstall.js +36 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "periderm-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"description": "Periderm CLI: The Local-First Security & Performance Code Scanner",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
-
"README.md"
|
|
12
|
+
"README.md",
|
|
13
|
+
"scripts"
|
|
13
14
|
],
|
|
14
15
|
"keywords": [
|
|
15
16
|
"cli",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"license": "MIT",
|
|
48
49
|
"scripts": {
|
|
49
50
|
"build": "tsc -p tsconfig.json && chmod +x dist/bin.js",
|
|
51
|
+
"postinstall": "node scripts/postinstall.js",
|
|
50
52
|
"postpublish": "cd ../../ && tsx --env-file=.env scripts/broadcast-update.ts",
|
|
51
53
|
"dev": "tsx src/index.ts",
|
|
52
54
|
"start": "node dist/index.js"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
|
|
5
|
+
// If this is running inside the curl install.sh script, skip cleanup!
|
|
6
|
+
// We want curl installations to KEEP their ~/.periderm/bin folders.
|
|
7
|
+
if (process.env.PERIDERM_CURL_INSTALL === "1") {
|
|
8
|
+
process.exit(0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Find actual home directory, even if running via sudo npm install -g
|
|
12
|
+
const isRoot = process.getuid && process.getuid() === 0;
|
|
13
|
+
const sudoUser = process.env.SUDO_USER;
|
|
14
|
+
|
|
15
|
+
let homeDir = os.homedir();
|
|
16
|
+
if (isRoot && sudoUser) {
|
|
17
|
+
// Basic fallback for Linux/macOS sudo users
|
|
18
|
+
if (fs.existsSync(`/home/${sudoUser}`)) {
|
|
19
|
+
homeDir = `/home/${sudoUser}`;
|
|
20
|
+
} else if (fs.existsSync(`/Users/${sudoUser}`)) {
|
|
21
|
+
homeDir = `/Users/${sudoUser}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const peridermDir = path.join(homeDir, ".periderm");
|
|
26
|
+
const binDir = path.join(peridermDir, "bin");
|
|
27
|
+
const nodeModulesDir = path.join(peridermDir, "node_modules");
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
// If the user installs globally via NPM, delete the legacy curl folders
|
|
31
|
+
// so that ~/.periderm/bin/periderm doesn't shadow /usr/local/bin/periderm.
|
|
32
|
+
fs.rmSync(binDir, { recursive: true, force: true });
|
|
33
|
+
fs.rmSync(nodeModulesDir, { recursive: true, force: true });
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// Silent fail
|
|
36
|
+
}
|