From b1aa5176d40a8d84a081c4e91b835a2fc094877e Mon Sep 17 00:00:00 2001 From: Vlad Hashimoto Date: Wed, 23 May 2018 02:42:49 +0300 Subject: [PATCH] feat: add Typescript type definitions (#28) * Add TypeScript definitions. * Return the void * Semicolon and docs * Create ILogger interface * Add more loggers * Add TSLint for linting --- index.d.ts | 35 +++++++++++++++++++++++++++++++++++ package.json | 8 ++++++-- tslint.json | 9 +++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 index.d.ts create mode 100644 tslint.json diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..c011088 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for update-electron-app 1.1.2 +// Project: https://github.com/electron/update-electron-app +// Definitions by: HashimotoYT + +export function updater( + opts?: { + /** + * @param {String} repo A GitHub repository in the format `owner/repo`. + * Defaults to your `package.json`'s `"repository"` field + */ + repo?: string; + /** + * @param {String} host Defaults to `https://update.electronjs.org` + */ + host?: string; + /** + * @param {String} updateInterval How frequently to check for updates. Defaults to `10 minutes`. + * Minimum allowed interval is `5 minutes`. + */ + updateInterval?: string; + /** + * @param {Object} logger A custom logger object that defines a `log` function. + * Defaults to `console`. See electron-log, a module + * that aggregates logs from main and renderer processes into a single file. + */ + logger?: ILogger; + }, +): void; + +interface ILogger { + log(message: string): void; + info(message: string): void; + error(message: string): void; + warn(message: string): void; +} diff --git a/package.json b/package.json index 5b4f2af..e753a94 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A drop-in module that adds autoUpdating capabilities to Electron apps", "repository": "https://github.com/electron/update-electron-app", "main": "index.js", + "types": "index.d.ts", "license": "MIT", "dependencies": { "electron-is-dev": "^0.3.0", @@ -13,13 +14,16 @@ }, "devDependencies": { "jest": "^22.4.3", + "semantic-release": "^15.1.7", "standard": "^11.0.1", "standard-markdown": "^4.0.2", "travis-deploy-once": "^4.4.1", - "semantic-release": "^15.1.7" + "tslint": "^5.10.0", + "typescript": "^2.8.3" }, "scripts": { - "test": "jest && standard --fix && standard-markdown", + "test": "jest && standard --fix && npm run lint && standard-markdown", + "lint": "tslint -c tslint.json index.d.ts", "watch": "jest --watch --notify --notifyMode=change --coverage", "travis-deploy-once": "travis-deploy-once", "semantic-release": "semantic-release" diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..7b73ab8 --- /dev/null +++ b/tslint.json @@ -0,0 +1,9 @@ +{ + "defaultSeverity": "error", + "extends": [ + "tslint:recommended" + ], + "jsRules": {}, + "rules": {}, + "rulesDirectory": [] +}