libnpmdiff 2.0.4 → 3.0.0

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
@@ -61,7 +61,7 @@ hesitate to jump in if you'd like to, or even ask us questions if something
61
61
  isn't clear.
62
62
 
63
63
  All participants and maintainers in this project are expected to follow the
64
- [npm Code of Conduct](https://www.npmjs.com/policies/conduct), and just
64
+ [npm Code of Conduct](https://docs.npmjs.com/policies/conduct), and just
65
65
  generally be excellent to each other.
66
66
 
67
67
  Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
@@ -30,8 +30,9 @@ const formatDiff = ({ files, opts = {}, refs, versions }) => {
30
30
  b: filenames.b && filenames.b.mode,
31
31
  }
32
32
 
33
- if (contents.a === contents.b && modes.a === modes.b)
33
+ if (contents.a === contents.b && modes.a === modes.b) {
34
34
  continue
35
+ }
35
36
 
36
37
  if (opts.diffNameOnly) {
37
38
  res += `${filename}${EOL}`
@@ -47,18 +48,19 @@ const formatDiff = ({ files, opts = {}, refs, versions }) => {
47
48
 
48
49
  // manually build a git diff-compatible header
49
50
  header(`diff --git ${names.a} ${names.b}`)
50
- if (modes.a === modes.b)
51
+ if (modes.a === modes.b) {
51
52
  fileMode = filenames.a.mode
52
- else {
53
- if (modes.a && !modes.b)
53
+ } else {
54
+ if (modes.a && !modes.b) {
54
55
  header(`deleted file mode ${modes.a}`)
55
- else if (!modes.a && modes.b)
56
+ } else if (!modes.a && modes.b) {
56
57
  header(`new file mode ${modes.b}`)
57
- else {
58
+ } else {
58
59
  header(`old mode ${modes.a}`)
59
60
  header(`new mode ${modes.b}`)
60
61
  }
61
62
  }
63
+ /* eslint-disable-next-line max-len */
62
64
  header(`index ${opts.tagVersionPrefix || 'v'}${versions.a}..${opts.tagVersionPrefix || 'v'}${versions.b} ${fileMode}`)
63
65
 
64
66
  if (shouldPrintPatch(filename)) {
@@ -1,17 +1,22 @@
1
1
  const pacote = require('pacote')
2
2
 
3
- const formatDiff = require('./lib/format-diff.js')
4
- const getTarball = require('./lib/tarball.js')
5
- const untar = require('./lib/untar.js')
6
-
3
+ const formatDiff = require('./format-diff.js')
4
+ const getTarball = require('./tarball.js')
5
+ const untar = require('./untar.js')
6
+
7
+ // TODO: we test this condition in the diff command
8
+ // so this error probably doesnt need to be here. Or
9
+ // if it does we should figure out a standard code
10
+ // so we can catch it in the cli and display it consistently
7
11
  const argsError = () =>
8
12
  Object.assign(
9
13
  new TypeError('libnpmdiff needs two arguments to compare'),
10
14
  { code: 'EDIFFARGS' }
11
15
  )
12
16
  const diff = async (specs, opts = {}) => {
13
- if (specs.length !== 2)
17
+ if (specs.length !== 2) {
14
18
  throw argsError()
19
+ }
15
20
 
16
21
  const [
17
22
  aManifest,
@@ -5,8 +5,9 @@ const binaryExtensions = require('binary-extensions')
5
5
  // we should try to print patches as long as the
6
6
  // extension is not identified as binary files
7
7
  const shouldPrintPatch = (path, opts = {}) => {
8
- if (opts.diffText)
8
+ if (opts.diffText) {
9
9
  return true
10
+ }
10
11
 
11
12
  const filename = basename(path)
12
13
  const extension = (
package/lib/tarball.js CHANGED
@@ -24,8 +24,9 @@ const tarball = (manifest, opts) => {
24
24
  const fromNodeModules = npa(resolved).type === 'directory'
25
25
  && /node_modules[\\/](@[^\\/]+\/)?[^\\/]+[\\/]?$/.test(relative(where, resolved))
26
26
 
27
- if (fromNodeModules)
27
+ if (fromNodeModules) {
28
28
  return nodeModulesTarball(manifest, opts)
29
+ }
29
30
 
30
31
  return pacote.tarball(manifest._resolved, opts)
31
32
  }
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "libnpmdiff",
3
- "version": "2.0.4",
3
+ "version": "3.0.0",
4
4
  "description": "The registry diff",
5
5
  "repository": "https://github.com/npm/libnpmdiff",
6
+ "main": "lib/index.js",
6
7
  "files": [
7
- "index.js",
8
+ "bin",
8
9
  "lib"
9
10
  ],
10
11
  "engines": {
11
- "node": ">=10"
12
+ "node": "^12.13.0 || ^14.15.0 || >=16"
12
13
  },
13
14
  "keywords": [
14
15
  "npm",
@@ -28,30 +29,22 @@
28
29
  "license": "ISC",
29
30
  "scripts": {
30
31
  "eslint": "eslint",
31
- "lint": "npm run eslint -- index.js \"lib/**/*.js\" \"test/*.js\"",
32
+ "lint": "eslint '**/*.js'",
32
33
  "lintfix": "npm run lint -- --fix",
33
- "test": "tap test/*.js",
34
+ "test": "tap",
34
35
  "posttest": "npm run lint",
35
- "snap": "tap test/*.js",
36
+ "snap": "tap",
36
37
  "preversion": "npm test",
37
38
  "postversion": "npm publish",
38
- "prepublishOnly": "git push origin --follow-tags"
39
+ "prepublishOnly": "git push origin --follow-tags",
40
+ "postlint": "npm-template-check"
39
41
  },
40
42
  "tap": {
41
43
  "check-coverage": true
42
44
  },
43
- "standard": {
44
- "ignore": [
45
- "/tap-snapshots/"
46
- ]
47
- },
48
45
  "devDependencies": {
49
- "eslint": "^7.18.0",
50
- "eslint-plugin-import": "^2.22.1",
51
- "eslint-plugin-node": "^11.1.0",
52
- "eslint-plugin-promise": "^4.2.1",
53
- "eslint-plugin-standard": "^5.0.0",
54
- "tap": "^14.11.0"
46
+ "eslint": "^8.1.0",
47
+ "tap": "^15.0.9"
55
48
  },
56
49
  "dependencies": {
57
50
  "@npmcli/disparity-colors": "^1.0.1",
@@ -59,8 +52,11 @@
59
52
  "binary-extensions": "^2.2.0",
60
53
  "diff": "^5.0.0",
61
54
  "minimatch": "^3.0.4",
62
- "npm-package-arg": "^8.1.1",
63
- "pacote": "^11.3.0",
55
+ "npm-package-arg": "^8.1.4",
56
+ "pacote": "^12.0.0",
64
57
  "tar": "^6.1.0"
58
+ },
59
+ "templateOSS": {
60
+ "version": "2.4.1"
65
61
  }
66
62
  }
package/CHANGELOG.md DELETED
@@ -1,30 +0,0 @@
1
- # Changelog
2
-
3
- ## 2.0.3
4
-
5
- - fix name of options sent by the npm cli
6
-
7
- ## 2.0.2
8
-
9
- - fix matching basename file filter
10
-
11
- ## 2.0.1
12
-
13
- - fix for tarballs not listing folder names
14
-
15
- ## 2.0.0
16
-
17
- - API rewrite:
18
- - normalized all options
19
- - specs to compare are now an array
20
- - fix context=0
21
- - added support to filtering by folder names
22
-
23
- ## 1.0.1
24
-
25
- - fixed nameOnly option
26
-
27
- ## 1.0.0
28
-
29
- - Initial release
30
-