tar 6.2.1 → 7.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.
Files changed (253) hide show
  1. package/README.md +30 -16
  2. package/dist/commonjs/create.d.ts +8 -0
  3. package/dist/commonjs/create.d.ts.map +1 -0
  4. package/dist/commonjs/create.js +106 -0
  5. package/dist/commonjs/create.js.map +1 -0
  6. package/dist/commonjs/cwd-error.d.ts +8 -0
  7. package/dist/commonjs/cwd-error.d.ts.map +1 -0
  8. package/dist/commonjs/cwd-error.js +18 -0
  9. package/dist/commonjs/cwd-error.js.map +1 -0
  10. package/dist/commonjs/extract.d.ts +8 -0
  11. package/dist/commonjs/extract.d.ts.map +1 -0
  12. package/dist/commonjs/extract.js +141 -0
  13. package/dist/commonjs/extract.js.map +1 -0
  14. package/dist/commonjs/get-write-flag.d.ts +2 -0
  15. package/dist/commonjs/get-write-flag.d.ts.map +1 -0
  16. package/dist/commonjs/get-write-flag.js +29 -0
  17. package/dist/commonjs/get-write-flag.js.map +1 -0
  18. package/dist/commonjs/header.d.ts +54 -0
  19. package/dist/commonjs/header.d.ts.map +1 -0
  20. package/dist/commonjs/header.js +308 -0
  21. package/dist/commonjs/header.js.map +1 -0
  22. package/dist/commonjs/index.d.ts +19 -0
  23. package/dist/commonjs/index.d.ts.map +1 -0
  24. package/dist/commonjs/index.js +54 -0
  25. package/dist/commonjs/index.js.map +1 -0
  26. package/dist/commonjs/large-numbers.d.ts +4 -0
  27. package/dist/commonjs/large-numbers.d.ts.map +1 -0
  28. package/dist/commonjs/large-numbers.js +99 -0
  29. package/dist/commonjs/large-numbers.js.map +1 -0
  30. package/dist/commonjs/list.d.ts +8 -0
  31. package/dist/commonjs/list.d.ts.map +1 -0
  32. package/dist/commonjs/list.js +167 -0
  33. package/dist/commonjs/list.js.map +1 -0
  34. package/dist/commonjs/mkdir.d.ts +27 -0
  35. package/dist/commonjs/mkdir.d.ts.map +1 -0
  36. package/dist/commonjs/mkdir.js +209 -0
  37. package/dist/commonjs/mkdir.js.map +1 -0
  38. package/dist/commonjs/mode-fix.d.ts +2 -0
  39. package/dist/commonjs/mode-fix.d.ts.map +1 -0
  40. package/dist/commonjs/mode-fix.js +29 -0
  41. package/dist/commonjs/mode-fix.js.map +1 -0
  42. package/dist/commonjs/normalize-unicode.d.ts +2 -0
  43. package/dist/commonjs/normalize-unicode.d.ts.map +1 -0
  44. package/dist/commonjs/normalize-unicode.js +17 -0
  45. package/dist/commonjs/normalize-unicode.js.map +1 -0
  46. package/dist/commonjs/normalize-windows-path.d.ts +2 -0
  47. package/dist/commonjs/normalize-windows-path.d.ts.map +1 -0
  48. package/dist/commonjs/normalize-windows-path.js +12 -0
  49. package/dist/commonjs/normalize-windows-path.js.map +1 -0
  50. package/dist/commonjs/options.d.ts +545 -0
  51. package/dist/commonjs/options.d.ts.map +1 -0
  52. package/dist/commonjs/options.js +55 -0
  53. package/dist/commonjs/options.js.map +1 -0
  54. package/dist/commonjs/pack.d.ts +98 -0
  55. package/dist/commonjs/pack.d.ts.map +1 -0
  56. package/dist/commonjs/pack.js +461 -0
  57. package/dist/commonjs/pack.js.map +1 -0
  58. package/dist/commonjs/package.json +3 -0
  59. package/dist/commonjs/parse.d.ts +84 -0
  60. package/dist/commonjs/parse.d.ts.map +1 -0
  61. package/dist/commonjs/parse.js +571 -0
  62. package/dist/commonjs/parse.js.map +1 -0
  63. package/dist/commonjs/path-reservations.d.ts +11 -0
  64. package/dist/commonjs/path-reservations.d.ts.map +1 -0
  65. package/dist/commonjs/path-reservations.js +169 -0
  66. package/dist/commonjs/path-reservations.js.map +1 -0
  67. package/dist/commonjs/pax.d.ts +27 -0
  68. package/dist/commonjs/pax.d.ts.map +1 -0
  69. package/dist/commonjs/pax.js +158 -0
  70. package/dist/commonjs/pax.js.map +1 -0
  71. package/dist/commonjs/read-entry.d.ts +37 -0
  72. package/dist/commonjs/read-entry.d.ts.map +1 -0
  73. package/dist/commonjs/read-entry.js +139 -0
  74. package/dist/commonjs/read-entry.js.map +1 -0
  75. package/dist/commonjs/replace.d.ts +5 -0
  76. package/dist/commonjs/replace.d.ts.map +1 -0
  77. package/dist/commonjs/replace.js +223 -0
  78. package/dist/commonjs/replace.js.map +1 -0
  79. package/dist/commonjs/strip-absolute-path.d.ts +2 -0
  80. package/dist/commonjs/strip-absolute-path.d.ts.map +1 -0
  81. package/dist/commonjs/strip-absolute-path.js +29 -0
  82. package/dist/commonjs/strip-absolute-path.js.map +1 -0
  83. package/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
  84. package/dist/commonjs/strip-trailing-slashes.d.ts.map +1 -0
  85. package/dist/commonjs/strip-trailing-slashes.js +18 -0
  86. package/dist/commonjs/strip-trailing-slashes.js.map +1 -0
  87. package/dist/commonjs/symlink-error.d.ts +9 -0
  88. package/dist/commonjs/symlink-error.d.ts.map +1 -0
  89. package/dist/commonjs/symlink-error.js +19 -0
  90. package/dist/commonjs/symlink-error.js.map +1 -0
  91. package/dist/commonjs/types.d.ts +7 -0
  92. package/dist/commonjs/types.d.ts.map +1 -0
  93. package/dist/commonjs/types.js +50 -0
  94. package/dist/commonjs/types.js.map +1 -0
  95. package/dist/commonjs/unpack.d.ts +98 -0
  96. package/dist/commonjs/unpack.d.ts.map +1 -0
  97. package/dist/commonjs/unpack.js +921 -0
  98. package/dist/commonjs/unpack.js.map +1 -0
  99. package/dist/commonjs/update.d.ts +3 -0
  100. package/dist/commonjs/update.d.ts.map +1 -0
  101. package/dist/commonjs/update.js +47 -0
  102. package/dist/commonjs/update.js.map +1 -0
  103. package/dist/commonjs/warn-method.d.ts +20 -0
  104. package/dist/commonjs/warn-method.d.ts.map +1 -0
  105. package/dist/commonjs/warn-method.js +31 -0
  106. package/dist/commonjs/warn-method.js.map +1 -0
  107. package/dist/commonjs/winchars.d.ts +3 -0
  108. package/dist/commonjs/winchars.d.ts.map +1 -0
  109. package/dist/commonjs/winchars.js +14 -0
  110. package/dist/commonjs/winchars.js.map +1 -0
  111. package/dist/commonjs/write-entry.d.ts +125 -0
  112. package/dist/commonjs/write-entry.d.ts.map +1 -0
  113. package/dist/commonjs/write-entry.js +657 -0
  114. package/dist/commonjs/write-entry.js.map +1 -0
  115. package/dist/esm/create.d.ts +8 -0
  116. package/dist/esm/create.d.ts.map +1 -0
  117. package/dist/esm/create.js +99 -0
  118. package/dist/esm/create.js.map +1 -0
  119. package/dist/esm/cwd-error.d.ts +8 -0
  120. package/dist/esm/cwd-error.d.ts.map +1 -0
  121. package/dist/esm/cwd-error.js +14 -0
  122. package/dist/esm/cwd-error.js.map +1 -0
  123. package/dist/esm/extract.d.ts +8 -0
  124. package/dist/esm/extract.d.ts.map +1 -0
  125. package/dist/esm/extract.js +111 -0
  126. package/dist/esm/extract.js.map +1 -0
  127. package/dist/esm/get-write-flag.d.ts +2 -0
  128. package/dist/esm/get-write-flag.d.ts.map +1 -0
  129. package/dist/esm/get-write-flag.js +23 -0
  130. package/dist/esm/get-write-flag.js.map +1 -0
  131. package/dist/esm/header.d.ts +54 -0
  132. package/dist/esm/header.d.ts.map +1 -0
  133. package/dist/esm/header.js +281 -0
  134. package/dist/esm/header.js.map +1 -0
  135. package/dist/esm/index.d.ts +19 -0
  136. package/dist/esm/index.d.ts.map +1 -0
  137. package/dist/esm/index.js +20 -0
  138. package/dist/esm/index.js.map +1 -0
  139. package/dist/esm/large-numbers.d.ts +4 -0
  140. package/dist/esm/large-numbers.d.ts.map +1 -0
  141. package/dist/esm/large-numbers.js +94 -0
  142. package/dist/esm/large-numbers.js.map +1 -0
  143. package/dist/esm/list.d.ts +8 -0
  144. package/dist/esm/list.d.ts.map +1 -0
  145. package/dist/esm/list.js +137 -0
  146. package/dist/esm/list.js.map +1 -0
  147. package/dist/esm/mkdir.d.ts +27 -0
  148. package/dist/esm/mkdir.d.ts.map +1 -0
  149. package/dist/esm/mkdir.js +201 -0
  150. package/dist/esm/mkdir.js.map +1 -0
  151. package/dist/esm/mode-fix.d.ts +2 -0
  152. package/dist/esm/mode-fix.d.ts.map +1 -0
  153. package/dist/esm/mode-fix.js +25 -0
  154. package/dist/esm/mode-fix.js.map +1 -0
  155. package/dist/esm/normalize-unicode.d.ts +2 -0
  156. package/dist/esm/normalize-unicode.d.ts.map +1 -0
  157. package/dist/esm/normalize-unicode.js +13 -0
  158. package/dist/esm/normalize-unicode.js.map +1 -0
  159. package/dist/esm/normalize-windows-path.d.ts +2 -0
  160. package/dist/esm/normalize-windows-path.d.ts.map +1 -0
  161. package/{lib → dist/esm}/normalize-windows-path.js +5 -4
  162. package/dist/esm/normalize-windows-path.js.map +1 -0
  163. package/dist/esm/options.d.ts +545 -0
  164. package/dist/esm/options.d.ts.map +1 -0
  165. package/dist/esm/options.js +48 -0
  166. package/dist/esm/options.js.map +1 -0
  167. package/dist/esm/pack.d.ts +98 -0
  168. package/dist/esm/pack.d.ts.map +1 -0
  169. package/dist/esm/pack.js +429 -0
  170. package/dist/esm/pack.js.map +1 -0
  171. package/dist/esm/package.json +3 -0
  172. package/dist/esm/parse.d.ts +84 -0
  173. package/dist/esm/parse.d.ts.map +1 -0
  174. package/dist/esm/parse.js +567 -0
  175. package/dist/esm/parse.js.map +1 -0
  176. package/dist/esm/path-reservations.d.ts +11 -0
  177. package/dist/esm/path-reservations.d.ts.map +1 -0
  178. package/dist/esm/path-reservations.js +165 -0
  179. package/dist/esm/path-reservations.js.map +1 -0
  180. package/dist/esm/pax.d.ts +27 -0
  181. package/dist/esm/pax.d.ts.map +1 -0
  182. package/dist/esm/pax.js +154 -0
  183. package/dist/esm/pax.js.map +1 -0
  184. package/dist/esm/read-entry.d.ts +37 -0
  185. package/dist/esm/read-entry.d.ts.map +1 -0
  186. package/dist/esm/read-entry.js +135 -0
  187. package/dist/esm/read-entry.js.map +1 -0
  188. package/dist/esm/replace.d.ts +5 -0
  189. package/dist/esm/replace.d.ts.map +1 -0
  190. package/dist/esm/replace.js +216 -0
  191. package/dist/esm/replace.js.map +1 -0
  192. package/dist/esm/strip-absolute-path.d.ts +2 -0
  193. package/dist/esm/strip-absolute-path.d.ts.map +1 -0
  194. package/dist/esm/strip-absolute-path.js +25 -0
  195. package/dist/esm/strip-absolute-path.js.map +1 -0
  196. package/dist/esm/strip-trailing-slashes.d.ts +2 -0
  197. package/dist/esm/strip-trailing-slashes.d.ts.map +1 -0
  198. package/dist/esm/strip-trailing-slashes.js +14 -0
  199. package/dist/esm/strip-trailing-slashes.js.map +1 -0
  200. package/dist/esm/symlink-error.d.ts +9 -0
  201. package/dist/esm/symlink-error.d.ts.map +1 -0
  202. package/dist/esm/symlink-error.js +15 -0
  203. package/dist/esm/symlink-error.js.map +1 -0
  204. package/dist/esm/types.d.ts +7 -0
  205. package/dist/esm/types.d.ts.map +1 -0
  206. package/dist/esm/types.js +45 -0
  207. package/dist/esm/types.js.map +1 -0
  208. package/dist/esm/unpack.d.ts +98 -0
  209. package/dist/esm/unpack.d.ts.map +1 -0
  210. package/dist/esm/unpack.js +890 -0
  211. package/dist/esm/unpack.js.map +1 -0
  212. package/dist/esm/update.d.ts +3 -0
  213. package/dist/esm/update.d.ts.map +1 -0
  214. package/dist/esm/update.js +43 -0
  215. package/dist/esm/update.js.map +1 -0
  216. package/dist/esm/warn-method.d.ts +20 -0
  217. package/dist/esm/warn-method.d.ts.map +1 -0
  218. package/dist/esm/warn-method.js +27 -0
  219. package/dist/esm/warn-method.js.map +1 -0
  220. package/dist/esm/winchars.d.ts +3 -0
  221. package/dist/esm/winchars.d.ts.map +1 -0
  222. package/dist/esm/winchars.js +9 -0
  223. package/dist/esm/winchars.js.map +1 -0
  224. package/dist/esm/write-entry.d.ts +125 -0
  225. package/dist/esm/write-entry.d.ts.map +1 -0
  226. package/dist/esm/write-entry.js +625 -0
  227. package/dist/esm/write-entry.js.map +1 -0
  228. package/package.json +255 -40
  229. package/index.js +0 -18
  230. package/lib/create.js +0 -111
  231. package/lib/extract.js +0 -113
  232. package/lib/get-write-flag.js +0 -20
  233. package/lib/header.js +0 -304
  234. package/lib/high-level-opt.js +0 -29
  235. package/lib/large-numbers.js +0 -104
  236. package/lib/list.js +0 -139
  237. package/lib/mkdir.js +0 -229
  238. package/lib/mode-fix.js +0 -27
  239. package/lib/normalize-unicode.js +0 -12
  240. package/lib/pack.js +0 -432
  241. package/lib/parse.js +0 -552
  242. package/lib/path-reservations.js +0 -156
  243. package/lib/pax.js +0 -150
  244. package/lib/read-entry.js +0 -107
  245. package/lib/replace.js +0 -246
  246. package/lib/strip-absolute-path.js +0 -24
  247. package/lib/strip-trailing-slashes.js +0 -13
  248. package/lib/types.js +0 -44
  249. package/lib/unpack.js +0 -923
  250. package/lib/update.js +0 -40
  251. package/lib/warn-mixin.js +0 -24
  252. package/lib/winchars.js +0 -23
  253. package/lib/write-entry.js +0 -546
@@ -0,0 +1,545 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { type GzipOptions, type ZlibOptions } from 'minizlib';
3
+ import { type Stats } from 'node:fs';
4
+ import { type ReadEntry } from './read-entry.js';
5
+ import { type WarnData } from './warn-method.js';
6
+ /**
7
+ * The options that can be provided to tar commands.
8
+ *
9
+ * Note that some of these are only relevant for certain commands, since
10
+ * they are specific to reading or writing.
11
+ *
12
+ * Aliases are provided in the {@link TarOptionsWithAliases} type.
13
+ */
14
+ export interface TarOptions {
15
+ /**
16
+ * Perform all I/O operations synchronously. If the stream is ended
17
+ * immediately, then it will be processed entirely synchronously.
18
+ */
19
+ sync?: boolean;
20
+ /**
21
+ * The tar file to be read and/or written. When this is set, a stream
22
+ * is not returned. Asynchronous commands will return a promise indicating
23
+ * when the operation is completed, and synchronous commands will return
24
+ * immediately.
25
+ */
26
+ file?: string;
27
+ /**
28
+ * Treat warnings as crash-worthy errors. Defaults false.
29
+ */
30
+ strict?: boolean;
31
+ /**
32
+ * The effective current working directory for this tar command
33
+ */
34
+ cwd?: string;
35
+ /**
36
+ * When creating a tar archive, this can be used to compress it as well.
37
+ * Set to `true` to use the default gzip options, or customize them as
38
+ * needed.
39
+ *
40
+ * When reading, if this is unset, then the compression status will be
41
+ * inferred from the archive data. This is generally best, unless you are
42
+ * sure of the compression settings in use to create the archive, and want to
43
+ * fail if the archive doesn't match expectations.
44
+ */
45
+ gzip?: boolean | GzipOptions;
46
+ /**
47
+ * When creating archives, preserve absolute and `..` paths in the archive,
48
+ * rather than sanitizing them under the cwd.
49
+ *
50
+ * When extracting, allow absolute paths, paths containing `..`, and
51
+ * extracting through symbolic links. By default, the root `/` is stripped
52
+ * from absolute paths (eg, turning `/x/y/z` into `x/y/z`), paths containing
53
+ * `..` are not extracted, and any file whose location would be modified by a
54
+ * symbolic link is not extracted.
55
+ *
56
+ * **WARNING** This is almost always unsafe, and must NEVER be used on
57
+ * archives from untrusted sources, such as user input, and every entry must
58
+ * be validated to ensure it is safe to write. Even if the input is not
59
+ * malicious, mistakes can cause a lot of damage!
60
+ */
61
+ preservePaths?: boolean;
62
+ /**
63
+ * When extracting, do not set the `mtime` value for extracted entries to
64
+ * match the `mtime` in the archive.
65
+ *
66
+ * When creating archives, do not store the `mtime` value in the entry. Note
67
+ * that this prevents properly using other mtime-based features (such as
68
+ * `tar.update` or the `newer` option) with the resulting archive.
69
+ */
70
+ noMtime?: boolean;
71
+ /**
72
+ * Set to `true` or an object with settings for `zlib.BrotliCompress()` to
73
+ * create a brotli-compressed archive
74
+ *
75
+ * When extracting, this will cause the archive to be treated as a
76
+ * brotli-compressed file if set to `true` or a ZlibOptions object.
77
+ *
78
+ * If set `false`, then brotli options will not be used.
79
+ *
80
+ * If both this and the `gzip` option are left `undefined`, then tar will
81
+ * attempt to infer the brotli compression status, but can only do so based
82
+ * on the filename. If the filename ends in `.tbr` or `.tar.br`, and the
83
+ * first 512 bytes are not a valid tar header, then brotli decompression
84
+ * will be attempted.
85
+ */
86
+ brotli?: boolean | ZlibOptions;
87
+ /**
88
+ * A function that is called with `(path, stat)` when creating an archive, or
89
+ * `(path, entry)` when extracting. Return true to process the file/entry, or
90
+ * false to exclude it.
91
+ */
92
+ filter?: (path: string, entry: Stats | ReadEntry) => boolean;
93
+ /**
94
+ * A function that gets called for any warning encountered.
95
+ *
96
+ * Note: if `strict` is set, then the warning will throw, and this method
97
+ * will not be called.
98
+ */
99
+ onwarn?: (code: string, message: string, data: WarnData) => any;
100
+ /**
101
+ * When extracting, unlink files before creating them. Without this option,
102
+ * tar overwrites existing files, which preserves existing hardlinks. With
103
+ * this option, existing hardlinks will be broken, as will any symlink that
104
+ * would affect the location of an extracted file.
105
+ */
106
+ unlink?: boolean;
107
+ /**
108
+ * When extracting, strip the specified number of path portions from the
109
+ * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be
110
+ * extracted to `{cwd}/c/d`.
111
+ *
112
+ * Any entry whose entire path is stripped will be excluded.
113
+ */
114
+ strip?: number;
115
+ /**
116
+ * When extracting, keep the existing file on disk if it's newer than the
117
+ * file in the archive.
118
+ */
119
+ newer?: boolean;
120
+ /**
121
+ * When extracting, do not overwrite existing files at all.
122
+ */
123
+ keep?: boolean;
124
+ /**
125
+ * When extracting, set the `uid` and `gid` of extracted entries to the `uid`
126
+ * and `gid` fields in the archive. Defaults to true when run as root, and
127
+ * false otherwise.
128
+ *
129
+ * If false, then files and directories will be set with the owner and group
130
+ * of the user running the process. This is similar to `-p` in `tar(1)`, but
131
+ * ACLs and other system-specific data is never unpacked in this
132
+ * implementation, and modes are set by default already.
133
+ */
134
+ preserveOwner?: boolean;
135
+ /**
136
+ * The maximum depth of subfolders to extract into. This defaults to 1024.
137
+ * Anything deeper than the limit will raise a warning and skip the entry.
138
+ * Set to `Infinity` to remove the limitation.
139
+ */
140
+ maxDepth?: number;
141
+ /**
142
+ * When extracting, force all created files and directories, and all
143
+ * implicitly created directories, to be owned by the specified user id,
144
+ * regardless of the `uid` field in the archive.
145
+ *
146
+ * Cannot be used along with `preserveOwner`. Requires also setting the `gid`
147
+ * option.
148
+ */
149
+ uid?: number;
150
+ /**
151
+ * When extracting, force all created files and directories, and all
152
+ * implicitly created directories, to be owned by the specified group id,
153
+ * regardless of the `gid` field in the archive.
154
+ *
155
+ * Cannot be used along with `preserveOwner`. Requires also setting the `uid`
156
+ * option.
157
+ */
158
+ gid?: number;
159
+ /**
160
+ * When extracting, provide a function that takes an `entry` object, and
161
+ * returns a stream, or any falsey value. If a stream is provided, then that
162
+ * stream's data will be written instead of the contents of the archive
163
+ * entry. If a falsey value is provided, then the entry is written to disk as
164
+ * normal.
165
+ *
166
+ * To exclude items from extraction, use the `filter` option.
167
+ *
168
+ * Note that using an asynchronous stream type with the `transform` option
169
+ * will cause undefined behavior in synchronous extractions.
170
+ * [MiniPass](http://npm.im/minipass)-based streams are designed for this use
171
+ * case.
172
+ */
173
+ transform?: (entry: ReadEntry) => any;
174
+ /**
175
+ * Call `chmod()` to ensure that extracted files match the entry's mode
176
+ * field. Without this field set, all mode fields in archive entries are a
177
+ * best effort attempt only.
178
+ *
179
+ * Setting this necessitates a call to the deprecated `process.umask()`
180
+ * method to determine the default umask value, unless a `processUmask`
181
+ * config is provided as well.
182
+ *
183
+ * If not set, tar will attempt to create file system entries with whatever
184
+ * mode is provided, and let the implicit process `umask` apply normally, but
185
+ * if a file already exists to be written to, then its existing mode will not
186
+ * be modified.
187
+ *
188
+ * When setting `chmod: true`, it is highly recommend to set the
189
+ * {@link TarOptions#processUmask} option as well, to avoid the call to the
190
+ * deprecated (and thread-unsafe) `process.umask()` method.
191
+ */
192
+ chmod?: boolean;
193
+ /**
194
+ * When setting the {@link TarOptions#noChmod} option to `false`, you may
195
+ * provide a value here to avoid having to call the deprecated and
196
+ * thread-unsafe `process.umask()` method.
197
+ *
198
+ * This has no effect with `noChmod` is not set to false explicitly, as
199
+ * mode values are not set explicitly anyway. If `noChmod` is set to `false`,
200
+ * and a value is not provided here, then `process.umask()` must be called,
201
+ * which will result in deprecation warnings.
202
+ *
203
+ * The most common values for this are `0o22` (resulting in directories
204
+ * created with mode `0o755` and files with `0o644` by default) and `0o2`
205
+ * (resulting in directores created with mode `0o775` and files `0o664`, so
206
+ * they are group-writable).
207
+ */
208
+ processUmask?: number;
209
+ /**
210
+ * When parsing/listing archives, `entry` streams are by default resumed
211
+ * (set into "flowing" mode) immediately after the call to `onentry()`.
212
+ * Set `noResume: true` to suppress this behavior.
213
+ *
214
+ * Note that when this is set, the stream will never complete until the
215
+ * data is consumed somehow.
216
+ *
217
+ * Set automatically in extract operations, since the entry is piped to
218
+ * a file system entry right away. Only relevant when parsing.
219
+ */
220
+ noResume?: boolean;
221
+ /**
222
+ * When extracting or listing archives, this method will be called with
223
+ * each entry that is not excluded by a `filter`.
224
+ *
225
+ * Important when listing archives synchronously from a file, because there
226
+ * is otherwise no way to interact with the data!
227
+ */
228
+ onentry?: (entry: ReadEntry) => any;
229
+ /**
230
+ * Pack the targets of symbolic links rather than the link itself.
231
+ */
232
+ follow?: boolean;
233
+ /**
234
+ * When creating archives, omit any metadata that is system-specific:
235
+ * `ctime`, `atime`, `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and
236
+ * `nlink`. Note that `mtime` is still included, because this is necessary
237
+ * for other time-based operations such as `tar.update`. Additionally, `mode`
238
+ * is set to a "reasonable default" for mose unix systems, based on an
239
+ * effective `umask` of `0o22`.
240
+ *
241
+ * This also defaults the `portable` option in the gzip configs when creating
242
+ * a compressed archive, in order to produce deterministic archives that are
243
+ * not operating-system specific.
244
+ */
245
+ portable?: boolean;
246
+ /**
247
+ * When creating archives, do not recursively archive the contents of
248
+ * directories. By default, archiving a directory archives all of its
249
+ * contents as well.
250
+ */
251
+ noDirRecurse?: boolean;
252
+ /**
253
+ * Suppress Pax extended headers when creating archives. Note that this means
254
+ * long paths and linkpaths will be truncated, and large or negative numeric
255
+ * values may be interpreted incorrectly.
256
+ */
257
+ noPax?: boolean;
258
+ /**
259
+ * Set to a `Date` object to force a specific `mtime` value for everything
260
+ * written to an archive.
261
+ *
262
+ * This is useful when creating archives that are intended to be
263
+ * deterministic based on their contents, irrespective of the file's last
264
+ * modification time.
265
+ *
266
+ * Overridden by `noMtime`.
267
+ */
268
+ mtime?: Date;
269
+ /**
270
+ * A path portion to prefix onto the entries added to an archive.
271
+ */
272
+ prefix?: string;
273
+ /**
274
+ * The mode to set on any created file archive, defaults to 0o666
275
+ * masked by the process umask, often resulting in 0o644.
276
+ *
277
+ * This does *not* affect the mode fields of individual entries, or the
278
+ * mode status of extracted entries on the filesystem.
279
+ */
280
+ mode?: number;
281
+ /**
282
+ * A cache of mtime values, to avoid having to stat the same file repeatedly.
283
+ *
284
+ * @internal
285
+ */
286
+ mtimeCache?: Map<string, Date>;
287
+ /**
288
+ * maximum buffer size for `fs.read()` operations.
289
+ *
290
+ * @internal
291
+ */
292
+ maxReadSize?: number;
293
+ /**
294
+ * Filter modes of entries being unpacked, like `process.umask()`
295
+ *
296
+ * @internal
297
+ */
298
+ umask?: number;
299
+ /**
300
+ * Default mode for directories. Used for all implicitly created directories,
301
+ * and any directories in the archive that do not have a mode field.
302
+ *
303
+ * @internal
304
+ */
305
+ dmode?: number;
306
+ /**
307
+ * default mode for files
308
+ *
309
+ * @internal
310
+ */
311
+ fmode?: number;
312
+ /**
313
+ * Map that tracks which directories already exist, for extraction
314
+ *
315
+ * @internal
316
+ */
317
+ dirCache?: Map<string, boolean>;
318
+ /**
319
+ * maximum supported size of meta entries. Defaults to 1MB
320
+ *
321
+ * @internal
322
+ */
323
+ maxMetaEntrySize?: number;
324
+ /**
325
+ * A Map object containing the device and inode value for any file whose
326
+ * `nlink` value is greater than 1, to identify hard links when creating
327
+ * archives.
328
+ *
329
+ * @internal
330
+ */
331
+ linkCache?: Map<LinkCacheKey, string>;
332
+ /**
333
+ * A map object containing the results of `fs.readdir()` calls.
334
+ *
335
+ * @internal
336
+ */
337
+ readdirCache?: Map<string, string[]>;
338
+ /**
339
+ * A cache of all `lstat` results, for use in creating archives.
340
+ *
341
+ * @internal
342
+ */
343
+ statCache?: Map<string, Stats>;
344
+ /**
345
+ * Number of concurrent jobs to run when creating archives.
346
+ *
347
+ * Defaults to 4.
348
+ *
349
+ * @internal
350
+ */
351
+ jobs?: number;
352
+ /**
353
+ * Automatically set to true on Windows systems.
354
+ *
355
+ * When extracting, causes behavior where filenames containing `<|>?:`
356
+ * characters are converted to windows-compatible escape sequences in the
357
+ * created filesystem entries.
358
+ *
359
+ * When packing, causes behavior where paths replace `\` with `/`, and
360
+ * filenames containing the windows-compatible escaped forms of `<|>?:` are
361
+ * converted to actual `<|>?:` characters in the archive.
362
+ *
363
+ * @internal
364
+ */
365
+ win32?: boolean;
366
+ /**
367
+ * For `WriteEntry` objects, the absolute path to the entry on the
368
+ * filesystem. By default, this is `resolve(cwd, entry.path)`, but it can be
369
+ * overridden explicitly.
370
+ *
371
+ * @internal
372
+ */
373
+ absolute?: string;
374
+ /**
375
+ * Used with Parser stream interface, to attach and take over when the
376
+ * stream is completely parsed. If this is set, then the prefinish,
377
+ * finish, and end events will not fire, and are the responsibility of
378
+ * the ondone method to emit properly.
379
+ *
380
+ * @internal
381
+ */
382
+ ondone?: () => void;
383
+ /**
384
+ * Mostly for testing, but potentially useful in some cases.
385
+ * Forcibly trigger a chown on every entry, no matter what.
386
+ */
387
+ forceChown?: boolean;
388
+ }
389
+ export type TarOptionsSync = TarOptions & {
390
+ sync: true;
391
+ };
392
+ export type TarOptionsFile = TarOptions & {
393
+ file: string;
394
+ };
395
+ export type TarOptionsSyncFile = TarOptionsSync & TarOptionsFile;
396
+ export type LinkCacheKey = `${number}:${number}`;
397
+ export interface TarOptionsWithAliases extends TarOptions {
398
+ /**
399
+ * The effective current working directory for this tar command
400
+ */
401
+ C?: TarOptions['cwd'];
402
+ /**
403
+ * The tar file to be read and/or written. When this is set, a stream
404
+ * is not returned. Asynchronous commands will return a promise indicating
405
+ * when the operation is completed, and synchronous commands will return
406
+ * immediately.
407
+ */
408
+ f?: TarOptions['file'];
409
+ /**
410
+ * When creating a tar archive, this can be used to compress it as well.
411
+ * Set to `true` to use the default gzip options, or customize them as
412
+ * needed.
413
+ *
414
+ * When reading, if this is unset, then the compression status will be
415
+ * inferred from the archive data. This is generally best, unless you are
416
+ * sure of the compression settings in use to create the archive, and want to
417
+ * fail if the archive doesn't match expectations.
418
+ */
419
+ z?: TarOptions['gzip'];
420
+ /**
421
+ * When creating archives, preserve absolute and `..` paths in the archive,
422
+ * rather than sanitizing them under the cwd.
423
+ *
424
+ * When extracting, allow absolute paths, paths containing `..`, and
425
+ * extracting through symbolic links. By default, the root `/` is stripped
426
+ * from absolute paths (eg, turning `/x/y/z` into `x/y/z`), paths containing
427
+ * `..` are not extracted, and any file whose location would be modified by a
428
+ * symbolic link is not extracted.
429
+ *
430
+ * **WARNING** This is almost always unsafe, and must NEVER be used on
431
+ * archives from untrusted sources, such as user input, and every entry must
432
+ * be validated to ensure it is safe to write. Even if the input is not
433
+ * malicious, mistakes can cause a lot of damage!
434
+ */
435
+ P?: TarOptions['preservePaths'];
436
+ /**
437
+ * When extracting, unlink files before creating them. Without this option,
438
+ * tar overwrites existing files, which preserves existing hardlinks. With
439
+ * this option, existing hardlinks will be broken, as will any symlink that
440
+ * would affect the location of an extracted file.
441
+ */
442
+ U?: TarOptions['unlink'];
443
+ /**
444
+ * When extracting, strip the specified number of path portions from the
445
+ * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be
446
+ * extracted to `{cwd}/c/d`.
447
+ */
448
+ 'strip-components'?: TarOptions['strip'];
449
+ /**
450
+ * When extracting, strip the specified number of path portions from the
451
+ * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be
452
+ * extracted to `{cwd}/c/d`.
453
+ */
454
+ stripComponents?: TarOptions['strip'];
455
+ /**
456
+ * When extracting, keep the existing file on disk if it's newer than the
457
+ * file in the archive.
458
+ */
459
+ 'keep-newer'?: TarOptions['newer'];
460
+ /**
461
+ * When extracting, keep the existing file on disk if it's newer than the
462
+ * file in the archive.
463
+ */
464
+ keepNewer?: TarOptions['newer'];
465
+ /**
466
+ * When extracting, keep the existing file on disk if it's newer than the
467
+ * file in the archive.
468
+ */
469
+ 'keep-newer-files'?: TarOptions['newer'];
470
+ /**
471
+ * When extracting, keep the existing file on disk if it's newer than the
472
+ * file in the archive.
473
+ */
474
+ keepNewerFiles?: TarOptions['newer'];
475
+ /**
476
+ * When extracting, do not overwrite existing files at all.
477
+ */
478
+ k?: TarOptions['keep'];
479
+ /**
480
+ * When extracting, do not overwrite existing files at all.
481
+ */
482
+ 'keep-existing'?: TarOptions['keep'];
483
+ /**
484
+ * When extracting, do not overwrite existing files at all.
485
+ */
486
+ keepExisting?: TarOptions['keep'];
487
+ /**
488
+ * When extracting, do not set the `mtime` value for extracted entries to
489
+ * match the `mtime` in the archive.
490
+ *
491
+ * When creating archives, do not store the `mtime` value in the entry. Note
492
+ * that this prevents properly using other mtime-based features (such as
493
+ * `tar.update` or the `newer` option) with the resulting archive.
494
+ */
495
+ m?: TarOptions['noMtime'];
496
+ /**
497
+ * When extracting, do not set the `mtime` value for extracted entries to
498
+ * match the `mtime` in the archive.
499
+ *
500
+ * When creating archives, do not store the `mtime` value in the entry. Note
501
+ * that this prevents properly using other mtime-based features (such as
502
+ * `tar.update` or the `newer` option) with the resulting archive.
503
+ */
504
+ 'no-mtime'?: TarOptions['noMtime'];
505
+ /**
506
+ * When extracting, set the `uid` and `gid` of extracted entries to the `uid`
507
+ * and `gid` fields in the archive. Defaults to true when run as root, and
508
+ * false otherwise.
509
+ *
510
+ * If false, then files and directories will be set with the owner and group
511
+ * of the user running the process. This is similar to `-p` in `tar(1)`, but
512
+ * ACLs and other system-specific data is never unpacked in this
513
+ * implementation, and modes are set by default already.
514
+ */
515
+ p?: TarOptions['preserveOwner'];
516
+ /**
517
+ * Pack the targets of symbolic links rather than the link itself.
518
+ */
519
+ L?: TarOptions['follow'];
520
+ /**
521
+ * Pack the targets of symbolic links rather than the link itself.
522
+ */
523
+ h?: TarOptions['follow'];
524
+ /**
525
+ * Deprecated option. Set explicitly false to set `chmod: true`. Ignored
526
+ * if {@link TarOptions#chmod} is set to any boolean value.
527
+ *
528
+ * @deprecated
529
+ */
530
+ noChmod?: boolean;
531
+ }
532
+ export type TarOptionsWithAliasesSync = TarOptionsWithAliases & {
533
+ sync: true;
534
+ };
535
+ export type TarOptionsWithAliasesFile = (TarOptionsWithAliases & {
536
+ file: string;
537
+ }) | (TarOptionsWithAliases & {
538
+ f: string;
539
+ });
540
+ export type TarOptionsWithAliasesSyncFile = TarOptionsWithAliasesSync & TarOptionsWithAliasesFile;
541
+ export declare const isSyncFile: (o: TarOptions) => o is TarOptionsSyncFile;
542
+ export declare const isSync: (o: TarOptions) => o is TarOptionsSync;
543
+ export declare const isFile: (o: TarOptions) => o is TarOptionsFile;
544
+ export declare const dealias: (opt?: TarOptionsWithAliases) => TarOptions;
545
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AA0BhD;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAIzB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAA;IAE5B;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;;;;;;;;;;OAcG;IACH,MAAM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,MAAM,CAAC,CAAA;IACjC;;;;;;;OAOG;IACH,CAAC,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IACzB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAClC;;;;;;;;;OASG;IACH,CAAC,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC/B;;OAEG;IACH,CAAC,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;IACxB;;OAEG;IACH,CAAC,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;IAExB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,GAAG;IAC9D,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AACD,MAAM,MAAM,yBAAyB,GACjC,CAAC,qBAAqB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,CAAC,GACF,CAAC,qBAAqB,GAAG;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAC3C,MAAM,MAAM,6BAA6B,GACvC,yBAAyB,GAAG,yBAAyB,CAAA;AAEvD,eAAO,MAAM,UAAU,MAAO,UAAU,4BAClB,CAAA;AACtB,eAAO,MAAM,MAAM,MAAO,UAAU,wBAAkC,CAAA;AACtE,eAAO,MAAM,MAAM,MAAO,UAAU,wBAAkC,CAAA;AAUtE,eAAO,MAAM,OAAO,SACb,qBAAqB,KACzB,UAiBF,CAAA"}
@@ -0,0 +1,48 @@
1
+ // turn tar(1) style args like `C` into the more verbose things like `cwd`
2
+ const argmap = new Map([
3
+ ['C', 'cwd'],
4
+ ['f', 'file'],
5
+ ['z', 'gzip'],
6
+ ['P', 'preservePaths'],
7
+ ['U', 'unlink'],
8
+ ['strip-components', 'strip'],
9
+ ['stripComponents', 'strip'],
10
+ ['keep-newer', 'newer'],
11
+ ['keepNewer', 'newer'],
12
+ ['keep-newer-files', 'newer'],
13
+ ['keepNewerFiles', 'newer'],
14
+ ['k', 'keep'],
15
+ ['keep-existing', 'keep'],
16
+ ['keepExisting', 'keep'],
17
+ ['m', 'noMtime'],
18
+ ['no-mtime', 'noMtime'],
19
+ ['p', 'preserveOwner'],
20
+ ['L', 'follow'],
21
+ ['h', 'follow'],
22
+ ]);
23
+ export const isSyncFile = (o) => !!o.sync && !!o.file;
24
+ export const isSync = (o) => !!o.sync;
25
+ export const isFile = (o) => !!o.file;
26
+ const dealiasKey = (k) => {
27
+ const d = argmap.get(k);
28
+ if (d)
29
+ return d;
30
+ return k;
31
+ };
32
+ export const dealias = (opt = {}) => {
33
+ if (!opt)
34
+ return {};
35
+ const result = {};
36
+ for (const [key, v] of Object.entries(opt)) {
37
+ // TS doesn't know that aliases are going to always be the same type
38
+ const k = dealiasKey(key);
39
+ result[k] = v;
40
+ }
41
+ // affordance for deprecated noChmod -> chmod
42
+ if (result.chmod === undefined && result.noChmod === false) {
43
+ result.chmod = true;
44
+ }
45
+ delete result.noChmod;
46
+ return result;
47
+ };
48
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAO1E,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB;IACE,CAAC,GAAG,EAAE,KAAK,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,QAAQ,CAAC;IACf,CAAC,kBAAkB,EAAE,OAAO,CAAC;IAC7B,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAC5B,CAAC,YAAY,EAAE,OAAO,CAAC;IACvB,CAAC,WAAW,EAAE,OAAO,CAAC;IACtB,CAAC,kBAAkB,EAAE,OAAO,CAAC;IAC7B,CAAC,gBAAgB,EAAE,OAAO,CAAC;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,CAAC;IACD,6CAA6C;IAC7C,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC3D,MAAM,CAAC,KAAK,GAAG,IAAI,CAAA;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACrB,OAAO,MAAoB,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["// turn tar(1) style args like `C` into the more verbose things like `cwd`\n\nimport { type GzipOptions, type ZlibOptions } from 'minizlib'\nimport { type Stats } from 'node:fs'\nimport { type ReadEntry } from './read-entry.js'\nimport { type WarnData } from './warn-method.js'\n\nconst argmap = new Map<keyof TarOptionsWithAliases, keyof TarOptions>(\n [\n ['C', 'cwd'],\n ['f', 'file'],\n ['z', 'gzip'],\n ['P', 'preservePaths'],\n ['U', 'unlink'],\n ['strip-components', 'strip'],\n ['stripComponents', 'strip'],\n ['keep-newer', 'newer'],\n ['keepNewer', 'newer'],\n ['keep-newer-files', 'newer'],\n ['keepNewerFiles', 'newer'],\n ['k', 'keep'],\n ['keep-existing', 'keep'],\n ['keepExisting', 'keep'],\n ['m', 'noMtime'],\n ['no-mtime', 'noMtime'],\n ['p', 'preserveOwner'],\n ['L', 'follow'],\n ['h', 'follow'],\n ],\n)\n\n/**\n * The options that can be provided to tar commands.\n *\n * Note that some of these are only relevant for certain commands, since\n * they are specific to reading or writing.\n *\n * Aliases are provided in the {@link TarOptionsWithAliases} type.\n */\nexport interface TarOptions {\n //////////////////////////\n // shared options\n\n /**\n * Perform all I/O operations synchronously. If the stream is ended\n * immediately, then it will be processed entirely synchronously.\n */\n sync?: boolean\n\n /**\n * The tar file to be read and/or written. When this is set, a stream\n * is not returned. Asynchronous commands will return a promise indicating\n * when the operation is completed, and synchronous commands will return\n * immediately.\n */\n file?: string\n\n /**\n * Treat warnings as crash-worthy errors. Defaults false.\n */\n strict?: boolean\n\n /**\n * The effective current working directory for this tar command\n */\n cwd?: string\n\n /**\n * When creating a tar archive, this can be used to compress it as well.\n * Set to `true` to use the default gzip options, or customize them as\n * needed.\n *\n * When reading, if this is unset, then the compression status will be\n * inferred from the archive data. This is generally best, unless you are\n * sure of the compression settings in use to create the archive, and want to\n * fail if the archive doesn't match expectations.\n */\n gzip?: boolean | GzipOptions\n\n /**\n * When creating archives, preserve absolute and `..` paths in the archive,\n * rather than sanitizing them under the cwd.\n *\n * When extracting, allow absolute paths, paths containing `..`, and\n * extracting through symbolic links. By default, the root `/` is stripped\n * from absolute paths (eg, turning `/x/y/z` into `x/y/z`), paths containing\n * `..` are not extracted, and any file whose location would be modified by a\n * symbolic link is not extracted.\n *\n * **WARNING** This is almost always unsafe, and must NEVER be used on\n * archives from untrusted sources, such as user input, and every entry must\n * be validated to ensure it is safe to write. Even if the input is not\n * malicious, mistakes can cause a lot of damage!\n */\n preservePaths?: boolean\n\n /**\n * When extracting, do not set the `mtime` value for extracted entries to\n * match the `mtime` in the archive.\n *\n * When creating archives, do not store the `mtime` value in the entry. Note\n * that this prevents properly using other mtime-based features (such as\n * `tar.update` or the `newer` option) with the resulting archive.\n */\n noMtime?: boolean\n\n /**\n * Set to `true` or an object with settings for `zlib.BrotliCompress()` to\n * create a brotli-compressed archive\n *\n * When extracting, this will cause the archive to be treated as a\n * brotli-compressed file if set to `true` or a ZlibOptions object.\n *\n * If set `false`, then brotli options will not be used.\n *\n * If both this and the `gzip` option are left `undefined`, then tar will\n * attempt to infer the brotli compression status, but can only do so based\n * on the filename. If the filename ends in `.tbr` or `.tar.br`, and the\n * first 512 bytes are not a valid tar header, then brotli decompression\n * will be attempted.\n */\n brotli?: boolean | ZlibOptions\n\n /**\n * A function that is called with `(path, stat)` when creating an archive, or\n * `(path, entry)` when extracting. Return true to process the file/entry, or\n * false to exclude it.\n */\n filter?: (path: string, entry: Stats | ReadEntry) => boolean\n\n /**\n * A function that gets called for any warning encountered.\n *\n * Note: if `strict` is set, then the warning will throw, and this method\n * will not be called.\n */\n onwarn?: (code: string, message: string, data: WarnData) => any\n\n //////////////////////////\n // extraction options\n\n /**\n * When extracting, unlink files before creating them. Without this option,\n * tar overwrites existing files, which preserves existing hardlinks. With\n * this option, existing hardlinks will be broken, as will any symlink that\n * would affect the location of an extracted file.\n */\n unlink?: boolean\n\n /**\n * When extracting, strip the specified number of path portions from the\n * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be\n * extracted to `{cwd}/c/d`.\n *\n * Any entry whose entire path is stripped will be excluded.\n */\n strip?: number\n\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n newer?: boolean\n\n /**\n * When extracting, do not overwrite existing files at all.\n */\n keep?: boolean\n\n /**\n * When extracting, set the `uid` and `gid` of extracted entries to the `uid`\n * and `gid` fields in the archive. Defaults to true when run as root, and\n * false otherwise.\n *\n * If false, then files and directories will be set with the owner and group\n * of the user running the process. This is similar to `-p` in `tar(1)`, but\n * ACLs and other system-specific data is never unpacked in this\n * implementation, and modes are set by default already.\n */\n preserveOwner?: boolean\n\n /**\n * The maximum depth of subfolders to extract into. This defaults to 1024.\n * Anything deeper than the limit will raise a warning and skip the entry.\n * Set to `Infinity` to remove the limitation.\n */\n maxDepth?: number\n\n /**\n * When extracting, force all created files and directories, and all\n * implicitly created directories, to be owned by the specified user id,\n * regardless of the `uid` field in the archive.\n *\n * Cannot be used along with `preserveOwner`. Requires also setting the `gid`\n * option.\n */\n uid?: number\n\n /**\n * When extracting, force all created files and directories, and all\n * implicitly created directories, to be owned by the specified group id,\n * regardless of the `gid` field in the archive.\n *\n * Cannot be used along with `preserveOwner`. Requires also setting the `uid`\n * option.\n */\n gid?: number\n\n /**\n * When extracting, provide a function that takes an `entry` object, and\n * returns a stream, or any falsey value. If a stream is provided, then that\n * stream's data will be written instead of the contents of the archive\n * entry. If a falsey value is provided, then the entry is written to disk as\n * normal.\n *\n * To exclude items from extraction, use the `filter` option.\n *\n * Note that using an asynchronous stream type with the `transform` option\n * will cause undefined behavior in synchronous extractions.\n * [MiniPass](http://npm.im/minipass)-based streams are designed for this use\n * case.\n */\n transform?: (entry: ReadEntry) => any\n\n /**\n * Call `chmod()` to ensure that extracted files match the entry's mode\n * field. Without this field set, all mode fields in archive entries are a\n * best effort attempt only.\n *\n * Setting this necessitates a call to the deprecated `process.umask()`\n * method to determine the default umask value, unless a `processUmask`\n * config is provided as well.\n *\n * If not set, tar will attempt to create file system entries with whatever\n * mode is provided, and let the implicit process `umask` apply normally, but\n * if a file already exists to be written to, then its existing mode will not\n * be modified.\n *\n * When setting `chmod: true`, it is highly recommend to set the\n * {@link TarOptions#processUmask} option as well, to avoid the call to the\n * deprecated (and thread-unsafe) `process.umask()` method.\n */\n chmod?: boolean\n\n /**\n * When setting the {@link TarOptions#noChmod} option to `false`, you may\n * provide a value here to avoid having to call the deprecated and\n * thread-unsafe `process.umask()` method.\n *\n * This has no effect with `noChmod` is not set to false explicitly, as\n * mode values are not set explicitly anyway. If `noChmod` is set to `false`,\n * and a value is not provided here, then `process.umask()` must be called,\n * which will result in deprecation warnings.\n *\n * The most common values for this are `0o22` (resulting in directories\n * created with mode `0o755` and files with `0o644` by default) and `0o2`\n * (resulting in directores created with mode `0o775` and files `0o664`, so\n * they are group-writable).\n */\n processUmask?: number\n\n //////////////////////////\n // archive creation options\n\n /**\n * When parsing/listing archives, `entry` streams are by default resumed\n * (set into \"flowing\" mode) immediately after the call to `onentry()`.\n * Set `noResume: true` to suppress this behavior.\n *\n * Note that when this is set, the stream will never complete until the\n * data is consumed somehow.\n *\n * Set automatically in extract operations, since the entry is piped to\n * a file system entry right away. Only relevant when parsing.\n */\n noResume?: boolean\n\n /**\n * When extracting or listing archives, this method will be called with\n * each entry that is not excluded by a `filter`.\n *\n * Important when listing archives synchronously from a file, because there\n * is otherwise no way to interact with the data!\n */\n onentry?: (entry: ReadEntry) => any\n\n /**\n * Pack the targets of symbolic links rather than the link itself.\n */\n follow?: boolean\n\n /**\n * When creating archives, omit any metadata that is system-specific:\n * `ctime`, `atime`, `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and\n * `nlink`. Note that `mtime` is still included, because this is necessary\n * for other time-based operations such as `tar.update`. Additionally, `mode`\n * is set to a \"reasonable default\" for mose unix systems, based on an\n * effective `umask` of `0o22`.\n *\n * This also defaults the `portable` option in the gzip configs when creating\n * a compressed archive, in order to produce deterministic archives that are\n * not operating-system specific.\n */\n portable?: boolean\n\n /**\n * When creating archives, do not recursively archive the contents of\n * directories. By default, archiving a directory archives all of its\n * contents as well.\n */\n noDirRecurse?: boolean\n\n /**\n * Suppress Pax extended headers when creating archives. Note that this means\n * long paths and linkpaths will be truncated, and large or negative numeric\n * values may be interpreted incorrectly.\n */\n noPax?: boolean\n\n /**\n * Set to a `Date` object to force a specific `mtime` value for everything\n * written to an archive.\n *\n * This is useful when creating archives that are intended to be\n * deterministic based on their contents, irrespective of the file's last\n * modification time.\n *\n * Overridden by `noMtime`.\n */\n mtime?: Date\n\n /**\n * A path portion to prefix onto the entries added to an archive.\n */\n prefix?: string\n\n /**\n * The mode to set on any created file archive, defaults to 0o666\n * masked by the process umask, often resulting in 0o644.\n *\n * This does *not* affect the mode fields of individual entries, or the\n * mode status of extracted entries on the filesystem.\n */\n mode?: number\n\n //////////////////////////\n // internal options\n\n /**\n * A cache of mtime values, to avoid having to stat the same file repeatedly.\n *\n * @internal\n */\n mtimeCache?: Map<string, Date>\n\n /**\n * maximum buffer size for `fs.read()` operations.\n *\n * @internal\n */\n maxReadSize?: number\n\n /**\n * Filter modes of entries being unpacked, like `process.umask()`\n *\n * @internal\n */\n umask?: number\n\n /**\n * Default mode for directories. Used for all implicitly created directories,\n * and any directories in the archive that do not have a mode field.\n *\n * @internal\n */\n dmode?: number\n\n /**\n * default mode for files\n *\n * @internal\n */\n fmode?: number\n\n /**\n * Map that tracks which directories already exist, for extraction\n *\n * @internal\n */\n dirCache?: Map<string, boolean>\n /**\n * maximum supported size of meta entries. Defaults to 1MB\n *\n * @internal\n */\n maxMetaEntrySize?: number\n\n /**\n * A Map object containing the device and inode value for any file whose\n * `nlink` value is greater than 1, to identify hard links when creating\n * archives.\n *\n * @internal\n */\n linkCache?: Map<LinkCacheKey, string>\n\n /**\n * A map object containing the results of `fs.readdir()` calls.\n *\n * @internal\n */\n readdirCache?: Map<string, string[]>\n\n /**\n * A cache of all `lstat` results, for use in creating archives.\n *\n * @internal\n */\n statCache?: Map<string, Stats>\n\n /**\n * Number of concurrent jobs to run when creating archives.\n *\n * Defaults to 4.\n *\n * @internal\n */\n jobs?: number\n\n /**\n * Automatically set to true on Windows systems.\n *\n * When extracting, causes behavior where filenames containing `<|>?:`\n * characters are converted to windows-compatible escape sequences in the\n * created filesystem entries.\n *\n * When packing, causes behavior where paths replace `\\` with `/`, and\n * filenames containing the windows-compatible escaped forms of `<|>?:` are\n * converted to actual `<|>?:` characters in the archive.\n *\n * @internal\n */\n win32?: boolean\n\n /**\n * For `WriteEntry` objects, the absolute path to the entry on the\n * filesystem. By default, this is `resolve(cwd, entry.path)`, but it can be\n * overridden explicitly.\n *\n * @internal\n */\n absolute?: string\n\n /**\n * Used with Parser stream interface, to attach and take over when the\n * stream is completely parsed. If this is set, then the prefinish,\n * finish, and end events will not fire, and are the responsibility of\n * the ondone method to emit properly.\n *\n * @internal\n */\n ondone?: () => void\n\n /**\n * Mostly for testing, but potentially useful in some cases.\n * Forcibly trigger a chown on every entry, no matter what.\n */\n forceChown?: boolean\n}\n\nexport type TarOptionsSync = TarOptions & { sync: true }\nexport type TarOptionsFile = TarOptions & { file: string }\nexport type TarOptionsSyncFile = TarOptionsSync & TarOptionsFile\n\nexport type LinkCacheKey = `${number}:${number}`\n\nexport interface TarOptionsWithAliases extends TarOptions {\n /**\n * The effective current working directory for this tar command\n */\n C?: TarOptions['cwd']\n /**\n * The tar file to be read and/or written. When this is set, a stream\n * is not returned. Asynchronous commands will return a promise indicating\n * when the operation is completed, and synchronous commands will return\n * immediately.\n */\n f?: TarOptions['file']\n /**\n * When creating a tar archive, this can be used to compress it as well.\n * Set to `true` to use the default gzip options, or customize them as\n * needed.\n *\n * When reading, if this is unset, then the compression status will be\n * inferred from the archive data. This is generally best, unless you are\n * sure of the compression settings in use to create the archive, and want to\n * fail if the archive doesn't match expectations.\n */\n z?: TarOptions['gzip']\n /**\n * When creating archives, preserve absolute and `..` paths in the archive,\n * rather than sanitizing them under the cwd.\n *\n * When extracting, allow absolute paths, paths containing `..`, and\n * extracting through symbolic links. By default, the root `/` is stripped\n * from absolute paths (eg, turning `/x/y/z` into `x/y/z`), paths containing\n * `..` are not extracted, and any file whose location would be modified by a\n * symbolic link is not extracted.\n *\n * **WARNING** This is almost always unsafe, and must NEVER be used on\n * archives from untrusted sources, such as user input, and every entry must\n * be validated to ensure it is safe to write. Even if the input is not\n * malicious, mistakes can cause a lot of damage!\n */\n P?: TarOptions['preservePaths']\n /**\n * When extracting, unlink files before creating them. Without this option,\n * tar overwrites existing files, which preserves existing hardlinks. With\n * this option, existing hardlinks will be broken, as will any symlink that\n * would affect the location of an extracted file.\n */\n U?: TarOptions['unlink']\n /**\n * When extracting, strip the specified number of path portions from the\n * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be\n * extracted to `{cwd}/c/d`.\n */\n 'strip-components'?: TarOptions['strip']\n /**\n * When extracting, strip the specified number of path portions from the\n * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be\n * extracted to `{cwd}/c/d`.\n */\n stripComponents?: TarOptions['strip']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n 'keep-newer'?: TarOptions['newer']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n keepNewer?: TarOptions['newer']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n 'keep-newer-files'?: TarOptions['newer']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n keepNewerFiles?: TarOptions['newer']\n /**\n * When extracting, do not overwrite existing files at all.\n */\n k?: TarOptions['keep']\n /**\n * When extracting, do not overwrite existing files at all.\n */\n 'keep-existing'?: TarOptions['keep']\n /**\n * When extracting, do not overwrite existing files at all.\n */\n keepExisting?: TarOptions['keep']\n /**\n * When extracting, do not set the `mtime` value for extracted entries to\n * match the `mtime` in the archive.\n *\n * When creating archives, do not store the `mtime` value in the entry. Note\n * that this prevents properly using other mtime-based features (such as\n * `tar.update` or the `newer` option) with the resulting archive.\n */\n m?: TarOptions['noMtime']\n /**\n * When extracting, do not set the `mtime` value for extracted entries to\n * match the `mtime` in the archive.\n *\n * When creating archives, do not store the `mtime` value in the entry. Note\n * that this prevents properly using other mtime-based features (such as\n * `tar.update` or the `newer` option) with the resulting archive.\n */\n 'no-mtime'?: TarOptions['noMtime']\n /**\n * When extracting, set the `uid` and `gid` of extracted entries to the `uid`\n * and `gid` fields in the archive. Defaults to true when run as root, and\n * false otherwise.\n *\n * If false, then files and directories will be set with the owner and group\n * of the user running the process. This is similar to `-p` in `tar(1)`, but\n * ACLs and other system-specific data is never unpacked in this\n * implementation, and modes are set by default already.\n */\n p?: TarOptions['preserveOwner']\n /**\n * Pack the targets of symbolic links rather than the link itself.\n */\n L?: TarOptions['follow']\n /**\n * Pack the targets of symbolic links rather than the link itself.\n */\n h?: TarOptions['follow']\n\n /**\n * Deprecated option. Set explicitly false to set `chmod: true`. Ignored\n * if {@link TarOptions#chmod} is set to any boolean value.\n *\n * @deprecated\n */\n noChmod?: boolean\n}\n\nexport type TarOptionsWithAliasesSync = TarOptionsWithAliases & {\n sync: true\n}\nexport type TarOptionsWithAliasesFile =\n | (TarOptionsWithAliases & {\n file: string\n })\n | (TarOptionsWithAliases & { f: string })\nexport type TarOptionsWithAliasesSyncFile =\n TarOptionsWithAliasesSync & TarOptionsWithAliasesFile\n\nexport const isSyncFile = (o: TarOptions): o is TarOptionsSyncFile =>\n !!o.sync && !!o.file\nexport const isSync = (o: TarOptions): o is TarOptionsSync => !!o.sync\nexport const isFile = (o: TarOptions): o is TarOptionsFile => !!o.file\n\nconst dealiasKey = (\n k: keyof TarOptionsWithAliases,\n): keyof TarOptions => {\n const d = argmap.get(k)\n if (d) return d\n return k as keyof TarOptions\n}\n\nexport const dealias = (\n opt: TarOptionsWithAliases = {},\n): TarOptions => {\n if (!opt) return {}\n const result: Record<string, any> = {}\n for (const [key, v] of Object.entries(opt) as [\n keyof TarOptionsWithAliases,\n any,\n ][]) {\n // TS doesn't know that aliases are going to always be the same type\n const k = dealiasKey(key)\n result[k] = v\n }\n // affordance for deprecated noChmod -> chmod\n if (result.chmod === undefined && result.noChmod === false) {\n result.chmod = true\n }\n delete result.noChmod\n return result as TarOptions\n}\n"]}