libnpmdiff 2.0.3 → 2.0.4
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 +1 -1
- package/index.js +3 -2
- package/lib/tarball.js +33 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ Fetches the registry tarballs and compare files between a spec `a` and spec `b`.
|
|
|
86
86
|
- `diffSrcPrefix <String>`: Prefix to be used in the filenames from `a`. Defaults to `a/`.
|
|
87
87
|
- `diffDstPrefix <String>`: Prefix to be used in the filenames from `b`. Defaults to `b/`.
|
|
88
88
|
- `diffText <Boolean>`: Should treat all files as text and try to print diff for binary files. Defaults to `false`.
|
|
89
|
-
- ...`cache`, `registry` and other common options accepted by [pacote](https://github.com/npm/pacote#options)
|
|
89
|
+
- ...`cache`, `registry`, `where` and other common options accepted by [pacote](https://github.com/npm/pacote#options)
|
|
90
90
|
|
|
91
91
|
Returns a `Promise` that fullfils with a `String` containing the resulting patch diffs.
|
|
92
92
|
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const pacote = require('pacote')
|
|
2
2
|
|
|
3
3
|
const formatDiff = require('./lib/format-diff.js')
|
|
4
|
+
const getTarball = require('./lib/tarball.js')
|
|
4
5
|
const untar = require('./lib/untar.js')
|
|
5
6
|
|
|
6
7
|
const argsError = () =>
|
|
@@ -25,8 +26,8 @@ const diff = async (specs, opts = {}) => {
|
|
|
25
26
|
|
|
26
27
|
// fetches tarball using pacote
|
|
27
28
|
const [a, b] = await Promise.all([
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
getTarball(aManifest, opts),
|
|
30
|
+
getTarball(bManifest, opts),
|
|
30
31
|
])
|
|
31
32
|
|
|
32
33
|
// read all files
|
package/lib/tarball.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { relative } = require('path')
|
|
2
|
+
|
|
3
|
+
const npa = require('npm-package-arg')
|
|
4
|
+
const pkgContents = require('@npmcli/installed-package-contents')
|
|
5
|
+
const pacote = require('pacote')
|
|
6
|
+
const { tarCreateOptions } = pacote.DirFetcher
|
|
7
|
+
const tar = require('tar')
|
|
8
|
+
|
|
9
|
+
// returns a simplified tarball when reading files from node_modules folder,
|
|
10
|
+
// thus avoiding running the prepare scripts and the extra logic from packlist
|
|
11
|
+
const nodeModulesTarball = (manifest, opts) =>
|
|
12
|
+
pkgContents({ path: manifest._resolved, depth: 1 })
|
|
13
|
+
.then(files =>
|
|
14
|
+
files.map(file => relative(manifest._resolved, file))
|
|
15
|
+
)
|
|
16
|
+
.then(files =>
|
|
17
|
+
tar.c(tarCreateOptions(manifest), files).concat()
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const tarball = (manifest, opts) => {
|
|
21
|
+
const resolved = manifest._resolved
|
|
22
|
+
const where = opts.where || process.cwd()
|
|
23
|
+
|
|
24
|
+
const fromNodeModules = npa(resolved).type === 'directory'
|
|
25
|
+
&& /node_modules[\\/](@[^\\/]+\/)?[^\\/]+[\\/]?$/.test(relative(where, resolved))
|
|
26
|
+
|
|
27
|
+
if (fromNodeModules)
|
|
28
|
+
return nodeModulesTarball(manifest, opts)
|
|
29
|
+
|
|
30
|
+
return pacote.tarball(manifest._resolved, opts)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = tarball
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libnpmdiff",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "The registry diff",
|
|
5
5
|
"repository": "https://github.com/npm/libnpmdiff",
|
|
6
6
|
"files": [
|
|
@@ -55,10 +55,12 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@npmcli/disparity-colors": "^1.0.1",
|
|
58
|
+
"@npmcli/installed-package-contents": "^1.0.7",
|
|
58
59
|
"binary-extensions": "^2.2.0",
|
|
59
60
|
"diff": "^5.0.0",
|
|
60
61
|
"minimatch": "^3.0.4",
|
|
61
|
-
"
|
|
62
|
+
"npm-package-arg": "^8.1.1",
|
|
63
|
+
"pacote": "^11.3.0",
|
|
62
64
|
"tar": "^6.1.0"
|
|
63
65
|
}
|
|
64
66
|
}
|