@gkiely/safe-install 0.1.2 → 0.1.4
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 +3 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,18 +25,12 @@ behind a reviewed allowlist in `package.json`.
|
|
|
25
25
|
ignore-scripts=true
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
2.
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
npm i --ignore-scripts -D safe-install
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
3. Add scripts to `package.json`:
|
|
28
|
+
2. Add script to `package.json`:
|
|
35
29
|
|
|
36
30
|
```json
|
|
37
31
|
{
|
|
38
32
|
"scripts": {
|
|
39
|
-
"safe-install": "safe-install"
|
|
33
|
+
"safe-install": "npx -y @gkiely/safe-install -- --no-audit --no-fund"
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
```
|
|
@@ -81,7 +75,7 @@ remote tarball URL specifier.
|
|
|
81
75
|
Equivalent manual flow:
|
|
82
76
|
|
|
83
77
|
```sh
|
|
84
|
-
npm install --ignore-scripts
|
|
78
|
+
npm install --ignore-scripts --no-audit --no-fund
|
|
85
79
|
npm rebuild --ignore-scripts=false esbuild sharp
|
|
86
80
|
```
|
|
87
81
|
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ type SafeInstallConfig = {
|
|
|
20
20
|
};
|
|
21
21
|
export declare function getSafeInstallConfig(pkg: PackageJson): SafeInstallConfig;
|
|
22
22
|
export declare function assertNoBlockedExoticSubdeps(config: SafeInstallConfig, packageLock: PackageLock): void;
|
|
23
|
+
export declare function getInstallArgs(args?: readonly string[]): string[];
|
|
23
24
|
export declare function reviewDepsCommand(): void;
|
|
24
|
-
export declare function installCommand(): void;
|
|
25
|
+
export declare function installCommand(args?: readonly string[]): void;
|
|
25
26
|
export declare function main(args?: string[]): void;
|
|
26
27
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -115,11 +115,15 @@ function run(command, args) {
|
|
|
115
115
|
process.exit(result.status ?? 1);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
export function getInstallArgs(args = []) {
|
|
119
|
+
return ["install", "--ignore-scripts", ...args];
|
|
120
|
+
}
|
|
118
121
|
function printHelp() {
|
|
119
122
|
console.log(`safe-install
|
|
120
123
|
|
|
121
124
|
Usage:
|
|
122
|
-
safe-install
|
|
125
|
+
safe-install [npm install flags]
|
|
126
|
+
Run npm install with scripts disabled, then rebuild trusted dependencies
|
|
123
127
|
safe-install review-deps
|
|
124
128
|
List dependencies that declare install-time scripts
|
|
125
129
|
`);
|
|
@@ -137,11 +141,11 @@ export function reviewDepsCommand() {
|
|
|
137
141
|
console.log("");
|
|
138
142
|
console.log("Review these packages before adding them to trustedDependencies.");
|
|
139
143
|
}
|
|
140
|
-
export function installCommand() {
|
|
144
|
+
export function installCommand(args = []) {
|
|
141
145
|
const pkg = readPackageJson();
|
|
142
146
|
const config = getSafeInstallConfig(pkg);
|
|
143
147
|
const trustedDependencies = getTrustedDependencies(pkg);
|
|
144
|
-
run("npm",
|
|
148
|
+
run("npm", getInstallArgs(args));
|
|
145
149
|
if (existsSync("package-lock.json")) {
|
|
146
150
|
assertNoBlockedExoticSubdeps(config, readPackageLock());
|
|
147
151
|
}
|
|
@@ -150,19 +154,19 @@ export function installCommand() {
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
export function main(args = process.argv.slice(2)) {
|
|
153
|
-
|
|
157
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
158
|
+
printHelp();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const command = args.find((arg) => arg !== "--" && !arg.startsWith("-"));
|
|
154
162
|
if (command === undefined) {
|
|
155
|
-
installCommand();
|
|
163
|
+
installCommand(args.filter((arg) => arg !== "--"));
|
|
156
164
|
return;
|
|
157
165
|
}
|
|
158
166
|
if (command === "review-deps") {
|
|
159
167
|
reviewDepsCommand();
|
|
160
168
|
return;
|
|
161
169
|
}
|
|
162
|
-
if (command === "--help" || command === "-h") {
|
|
163
|
-
printHelp();
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
170
|
throw new Error(`Unknown command: ${command}`);
|
|
167
171
|
}
|
|
168
172
|
if (process.argv[1] && realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1])) {
|
package/package.json
CHANGED