npmguard-cli 0.3.0 → 0.3.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/dist/commands/install.js +15 -2
- package/package.json +1 -1
package/dist/commands/install.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import ora from "ora";
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
|
-
import { writeFile, unlink, mkdir } from "node:fs/promises";
|
|
4
|
+
import { readFile, writeFile, unlink, mkdir } from "node:fs/promises";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
const IPFS_GATEWAY = "https://gateway.pinata.cloud/ipfs";
|
|
@@ -91,7 +91,20 @@ export async function installCommand(packageSpec, auditSource, force = false) {
|
|
|
91
91
|
console.log(chalk.green(` Installing from verified IPFS source...`));
|
|
92
92
|
console.log();
|
|
93
93
|
execSync(`npm install ${tarballPath}`, { stdio: "inherit" });
|
|
94
|
-
//
|
|
94
|
+
// Fix package.json — replace the file: path with the real version
|
|
95
|
+
try {
|
|
96
|
+
const pkgPath = join(process.cwd(), "package.json");
|
|
97
|
+
const pkgRaw = await readFile(pkgPath, "utf-8");
|
|
98
|
+
const pkg = JSON.parse(pkgRaw);
|
|
99
|
+
if (pkg.dependencies?.[packageName]?.startsWith("file:")) {
|
|
100
|
+
pkg.dependencies[packageName] = `^${requestedVersion}`;
|
|
101
|
+
await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// Not critical if this fails
|
|
106
|
+
}
|
|
107
|
+
// Cleanup tarball
|
|
95
108
|
await unlink(tarballPath).catch(() => { });
|
|
96
109
|
}
|
|
97
110
|
catch (err) {
|