@infinitedusky/indusk-mcp 1.0.1 → 1.0.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
|
-
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { globSync } from "glob";
|
|
@@ -113,23 +113,35 @@ export async function extensionsAdd(projectRoot, name, from) {
|
|
|
113
113
|
ensureExtensionsDirs(projectRoot);
|
|
114
114
|
let manifestContent = null;
|
|
115
115
|
if (from.startsWith("npm:")) {
|
|
116
|
-
// Fetch from npm package
|
|
116
|
+
// Fetch from npm package by downloading tarball and extracting the manifest
|
|
117
117
|
const pkg = from.slice(4);
|
|
118
118
|
try {
|
|
119
|
-
|
|
119
|
+
// npm pack downloads the tarball to cwd
|
|
120
|
+
const tmpDir = join(projectRoot, ".indusk/tmp");
|
|
121
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
122
|
+
execSync(`npm pack ${pkg} --pack-destination "${tmpDir}"`, {
|
|
120
123
|
encoding: "utf-8",
|
|
121
124
|
timeout: 30000,
|
|
125
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
122
126
|
});
|
|
123
|
-
//
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
// Find the tarball
|
|
128
|
+
const tarballs = readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
|
|
129
|
+
if (tarballs.length === 0) {
|
|
130
|
+
console.info(` ${name}: failed to download ${pkg}`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// Extract indusk-extension.json from the tarball
|
|
134
|
+
try {
|
|
135
|
+
manifestContent = execSync(`tar -xzf "${join(tmpDir, tarballs[tarballs.length - 1])}" -O package/indusk-extension.json`, { encoding: "utf-8", timeout: 10000 });
|
|
128
136
|
}
|
|
129
|
-
|
|
137
|
+
catch {
|
|
130
138
|
console.info(` ${name}: no indusk-extension.json found in ${pkg}`);
|
|
139
|
+
// Cleanup
|
|
140
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
131
141
|
return;
|
|
132
142
|
}
|
|
143
|
+
// Cleanup
|
|
144
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
133
145
|
}
|
|
134
146
|
catch {
|
|
135
147
|
console.info(` ${name}: failed to fetch from npm:${pkg}`);
|