@@ -125,8 +125,8 @@ class PackageManager {
|
|||||||
|
|
||||||
const packages = Object.entries(dependencies).map(([name, version]) => `${name}@${version}`);
|
const packages = Object.entries(dependencies).map(([name, version]) => `${name}@${version}`);
|
||||||
|
|
||||||
// Call the main installation logic directly, bypassing the package.json check
|
// Call the main installation logic with special flag for package.json installs
|
||||||
return await this.installPackages(packages, { ...options, fromPackageJson: true });
|
return await this.installPackages(packages, { ...options, fromPackageJsonMain: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
async installPackages(packages, options = {}) {
|
async installPackages(packages, options = {}) {
|
||||||
@@ -134,6 +134,13 @@ class PackageManager {
|
|||||||
return;
|
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)...`));
|
console.log(chalk.blue(`Installing ${packages.length} package(s)...`));
|
||||||
|
|
||||||
const results = [];
|
const results = [];
|
||||||
@@ -281,21 +288,32 @@ class PackageManager {
|
|||||||
// Update lock file
|
// Update lock file
|
||||||
await this.lock.update(results.filter(r => !r.error));
|
await this.lock.update(results.filter(r => !r.error));
|
||||||
|
|
||||||
// Show installation summary only for main installations (not dependency installations)
|
// Show installation summary for main installations (including package.json main installs)
|
||||||
if (!options.fromPackageJson) {
|
if (shouldShowSummary) {
|
||||||
const successfulInstalls = results.filter(r => !r.error);
|
const successfulInstalls = results.filter(r => !r.error);
|
||||||
const failedInstalls = 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('');
|
||||||
console.log(chalk.green('📦 Installation Summary:'));
|
console.log(chalk.green('📦 Installation Summary:'));
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
if (successfulInstalls.length > 0) {
|
if (successfulInstalls.length > 0) {
|
||||||
console.log(chalk.green(`✓ Successfully installed ${successfulInstalls.length} package(s):`));
|
if (successfulInstalls.length === 1 && !isPackageJsonMain) {
|
||||||
successfulInstalls.forEach(result => {
|
const result = successfulInstalls[0];
|
||||||
const sourceLabel = result.source === 'cache' ? '(cached)' : `(${result.source})`;
|
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) {
|
if (failedInstalls.length > 0) {
|
||||||
@@ -307,6 +325,8 @@ class PackageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('');
|
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.`));
|
console.log(chalk.green(`Installation completed. ${results.filter(r => !r.error).length} packages installed.`));
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user