node-power-user 0.0.19 → 0.0.22
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/README.md +1 -0
- package/dist/index.js +39 -0
- package/package.json +5 -5
- package/src/index.js +39 -0
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ Note: you may have to run cli commands with `npx npu <command>` if you install t
|
|
|
47
47
|
* `npu bump 1`: Bump the last number (`patch` version).
|
|
48
48
|
* `npu bump 2`: Bump the middle number (`minor` version).
|
|
49
49
|
* `npu bump 3`: Bump the first number (`major` version).
|
|
50
|
+
* `npu outdated`: Compare the versions of installed modules to those in your package.json
|
|
50
51
|
|
|
51
52
|
## Final Words
|
|
52
53
|
If you are still having difficulty, we would love for you to post a question to [the Node Power User issues page](https://github.com/itw-creative-works/node-power-user/issues). It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ const path = require('path');
|
|
|
12
12
|
const { spawn, exec } = require('child_process');
|
|
13
13
|
const argv = require('yargs').argv;
|
|
14
14
|
const JSON5 = require('json5');
|
|
15
|
+
const { isEqual } = require('lodash');
|
|
16
|
+
// const npm = require('npm');
|
|
15
17
|
|
|
16
18
|
function Main() {
|
|
17
19
|
|
|
@@ -71,6 +73,7 @@ const self = this;
|
|
|
71
73
|
|
|
72
74
|
if (self.options.lp || self.options.listpackages || self.options['-lp'] || self.options['--listpackages']) {
|
|
73
75
|
self.log(chalk.blue.bold(`Dependencies:`));
|
|
76
|
+
|
|
74
77
|
Object.keys(self.proj_packageJSON.dependencies || {})
|
|
75
78
|
.forEach((dep, i) => {
|
|
76
79
|
self.log(chalk.blue(`${dep} @ ${self.proj_packageJSON.dependencies[dep]}`));
|
|
@@ -95,6 +98,42 @@ const self = this;
|
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
100
|
|
|
101
|
+
if (self.options.out || self.options.outdated || self.options.match || self.options['-o'] || self.options['--outdated'] || self.options['--match']) {
|
|
102
|
+
self.log(chalk.blue.bold(`Match:`));
|
|
103
|
+
|
|
104
|
+
const response = {};
|
|
105
|
+
const isEqualFn = require('semver/functions/eq')
|
|
106
|
+
const coerceFn = require('semver/functions/coerce')
|
|
107
|
+
|
|
108
|
+
Object.keys(self.proj_packageJSON.dependencies || {})
|
|
109
|
+
.forEach(async (dep, i) => {
|
|
110
|
+
const packageVersion = coerceFn(self.proj_packageJSON.dependencies[dep]);
|
|
111
|
+
const installedVersion = coerceFn(
|
|
112
|
+
(await asyncCommand(`npm list ${dep} --depth=0 | grep ${dep}`))
|
|
113
|
+
.split(' ')[1]
|
|
114
|
+
.split('@')[1]
|
|
115
|
+
);
|
|
116
|
+
const isEqual = isEqualFn(installedVersion, packageVersion);
|
|
117
|
+
const verb = isEqual ? 'green' : 'yellow'
|
|
118
|
+
|
|
119
|
+
response[dep] = {
|
|
120
|
+
isEqual: isEqual,
|
|
121
|
+
package: packageVersion,
|
|
122
|
+
installed: installedVersion,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
self.log(chalk[verb](`${dep}: ${packageVersion} = ${installedVersion}`));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// self.log(chalk.blue.bold(`\nDev Dependencies:`));
|
|
129
|
+
// Object.keys(self.proj_packageJSON.devDependencies || {})
|
|
130
|
+
// .forEach((dep, i) => {
|
|
131
|
+
// self.log(chalk.blue(`${dep} @ ${self.proj_packageJSON.devDependencies[dep]}`));
|
|
132
|
+
// });
|
|
133
|
+
|
|
134
|
+
return response;
|
|
135
|
+
}
|
|
136
|
+
|
|
98
137
|
if (self.options.clean) {
|
|
99
138
|
const NPM_INSTALL_FLAG = self.options['--no-optional'] || self.options['-no-optional'] || self.options['no-optional'] ? '--no-optional' : ''
|
|
100
139
|
const NPM_CLEAN = `rm -fr node_modules && rm -fr package-lock.json && npm cache clean --force && npm install ${NPM_INSTALL_FLAG} && npm rb`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-power-user",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Easy tools for every Node.js developer!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://itwcreativeworks.com",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"chalk": "^4.1.
|
|
32
|
+
"chalk": "^4.1.2",
|
|
33
33
|
"fs-jetpack": "^4.3.1",
|
|
34
|
-
"inquirer": "^8.
|
|
35
|
-
"json5": "^2.2.
|
|
34
|
+
"inquirer": "^8.2.4",
|
|
35
|
+
"json5": "^2.2.1",
|
|
36
36
|
"keychain": "^1.3.0",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
38
|
"semver": "^7.3.7",
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"mocha": "^8.4.0",
|
|
47
|
-
"prepare-package": "^0.0.
|
|
47
|
+
"prepare-package": "^0.0.13"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,8 @@ const path = require('path');
|
|
|
12
12
|
const { spawn, exec } = require('child_process');
|
|
13
13
|
const argv = require('yargs').argv;
|
|
14
14
|
const JSON5 = require('json5');
|
|
15
|
+
const { isEqual } = require('lodash');
|
|
16
|
+
// const npm = require('npm');
|
|
15
17
|
|
|
16
18
|
function Main() {
|
|
17
19
|
|
|
@@ -71,6 +73,7 @@ const self = this;
|
|
|
71
73
|
|
|
72
74
|
if (self.options.lp || self.options.listpackages || self.options['-lp'] || self.options['--listpackages']) {
|
|
73
75
|
self.log(chalk.blue.bold(`Dependencies:`));
|
|
76
|
+
|
|
74
77
|
Object.keys(self.proj_packageJSON.dependencies || {})
|
|
75
78
|
.forEach((dep, i) => {
|
|
76
79
|
self.log(chalk.blue(`${dep} @ ${self.proj_packageJSON.dependencies[dep]}`));
|
|
@@ -95,6 +98,42 @@ const self = this;
|
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
100
|
|
|
101
|
+
if (self.options.out || self.options.outdated || self.options.match || self.options['-o'] || self.options['--outdated'] || self.options['--match']) {
|
|
102
|
+
self.log(chalk.blue.bold(`Match:`));
|
|
103
|
+
|
|
104
|
+
const response = {};
|
|
105
|
+
const isEqualFn = require('semver/functions/eq')
|
|
106
|
+
const coerceFn = require('semver/functions/coerce')
|
|
107
|
+
|
|
108
|
+
Object.keys(self.proj_packageJSON.dependencies || {})
|
|
109
|
+
.forEach(async (dep, i) => {
|
|
110
|
+
const packageVersion = coerceFn(self.proj_packageJSON.dependencies[dep]);
|
|
111
|
+
const installedVersion = coerceFn(
|
|
112
|
+
(await asyncCommand(`npm list ${dep} --depth=0 | grep ${dep}`))
|
|
113
|
+
.split(' ')[1]
|
|
114
|
+
.split('@')[1]
|
|
115
|
+
);
|
|
116
|
+
const isEqual = isEqualFn(installedVersion, packageVersion);
|
|
117
|
+
const verb = isEqual ? 'green' : 'yellow'
|
|
118
|
+
|
|
119
|
+
response[dep] = {
|
|
120
|
+
isEqual: isEqual,
|
|
121
|
+
package: packageVersion,
|
|
122
|
+
installed: installedVersion,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
self.log(chalk[verb](`${dep}: ${packageVersion} = ${installedVersion}`));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// self.log(chalk.blue.bold(`\nDev Dependencies:`));
|
|
129
|
+
// Object.keys(self.proj_packageJSON.devDependencies || {})
|
|
130
|
+
// .forEach((dep, i) => {
|
|
131
|
+
// self.log(chalk.blue(`${dep} @ ${self.proj_packageJSON.devDependencies[dep]}`));
|
|
132
|
+
// });
|
|
133
|
+
|
|
134
|
+
return response;
|
|
135
|
+
}
|
|
136
|
+
|
|
98
137
|
if (self.options.clean) {
|
|
99
138
|
const NPM_INSTALL_FLAG = self.options['--no-optional'] || self.options['-no-optional'] || self.options['no-optional'] ? '--no-optional' : ''
|
|
100
139
|
const NPM_CLEAN = `rm -fr node_modules && rm -fr package-lock.json && npm cache clean --force && npm install ${NPM_INSTALL_FLAG} && npm rb`;
|