diff --git a/types/appdmg/appdmg-tests.ts b/types/appdmg/appdmg-tests.ts new file mode 100644 index 0000000000..47800d622f --- /dev/null +++ b/types/appdmg/appdmg-tests.ts @@ -0,0 +1,47 @@ +import appdmg = require("appdmg"); +import { Options, Specification, SpecificationOptions } from "appdmg"; + +const proc = appdmg({ + target: "/foo/bar.dmg", + basepath: "/baz", + specification: { + title: "Happy", + icon: "happy.icns", + background: "happy.tiff", + format: "UDBZ", + "icon-size": 98, + contents: [ + { + x: 405, + y: 150, + type: "link", + path: "/Applications" + }, + { + x: 127, + y: 150, + type: "file", + path: "/foo/bar.app" + } + ] + } +}); + +proc.on("progress", info => { + if (info.type === "step-begin") { + process.stdout.write(`${info.title}... `); + } + + if (info.type === "step-end") { + process.stdout.write(`${info.status}\n`); + } +}); + +proc.on("finish", () => { + console.log('Installer was created successfully!'); +}); + +proc.on("error", (err) => { + console.error('Installer could not be created', err); + process.exit(1); +}); diff --git a/types/appdmg/index.d.ts b/types/appdmg/index.d.ts new file mode 100644 index 0000000000..2e23009f44 --- /dev/null +++ b/types/appdmg/index.d.ts @@ -0,0 +1,70 @@ +// Type definitions for appdmg 0.5 +// Project: https://github.com/LinusU/node-appdmg#readme +// Definitions by: Daniel Perez Alvarez +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace appdmg { + interface Progress { + current: number; + total: number; + type: "step-begin" | "step-end"; + title: string; + status: "ok" | "skip" | "fail"; + } + + interface EventEmitter extends NodeJS.EventEmitter { + on(event: "progress", listener: (info: Progress) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "error", listener: (err: any) => void): this; + } + + interface SpecificationOptions { + app: string; + background: string; + icon: string; + iconSize: number; + title: string; + } + + interface SpecificationWindow { + position?: { x: number; y: number }; + size?: { width: number; height: number }; + } + + interface SpecificationContents { + x: number; + y: number; + type: "link" | "file" | "position"; + path: string; + name?: string; + } + + interface SpecificationCodeSign { + "signing-identity": string; + identifier?: string; + } + + interface Specification { + title: string; + icon?: string; + background?: string; + "background-color"?: string; + "icon-size"?: number; + window?: SpecificationWindow; + format: "UDRW" | "UDRO" | "UDCO" | "UDZO" | "UDBZ" | "ULFO"; + contents: SpecificationContents[]; + "code-sign"?: SpecificationCodeSign; + } + + interface Options { + target: string; + basepath: string; + specification: Specification; + } +} + +declare function appdmg(options?: appdmg.Options): appdmg.EventEmitter; + +export = appdmg; diff --git a/types/appdmg/tsconfig.json b/types/appdmg/tsconfig.json new file mode 100644 index 0000000000..f4ca0f95c5 --- /dev/null +++ b/types/appdmg/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "appdmg-tests.ts" + ] +} diff --git a/types/appdmg/tslint.json b/types/appdmg/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/appdmg/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }