diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4a860113c..70f7a7473 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -288,6 +288,7 @@ All definitions files include a header with the author and editors, so at some p * [nodeunit](https://github.com/caolan/nodeunit) (by [Jeff Goddard](https://github.com/jedigo)) * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) +* [node-tar](https://github.com/npm/node-tar) (by [Maxime LUCE](https://github.com/SomaticIT)) * [node-uuid](https://github.com/broofa/node-uuid) (by [Jeff May](https://github.com/jeffmay)) * [notify.js](https://github.com/alexgibson/notify.js) (by [soundTricker](https://github.com/soundTricker)) * [npm](https://github.com/npm/npm) (by [Maxime LUCE](https://github.com/SomaticIT)) diff --git a/tar/tar-tests.ts b/tar/tar-tests.ts new file mode 100644 index 000000000..3a7783d52 --- /dev/null +++ b/tar/tar-tests.ts @@ -0,0 +1,28 @@ +/** +* Test suite created by Maxime LUCE +* +* Created by using code samples from https://github.com/npm/node-tar. +*/ + +/// +/// + +import tar = require("tar"); +import fs = require("fs"); + +/** + * Quick Extract + */ +fs.createReadStream("path/to/file.tar").pipe(tar.Extract("path/to/extract")); + +/** + * Use with events + */ +var readStream = fs.createReadStream("/path/to/file.tar"); +var extract = tar.Extract("/path/to/target"); + +readStream.pipe(extract); + +extract.on("entry", (entry: any) => { + +}); diff --git a/tar/tar.d.ts b/tar/tar.d.ts new file mode 100644 index 000000000..6b25a02a7 --- /dev/null +++ b/tar/tar.d.ts @@ -0,0 +1,209 @@ +// Type definitions for tar v1.0.1 +// Project: https://github.com/npm/node-tar +// Definitions by: Maxime LUCE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "tar" { + import stream = require("stream"); + + //#region Interfaces + + export interface HeaderProperties { + path?: string; + mode?: number; + uid?: number; + gid?: number; + size?: number; + mtime?: number; + uname?: string; + gname?: string; + devmaj?: number; + devmin?: number; + } + + export interface ExtractOptions { + type?: string; + Directory?: boolean; + path?: string; + strip?: number; + } + + export interface ParseStream extends NodeJS.ReadWriteStream { + position: number; + + _stream: stream.Stream; + _ended: boolean; + + _streamEnd(): void; + _process(c: Buffer): void; + _startEntry(c: Buffer): void; + } + + export interface PackStream extends NodeJS.ReadWriteStream { + writable: boolean; + readable: boolean; + + _noProprietary: boolean; + _global: HeaderProperties; + _buffer: stream.Stream[]; + _currentEntry: any; + _processing: boolean; + _pipeRoot: stream.Stream; + _needDrain: boolean; + _paused: boolean; + + addGlobal(props: HeaderProperties): void; + add(stream: stream.Stream): boolean; + destroy(): void; + + _process(): void; + } + + export interface ExtractStream extends ParseStream { + } + + //#endregion + + //#region Enums + + export var fields: { + path: number; + mode: number; + uid: number; + gid: number; + size: number; + mtime: number; + cksum: number; + type: number; + linkpath: number; + ustar: number; + ustarvar: number; + uname: number; + gname: number; + devmaj: number; + devmin: number; + prefix: number; + fill: number; + }; + + export var fieldSize: number[]; + export var fieldOffs: number[]; + export var fieldEnds: number[]; + + /** + * Different values of the 'type' field + * paths match the values of Stats.isX() functions, where appropriate + */ + export var types: { + 0: string; + "\0": string; + "": string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; + 6: string; + 7: string; + g: string; + x: string; + A: string; + D: string; + I: string; + K: string; + L: string; + M: string; + N: string; + S: string; + V: string; + X: string; + File: string; + OldFile: string; + Link: string; + SymbolicLick: string; + CharacterDevice: string; + BlockDevice: string; + Directory: string; + FIFO: string; + ContiguousFile: string; + GlobalExtendedHeader: string; + ExtendedHeader: string; + SolarisACL: string; + GNUDumpDir: string; + INode: string; + NextFileHasLonLinkPath: string; + NextFileHasLongPath: string; + ContinuationFile: string; + TapeVolumeHeader: string; + OldExtendedHeader: string; + }; + + /** + * Values for the mode field + */ + export var modes: { + suid: number; + sgid: number; + svtx: number; + uread: number; + uwrite: number; + uexec: number; + gread: number; + gwrite: number; + gexec: number; + oread: number; + owrite: number; + oexec: number; + }; + + export var numeric: { + mode: boolean; + uid: boolean; + gid: boolean; + size: boolean; + mtime: boolean; + devmaj: boolean; + devmin: boolean; + cksum: boolean; + atime: boolean; + ctime: boolean; + dev: boolean; + ino: boolean; + nlink: boolean; + }; + + export var knownExtended: { + atime: boolean; + charset: boolean; + comment: boolean; + ctime: boolean; + gid: boolean; + gname: boolean; + linkpat: boolean; + mtime: boolean; + path: boolean; + realtime: boolean; + security: boolean; + size: boolean; + uid: boolean; + uname: boolean; + }; + + export var headerSize: number; + export var blockSize: number; + + //#endregion + + //#region Global Methods + + export function Parse(): ParseStream; + + export function Pack(props: HeaderProperties): PackStream; + + export function Extract(path: string): ExtractStream; + export function Extract(opts: ExtractOptions): ExtractStream; + + //#endregion +} \ No newline at end of file