devcompass 1.0.3 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devcompass",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Analyze your JavaScript projects for unused dependencies and outdated packages",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -13,12 +13,13 @@ const {
13
13
  logDivider,
14
14
  getScoreColor
15
15
  } = require('../utils/logger');
16
+ const packageJson = require('../../package.json');
16
17
 
17
18
  async function analyze(options) {
18
19
  const projectPath = options.path || process.cwd();
19
20
 
20
21
  console.log('\n');
21
- log(chalk.cyan.bold('šŸ” DevCompass v1.0.0') + ' - Analyzing your project...\n');
22
+ log(chalk.cyan.bold(`šŸ” DevCompass v${packageJson.version}`) + ' - Analyzing your project...\n');
22
23
 
23
24
  const spinner = ora({
24
25
  text: 'Loading project...',
@@ -34,10 +35,10 @@ async function analyze(options) {
34
35
  process.exit(1);
35
36
  }
36
37
 
37
- let packageJson;
38
+ let projectPackageJson;
38
39
  try {
39
40
  const fileContent = fs.readFileSync(packageJsonPath, 'utf8');
40
- packageJson = JSON.parse(fileContent);
41
+ projectPackageJson = JSON.parse(fileContent);
41
42
  } catch (error) {
42
43
  spinner.fail(chalk.red('Invalid package.json format'));
43
44
  console.log(chalk.yellow(`\nšŸ’” Error: ${error.message}\n`));
@@ -45,8 +46,8 @@ async function analyze(options) {
45
46
  }
46
47
 
47
48
  const dependencies = {
48
- ...(packageJson.dependencies || {}),
49
- ...(packageJson.devDependencies || {})
49
+ ...(projectPackageJson.dependencies || {}),
50
+ ...(projectPackageJson.devDependencies || {})
50
51
  };
51
52
 
52
53
  const totalDeps = Object.keys(dependencies).length;
@@ -103,13 +104,13 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
103
104
  if (unusedDeps.length > 0) {
104
105
  logSection('šŸ”“ UNUSED DEPENDENCIES', unusedDeps.length);
105
106
 
106
- const displayCount = Math.min(5, unusedDeps.length);
107
+ const displayCount = Math.min(10, unusedDeps.length);
107
108
  unusedDeps.slice(0, displayCount).forEach(dep => {
108
109
  log(` ${chalk.red('ā—')} ${dep.name}`);
109
110
  });
110
111
 
111
- if (unusedDeps.length > 5) {
112
- log(chalk.gray(`\n ... and ${unusedDeps.length - 5} more\n`));
112
+ if (unusedDeps.length > 10) {
113
+ log(chalk.gray(`\n ... and ${unusedDeps.length - 10} more\n`));
113
114
  }
114
115
 
115
116
  log(chalk.gray('\n Why marked unused:'));
@@ -126,7 +127,7 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
126
127
  if (outdatedDeps.length > 0) {
127
128
  logSection('🟔 OUTDATED PACKAGES', outdatedDeps.length);
128
129
 
129
- const displayCount = Math.min(5, outdatedDeps.length);
130
+ const displayCount = Math.min(10, outdatedDeps.length);
130
131
  outdatedDeps.slice(0, displayCount).forEach(dep => {
131
132
  const nameCol = dep.name.padEnd(20);
132
133
  const currentVer = chalk.yellow(dep.current);
@@ -137,8 +138,10 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
137
138
  log(` ${nameCol} ${currentVer} ${arrow} ${latestVer} ${updateType}`);
138
139
  });
139
140
 
140
- if (outdatedDeps.length > 5) {
141
- log(chalk.gray(`\n ... and ${outdatedDeps.length - 5} more\n`));
141
+ if (outdatedDeps.length > 10) {
142
+ log(chalk.gray(`\n ... and ${outdatedDeps.length - 10} more\n`));
143
+ } else {
144
+ log('');
142
145
  }
143
146
  } else {
144
147
  logSection('āœ… OUTDATED PACKAGES');
@@ -162,7 +165,7 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
162
165
  log(' Clean up unused dependencies:\n');
163
166
 
164
167
  const packagesToRemove = unusedDeps
165
- .slice(0, 5)
168
+ .slice(0, 10)
166
169
  .map(d => d.name)
167
170
  .join(' ');
168
171