devcompass 1.0.3 ā 1.0.5
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 +1 -1
- package/src/commands/analyze.js +11 -17
package/package.json
CHANGED
package/src/commands/analyze.js
CHANGED
|
@@ -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(
|
|
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
|
|
38
|
+
let projectPackageJson;
|
|
38
39
|
try {
|
|
39
40
|
const fileContent = fs.readFileSync(packageJsonPath, 'utf8');
|
|
40
|
-
|
|
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
|
-
...(
|
|
49
|
-
...(
|
|
49
|
+
...(projectPackageJson.dependencies || {}),
|
|
50
|
+
...(projectPackageJson.devDependencies || {})
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
const totalDeps = Object.keys(dependencies).length;
|
|
@@ -103,15 +104,11 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
|
|
|
103
104
|
if (unusedDeps.length > 0) {
|
|
104
105
|
logSection('š“ UNUSED DEPENDENCIES', unusedDeps.length);
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
unusedDeps.
|
|
107
|
+
// Show ALL unused deps
|
|
108
|
+
unusedDeps.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`));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
112
|
log(chalk.gray('\n Why marked unused:'));
|
|
116
113
|
log(chalk.gray(' ⢠No import/require found in source files'));
|
|
117
114
|
log(chalk.gray(' ⢠Excludes node_modules, build folders'));
|
|
@@ -126,8 +123,8 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
|
|
|
126
123
|
if (outdatedDeps.length > 0) {
|
|
127
124
|
logSection('š” OUTDATED PACKAGES', outdatedDeps.length);
|
|
128
125
|
|
|
129
|
-
|
|
130
|
-
outdatedDeps.
|
|
126
|
+
// Show ALL outdated packages
|
|
127
|
+
outdatedDeps.forEach(dep => {
|
|
131
128
|
const nameCol = dep.name.padEnd(20);
|
|
132
129
|
const currentVer = chalk.yellow(dep.current);
|
|
133
130
|
const arrow = chalk.gray('ā');
|
|
@@ -137,9 +134,7 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
|
|
|
137
134
|
log(` ${nameCol} ${currentVer} ${arrow} ${latestVer} ${updateType}`);
|
|
138
135
|
});
|
|
139
136
|
|
|
140
|
-
|
|
141
|
-
log(chalk.gray(`\n ... and ${outdatedDeps.length - 5} more\n`));
|
|
142
|
-
}
|
|
137
|
+
log('');
|
|
143
138
|
} else {
|
|
144
139
|
logSection('ā
OUTDATED PACKAGES');
|
|
145
140
|
log(chalk.green(' All packages are up to date!\n'));
|
|
@@ -162,7 +157,6 @@ function displayResults(unusedDeps, outdatedDeps, score, totalDeps) {
|
|
|
162
157
|
log(' Clean up unused dependencies:\n');
|
|
163
158
|
|
|
164
159
|
const packagesToRemove = unusedDeps
|
|
165
|
-
.slice(0, 5)
|
|
166
160
|
.map(d => d.name)
|
|
167
161
|
.join(' ');
|
|
168
162
|
|