tar 7.5.24 → 8.0.1

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 (330) hide show
  1. package/README.md +1712 -1147
  2. package/dist/commonjs/bytes.d.ts +21 -0
  3. package/dist/commonjs/bytes.d.ts.map +1 -0
  4. package/dist/commonjs/bytes.js +83 -0
  5. package/dist/commonjs/bytes.js.map +1 -0
  6. package/dist/commonjs/codec.d.ts +53 -0
  7. package/dist/commonjs/codec.d.ts.map +1 -0
  8. package/dist/commonjs/codec.js +35 -0
  9. package/dist/commonjs/codec.js.map +1 -0
  10. package/dist/commonjs/concat.d.ts +3 -0
  11. package/dist/commonjs/concat.d.ts.map +1 -0
  12. package/dist/commonjs/concat.js +20 -0
  13. package/dist/commonjs/concat.js.map +1 -0
  14. package/dist/commonjs/create.d.ts +39 -2
  15. package/dist/commonjs/create.d.ts.map +1 -1
  16. package/dist/commonjs/create.js +150 -64
  17. package/dist/commonjs/create.js.map +1 -1
  18. package/dist/commonjs/dealias.d.ts +79 -0
  19. package/dist/commonjs/dealias.d.ts.map +1 -0
  20. package/dist/commonjs/dealias.js +50 -0
  21. package/dist/commonjs/dealias.js.map +1 -0
  22. package/dist/commonjs/delete.d.ts +19 -0
  23. package/dist/commonjs/delete.d.ts.map +1 -0
  24. package/dist/commonjs/delete.js +121 -0
  25. package/dist/commonjs/delete.js.map +1 -0
  26. package/dist/commonjs/entries.d.ts +82 -0
  27. package/dist/commonjs/entries.d.ts.map +1 -0
  28. package/dist/commonjs/entries.js +398 -0
  29. package/dist/commonjs/entries.js.map +1 -0
  30. package/dist/commonjs/extract.d.ts +14 -2
  31. package/dist/commonjs/extract.d.ts.map +1 -1
  32. package/dist/commonjs/extract.js +40 -81
  33. package/dist/commonjs/extract.js.map +1 -1
  34. package/dist/commonjs/fs.d.ts +201 -0
  35. package/dist/commonjs/fs.d.ts.map +1 -0
  36. package/dist/commonjs/fs.js +5 -0
  37. package/dist/commonjs/fs.js.map +1 -0
  38. package/dist/commonjs/header.d.ts +4 -4
  39. package/dist/commonjs/header.d.ts.map +1 -1
  40. package/dist/commonjs/header.js +38 -42
  41. package/dist/commonjs/header.js.map +1 -1
  42. package/dist/commonjs/index.d.ts +25 -18
  43. package/dist/commonjs/index.d.ts.map +1 -1
  44. package/dist/commonjs/index.js +46 -18
  45. package/dist/commonjs/index.js.map +1 -1
  46. package/dist/commonjs/index.min.js +2 -3
  47. package/dist/commonjs/index.min.js.map +4 -4
  48. package/dist/commonjs/large-numbers.d.ts +2 -2
  49. package/dist/commonjs/large-numbers.d.ts.map +1 -1
  50. package/dist/commonjs/large-numbers.js +4 -4
  51. package/dist/commonjs/large-numbers.js.map +1 -1
  52. package/dist/commonjs/list.d.ts +23 -6
  53. package/dist/commonjs/list.d.ts.map +1 -1
  54. package/dist/commonjs/list.js +99 -138
  55. package/dist/commonjs/list.js.map +1 -1
  56. package/dist/commonjs/mkdir.d.ts +16 -11
  57. package/dist/commonjs/mkdir.d.ts.map +1 -1
  58. package/dist/commonjs/mkdir.js +121 -159
  59. package/dist/commonjs/mkdir.js.map +1 -1
  60. package/dist/commonjs/options.d.ts +284 -513
  61. package/dist/commonjs/options.d.ts.map +1 -1
  62. package/dist/commonjs/options.js +20 -61
  63. package/dist/commonjs/options.js.map +1 -1
  64. package/dist/commonjs/pack.d.ts +150 -96
  65. package/dist/commonjs/pack.d.ts.map +1 -1
  66. package/dist/commonjs/pack.js +752 -445
  67. package/dist/commonjs/pack.js.map +1 -1
  68. package/dist/commonjs/parser.d.ts +94 -0
  69. package/dist/commonjs/parser.d.ts.map +1 -0
  70. package/dist/commonjs/parser.js +381 -0
  71. package/dist/commonjs/parser.js.map +1 -0
  72. package/dist/commonjs/path-reservations.d.ts +17 -7
  73. package/dist/commonjs/path-reservations.d.ts.map +1 -1
  74. package/dist/commonjs/path-reservations.js +96 -119
  75. package/dist/commonjs/path-reservations.js.map +1 -1
  76. package/dist/commonjs/path.d.ts +19 -0
  77. package/dist/commonjs/path.d.ts.map +1 -0
  78. package/dist/commonjs/path.js +90 -0
  79. package/dist/commonjs/path.js.map +1 -0
  80. package/dist/commonjs/pax.d.ts +3 -1
  81. package/dist/commonjs/pax.d.ts.map +1 -1
  82. package/dist/commonjs/pax.js +53 -43
  83. package/dist/commonjs/pax.js.map +1 -1
  84. package/dist/commonjs/read-entry.d.ts +97 -11
  85. package/dist/commonjs/read-entry.d.ts.map +1 -1
  86. package/dist/commonjs/read-entry.js +248 -97
  87. package/dist/commonjs/read-entry.js.map +1 -1
  88. package/dist/commonjs/read-file.d.ts +22 -0
  89. package/dist/commonjs/read-file.d.ts.map +1 -0
  90. package/dist/commonjs/read-file.js +104 -0
  91. package/dist/commonjs/read-file.js.map +1 -0
  92. package/dist/commonjs/replace.d.ts +45 -1
  93. package/dist/commonjs/replace.d.ts.map +1 -1
  94. package/dist/commonjs/replace.js +165 -211
  95. package/dist/commonjs/replace.js.map +1 -1
  96. package/dist/commonjs/server/codecs.d.ts +38 -0
  97. package/dist/commonjs/server/codecs.d.ts.map +1 -0
  98. package/dist/commonjs/server/codecs.js +252 -0
  99. package/dist/commonjs/server/codecs.js.map +1 -0
  100. package/dist/commonjs/server/index.d.ts +115 -0
  101. package/dist/commonjs/server/index.d.ts.map +1 -0
  102. package/dist/commonjs/server/index.js +166 -0
  103. package/dist/commonjs/server/index.js.map +1 -0
  104. package/dist/commonjs/server/index.min.js +3 -0
  105. package/dist/commonjs/server/index.min.js.map +7 -0
  106. package/dist/commonjs/strip-absolute-path.d.ts +8 -0
  107. package/dist/commonjs/strip-absolute-path.d.ts.map +1 -1
  108. package/dist/commonjs/strip-absolute-path.js +17 -20
  109. package/dist/commonjs/strip-absolute-path.js.map +1 -1
  110. package/dist/commonjs/to-stream.d.ts +7 -0
  111. package/dist/commonjs/to-stream.d.ts.map +1 -0
  112. package/dist/commonjs/to-stream.js +22 -0
  113. package/dist/commonjs/to-stream.js.map +1 -0
  114. package/dist/commonjs/types.d.ts +4 -3
  115. package/dist/commonjs/types.d.ts.map +1 -1
  116. package/dist/commonjs/types.js +4 -3
  117. package/dist/commonjs/types.js.map +1 -1
  118. package/dist/commonjs/unpack.d.ts +143 -89
  119. package/dist/commonjs/unpack.d.ts.map +1 -1
  120. package/dist/commonjs/unpack.js +782 -725
  121. package/dist/commonjs/unpack.js.map +1 -1
  122. package/dist/commonjs/update.d.ts +11 -1
  123. package/dist/commonjs/update.d.ts.map +1 -1
  124. package/dist/commonjs/update.js +37 -28
  125. package/dist/commonjs/update.js.map +1 -1
  126. package/dist/commonjs/warn.d.ts +27 -0
  127. package/dist/commonjs/warn.d.ts.map +1 -0
  128. package/dist/commonjs/warn.js +36 -0
  129. package/dist/commonjs/warn.js.map +1 -0
  130. package/dist/commonjs/win32-path.d.ts +16 -0
  131. package/dist/commonjs/win32-path.d.ts.map +1 -0
  132. package/dist/commonjs/win32-path.js +67 -0
  133. package/dist/commonjs/win32-path.js.map +1 -0
  134. package/dist/commonjs/write-entry.d.ts +64 -111
  135. package/dist/commonjs/write-entry.d.ts.map +1 -1
  136. package/dist/commonjs/write-entry.js +108 -672
  137. package/dist/commonjs/write-entry.js.map +1 -1
  138. package/dist/commonjs/write-flag.d.ts +18 -0
  139. package/dist/commonjs/write-flag.d.ts.map +1 -0
  140. package/dist/commonjs/write-flag.js +29 -0
  141. package/dist/commonjs/write-flag.js.map +1 -0
  142. package/dist/esm/bytes.d.ts +21 -0
  143. package/dist/esm/bytes.d.ts.map +1 -0
  144. package/dist/esm/bytes.js +72 -0
  145. package/dist/esm/bytes.js.map +1 -0
  146. package/dist/esm/codec.d.ts +53 -0
  147. package/dist/esm/codec.d.ts.map +1 -0
  148. package/dist/esm/codec.js +32 -0
  149. package/dist/esm/codec.js.map +1 -0
  150. package/dist/esm/concat.d.ts +3 -0
  151. package/dist/esm/concat.d.ts.map +1 -0
  152. package/dist/esm/concat.js +16 -0
  153. package/dist/esm/concat.js.map +1 -0
  154. package/dist/esm/create.d.ts +39 -2
  155. package/dist/esm/create.d.ts.map +1 -1
  156. package/dist/esm/create.js +144 -61
  157. package/dist/esm/create.js.map +1 -1
  158. package/dist/esm/dealias.d.ts +79 -0
  159. package/dist/esm/dealias.d.ts.map +1 -0
  160. package/dist/esm/dealias.js +46 -0
  161. package/dist/esm/dealias.js.map +1 -0
  162. package/dist/esm/delete.d.ts +19 -0
  163. package/dist/esm/delete.d.ts.map +1 -0
  164. package/dist/esm/delete.js +117 -0
  165. package/dist/esm/delete.js.map +1 -0
  166. package/dist/esm/entries.d.ts +82 -0
  167. package/dist/esm/entries.d.ts.map +1 -0
  168. package/dist/esm/entries.js +388 -0
  169. package/dist/esm/entries.js.map +1 -0
  170. package/dist/esm/extract.d.ts +14 -2
  171. package/dist/esm/extract.d.ts.map +1 -1
  172. package/dist/esm/extract.js +37 -44
  173. package/dist/esm/extract.js.map +1 -1
  174. package/dist/esm/fs.d.ts +201 -0
  175. package/dist/esm/fs.d.ts.map +1 -0
  176. package/dist/esm/fs.js +4 -0
  177. package/dist/esm/fs.js.map +1 -0
  178. package/dist/esm/header.d.ts +4 -4
  179. package/dist/esm/header.d.ts.map +1 -1
  180. package/dist/esm/header.js +38 -42
  181. package/dist/esm/header.js.map +1 -1
  182. package/dist/esm/index.d.ts +25 -18
  183. package/dist/esm/index.d.ts.map +1 -1
  184. package/dist/esm/index.js +23 -18
  185. package/dist/esm/index.js.map +1 -1
  186. package/dist/esm/index.min.js +2 -3
  187. package/dist/esm/index.min.js.map +4 -4
  188. package/dist/esm/large-numbers.d.ts +2 -2
  189. package/dist/esm/large-numbers.d.ts.map +1 -1
  190. package/dist/esm/large-numbers.js +4 -4
  191. package/dist/esm/large-numbers.js.map +1 -1
  192. package/dist/esm/list.d.ts +23 -6
  193. package/dist/esm/list.d.ts.map +1 -1
  194. package/dist/esm/list.js +96 -101
  195. package/dist/esm/list.js.map +1 -1
  196. package/dist/esm/mkdir.d.ts +16 -11
  197. package/dist/esm/mkdir.d.ts.map +1 -1
  198. package/dist/esm/mkdir.js +119 -154
  199. package/dist/esm/mkdir.js.map +1 -1
  200. package/dist/esm/options.d.ts +284 -513
  201. package/dist/esm/options.d.ts.map +1 -1
  202. package/dist/esm/options.js +17 -51
  203. package/dist/esm/options.js.map +1 -1
  204. package/dist/esm/pack.d.ts +150 -96
  205. package/dist/esm/pack.d.ts.map +1 -1
  206. package/dist/esm/pack.js +750 -441
  207. package/dist/esm/pack.js.map +1 -1
  208. package/dist/esm/parser.d.ts +94 -0
  209. package/dist/esm/parser.d.ts.map +1 -0
  210. package/dist/esm/parser.js +377 -0
  211. package/dist/esm/parser.js.map +1 -0
  212. package/dist/esm/path-reservations.d.ts +17 -7
  213. package/dist/esm/path-reservations.d.ts.map +1 -1
  214. package/dist/esm/path-reservations.js +96 -119
  215. package/dist/esm/path-reservations.js.map +1 -1
  216. package/dist/esm/path.d.ts +19 -0
  217. package/dist/esm/path.d.ts.map +1 -0
  218. package/dist/esm/path.js +80 -0
  219. package/dist/esm/path.js.map +1 -0
  220. package/dist/esm/pax.d.ts +3 -1
  221. package/dist/esm/pax.d.ts.map +1 -1
  222. package/dist/esm/pax.js +52 -42
  223. package/dist/esm/pax.js.map +1 -1
  224. package/dist/esm/read-entry.d.ts +97 -11
  225. package/dist/esm/read-entry.d.ts.map +1 -1
  226. package/dist/esm/read-entry.js +245 -96
  227. package/dist/esm/read-entry.js.map +1 -1
  228. package/dist/esm/read-file.d.ts +22 -0
  229. package/dist/esm/read-file.d.ts.map +1 -0
  230. package/dist/esm/read-file.js +99 -0
  231. package/dist/esm/read-file.js.map +1 -0
  232. package/dist/esm/replace.d.ts +45 -1
  233. package/dist/esm/replace.d.ts.map +1 -1
  234. package/dist/esm/replace.js +161 -207
  235. package/dist/esm/replace.js.map +1 -1
  236. package/dist/esm/server/codecs.d.ts +38 -0
  237. package/dist/esm/server/codecs.d.ts.map +1 -0
  238. package/dist/esm/server/codecs.js +214 -0
  239. package/dist/esm/server/codecs.js.map +1 -0
  240. package/dist/esm/server/index.d.ts +115 -0
  241. package/dist/esm/server/index.d.ts.map +1 -0
  242. package/dist/esm/server/index.js +102 -0
  243. package/dist/esm/server/index.js.map +1 -0
  244. package/dist/esm/server/index.min.js +3 -0
  245. package/dist/esm/server/index.min.js.map +7 -0
  246. package/dist/esm/strip-absolute-path.d.ts +8 -0
  247. package/dist/esm/strip-absolute-path.d.ts.map +1 -1
  248. package/dist/esm/strip-absolute-path.js +17 -20
  249. package/dist/esm/strip-absolute-path.js.map +1 -1
  250. package/dist/esm/to-stream.d.ts +7 -0
  251. package/dist/esm/to-stream.d.ts.map +1 -0
  252. package/dist/esm/to-stream.js +18 -0
  253. package/dist/esm/to-stream.js.map +1 -0
  254. package/dist/esm/types.d.ts +4 -3
  255. package/dist/esm/types.d.ts.map +1 -1
  256. package/dist/esm/types.js +4 -3
  257. package/dist/esm/types.js.map +1 -1
  258. package/dist/esm/unpack.d.ts +143 -89
  259. package/dist/esm/unpack.d.ts.map +1 -1
  260. package/dist/esm/unpack.js +778 -719
  261. package/dist/esm/unpack.js.map +1 -1
  262. package/dist/esm/update.d.ts +11 -1
  263. package/dist/esm/update.d.ts.map +1 -1
  264. package/dist/esm/update.js +35 -28
  265. package/dist/esm/update.js.map +1 -1
  266. package/dist/esm/warn.d.ts +27 -0
  267. package/dist/esm/warn.d.ts.map +1 -0
  268. package/dist/esm/warn.js +31 -0
  269. package/dist/esm/warn.js.map +1 -0
  270. package/dist/esm/win32-path.d.ts +16 -0
  271. package/dist/esm/win32-path.d.ts.map +1 -0
  272. package/dist/esm/win32-path.js +60 -0
  273. package/dist/esm/win32-path.js.map +1 -0
  274. package/dist/esm/write-entry.d.ts +64 -111
  275. package/dist/esm/write-entry.d.ts.map +1 -1
  276. package/dist/esm/write-entry.js +107 -633
  277. package/dist/esm/write-entry.js.map +1 -1
  278. package/dist/esm/write-flag.d.ts +18 -0
  279. package/dist/esm/write-flag.d.ts.map +1 -0
  280. package/dist/esm/write-flag.js +25 -0
  281. package/dist/esm/write-flag.js.map +1 -0
  282. package/package.json +68 -224
  283. package/dist/commonjs/get-write-flag.d.ts +0 -2
  284. package/dist/commonjs/get-write-flag.d.ts.map +0 -1
  285. package/dist/commonjs/get-write-flag.js +0 -32
  286. package/dist/commonjs/get-write-flag.js.map +0 -1
  287. package/dist/commonjs/make-command.d.ts +0 -49
  288. package/dist/commonjs/make-command.d.ts.map +0 -1
  289. package/dist/commonjs/make-command.js +0 -52
  290. package/dist/commonjs/make-command.js.map +0 -1
  291. package/dist/commonjs/normalize-windows-path.d.ts +0 -2
  292. package/dist/commonjs/normalize-windows-path.d.ts.map +0 -1
  293. package/dist/commonjs/normalize-windows-path.js +0 -12
  294. package/dist/commonjs/normalize-windows-path.js.map +0 -1
  295. package/dist/commonjs/parse.d.ts +0 -92
  296. package/dist/commonjs/parse.d.ts.map +0 -1
  297. package/dist/commonjs/parse.js +0 -655
  298. package/dist/commonjs/parse.js.map +0 -1
  299. package/dist/commonjs/process-umask.d.ts +0 -2
  300. package/dist/commonjs/process-umask.d.ts.map +0 -1
  301. package/dist/commonjs/process-umask.js +0 -7
  302. package/dist/commonjs/process-umask.js.map +0 -1
  303. package/dist/commonjs/warn-method.d.ts +0 -24
  304. package/dist/commonjs/warn-method.d.ts.map +0 -1
  305. package/dist/commonjs/warn-method.js +0 -31
  306. package/dist/commonjs/warn-method.js.map +0 -1
  307. package/dist/esm/get-write-flag.d.ts +0 -2
  308. package/dist/esm/get-write-flag.d.ts.map +0 -1
  309. package/dist/esm/get-write-flag.js +0 -26
  310. package/dist/esm/get-write-flag.js.map +0 -1
  311. package/dist/esm/make-command.d.ts +0 -49
  312. package/dist/esm/make-command.d.ts.map +0 -1
  313. package/dist/esm/make-command.js +0 -48
  314. package/dist/esm/make-command.js.map +0 -1
  315. package/dist/esm/normalize-windows-path.d.ts +0 -2
  316. package/dist/esm/normalize-windows-path.d.ts.map +0 -1
  317. package/dist/esm/normalize-windows-path.js +0 -9
  318. package/dist/esm/normalize-windows-path.js.map +0 -1
  319. package/dist/esm/parse.d.ts +0 -92
  320. package/dist/esm/parse.d.ts.map +0 -1
  321. package/dist/esm/parse.js +0 -651
  322. package/dist/esm/parse.js.map +0 -1
  323. package/dist/esm/process-umask.d.ts +0 -2
  324. package/dist/esm/process-umask.d.ts.map +0 -1
  325. package/dist/esm/process-umask.js +0 -3
  326. package/dist/esm/process-umask.js.map +0 -1
  327. package/dist/esm/warn-method.d.ts +0 -24
  328. package/dist/esm/warn-method.d.ts.map +0 -1
  329. package/dist/esm/warn-method.js +0 -27
  330. package/dist/esm/warn-method.js.map +0 -1
