Merge pull request #22071 from unindented/appdmg

Add types for appdmg
This commit is contained in:
Mine Starks
2017-12-11 09:44:44 -08:00
committed by GitHub
4 changed files with 141 additions and 0 deletions
+47
View File
@@ -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);
});
+70
View File
@@ -0,0 +1,70 @@
// Type definitions for appdmg 0.5
// Project: https://github.com/LinusU/node-appdmg#readme
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
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;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }