node-power-user 0.0.22 → 0.0.23
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/dist/index.js +23 -6
- package/package.json +3 -3
- package/src/index.js +23 -6
package/dist/index.js
CHANGED
|
@@ -13,6 +13,8 @@ const { spawn, exec } = require('child_process');
|
|
|
13
13
|
const argv = require('yargs').argv;
|
|
14
14
|
const JSON5 = require('json5');
|
|
15
15
|
const { isEqual } = require('lodash');
|
|
16
|
+
const semverIsEqual = require('semver/functions/eq')
|
|
17
|
+
const semverCoerce = require('semver/functions/coerce')
|
|
16
18
|
// const npm = require('npm');
|
|
17
19
|
|
|
18
20
|
function Main() {
|
|
@@ -99,21 +101,20 @@ const self = this;
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
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(`
|
|
104
|
+
self.log(chalk.blue.bold(`Outdated:`));
|
|
105
|
+
self.log(chalk.green(`name: package = installed`));
|
|
103
106
|
|
|
104
107
|
const response = {};
|
|
105
|
-
const isEqualFn = require('semver/functions/eq')
|
|
106
|
-
const coerceFn = require('semver/functions/coerce')
|
|
107
108
|
|
|
108
109
|
Object.keys(self.proj_packageJSON.dependencies || {})
|
|
109
110
|
.forEach(async (dep, i) => {
|
|
110
|
-
const packageVersion =
|
|
111
|
-
const installedVersion =
|
|
111
|
+
const packageVersion = _coerce(self.proj_packageJSON.dependencies[dep]);
|
|
112
|
+
const installedVersion = _coerce(
|
|
112
113
|
(await asyncCommand(`npm list ${dep} --depth=0 | grep ${dep}`))
|
|
113
114
|
.split(' ')[1]
|
|
114
115
|
.split('@')[1]
|
|
115
116
|
);
|
|
116
|
-
const isEqual =
|
|
117
|
+
const isEqual = _isEqual(installedVersion, packageVersion);
|
|
117
118
|
const verb = isEqual ? 'green' : 'yellow'
|
|
118
119
|
|
|
119
120
|
response[dep] = {
|
|
@@ -210,3 +211,19 @@ async function asyncCommand(command) {
|
|
|
210
211
|
});
|
|
211
212
|
});
|
|
212
213
|
}
|
|
214
|
+
|
|
215
|
+
function _coerce(v) {
|
|
216
|
+
try {
|
|
217
|
+
return semverCoerce(v)
|
|
218
|
+
} catch (e) {
|
|
219
|
+
return '0.0.0'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function _isEqual(v1, v2) {
|
|
224
|
+
try {
|
|
225
|
+
return semverIsEqual(v1, v2)
|
|
226
|
+
} catch (e) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-power-user",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "Easy tools for every Node.js developer!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
|
|
13
13
|
"start": "npm run prepare && node -e 'new (require(`./dist/index.js`))().process()'",
|
|
14
|
-
"prepare": "node -e 'require(`prepare-package`)'"
|
|
14
|
+
"prepare": "node -e 'require(`prepare-package`)()'"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -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.16"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,8 @@ const { spawn, exec } = require('child_process');
|
|
|
13
13
|
const argv = require('yargs').argv;
|
|
14
14
|
const JSON5 = require('json5');
|
|
15
15
|
const { isEqual } = require('lodash');
|
|
16
|
+
const semverIsEqual = require('semver/functions/eq')
|
|
17
|
+
const semverCoerce = require('semver/functions/coerce')
|
|
16
18
|
// const npm = require('npm');
|
|
17
19
|
|
|
18
20
|
function Main() {
|
|
@@ -99,21 +101,20 @@ const self = this;
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
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(`
|
|
104
|
+
self.log(chalk.blue.bold(`Outdated:`));
|
|
105
|
+
self.log(chalk.green(`name: package = installed`));
|
|
103
106
|
|
|
104
107
|
const response = {};
|
|
105
|
-
const isEqualFn = require('semver/functions/eq')
|
|
106
|
-
const coerceFn = require('semver/functions/coerce')
|
|
107
108
|
|
|
108
109
|
Object.keys(self.proj_packageJSON.dependencies || {})
|
|
109
110
|
.forEach(async (dep, i) => {
|
|
110
|
-
const packageVersion =
|
|
111
|
-
const installedVersion =
|
|
111
|
+
const packageVersion = _coerce(self.proj_packageJSON.dependencies[dep]);
|
|
112
|
+
const installedVersion = _coerce(
|
|
112
113
|
(await asyncCommand(`npm list ${dep} --depth=0 | grep ${dep}`))
|
|
113
114
|
.split(' ')[1]
|
|
114
115
|
.split('@')[1]
|
|
115
116
|
);
|
|
116
|
-
const isEqual =
|
|
117
|
+
const isEqual = _isEqual(installedVersion, packageVersion);
|
|
117
118
|
const verb = isEqual ? 'green' : 'yellow'
|
|
118
119
|
|
|
119
120
|
response[dep] = {
|
|
@@ -210,3 +211,19 @@ async function asyncCommand(command) {
|
|
|
210
211
|
});
|
|
211
212
|
});
|
|
212
213
|
}
|
|
214
|
+
|
|
215
|
+
function _coerce(v) {
|
|
216
|
+
try {
|
|
217
|
+
return semverCoerce(v)
|
|
218
|
+
} catch (e) {
|
|
219
|
+
return '0.0.0'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function _isEqual(v1, v2) {
|
|
224
|
+
try {
|
|
225
|
+
return semverIsEqual(v1, v2)
|
|
226
|
+
} catch (e) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|