@@ -1,604 +1,375 @@
1
- import { type GzipOptions, type ZlibOptions } from 'minizlib';
2
- import { type Stats } from 'node:fs';
3
- import { type ReadEntry } from './read-entry.js';
4
- import { type WarnData } from './warn-method.js';
1
+ import type { Codec } from './codec.js';
2
+ import type { EntryData, ReadEntry, ReadEntrySync } from './read-entry.js';
3
+ import type { ExtractFS, ExtractFSSync, TarFS, TarFSSync } from './fs.js';
4
+ import type { WarnOptions } from './warn.js';
5
+ import type { CreateFS, CreateFSSync, CreateStats, DeleteFS, DeleteFSSync, ReplaceFS, ReplaceFSSync } from './fs.js';
5
6
  import type { WriteEntry } from './write-entry.js';
6
7
  /**
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.
8
+ * A copy of the options with no prototype, so that an option that is
9
+ * not set cannot get a value from a changed `Object.prototype`.
13
10
  */
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;
11
+ export declare const ownOptions: <T extends object>(opt: T, more?: Partial<T>) => T;
12
+ /**
13
+ * The value of an option that is a count, such as `jobs`: the
14
+ * default if the option is not set or is 0, and a `TypeError` if the
15
+ * value is not a positive integer or `Infinity`.
16
+ */
17
+ export declare const countOption: (name: string, value: unknown, def: number) => number;
18
+ /** The options of a `Parser`. */
19
+ export type ParserOptions<E extends EntryData = EntryData> = WarnOptions & {
20
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.
21
+ * Called with each entry that is an object of the file system.
22
+ * If it returns false, the entry is ignored.
25
23
  */
26
- file?: string;
24
+ filter?: (path: string, entry: E) => boolean;
27
25
  /**
28
- * Treat warnings as crash-worthy errors. Defaults false.
26
+ * The largest PAX or GNU long name entry to read, in bytes. A
27
+ * larger one is skipped. Default 1 MiB.
29
28
  */
30
- strict?: boolean;
29
+ maxMetaEntrySize?: number;
30
+ /** With `'win32'`, each `\` in a path is changed to `/`. */
31
+ platform?: 'win32' | 'posix';
32
+ };
33
+ /** The options of the readers. */
34
+ export type ReadOptions<E extends EntryData = ReadEntry> = ParserOptions<E> & {
31
35
  /**
32
- * The effective current working directory for this tar command
36
+ * Stop with an error when the decompressed size is more than this
37
+ * many times the compressed size. Default 1000.
33
38
  */
34
- cwd?: string;
39
+ maxDecompressionRatio?: number;
35
40
  /**
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!
41
+ * Compression formats, tried in order before the gzip support of
42
+ * the runtime.
60
43
  */
61
- preservePaths?: boolean;
44
+ codecs?: Codec[];
45
+ };
46
+ /** The options of `entriesSync`. */
47
+ export type ReadOptionsSync = ReadOptions<ReadEntrySync>;
48
+ /** The archive data that `entries` reads. */
49
+ export type TarInput = Uint8Array | ArrayBuffer | Blob | ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Iterable<Uint8Array>;
50
+ /** The archive data that `entriesSync` reads. */
51
+ export type TarInputSync = Uint8Array | ArrayBuffer | Iterable<Uint8Array>;
52
+ /** The options of `list`. Set `input`, or `file` and `fs`. */
53
+ export type ListOptions = ReadOptions & {
54
+ input?: TarInput;
55
+ /** The path of the archive file. */
56
+ file?: string;
57
+ fs?: TarFS;
62
58
  /**
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.
59
+ * The most bytes to read from the file at one time. Default, and
60
+ * with 0, 16 MiB. A positive integer, or `Infinity`.
69
61
  */
70
- noMtime?: boolean;
62
+ maxReadSize?: number;
71
63
  /**
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 this, the `gzip`, and `zstd` options are left `undefined`, then tar
81
- * will attempt to infer the brotli compression status, but can only do so
82
- * based on the filename. If the filename ends in `.tbr` or `.tar.br`, and
83
- * the first 512 bytes are not a valid tar header, then brotli decompression
84
- * will be attempted.
85
- */
86
- brotli?: boolean | ZlibOptions;
87
- /**
88
- * Set to `true` or an object with settings for `zstd.compress()` to
89
- * create a zstd-compressed archive
90
- *
91
- * When extracting, this will cause the archive to be treated as a
92
- * zstd-compressed file if set to `true` or a ZlibOptions object.
93
- *
94
- * If set `false`, then zstd options will not be used.
95
- *
96
- * If this, the `gzip`, and `brotli` options are left `undefined`, then tar
97
- * will attempt to infer the zstd compression status, but can only do so
98
- * based on the filename. If the filename ends in `.tzst` or `.tar.zst`, and
99
- * the first 512 bytes are not a valid tar header, then zstd decompression
100
- * will be attempted.
101
- */
102
- zstd?: boolean | ZlibOptions;
103
- /**
104
- * A function that is called with `(path, stat)` when creating an archive, or
105
- * `(path, entry)` when extracting. Return true to process the file/entry, or
106
- * false to exclude it.
107
- */
108
- filter?: (path: string, entry: Stats | ReadEntry) => boolean;
109
- /**
110
- * A function that gets called for any warning encountered.
111
- *
112
- * Note: if `strict` is set, then the warning will throw, and this method
113
- * will not be called.
114
- */
115
- onwarn?: (code: string, message: string, data: WarnData) => unknown;
116
- /**
117
- * The maximum allowed ratio of decompressed bytes to compressed bytes when
118
- * reading gzip, brotli, or zstd-compressed archives.
119
- *
120
- * This defaults to `1000` and aborts extraction or parsing when exceeded.
121
- * Set to `Infinity` to disable the limit.
64
+ * Called with each entry. A promise is awaited before the next
65
+ * entry.
122
66
  */
123
- maxDecompressionRatio?: number;
67
+ onEntry?: (entry: ReadEntry) => unknown;
68
+ };
69
+ /** The options of `listSync`. Set `input`, or `file` and `fs`. */
70
+ export type ListOptionsSync = ReadOptionsSync & {
71
+ input?: TarInputSync;
72
+ /** The path of the archive file. */
73
+ file?: string;
74
+ fs?: TarFSSync;
124
75
  /**
125
- * When extracting, unlink files before creating them. Without this option,
126
- * tar overwrites existing files, which preserves existing hardlinks. With
127
- * this option, existing hardlinks will be broken, as will any symlink that
128
- * would affect the location of an extracted file.
76
+ * The most bytes to read from the file at one time. Default, and
77
+ * with 0, 16 MiB. A positive integer, or `Infinity`.
129
78
  */
130
- unlink?: boolean;
79
+ maxReadSize?: number;
80
+ /** Called with each entry. */
81
+ onEntry?: (entry: ReadEntrySync) => unknown;
82
+ };
83
+ /**
84
+ * The options of the extraction that are not about the archive data
85
+ * or the file system functions.
86
+ */
87
+ export type UnpackOptions = {
88
+ /** The absolute path of the directory to extract into. */
89
+ cwd: string;
131
90
  /**
132
- * When extracting, strip the specified number of path portions from the
133
- * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be
134
- * extracted to `{cwd}/c/d`.
135
- *
136
- * Any entry whose entire path is stripped will be excluded.
91
+ * With `'win32'`: the path rules of Windows, the characters `<|>?:`
92
+ * in a name are changed to private-use characters, a file is
93
+ * renamed before it is removed, and one entry is extracted at a
94
+ * time.
137
95
  */
96
+ platform?: 'win32' | 'posix';
97
+ /** Remove this number of leading parts from each path. */
138
98
  strip?: number;
139
99
  /**
140
- * When extracting, keep the existing file on disk if it's newer than the
141
- * file in the archive.
100
+ * Permit absolute paths, `..` in paths, and extraction through
101
+ * symbolic links. This is not safe with an archive that is not
102
+ * trusted.
142
103
  */
143
- newer?: boolean;
104
+ preservePaths?: boolean;
144
105
  /**
145
- * When extracting, do not overwrite existing files at all.
106
+ * Remove a file before the entry is written, in place of a write
107
+ * into the existing file. Also remove a symbolic link in the path
108
+ * to an entry.
146
109
  */
110
+ unlink?: boolean;
111
+ /** Do not write over an existing file. */
147
112
  keep?: boolean;
113
+ /** Do not write over a file that is newer than the entry. */
114
+ newer?: boolean;
115
+ /** Do not set the times of the entries. */
116
+ noMtime?: boolean;
148
117
  /**
149
- * When extracting, set the `uid` and `gid` of extracted entries to the `uid`
150
- * and `gid` fields in the archive. Defaults to true when run as root, and
151
- * false otherwise.
152
- *
153
- * If false, then files and directories will be set with the owner and group
154
- * of the user running the process. This is similar to `-p` in `tar(1)`, but
155
- * ACLs and other system-specific data is never unpacked in this
156
- * implementation, and modes are set by default already.
118
+ * Set the owner of each entry to the `uid` and `gid` in the
119
+ * archive. Default: true if `processUid` is 0 and `uid` is not set.
157
120
  */
158
121
  preserveOwner?: boolean;
159
- /**
160
- * The maximum depth of subfolders to extract into. This defaults to 1024.
161
- * Anything deeper than the limit will raise a warning and skip the entry.
162
- * Set to `Infinity` to remove the limitation.
163
- */
164
- maxDepth?: number;
165
- /**
166
- * When extracting, force all created files and directories, and all
167
- * implicitly created directories, to be owned by the specified user id,
168
- * regardless of the `uid` field in the archive.
169
- *
170
- * Cannot be used along with `preserveOwner`. Requires also setting the `gid`
171
- * option.
172
- */
122
+ /** Set the owner of each entry to this user. Needs `gid`. */
173
123
  uid?: number;
174
- /**
175
- * When extracting, force all created files and directories, and all
176
- * implicitly created directories, to be owned by the specified group id,
177
- * regardless of the `gid` field in the archive.
178
- *
179
- * Cannot be used along with `preserveOwner`. Requires also setting the `uid`
180
- * option.
181
- */
124
+ /** Set the owner of each entry to this group. Needs `uid`. */
182
125
  gid?: number;
126
+ /** Set the owner of each entry, also when it is the process owner. */
127
+ forceChown?: boolean;
183
128
  /**
184
- * When extracting, provide a function that takes an `entry` object, and
185
- * returns a stream, or any falsey value. If a stream is provided, then that
186
- * stream's data will be written instead of the contents of the archive
187
- * entry. If a falsey value is provided, then the entry is written to disk as
188
- * normal.
189
- *
190
- * To exclude items from extraction, use the `filter` option.
191
- *
192
- * Note that using an asynchronous stream type with the `transform` option
193
- * will cause undefined behavior in synchronous extractions.
194
- * [MiniPass](http://npm.im/minipass)-based streams are designed for this use
195
- * case.
196
- */
197
- transform?: (entry: ReadEntry) => ReadEntry | null | undefined | false | 0 | '';
198
- /**
199
- * Call `chmod()` to ensure that extracted files match the entry's mode
200
- * field. Without this field set, all mode fields in archive entries are a
201
- * best effort attempt only.
202
- *
203
- * Setting this necessitates a call to the deprecated `process.umask()`
204
- * method to determine the default umask value, unless a `processUmask`
205
- * config is provided as well.
206
- *
207
- * If not set, tar will attempt to create file system entries with whatever
208
- * mode is provided, and let the implicit process `umask` apply normally, but
209
- * if a file already exists to be written to, then its existing mode will not
210
- * be modified.
211
- *
212
- * When setting `chmod: true`, it is highly recommend to set the
213
- * {@link TarOptions#processUmask} option as well, to avoid the call to the
214
- * deprecated (and thread-unsafe) `process.umask()` method.
129
+ * Set the mode of each directory with `chmod`, so that the umask of
130
+ * the process does not change it.
215
131
  */
216
132
  chmod?: boolean;
217
133
  /**
218
- * When setting the {@link TarOptions#chmod} option to `true`, you may
219
- * provide a value here to avoid having to call the deprecated and
220
- * thread-unsafe `process.umask()` method.
221
- *
222
- * This has no effect with `chmod` is not set to true, as mode values are not
223
- * set explicitly anyway. If `chmod` is set to `true`, and a value is not
224
- * provided here, then `process.umask()` must be called, which will result in
225
- * deprecation warnings.
226
- *
227
- * The most common values for this are `0o22` (resulting in directories
228
- * created with mode `0o755` and files with `0o644` by default) and `0o2`
229
- * (resulting in directores created with mode `0o775` and files `0o664`, so
230
- * they are group-writable).
134
+ * The umask of the process. Only used with `chmod`. Default 0o22.
231
135
  */
232
136
  processUmask?: number;
137
+ /** The user ID of the process. */
138
+ processUid?: number;
139
+ /** The group ID of the process. */
140
+ processGid?: number;
141
+ /** Sets the default of `dmode` and `fmode`. Default: `processUmask`. */
142
+ umask?: number;
143
+ /** The mode of a directory that has no mode in the archive. */
144
+ dmode?: number;
145
+ /** The mode of a file that has no mode in the archive. */
146
+ fmode?: number;
233
147
  /**
234
- * When parsing/listing archives, `entry` streams are by default resumed
235
- * (set into "flowing" mode) immediately after the call to `onReadEntry()`.
236
- * Set `noResume: true` to suppress this behavior.
237
- *
238
- * Note that when this is set, the stream will never complete until the
239
- * data is consumed somehow.
240
- *
241
- * Set automatically in extract operations, since the entry is piped to
242
- * a file system entry right away. Only relevant when parsing.
148
+ * The most parts that a path or a link target can have. Default
149
+ * 1024. `Infinity` removes the limit.
243
150
  */
244
- noResume?: boolean;
151
+ maxDepth?: number;
152
+ };
153
+ /**
154
+ * The options of `extract`. Set `input`, or `file`. With `file`, the
155
+ * `fs` must also have the functions of `TarFS`.
156
+ */
157
+ export type ExtractOptions = ReadOptions & UnpackOptions & {
245
158
  /**
246
- * When creating, updating, or replacing within archives, this method will
247
- * be called with each WriteEntry that is created.
159
+ * The most bytes to read from the file at one time. Default, and
160
+ * with 0, 16 MiB. A positive integer, or `Infinity`.
248
161
  */
249
- onWriteEntry?: (entry: WriteEntry) => unknown;
162
+ maxReadSize?: number;
250
163
  /**
251
- * When extracting or listing archives, this method will be called with
252
- * each entry that is not excluded by a `filter`.
253
- *
254
- * Important when listing archives synchronously from a file, because there
255
- * is otherwise no way to interact with the data!
164
+ * Called with each entry before it is extracted. A promise is
165
+ * awaited before the entry is extracted.
256
166
  */
257
- onReadEntry?: (entry: ReadEntry) => unknown;
167
+ onEntry?: (entry: ReadEntry) => unknown;
258
168
  /**
259
- * Pack the targets of symbolic links rather than the link itself.
169
+ * Return a stream that changes the content of a file entry, or
170
+ * `undefined` to write the content as it is.
260
171
  */
261
- follow?: boolean;
172
+ transform?: (entry: ReadEntry) => TransformStream<Uint8Array, Uint8Array> | undefined;
262
173
  /**
263
- * When creating archives, omit any metadata that is system-specific:
264
- * `ctime`, `atime`, `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and
265
- * `nlink`. Note that `mtime` is still included, because this is necessary
266
- * for other time-based operations such as `tar.update`. Additionally, `mode`
267
- * is set to a "reasonable default" for mose unix systems, based on an
268
- * effective `umask` of `0o22`.
269
- *
270
- * This also defaults the `portable` option in the gzip configs when creating
271
- * a compressed archive, in order to produce deterministic archives that are
272
- * not operating-system specific.
174
+ * The most entries to extract at one time. Default, and with 0,
175
+ * 16. A positive integer, or `Infinity`.
273
176
  */
274
- portable?: boolean;
177
+ jobs?: number;
178
+ } & ({
275
179
  /**
276
- * When creating archives, do not recursively archive the contents of
277
- * directories. By default, archiving a directory archives all of its
278
- * contents as well.
180
+ * The archive data. A chunk must not change after the source
181
+ * gives it.
279
182
  */
280
- noDirRecurse?: boolean;
183
+ input: TarInput;
184
+ /** The name of the archive, for warnings. */
185
+ file?: string;
186
+ fs: ExtractFS;
187
+ } | {
188
+ input?: undefined;
189
+ /** The path of the archive file. */
190
+ file: string;
191
+ fs: ExtractFS & TarFS;
192
+ });
193
+ /** The options of `extractSync`. Set `input`, or `file`. */
194
+ export type ExtractOptionsSync = ReadOptionsSync & UnpackOptions & {
281
195
  /**
282
- * Suppress Pax extended headers when creating archives. Note that this means
283
- * long paths and linkpaths will be truncated, and large or negative numeric
284
- * values may be interpreted incorrectly.
196
+ * The most bytes to read from the file at one time. Default, and
197
+ * with 0, 16 MiB. A positive integer, or `Infinity`.
285
198
  */
286
- noPax?: boolean;
199
+ maxReadSize?: number;
200
+ /** Called with each entry before it is extracted. */
201
+ onEntry?: (entry: ReadEntrySync) => unknown;
287
202
  /**
288
- * Set to a `Date` object to force a specific `mtime` value for everything
289
- * written to an archive.
290
- *
291
- * This is useful when creating archives that are intended to be
292
- * deterministic based on their contents, irrespective of the file's last
293
- * modification time.
294
- *
295
- * Overridden by `noMtime`.
203
+ * Return a function that changes each chunk of the content of a
204
+ * file entry, or `undefined` to write the content as it is.
296
205
  */
297
- mtime?: Date;
206
+ transform?: (entry: ReadEntrySync) => ((chunk: Uint8Array) => Uint8Array) | undefined;
207
+ } & ({
208
+ input: TarInputSync;
209
+ /** The name of the archive, for warnings. */
210
+ file?: string;
211
+ fs: ExtractFSSync;
212
+ } | {
213
+ input?: undefined;
214
+ /** The path of the archive file. */
215
+ file: string;
216
+ fs: ExtractFSSync & TarFSSync;
217
+ });
218
+ /** The options that `Pack` and `PackSync` share. */
219
+ export type PackOptionsBase<E extends EntryData> = WarnOptions & {
298
220
  /**
299
- * A path portion to prefix onto the entries added to an archive.
221
+ * The absolute path of the directory that the paths to add are
222
+ * relative to. A pack needs it, and `fs`, to add a path. A path
223
+ * that is not absolute is a `TypeError`.
300
224
  */
225
+ cwd?: string;
226
+ /** A directory to put before the path of each entry. */
301
227
  prefix?: string;
302
228
  /**
303
- * The mode to set on any created file archive, defaults to 0o666
304
- * masked by the process umask, often resulting in 0o644.
305
- *
306
- * This does *not* affect the mode fields of individual entries, or the
307
- * mode status of extracted entries on the filesystem.
229
+ * Leave out the data that is specific to one system: `uid`, `gid`,
230
+ * `uname`, `gname`, `atime`, `ctime`, `dev`, `ino`, `nlink`, and
231
+ * the `mtime` of a directory. Remove the write permission of the
232
+ * group and of others.
308
233
  */
309
- mode?: number;
234
+ portable?: boolean;
235
+ /** Write no PAX header for a field that does not fit the header. */
236
+ noPax?: boolean;
237
+ /** Add the target of a symbolic link, not the link. */
238
+ follow?: boolean;
239
+ /** Add a directory without the entries in it. */
240
+ noDirRecurse?: boolean;
241
+ /** Write no `mtime`. */
242
+ noMtime?: boolean;
243
+ /** The `mtime` of each entry. */
244
+ mtime?: Date;
245
+ /** Keep a root at the start of a path, such as `/`. */
246
+ preservePaths?: boolean;
310
247
  /**
311
- * A cache of mtime values, to avoid having to stat the same file repeatedly.
312
- *
313
- * @internal
248
+ * Called with each path and its `lstat` result (its `stat` result
249
+ * with `follow`), and with each entry of another archive. If it
250
+ * returns false, the path or the entry is not added.
314
251
  */
315
- mtimeCache?: Map<string, Date>;
252
+ filter?: (path: string, entry: CreateStats | E) => boolean;
316
253
  /**
317
- * maximum buffer size for `fs.read()` operations.
318
- *
319
- * @internal
254
+ * The most bytes to read from a file at one time. Default, and
255
+ * with 0, 16 MiB. A positive integer, or `Infinity`. A larger file
256
+ * is not read before the pack comes to it.
320
257
  */
321
258
  maxReadSize?: number;
322
259
  /**
323
- * Filter modes of entries being unpacked, like `process.umask()`
324
- *
325
- * @internal
326
- */
327
- umask?: number;
328
- /**
329
- * Default mode for directories. Used for all implicitly created directories,
330
- * and any directories in the archive that do not have a mode field.
331
- *
332
- * @internal
260
+ * With `'win32'`, each `\` in a path is changed to `/`, and the
261
+ * characters that `winchars` encodes are decoded.
333
262
  */
334
- dmode?: number;
335
- /**
336
- * default mode for files
337
- *
338
- * @internal
339
- */
340
- fmode?: number;
341
- /**
342
- * Map that tracks which directories already exist, for extraction
343
- *
344
- * @internal
345
- */
346
- dirCache?: Map<string, boolean>;
347
- /**
348
- * maximum supported size of meta entries. Defaults to 1MB
349
- *
350
- * @internal
351
- */
352
- maxMetaEntrySize?: number;
263
+ platform?: 'win32' | 'posix';
264
+ /** The user ID of the process. */
265
+ processUid?: number;
266
+ /** The `uname` of each file that `processUid` owns. */
267
+ processUname?: string;
353
268
  /**
354
- * A Map object containing the device and inode value for any file whose
355
- * `nlink` value is greater than 1, to identify hard links when creating
356
- * archives.
357
- *
358
- * @internal
269
+ * Called with each entry before its header is written. It can
270
+ * change the fields of the entry.
359
271
  */
360
- linkCache?: Map<LinkCacheKey, string>;
272
+ onWriteEntry?: (entry: WriteEntry) => unknown;
361
273
  /**
362
- * A map object containing the results of `fs.readdir()` calls.
363
- *
364
- * @internal
274
+ * Compression formats, before the gzip support of the runtime. The
275
+ * options `gzip`, `brotli`, and `zstd` select the first codec that
276
+ * has that name.
365
277
  */
366
- readdirCache?: Map<string, string[]>;
278
+ codecs?: Codec[];
279
+ /** Compress with the codec named `gzip`. */
280
+ gzip?: boolean | Record<string, unknown>;
281
+ /** Compress with the codec named `brotli` in `codecs`. */
282
+ brotli?: boolean | Record<string, unknown>;
283
+ /** Compress with the codec named `zstd` in `codecs`. */
284
+ zstd?: boolean | Record<string, unknown>;
367
285
  /**
368
- * A cache of all `lstat` results, for use in creating archives.
369
- *
370
- * @internal
286
+ * Compress with this codec. It does not need to be in `codecs`.
287
+ * With a pair, the second item is given to the `compress` function
288
+ * of the codec.
371
289
  */
372
- statCache?: Map<string, Stats>;
290
+ compress?: Codec | [codec: Codec, options: Record<string, unknown>];
291
+ };
292
+ /** The options of `Pack`. */
293
+ export type PackOptions = PackOptionsBase<ReadEntry> & {
294
+ fs?: CreateFS;
373
295
  /**
374
- * Number of concurrent jobs to run when creating archives.
375
- *
376
- * Defaults to 4.
377
- *
378
- * @internal
296
+ * The number of paths at the start of the queue that are read
297
+ * before the pack writes them. Default, and with 0, 4. A positive
298
+ * integer, or `Infinity`.
379
299
  */
380
300
  jobs?: number;
381
- /**
382
- * Automatically set to true on Windows systems.
383
- *
384
- * When extracting, causes behavior where filenames containing `<|>?:`
385
- * characters are converted to windows-compatible escape sequences in the
386
- * created filesystem entries.
387
- *
388
- * When packing, causes behavior where paths replace `\` with `/`, and
389
- * filenames containing the windows-compatible escaped forms of `<|>?:` are
390
- * converted to actual `<|>?:` characters in the archive.
391
- *
392
- * @internal
393
- */
394
- win32?: boolean;
395
- /**
396
- * For `WriteEntry` objects, the absolute path to the entry on the
397
- * filesystem. By default, this is `resolve(cwd, entry.path)`, but it can be
398
- * overridden explicitly.
399
- *
400
- * @internal
401
- */
402
- absolute?: string;
403
- /**
404
- * Used with Parser stream interface, to attach and take over when the
405
- * stream is completely parsed. If this is set, then the prefinish,
406
- * finish, and end events will not fire, and are the responsibility of
407
- * the ondone method to emit properly.
408
- *
409
- * @internal
410
- */
411
- ondone?: () => void;
412
- /**
413
- * Mostly for testing, but potentially useful in some cases.
414
- * Forcibly trigger a chown on every entry, no matter what.
415
- */
416
- forceChown?: boolean;
417
- /**
418
- * ambiguous deprecated name for {@link onReadEntry}
419
- *
420
- * @deprecated
421
- */
422
- onentry?: (entry: ReadEntry) => unknown;
423
- }
424
- export type TarOptionsSync = TarOptions & {
425
- sync: true;
426
301
  };
