@gkiely/safe-install 0.1.2 → 0.1.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 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11 -3
- 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"
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
```
|
|
@@ -65,7 +59,7 @@ specifiers.
|
|
|
65
59
|
6. Use `safe-install` for future installs:
|
|
66
60
|
|
|
67
61
|
```sh
|
|
68
|
-
npm run safe-install
|
|
62
|
+
npm run safe-install -- --no-audit --no-fund
|
|
69
63
|
```
|
|
70
64
|
|
|
71
65
|
## What `safe-install` does
|
|
@@ -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
|
}
|
|
@@ -163,6 +167,10 @@ export function main(args = process.argv.slice(2)) {
|
|
|
163
167
|
printHelp();
|
|
164
168
|
return;
|
|
165
169
|
}
|
|
170
|
+
if (command.startsWith("-")) {
|
|
171
|
+
installCommand(args);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
166
174
|
throw new Error(`Unknown command: ${command}`);
|
|
167
175
|
}
|
|
168
176
|
if (process.argv[1] && realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1])) {
|
package/package.json
CHANGED