node-power-user 0.0.21 → 0.0.24

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 CHANGED
@@ -47,7 +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 match`: Compare the versions of installed modules to those in your package.json
50
+ * `npu outdated`: Compare the versions of installed modules to those in your package.json
51
51
 
52
52
  ## Final Words
53
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
@@ -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() {
@@ -98,22 +100,22 @@ const self = this;
98
100
  };
99
101
  }
100
102
 
101
- if (self.options.mm || self.options.matchmodules || self.options.match || self.options['-mm'] || self.options['--matchmodules'] || self.options['--match']) {
102
- self.log(chalk.blue.bold(`Match:`));
103
+ if (self.options.out || self.options.outdated || self.options.match || self.options['-o'] || self.options['--outdated'] || self.options['--match']) {
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 = 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]
111
+ const packageVersion = _coerce(self.proj_packageJSON.dependencies[dep]);
112
+ const installedVersion = _coerce(
113
+ _getVersion(
114
+ (await asyncCommand(`npm list ${dep} --depth=0 | grep ${dep}`))
115
+ .split(' ')[1]
116
+ )
115
117
  );
116
- const isEqual = isEqualFn(installedVersion, packageVersion);
118
+ const isEqual = _isEqual(installedVersion, packageVersion);
117
119
  const verb = isEqual ? 'green' : 'yellow'
118
120
 
119
121
  response[dep] = {
@@ -210,3 +212,24 @@ async function asyncCommand(command) {
210
212
  });
211
213
  });
212
214
  }
215
+
216
+ function _coerce(v) {
217
+ try {
218
+ return semverCoerce(v)
219
+ } catch (e) {
220
+ return '0.0.0'
221
+ }
222
+ }
223
+
224
+ function _isEqual(v1, v2) {
225
+ try {
226
+ return semverIsEqual(v1, v2)
227
+ } catch (e) {
228
+ return false;
229
+ }
230
+ }
231
+
232
+ function _getVersion(v) {
233
+ v = v.split('@');
234
+ return v[v.length - 1]
235
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-power-user",
3
- "version": "0.0.21",
3
+ "version": "0.0.24",
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.13"
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() {
@@ -98,22 +100,22 @@ const self = this;
98
100
  };
99
101
  }
100
102
 
101
- if (self.options.mm || self.options.matchmodules || self.options.match || self.options['-mm'] || self.options['--matchmodules'] || self.options['--match']) {
102
- self.log(chalk.blue.bold(`Match:`));
103
+ if (self.options.out || self.options.outdated || self.options.match || self.options['-o'] || self.options['--outdated'] || self.options['--match']) {
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 = 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]
111
+ const packageVersion = _coerce(self.proj_packageJSON.dependencies[dep]);
112
+ const installedVersion = _coerce(
113
+ _getVersion(
114
+ (await asyncCommand(`npm list ${dep} --depth=0 | grep ${dep}`))
115
+ .split(' ')[1]
116
+ )
115
117
  );
116
- const isEqual = isEqualFn(installedVersion, packageVersion);
118
+ const isEqual = _isEqual(installedVersion, packageVersion);
117
119
  const verb = isEqual ? 'green' : 'yellow'
118
120
 
119
121
  response[dep] = {
@@ -210,3 +212,24 @@ async function asyncCommand(command) {
210
212
  });
211
213
  });
212
214
  }
215
+
216
+ function _coerce(v) {
217
+ try {
218
+ return semverCoerce(v)
219
+ } catch (e) {
220
+ return '0.0.0'
221
+ }
222
+ }
223
+
224
+ function _isEqual(v1, v2) {
225
+ try {
226
+ return semverIsEqual(v1, v2)
227
+ } catch (e) {
228
+ return false;
229
+ }
230
+ }
231
+
232
+ function _getVersion(v) {
233
+ v = v.split('@');
234
+ return v[v.length - 1]
235
+ }