Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-08-19 06:28:08 +02:00
padre a92b2496e1
commit fdeb3b2a2c
Se han modificado 2 ficheros con 14 adiciones y 12 borrados

Ver fichero

@@ -216,7 +216,9 @@ class PackageManager {
try {
// Write buffer to temporary file and extract from there
const tempFile = path.join(os.tmpdir(), `${name}-${Date.now()}.tgz`);
// Sanitize package name for file system
const sanitizedName = name.replace(/[@/]/g, '-');
const tempFile = path.join(os.tmpdir(), `${sanitizedName}-${Date.now()}.tgz`);
await fs.writeFile(tempFile, packageData);
// Extract the tarball directly to the target directory
@@ -799,7 +801,12 @@ class PackageManager {
}
// Handle standard npm packages
const match = spec.match(/^(@?[^@]+)(?:@(.+))?$/);
// Improved regex to handle scoped packages like @scope/package@version
const match = spec.match(/^(@[^/]+\/[^@]+|[^@]+)(?:@(.+))?$/);
if (!match) {
throw new Error(`Invalid package specification: ${spec}`);
}
return {
name: match[1],
version: match[2] || 'latest',
@@ -1201,7 +1208,8 @@ class PackageManager {
// Create tarball from cloned directory
const tar = require('tar');
const tarballPath = path.join(os.tmpdir(), `${gitSpec.name}-${Date.now()}.tgz`);
const sanitizedName = gitSpec.name.replace(/[@/]/g, '-');
const tarballPath = path.join(os.tmpdir(), `${sanitizedName}-${Date.now()}.tgz`);
await tar.create({
gzip: true,
@@ -1242,7 +1250,8 @@ class PackageManager {
// Handle directory - create tarball
const tar = require('tar');
const os = require('os');
const tarballPath = path.join(os.tmpdir(), `${fileSpec.name}-${Date.now()}.tgz`);
const sanitizedName = fileSpec.name.replace(/[@/]/g, '-');
const tarballPath = path.join(os.tmpdir(), `${sanitizedName}-${Date.now()}.tgz`);
await tar.create({
gzip: true,