libnpmexec 1.2.0 → 3.0.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.
package/README.md CHANGED
@@ -17,7 +17,8 @@ The `npm exec` (`npx`) Programmatic API
17
17
  const libexec = require('libnpmexec')
18
18
  await libexec({
19
19
  args: ['yosay', 'Bom dia!'],
20
- cache: '~/.npm',
20
+ cache: '~/.npm/_cacache',
21
+ npxCache: '~/.npm/_npx',
21
22
  yes: true,
22
23
  })
23
24
  ```
@@ -30,6 +31,7 @@ await libexec({
30
31
  - `args`: List of pkgs to execute **Array<String>**, defaults to `[]`
31
32
  - `call`: An alternative command to run when using `packages` option **String**, defaults to empty string.
32
33
  - `cache`: The path location to where the npm cache folder is placed **String**
34
+ - `npxCache`: The path location to where the npx cache folder is placed **String**
33
35
  - `color`: Output should use color? **Boolean**, defaults to `false`
34
36
  - `localBin`: Location to the `node_modules/.bin` folder of the local project to start scanning for bin files **String**, defaults to `./node_modules/.bin`. **libexec** will walk up the directory structure looking for `node_modules/.bin` folders in parent folders that might satisfy the current `arg` and will use that bin if found.
35
37
  - `locationMsg`: Overrides "at location" message when entering interactive mode **String**
@@ -2,12 +2,12 @@ const crypto = require('crypto')
2
2
 
3
3
  const { resolve } = require('path')
4
4
 
5
- const cacheInstallDir = ({ cache, packages }) => {
6
- if (!cache)
7
- throw new Error('Must provide a valid cache path')
5
+ const cacheInstallDir = ({ npxCache, packages }) => {
6
+ if (!npxCache)
7
+ throw new Error('Must provide a valid npxCache path')
8
8
 
9
9
  // only packages not found in ${prefix}/node_modules
10
- return resolve(cache, '_npx', getHash(packages))
10
+ return resolve(npxCache, getHash(packages))
11
11
  }
12
12
 
13
13
  const getHash = (packages) =>
package/lib/index.js CHANGED
@@ -124,8 +124,8 @@ const exec = async (opts) => {
124
124
  manis.some(manifest => manifestMissing({ tree, manifest }))
125
125
 
126
126
  if (needInstall) {
127
- const { cache } = flatOptions
128
- const installDir = cacheInstallDir({ cache, packages })
127
+ const { npxCache } = flatOptions
128
+ const installDir = cacheInstallDir({ npxCache, packages })
129
129
  await mkdirp(installDir)
130
130
  const arb = new Arborist({
131
131
  ...flatOptions,
@@ -165,6 +165,8 @@ const exec = async (opts) => {
165
165
  const prompt = `Need to install the following packages:\n${
166
166
  addList
167
167
  }Ok to proceed? `
168
+ if (typeof log.clearProgress === 'function')
169
+ log.clearProgress()
168
170
  const confirm = await read({ prompt, default: 'y' })
169
171
  if (confirm.trim().toLowerCase().charAt(0) !== 'y')
170
172
  throw new Error('canceled')
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "libnpmexec",
3
- "version": "1.2.0",
3
+ "version": "3.0.1",
4
4
  "files": [
5
5
  "lib"
6
6
  ],
7
7
  "main": "lib/index.js",
8
8
  "engines": {
9
- "node": ">=10"
9
+ "node": "^12.13.0 || ^14.15.0 || >=16"
10
10
  },
11
11
  "description": "npm exec (npx) programmatic API",
12
12
  "repository": "https://github.com/npm/libnpmexec",
@@ -37,6 +37,7 @@
37
37
  "prepublishOnly": "git push origin --follow-tags"
38
38
  },
39
39
  "tap": {
40
+ "color": true,
40
41
  "check-coverage": true
41
42
  },
42
43
  "devDependencies": {
@@ -49,13 +50,13 @@
49
50
  "tap": "^15.0.6"
50
51
  },
51
52
  "dependencies": {
52
- "@npmcli/arborist": "^2.3.0",
53
+ "@npmcli/arborist": "^4.0.0",
53
54
  "@npmcli/ci-detect": "^1.3.0",
54
- "@npmcli/run-script": "^1.8.4",
55
+ "@npmcli/run-script": "^2.0.0",
55
56
  "chalk": "^4.1.0",
56
57
  "mkdirp-infer-owner": "^2.0.0",
57
58
  "npm-package-arg": "^8.1.2",
58
- "pacote": "^11.3.1",
59
+ "pacote": "^12.0.0",
59
60
  "proc-log": "^1.0.0",
60
61
  "read": "^1.0.7",
61
62
  "read-package-json-fast": "^2.0.2",
package/CHANGELOG.md DELETED
@@ -1,17 +0,0 @@
1
- # Changelog
2
-
3
- ## v1.1.0
4
-
5
- - Add add walk up dir lookup logic to satisfy local bins,
6
- similar to `@npmcli/run-script`
7
-
8
- ## v1.0.1
9
-
10
- - Fix `scriptShell` option name.
11
-
12
- ## v1.0.0
13
-
14
- - Initial implementation, moves the code that used to live in the **npm cli**,
15
- ref: https://github.com/npm/cli/blob/release/v7.10.0/lib/exec.js into this
16
- separate module, providing a programmatic API to the **npm exec** functionality.
17
-