diff --git a/types/semantic-release/index.d.ts b/types/semantic-release/index.d.ts new file mode 100644 index 0000000000..656461b756 --- /dev/null +++ b/types/semantic-release/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for semantic-release 15.13 +// Project: https://github.com/semantic-release/semantic-release#readme +// Definitions by: Leonardo Gatica +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * The semantic release configuration itself. + */ +export interface GlobalConfig { + /** The full prepare step configuration. */ + prepare?: any; + /** The branch on which releases should happen. */ + branch: string; + /** The Git repository URL, in any supported format. */ + repositoryUrl: string; + /** The Git tag format used by semantic-release to identify releases. */ + tagFormat: string; +} + +export interface LastRelease { + /** The version name of the release */ + version: string; + /** The Git tag of the release. */ + gitTag: string; + /** The Git checksum of the last commit of the release. */ + gitHead: string; +} + +export interface NextRelease extends LastRelease { + /** The release notes of the next release. */ + notes: string; +} + +export interface Context { + /** The semantic release configuration itself. */ + options?: GlobalConfig; + /** The previous release details. */ + lastRelease?: LastRelease; + /** The next release details. */ + nextRelease?: NextRelease; + /** The shared logger instance of semantic release. */ + logger: { + log: (message: string, ...vars: any[]) => void, + error: (message: string, ...vars: any[]) => void, + }; +} diff --git a/types/semantic-release/semantic-release-tests.ts b/types/semantic-release/semantic-release-tests.ts new file mode 100644 index 0000000000..0c954fe295 --- /dev/null +++ b/types/semantic-release/semantic-release-tests.ts @@ -0,0 +1,17 @@ +import * as lib from 'semantic-release'; + +function publish(pluginConfig: any, context: lib.Context) { + const version = context.nextRelease && context.nextRelease.version; + context.logger.log(`New version ${version}`); +} + +const context = { + nextRelease: { + version: '1.0.0', + gitTag: '1.0.0', + gitHead: 'f1eed296d2ffe184fb15f52b1c5ad778f5c87645', + notes: 'New release' + }, + logger: console +}; +publish({}, context); diff --git a/types/semantic-release/tsconfig.json b/types/semantic-release/tsconfig.json new file mode 100644 index 0000000000..d226e296ce --- /dev/null +++ b/types/semantic-release/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "semantic-release-tests.ts" + ] +} diff --git a/types/semantic-release/tslint.json b/types/semantic-release/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/semantic-release/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }