Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-08-19 06:51:59 +02:00
padre 30d2b35bda
commit e46dd6a16a

Ver fichero

@@ -125,8 +125,8 @@ class PackageManager {
const packages = Object.entries(dependencies).map(([name, version]) => `${name}@${version}`);
// Call the main installation logic directly, bypassing the package.json check
return await this.installPackages(packages, { ...options, fromPackageJson: true });
// Call the main installation logic with special flag for package.json installs
return await this.installPackages(packages, { ...options, fromPackageJsonMain: true });
}
async installPackages(packages, options = {}) {
@@ -134,6 +134,13 @@ class PackageManager {
return;
}
// Start timer for installation (for main installations only)
const isMainInstall = !options.fromPackageJson && !options._depth;
const isPackageJsonMain = options.fromPackageJsonMain;
const isRecursiveInstall = options._depth > 0;
const shouldShowSummary = (isMainInstall || isPackageJsonMain) && !isRecursiveInstall;
const startTime = shouldShowSummary ? Date.now() : null;
console.log(chalk.blue(`Installing ${packages.length} package(s)...`));
const results = [];
@@ -281,21 +288,32 @@ class PackageManager {
// Update lock file
await this.lock.update(results.filter(r => !r.error));
// Show installation summary only for main installations (not dependency installations)
if (!options.fromPackageJson) {
// Show installation summary for main installations (including package.json main installs)
if (shouldShowSummary) {
const successfulInstalls = results.filter(r => !r.error);
const failedInstalls = results.filter(r => r.error);
// Calculate elapsed time
const endTime = Date.now();
const elapsedTime = startTime ? endTime - startTime : 0;
const elapsedSeconds = (elapsedTime / 1000).toFixed(2);
console.log('');
console.log(chalk.green('📦 Installation Summary:'));
console.log('');
if (successfulInstalls.length > 0) {
console.log(chalk.green(`✓ Successfully installed ${successfulInstalls.length} package(s):`));
successfulInstalls.forEach(result => {
if (successfulInstalls.length === 1 && !isPackageJsonMain) {
const result = successfulInstalls[0];
const sourceLabel = result.source === 'cache' ? '(cached)' : `(${result.source})`;
console.log(chalk.green(` ${result.name}@${result.version} ${chalk.gray(sourceLabel)}`));
});
console.log(chalk.green(`✓ Successfully installed ${result.name}@${result.version} ${chalk.gray(sourceLabel)}`));
} else {
console.log(chalk.green(`✓ Successfully installed ${successfulInstalls.length} package(s):`));
successfulInstalls.forEach(result => {
const sourceLabel = result.source === 'cache' ? '(cached)' : `(${result.source})`;
console.log(chalk.green(`${result.name}@${result.version} ${chalk.gray(sourceLabel)}`));
});
}
}
if (failedInstalls.length > 0) {
@@ -307,6 +325,8 @@ class PackageManager {
}
console.log('');
console.log(chalk.gray(`⏱️ Total time: ${elapsedSeconds}s`));
console.log('');
}
console.log(chalk.green(`Installation completed. ${results.filter(r => !r.error).length} packages installed.`));