427
- export type TarOptionsAsync = TarOptions & {
428
- sync?: false;
302
+ /** The options of `PackSync`. */
303
+ export type PackOptionsSync = PackOptionsBase<ReadEntrySync> & {
304
+ fs?: CreateFSSync;
429
305
  };
430
- export type TarOptionsFile = TarOptions & {
431
- file: string;
306
+ /**
307
+ * The options of `create`. With `file`, the archive is written to
308
+ * that path through `fs`.
309
+ */
310
+ export type CreateOptions = PackOptions & {
311
+ /** The mode of the archive file. Default 0o666. */
312
+ mode?: number;
432
313
  };
433
- export type TarOptionsNoFile = TarOptions & {
434
- file?: undefined;
314
+ /** The options of `createSync`. */
315
+ export type CreateOptionsSync = PackOptionsSync & {
316
+ /** The mode of the archive file. Default 0o666. */
317
+ mode?: number;
435
318
  };
436
- export type TarOptionsSyncFile = TarOptionsSync & TarOptionsFile;
437
- export type TarOptionsAsyncFile = TarOptionsAsync & TarOptionsFile;
438
- export type TarOptionsSyncNoFile = TarOptionsSync & TarOptionsNoFile;
439
- export type TarOptionsAsyncNoFile = TarOptionsAsync & TarOptionsNoFile;
440
- export type LinkCacheKey = `${number}:${number}`;
441
- export interface TarOptionsWithAliases extends TarOptions {
442
- /**
443
- * The effective current working directory for this tar command
444
- */
445
- C?: TarOptions['cwd'];
446
- /**
447
- * The tar file to be read and/or written. When this is set, a stream
448
- * is not returned. Asynchronous commands will return a promise indicating
449
- * when the operation is completed, and synchronous commands will return
450
- * immediately.
451
- */
452
- f?: TarOptions['file'];
453
- /**
454
- * When creating a tar archive, this can be used to compress it as well.
455
- * Set to `true` to use the default gzip options, or customize them as
456
- * needed.
457
- *
458
- * When reading, if this is unset, then the compression status will be
459
- * inferred from the archive data. This is generally best, unless you are
460
- * sure of the compression settings in use to create the archive, and want to
461
- * fail if the archive doesn't match expectations.
462
- */
463
- z?: TarOptions['gzip'];
464
- /**
465
- * When creating archives, preserve absolute and `..` paths in the archive,
466
- * rather than sanitizing them under the cwd.
467
- *
468
- * When extracting, allow absolute paths, paths containing `..`, and
469
- * extracting through symbolic links. By default, the root `/` is stripped
470
- * from absolute paths (eg, turning `/x/y/z` into `x/y/z`), paths containing
471
- * `..` are not extracted, and any file whose location would be modified by a
472
- * symbolic link is not extracted.
473
- *
474
- * **WARNING** This is almost always unsafe, and must NEVER be used on
475
- * archives from untrusted sources, such as user input, and every entry must
476
- * be validated to ensure it is safe to write. Even if the input is not
477
- * malicious, mistakes can cause a lot of damage!
478
- */
479
- P?: TarOptions['preservePaths'];
480
- /**
481
- * When extracting, unlink files before creating them. Without this option,
482
- * tar overwrites existing files, which preserves existing hardlinks. With
483
- * this option, existing hardlinks will be broken, as will any symlink that
484
- * would affect the location of an extracted file.
485
- */
486
- U?: TarOptions['unlink'];
487
- /**
488
- * When extracting, strip the specified number of path portions from the
489
- * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be
490
- * extracted to `{cwd}/c/d`.
491
- */
492
- 'strip-components'?: TarOptions['strip'];
493
- /**
494
- * When extracting, strip the specified number of path portions from the
495
- * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be
496
- * extracted to `{cwd}/c/d`.
497
- */
498
- stripComponents?: TarOptions['strip'];
499
- /**
500
- * When extracting, keep the existing file on disk if it's newer than the
501
- * file in the archive.
502
- */
503
- 'keep-newer'?: TarOptions['newer'];
504
- /**
505
- * When extracting, keep the existing file on disk if it's newer than the
506
- * file in the archive.
507
- */
508
- keepNewer?: TarOptions['newer'];
509
- /**
510
- * When extracting, keep the existing file on disk if it's newer than the
511
- * file in the archive.
512
- */
513
- 'keep-newer-files'?: TarOptions['newer'];
514
- /**
515
- * When extracting, keep the existing file on disk if it's newer than the
516
- * file in the archive.
517
- */
518
- keepNewerFiles?: TarOptions['newer'];
519
- /**
520
- * When extracting, do not overwrite existing files at all.
521
- */
522
- k?: TarOptions['keep'];
523
- /**
524
- * When extracting, do not overwrite existing files at all.
525
- */
526
- 'keep-existing'?: TarOptions['keep'];
527
- /**
528
- * When extracting, do not overwrite existing files at all.
529
- */
530
- keepExisting?: TarOptions['keep'];
319
+ /** The options of `replace` and `update`. */
320
+ export type ReplaceOptions = CreateOptions & {
321
+ /** The path of the archive file. It is made if it does not exist. */
322
+ file: string;
323
+ fs: ReplaceFS;
531
324
  /**
532
- * When extracting, do not set the `mtime` value for extracted entries to
533
- * match the `mtime` in the archive.
534
- *
535
- * When creating archives, do not store the `mtime` value in the entry. Note
536
- * that this prevents properly using other mtime-based features (such as
537
- * `tar.update` or the `newer` option) with the resulting archive.
325
+ * Gets the path and the `mtime` of each entry that the archive
326
+ * has. `update` adds a path only if it is newer than the `mtime`
327
+ * here.
538
328
  */
539
- m?: TarOptions['noMtime'];
329
+ mtimeCache?: Map<string, Date>;
330
+ };
331
+ /** The options of `replaceSync` and `updateSync`. */
332
+ export type ReplaceOptionsSync = CreateOptionsSync & {
333
+ /** The path of the archive file. It is made if it does not exist. */
334
+ file: string;
335
+ fs: ReplaceFSSync;
540
336
  /**
541
- * When extracting, do not set the `mtime` value for extracted entries to
542
- * match the `mtime` in the archive.
543
- *
544
- * When creating archives, do not store the `mtime` value in the entry. Note
545
- * that this prevents properly using other mtime-based features (such as
546
- * `tar.update` or the `newer` option) with the resulting archive.
337
+ * Gets the path and the `mtime` of each entry that the archive
338
+ * has. `updateSync` adds a path only if it is newer than the
339
+ * `mtime` here.
547
340
  */
548
- 'no-mtime'?: TarOptions['noMtime'];
341
+ mtimeCache?: Map<string, Date>;
342
+ };
343
+ /** The options of `delete`. */
344
+ export type DeleteOptions = Omit<ReadOptions, 'filter'> & {
345
+ /** The path of the archive file. */
346
+ file: string;
347
+ fs: DeleteFS;
549
348
  /**
550
- * When extracting, set the `uid` and `gid` of extracted entries to the `uid`
551
- * and `gid` fields in the archive. Defaults to true when run as root, and
552
- * false otherwise.
553
- *
554
- * If false, then files and directories will be set with the owner and group
555
- * of the user running the process. This is similar to `-p` in `tar(1)`, but
556
- * ACLs and other system-specific data is never unpacked in this
557
- * implementation, and modes are set by default already.
349
+ * Return true to remove the entry. With a list of paths, an entry
350
+ * is removed only if the list also has it.
558
351
  */
559
- p?: TarOptions['preserveOwner'];
352
+ filter?: (path: string, entry: ReadEntry) => boolean;
560
353
  /**
561
- * Pack the targets of symbolic links rather than the link itself.
354
+ * The most bytes to read from the file at one time. Default, and
355
+ * with 0, 16 MiB. A positive integer, or `Infinity`.
562
356
  */
563
- L?: TarOptions['follow'];
357
+ maxReadSize?: number;
358
+ };
359
+ /** The options of `deleteSync`. */
360
+ export type DeleteOptionsSync = Omit<ReadOptionsSync, 'filter'> & {
361
+ /** The path of the archive file. */
362
+ file: string;
363
+ fs: DeleteFSSync;
564
364
  /**
565
- * Pack the targets of symbolic links rather than the link itself.
365
+ * Return true to remove the entry. With a list of paths, an entry
366
+ * is removed only if the list also has it.
566
367
  */
567
- h?: TarOptions['follow'];
368
+ filter?: (path: string, entry: ReadEntrySync) => boolean;
568
369
  /**
569
- * Deprecated option. Set explicitly false to set `chmod: true`. Ignored
570
- * if {@link TarOptions#chmod} is set to any boolean value.
571
- *
572
- * @deprecated
370
+ * The most bytes to read from the file at one time. Default, and
371
+ * with 0, 16 MiB. A positive integer, or `Infinity`.
573
372
  */
574
- noChmod?: boolean;
575
- }
576
- export type TarOptionsWithAliasesSync = TarOptionsWithAliases & {
577
- sync: true;
578
- };
579
- export type TarOptionsWithAliasesAsync = TarOptionsWithAliases & {
580
- sync?: false;
581
- };
582
- export type TarOptionsWithAliasesFile = (TarOptionsWithAliases & {
583
- file: string;
584
- }) | (TarOptionsWithAliases & {
585
- f: string;
586
- });
587
- export type TarOptionsWithAliasesSyncFile = TarOptionsWithAliasesSync & TarOptionsWithAliasesFile;
588
- export type TarOptionsWithAliasesAsyncFile = TarOptionsWithAliasesAsync & TarOptionsWithAliasesFile;
589
- export type TarOptionsWithAliasesNoFile = TarOptionsWithAliases & {
590
- f?: undefined;
591
- file?: undefined;
373
+ maxReadSize?: number;
592
374
  };
593
- export type TarOptionsWithAliasesSyncNoFile = TarOptionsWithAliasesSync & TarOptionsWithAliasesNoFile;
594
- export type TarOptionsWithAliasesAsyncNoFile = TarOptionsWithAliasesAsync & TarOptionsWithAliasesNoFile;
595
- export declare const isSyncFile: <O extends TarOptions>(o: O) => o is O & TarOptionsSyncFile;
596
- export declare const isAsyncFile: <O extends TarOptions>(o: O) => o is O & TarOptionsAsyncFile;
597
- export declare const isSyncNoFile: <O extends TarOptions>(o: O) => o is O & TarOptionsSyncNoFile;
598
- export declare const isAsyncNoFile: <O extends TarOptions>(o: O) => o is O & TarOptionsAsyncNoFile;
599
- export declare const isSync: <O extends TarOptions>(o: O) => o is O & TarOptionsSync;
600
- export declare const isAsync: <O extends TarOptions>(o: O) => o is O & TarOptionsAsync;
601
- export declare const isFile: <O extends TarOptions>(o: O) => o is O & TarOptionsFile;
602
- export declare const isNoFile: <O extends TarOptions>(o: O) => o is O & TarOptionsNoFile;
603
- export declare const dealias: (opt?: TarOptionsWithAliases) => TarOptions;
604
375
  //# sourceMappingURL=options.d.ts.map