pacote 11.2.7 → 11.3.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 +12 -0
- package/lib/dir.js +7 -26
- package/lib/index.js +11 -0
- package/lib/util/tar-create-options.js +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -168,6 +168,18 @@ resolved, and other properties, as they are determined.
|
|
|
168
168
|
times (even just to validate the cache) for a given packument, since it
|
|
169
169
|
is unlikely to change in the span of a single command.
|
|
170
170
|
|
|
171
|
+
|
|
172
|
+
### Advanced API
|
|
173
|
+
|
|
174
|
+
Each different type of fetcher is exposed for more advanced usage such as
|
|
175
|
+
using helper methods from this classes:
|
|
176
|
+
|
|
177
|
+
* `DirFetcher`
|
|
178
|
+
* `FileFetcher`
|
|
179
|
+
* `GitFetcher`
|
|
180
|
+
* `RegistryFetcher`
|
|
181
|
+
* `RemoteFetcher`
|
|
182
|
+
|
|
171
183
|
## Extracted File Modes
|
|
172
184
|
|
|
173
185
|
Files are extracted with a mode matching the following formula:
|
package/lib/dir.js
CHANGED
|
@@ -4,11 +4,10 @@ const cacache = require('cacache')
|
|
|
4
4
|
const Minipass = require('minipass')
|
|
5
5
|
const { promisify } = require('util')
|
|
6
6
|
const readPackageJson = require('read-package-json-fast')
|
|
7
|
-
const
|
|
7
|
+
const tarCreateOptions = require('./util/tar-create-options.js')
|
|
8
8
|
const packlist = require('npm-packlist')
|
|
9
9
|
const tar = require('tar')
|
|
10
10
|
const _prepareDir = Symbol('_prepareDir')
|
|
11
|
-
const _tarcOpts = Symbol('_tarcOpts')
|
|
12
11
|
const { resolve } = require('path')
|
|
13
12
|
|
|
14
13
|
const runScript = require('@npmcli/run-script')
|
|
@@ -21,6 +20,11 @@ class DirFetcher extends Fetcher {
|
|
|
21
20
|
this.resolved = this.spec.fetchSpec
|
|
22
21
|
}
|
|
23
22
|
|
|
23
|
+
// exposes tarCreateOptions as public API
|
|
24
|
+
static tarCreateOptions (manifest) {
|
|
25
|
+
return tarCreateOptions(manifest)
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
get types () {
|
|
25
29
|
return ['directory']
|
|
26
30
|
}
|
|
@@ -65,35 +69,12 @@ class DirFetcher extends Fetcher {
|
|
|
65
69
|
// pipe to the stream, and proxy errors the chain.
|
|
66
70
|
this[_prepareDir]()
|
|
67
71
|
.then(() => packlist({ path: this.resolved }))
|
|
68
|
-
.then(files => tar.c(this
|
|
72
|
+
.then(files => tar.c(tarCreateOptions(this.package), files)
|
|
69
73
|
.on('error', er => stream.emit('error', er)).pipe(stream))
|
|
70
74
|
.catch(er => stream.emit('error', er))
|
|
71
75
|
return stream
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
[_tarcOpts] () {
|
|
75
|
-
return {
|
|
76
|
-
cwd: this.resolved,
|
|
77
|
-
prefix: 'package/',
|
|
78
|
-
portable: true,
|
|
79
|
-
gzip: true,
|
|
80
|
-
|
|
81
|
-
// ensure that package bins are always executable
|
|
82
|
-
// Note that npm-packlist is already filtering out
|
|
83
|
-
// anything that is not a regular file, ignored by
|
|
84
|
-
// .npmignore or package.json "files", etc.
|
|
85
|
-
filter: (path, stat) => {
|
|
86
|
-
if (isPackageBin(this.package, path))
|
|
87
|
-
stat.mode |= 0o111
|
|
88
|
-
return true
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
// Provide a specific date in the 1980s for the benefit of zip,
|
|
92
|
-
// which is confounded by files dated at the Unix epoch 0.
|
|
93
|
-
mtime: new Date('1985-10-26T08:15:00.000Z'),
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
78
|
manifest () {
|
|
98
79
|
if (this.package)
|
|
99
80
|
return Promise.resolve(this.package)
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
const { get } = require('./fetcher.js')
|
|
2
|
+
const GitFetcher = require('./git.js')
|
|
3
|
+
const RegistryFetcher = require('./registry.js')
|
|
4
|
+
const FileFetcher = require('./file.js')
|
|
5
|
+
const DirFetcher = require('./dir.js')
|
|
6
|
+
const RemoteFetcher = require('./remote.js')
|
|
7
|
+
|
|
2
8
|
module.exports = {
|
|
9
|
+
GitFetcher,
|
|
10
|
+
RegistryFetcher,
|
|
11
|
+
FileFetcher,
|
|
12
|
+
DirFetcher,
|
|
13
|
+
RemoteFetcher,
|
|
3
14
|
resolve: (spec, opts) => get(spec, opts).resolve(),
|
|
4
15
|
extract: (spec, dest, opts) => get(spec, opts).extract(dest),
|
|
5
16
|
manifest: (spec, opts) => get(spec, opts).manifest(),
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const isPackageBin = require('./is-package-bin.js')
|
|
2
|
+
|
|
3
|
+
const tarCreateOptions = manifest => ({
|
|
4
|
+
cwd: manifest._resolved,
|
|
5
|
+
prefix: 'package/',
|
|
6
|
+
portable: true,
|
|
7
|
+
gzip: true,
|
|
8
|
+
|
|
9
|
+
// ensure that package bins are always executable
|
|
10
|
+
// Note that npm-packlist is already filtering out
|
|
11
|
+
// anything that is not a regular file, ignored by
|
|
12
|
+
// .npmignore or package.json "files", etc.
|
|
13
|
+
filter: (path, stat) => {
|
|
14
|
+
if (isPackageBin(manifest, path))
|
|
15
|
+
stat.mode |= 0o111
|
|
16
|
+
return true
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// Provide a specific date in the 1980s for the benefit of zip,
|
|
20
|
+
// which is confounded by files dated at the Unix epoch 0.
|
|
21
|
+
mtime: new Date('1985-10-26T08:15:00.000Z'),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
module.exports = tarCreateOptions
|