node-power-user 2.2.0 → 2.2.1

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.
@@ -1,6 +1,11 @@
1
1
  // Libraries
2
2
  const logger = new (require('../lib/logger'))('node-power-user');
3
+ const chalk = require('chalk').default;
3
4
  const socket = require('../lib/socket');
5
+ const jetpack = require('fs-jetpack');
6
+ const path = require('path');
7
+
8
+ const projectPath = process.cwd();
4
9
 
5
10
  // Module
6
11
  module.exports = async function (options) {
@@ -14,6 +19,7 @@ module.exports = async function (options) {
14
19
  }
15
20
 
16
21
  const command = `npx ${args.join(' ')}`;
22
+ const binaryName = args[0];
17
23
 
18
24
  // Check firewall status upfront (blocks if not installed unless --force)
19
25
  await socket.check({ force: options.force });
@@ -32,7 +38,25 @@ module.exports = async function (options) {
32
38
  }
33
39
 
34
40
  logger.log('');
35
- logger.log('Command blocked. See the output above for details.');
41
+
42
+ // Check if the binary exists locally — if not, npx tried to download from npm
43
+ const localBin = path.join(projectPath, 'node_modules', '.bin', binaryName);
44
+ if (!jetpack.exists(localBin)) {
45
+ logger.error(`'${binaryName}' was not found in node_modules/.bin/`);
46
+ logger.log(`npx tried to download package '${binaryName}' from npm, which was blocked by Socket Firewall.`);
47
+
48
+ // Check if it's defined in this project's own bin field
49
+ const pkgJson = jetpack.read(path.join(projectPath, 'package.json'), 'json');
50
+ if (pkgJson?.bin?.[binaryName]) {
51
+ logger.log('');
52
+ logger.log(`'${binaryName}' is defined in this project's ${chalk.cyan('bin')} field but is not installed as a command.`);
53
+ logger.log(`Run it directly: ${logger.format.cyan(`${pkgJson.bin[binaryName]} ${args.slice(1).join(' ')}`.trim())}`);
54
+ }
55
+ } else {
56
+ logger.log('Command blocked by Socket Firewall. See the output above for details.');
57
+ }
58
+
59
+ logger.log('');
36
60
  logger.log('To retry without firewall protection:');
37
61
  logger.log(logger.format.cyan(` npu npx ${args.join(' ')} --force`));
38
62
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-power-user",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Easy tools for every Node.js developer!",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {