From bd677abc92fffa701cd87c42a638dd827136acc4 Mon Sep 17 00:00:00 2001 From: Florian Keller Date: Thu, 30 May 2019 21:15:34 +0200 Subject: [PATCH] Add type definitions for ci-info (#35772) --- types/ci-info/ci-info-tests.ts | 33 +++++++++++++++++++ types/ci-info/index.d.ts | 58 ++++++++++++++++++++++++++++++++++ types/ci-info/tsconfig.json | 23 ++++++++++++++ types/ci-info/tslint.json | 1 + types/is-ci/index.d.ts | 9 +++--- types/is-ci/is-ci-tests.ts | 4 +-- 6 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 types/ci-info/ci-info-tests.ts create mode 100644 types/ci-info/index.d.ts create mode 100644 types/ci-info/tsconfig.json create mode 100644 types/ci-info/tslint.json diff --git a/types/ci-info/ci-info-tests.ts b/types/ci-info/ci-info-tests.ts new file mode 100644 index 0000000000..31407a73a8 --- /dev/null +++ b/types/ci-info/ci-info-tests.ts @@ -0,0 +1,33 @@ +import * as ci from 'ci-info'; + +ci.isCI; // $ExpectType boolean +ci.isPR; // $ExpectType boolean | null +ci.name; // $ExpectType string | null + +ci.APPVEYOR; // $ExpectType boolean +ci.AZURE_PIPELINES; // $ExpectType boolean +ci.BAMBOO; // $ExpectType boolean +ci.BITBUCKET; // $ExpectType boolean +ci.BITRISE; // $ExpectType boolean +ci.BUDDY; // $ExpectType boolean +ci.BUILDKITE; // $ExpectType boolean +ci.CIRCLE; // $ExpectType boolean +ci.CIRRUS; // $ExpectType boolean +ci.CODEBUILD; // $ExpectType boolean +ci.CODESHIP; // $ExpectType boolean +ci.DRONE; // $ExpectType boolean +ci.DSARI; // $ExpectType boolean +ci.GITLAB; // $ExpectType boolean +ci.GOCD; // $ExpectType boolean +ci.HUDSON; // $ExpectType boolean +ci.JENKINS; // $ExpectType boolean +ci.MAGNUM; // $ExpectType boolean +ci.NETLIFY; // $ExpectType boolean +ci.SAIL; // $ExpectType boolean +ci.SEMAPHORE; // $ExpectType boolean +ci.SHIPPABLE; // $ExpectType boolean +ci.SOLANO; // $ExpectType boolean +ci.STRIDER; // $ExpectType boolean +ci.TASKCLUSTER; // $ExpectType boolean +ci.TEAMCITY; // $ExpectType boolean +ci.TRAVIS; // $ExpectType boolean diff --git a/types/ci-info/index.d.ts b/types/ci-info/index.d.ts new file mode 100644 index 0000000000..db8e5090e4 --- /dev/null +++ b/types/ci-info/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for ci-info 2.0 +// Project: https://github.com/watson/ci-info +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Returns a boolean. Will be `true` if the code is running on a CI server, + * otherwise `false`. + * + * Some CI servers not listed here might still trigger the `ci.isCI` + * boolean to be set to `true` if they use certain vendor neutral environment + * variables. In those cases `ci.name` will be `null` and no vendor specific + * boolean will be set to `true`. + */ +export const isCI: boolean; +/** + * Returns a boolean if PR detection is supported for the current CI server. + * Will be `true` if a PR is being tested, otherwise `false`. If PR detection is + * not supported for the current CI server, the value will be `null`. + */ +export const isPR: boolean | null; +/** + * Returns a string containing name of the CI server the code is running on. If + * CI server is not detected, it returns `null`. + * + * Don't depend on the value of this string not to change for a specific vendor. + * If you find your self writing `ci.name === 'Travis CI'`, you most likely want + * to use `ci.TRAVIS` instead. + */ +export const name: string | null; + +export const APPVEYOR: boolean; +export const AZURE_PIPELINES: boolean; +export const BAMBOO: boolean; +export const BITBUCKET: boolean; +export const BITRISE: boolean; +export const BUDDY: boolean; +export const BUILDKITE: boolean; +export const CIRCLE: boolean; +export const CIRRUS: boolean; +export const CODEBUILD: boolean; +export const CODESHIP: boolean; +export const DRONE: boolean; +export const DSARI: boolean; +export const GITLAB: boolean; +export const GOCD: boolean; +export const HUDSON: boolean; +export const JENKINS: boolean; +export const MAGNUM: boolean; +export const NETLIFY: boolean; +export const SAIL: boolean; +export const SEMAPHORE: boolean; +export const SHIPPABLE: boolean; +export const SOLANO: boolean; +export const STRIDER: boolean; +export const TASKCLUSTER: boolean; +export const TEAMCITY: boolean; +export const TRAVIS: boolean; diff --git a/types/ci-info/tsconfig.json b/types/ci-info/tsconfig.json new file mode 100644 index 0000000000..edace3bac2 --- /dev/null +++ b/types/ci-info/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", + "ci-info-tests.ts" + ] +} diff --git a/types/ci-info/tslint.json b/types/ci-info/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ci-info/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/is-ci/index.d.ts b/types/is-ci/index.d.ts index 6e9e3a7b5b..f1137ee35f 100644 --- a/types/is-ci/index.d.ts +++ b/types/is-ci/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for is-ci 1.1 +// Type definitions for is-ci 2.0 // Project: https://github.com/watson/is-ci -// Definitions by: Arne Schubert +// Definitions by: Arne Schubert , +// Florian Keller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = is_ci; +import { isCI } from 'ci-info'; -declare const is_ci: boolean; +export = isCI; diff --git a/types/is-ci/is-ci-tests.ts b/types/is-ci/is-ci-tests.ts index a4f5a7c32c..d3b7cc0e82 100644 --- a/types/is-ci/is-ci-tests.ts +++ b/types/is-ci/is-ci-tests.ts @@ -1,5 +1,3 @@ import isCi = require('is-ci'); -let booleanValue: boolean; - -booleanValue = isCi; +isCi; // $ExpectType boolean