npq 3.16.4 → 3.16.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/README.md CHANGED
@@ -179,6 +179,8 @@ Here are all the available environment variable names for disabling specific mar
179
179
 
180
180
  ### Run checks on package without installing it
181
181
 
182
+ Running `npq` without an `install` / `i` / `add` subcommand (for example from a project directory with a `package.json`) audits dependencies only and does not run the package manager. The same applies to `npq <package>`: checks only, no install passthrough. Use `npq install …` when you want npq to hand off to npm (or `NPQ_PKG_MGR`) after the checks.
183
+
182
184
  ```sh
183
185
  npq install express --dry-run
184
186
  ```
package/bin/npq.js CHANGED
@@ -19,6 +19,7 @@ const { promiseThrottleHelper } = require('../lib/helpers/promiseThrottler')
19
19
  const debug = util.debuglog('npq')
20
20
 
21
21
  const cliArgs = CliParser.parseArgsFull()
22
+ const auditOnly = cliArgs.dryRun || !cliArgs.installSubcommandExplicit
22
23
  const isInteractive = cliSupport.isInteractiveTerminal() && !cliArgs.plain
23
24
  const spinner = isInteractive ? new Spinner({ text: 'Initiating...' }) : null
24
25
 
@@ -89,11 +90,12 @@ Promise.resolve()
89
90
  return undefined
90
91
  })
91
92
  .then((result) => {
92
- if (cliArgs.dryRun) {
93
+ if (auditOnly) {
93
94
  CliParser.exit({
94
95
  errorCode: 0,
95
96
  spinner
96
97
  })
98
+ return undefined
97
99
  }
98
100
 
99
101
  if (result && result.countErrors > 0) {
package/lib/cli.js CHANGED
@@ -4,7 +4,25 @@ const { parseArgs } = require('node:util')
4
4
  const npa = require('npm-package-arg')
5
5
  const pkg = require('../package.json')
6
6
 
7
+ const INSTALL_SUBCOMMANDS = new Set([
8
+ 'install',
9
+ 'i',
10
+ 'add',
11
+ 'isntall',
12
+ 'in',
13
+ 'ins',
14
+ 'inst',
15
+ 'insta',
16
+ 'instal',
17
+ 'isnt',
18
+ 'isnta',
19
+ 'isntal'
20
+ ])
21
+
7
22
  class CliParser {
23
+ static isInstallSubcommand(token) {
24
+ return INSTALL_SUBCOMMANDS.has(token)
25
+ }
8
26
  static exit({ errorCode, message, spinner }) {
9
27
  if (spinner && spinner.isSpinning) {
10
28
  spinner.stop()
@@ -25,32 +43,13 @@ class CliParser {
25
43
  if (positionals.length > 0) {
26
44
  const command = positionals[0]
27
45
 
28
- switch (command) {
29
- case 'install':
30
- case 'i':
31
- case 'add':
32
- case 'isntall':
33
- case 'in':
34
- case 'ins':
35
- case 'inst':
36
- case 'insta':
37
- case 'instal':
38
- case 'isnt':
39
- case 'isnta':
40
- case 'isntal':
41
- packages = positionals.slice(1)
42
- break
43
- default:
44
- if (earlyExitNoInstall) {
45
- // If no install command, exit early
46
- // needed for npq-hero command which only runs on 'install' use-cases of npm
47
- break
48
- }
49
-
50
- // Treat first positional as package if no explicit command
51
- packages = positionals
52
- break
46
+ if (this.isInstallSubcommand(command)) {
47
+ packages = positionals.slice(1)
48
+ } else if (!earlyExitNoInstall) {
49
+ // Treat first positional as package if no explicit command
50
+ packages = positionals
53
51
  }
52
+ // earlyExitNoInstall + non-install: packages stay [] (npq-hero)
54
53
  }
55
54
 
56
55
  // Parse and normalize packages
@@ -85,7 +84,10 @@ class CliParser {
85
84
  console.log(`Usage: npq install <package> [options]
86
85
 
87
86
  Commands:
88
- install [package...] install a package
87
+ install [package...] install a package (required to run the package manager)
88
+
89
+ With no install subcommand, npq audits packages only (current project deps from
90
+ package.json, or package names you pass) and does not invoke npm install.
89
91
 
90
92
  Options:
91
93
  --dry-run Run checks only, don't install
@@ -97,7 +99,7 @@ Options:
97
99
  -v, --version Show version
98
100
 
99
101
  Environment Variables:
100
- NPQ_PKG_MGR Package manager to use (default: npm)
102
+ NPQ_PKG_MGR Package manager to use; overrides --packageManager when set (default: npm)
101
103
  NPQ_DISABLE_AUTO_CONTINUE Set to 'true' to disable auto-continue
102
104
 
103
105
  Examples:
@@ -115,14 +117,17 @@ curated by Liran Tal at https://github.com/lirantal/npq`)
115
117
 
116
118
  // Process install command and packages
117
119
  const normalizedPackages = this._extractPackagesFromPositionals(positionals)
120
+ const installSubcommandExplicit =
121
+ positionals.length > 0 && this.isInstallSubcommand(positionals[0])
118
122
 
119
123
  return {
120
124
  packages: normalizedPackages,
121
- packageManager: values.packageManager || values.pkgMgr || process.env.NPQ_PKG_MGR || 'npm',
125
+ packageManager: process.env.NPQ_PKG_MGR || values.packageManager || values.pkgMgr || 'npm',
122
126
  dryRun: values['dry-run'] || false,
123
127
  plain: values.plain || false,
124
128
  disableAutoContinue:
125
- values['disable-auto-continue'] || process.env.NPQ_DISABLE_AUTO_CONTINUE === 'true'
129
+ values['disable-auto-continue'] || process.env.NPQ_DISABLE_AUTO_CONTINUE === 'true',
130
+ installSubcommandExplicit
126
131
  }
127
132
  }
128
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npq",
3
- "version": "3.16.4",
3
+ "version": "3.16.5",
4
4
  "description": "marshall your npm/npm package installs with high quality and class 🎖",
5
5
  "bin": {
6
6
  "npq": "./bin/npq.js",