libnpmpack 3.0.0 → 4.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.
@@ -3,6 +3,9 @@
3
3
  const pacote = require('pacote')
4
4
  const npa = require('npm-package-arg')
5
5
  const runScript = require('@npmcli/run-script')
6
+ const path = require('path')
7
+ const util = require('util')
8
+ const writeFile = util.promisify(require('fs').writeFile)
6
9
 
7
10
  module.exports = pack
8
11
  async function pack (spec = 'file:.', opts = {}) {
@@ -13,7 +16,7 @@ async function pack (spec = 'file:.', opts = {}) {
13
16
 
14
17
  // Default to true if no log options passed, set to false if we're in silent
15
18
  // mode
16
- const banner = !opts.log || (opts.log.level !== 'silent')
19
+ const banner = !opts.silent
17
20
 
18
21
  if (spec.type === 'directory') {
19
22
  // prepack
@@ -23,16 +26,24 @@ async function pack (spec = 'file:.', opts = {}) {
23
26
  path: spec.fetchSpec,
24
27
  stdio: 'inherit',
25
28
  pkg: manifest,
26
- banner
29
+ banner,
27
30
  })
28
31
  }
29
32
 
30
33
  // packs tarball
31
34
  const tarball = await pacote.tarball(manifest._resolved, {
32
35
  ...opts,
33
- integrity: manifest._integrity
36
+ integrity: manifest._integrity,
34
37
  })
35
38
 
39
+ // check for explicit `false` so the default behavior is to skip writing to disk
40
+ if (opts.dryRun === false) {
41
+ const filename = `${manifest.name}-${manifest.version}.tgz`
42
+ .replace(/^@/, '').replace(/\//, '-')
43
+ const destination = path.resolve(opts.packDestination, filename)
44
+ await writeFile(destination, tarball)
45
+ }
46
+
36
47
  if (spec.type === 'directory') {
37
48
  // postpack
38
49
  await runScript({
@@ -45,8 +56,8 @@ async function pack (spec = 'file:.', opts = {}) {
45
56
  env: {
46
57
  npm_package_from: tarball.from,
47
58
  npm_package_resolved: tarball.resolved,
48
- npm_package_integrity: tarball.integrity
49
- }
59
+ npm_package_integrity: tarball.integrity,
60
+ },
50
61
  })
51
62
  }
52
63
 
package/package.json CHANGED
@@ -1,31 +1,35 @@
1
1
  {
2
2
  "name": "libnpmpack",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Programmatic API for the bits behind npm pack",
5
- "author": "npm Inc. <support@npmjs.com>",
5
+ "author": "GitHub Inc.",
6
+ "main": "lib/index.js",
6
7
  "contributors": [
7
8
  "Claudia Hernández <claudia@npmjs.com>"
8
9
  ],
9
- "main": "index.js",
10
10
  "files": [
11
- "*.js"
11
+ "bin",
12
+ "lib"
12
13
  ],
13
14
  "license": "ISC",
14
15
  "scripts": {
15
16
  "preversion": "npm test",
16
17
  "postversion": "npm publish",
17
18
  "prepublishOnly": "git push origin --follow-tags",
18
- "lint": "standard",
19
+ "lint": "eslint '**/*.js'",
19
20
  "test": "tap",
20
- "posttest": "npm run lint"
21
+ "posttest": "npm run lint",
22
+ "postlint": "npm-template-check",
23
+ "lintfix": "npm run lint -- --fix",
24
+ "snap": "tap"
21
25
  },
22
26
  "tap": {
23
27
  "check-coverage": true
24
28
  },
25
29
  "devDependencies": {
30
+ "@npmcli/template-oss": "^2.4.2",
26
31
  "nock": "^13.0.7",
27
- "standard": "^16.0.3",
28
- "tap": "^14.11.0"
32
+ "tap": "^15.0.0"
29
33
  },
30
34
  "repository": {
31
35
  "type": "git",
@@ -34,11 +38,14 @@
34
38
  "bugs": "https://github.com/npm/libnpmpack/issues",
35
39
  "homepage": "https://npmjs.com/package/libnpmpack",
36
40
  "dependencies": {
37
- "@npmcli/run-script": "^2.0.0",
38
- "npm-package-arg": "^8.1.0",
39
- "pacote": "^12.0.0"
41
+ "@npmcli/run-script": "^3.0.0",
42
+ "npm-package-arg": "^9.0.0",
43
+ "pacote": "^13.0.2"
40
44
  },
41
45
  "engines": {
42
46
  "node": "^12.13.0 || ^14.15.0 || >=16"
47
+ },
48
+ "templateOSS": {
49
+ "version": "2.4.3"
43
50
  }
44
51
  }