Comparing version 4.0.0 to 4.1.0
# Changelog | ||
### v4.1.0 | ||
- support Appcircle PR [1d42c26](https://github.com/watson/ci-info/commit/1d42c26) | ||
- support AWS CodeBuild PR [e6fcdd2](https://github.com/watson/ci-info/commit/e6fcdd2) | ||
- add `ci.id` to return vendor constant [81fd993](https://github.com/watson/ci-info/commit/81fd993) | ||
## v4.0.0 | ||
@@ -4,0 +11,0 @@ |
@@ -28,3 +28,9 @@ // This file is generated at pre-commit by running `node create-typings.js`. | ||
export const name: string | null; | ||
/** | ||
* Returns a string containing the identifier of the CI server the code is running on. If | ||
* CI server is not detected, it returns `null`. | ||
*/ | ||
export const id: string | null; | ||
/* Vendor constants */ | ||
export const AGOLA: boolean; | ||
@@ -31,0 +37,0 @@ export const APPCIRCLE: boolean; |
80
index.js
@@ -16,2 +16,3 @@ 'use strict' | ||
exports.isPR = null | ||
exports.id = null | ||
@@ -31,26 +32,4 @@ vendors.forEach(function (vendor) { | ||
exports.name = vendor.name | ||
switch (typeof vendor.pr) { | ||
case 'string': | ||
// "pr": "CIRRUS_PR" | ||
exports.isPR = !!env[vendor.pr] | ||
break | ||
case 'object': | ||
if ('env' in vendor.pr) { | ||
// "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" } | ||
exports.isPR = vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne | ||
} else if ('any' in vendor.pr) { | ||
// "pr": { "any": ["ghprbPullId", "CHANGE_ID"] } | ||
exports.isPR = vendor.pr.any.some(function (key) { | ||
return !!env[key] | ||
}) | ||
} else { | ||
// "pr": { "DRONE_BUILD_EVENT": "pull_request" } | ||
exports.isPR = checkEnv(vendor.pr) | ||
} | ||
break | ||
default: | ||
// PR detection not supported for this vendor | ||
exports.isPR = null | ||
} | ||
exports.isPR = checkPR(vendor) | ||
exports.id = vendor.constant | ||
}) | ||
@@ -61,12 +40,12 @@ | ||
(env.BUILD_ID || // Jenkins, Cloudbees | ||
env.BUILD_NUMBER || // Jenkins, TeamCity | ||
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari | ||
env.CI_APP_ID || // Appflow | ||
env.CI_BUILD_ID || // Appflow | ||
env.CI_BUILD_NUMBER || // Appflow | ||
env.CI_NAME || // Codeship and others | ||
env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI | ||
env.RUN_ID || // TaskCluster, dsari | ||
exports.name || | ||
false) | ||
env.BUILD_NUMBER || // Jenkins, TeamCity | ||
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari | ||
env.CI_APP_ID || // Appflow | ||
env.CI_BUILD_ID || // Appflow | ||
env.CI_BUILD_NUMBER || // Appflow | ||
env.CI_NAME || // Codeship and others | ||
env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI | ||
env.RUN_ID || // TaskCluster, dsari | ||
exports.name || | ||
false) | ||
) | ||
@@ -85,2 +64,3 @@ | ||
} | ||
if ('any' in obj) { | ||
@@ -91,2 +71,3 @@ return obj.any.some(function (k) { | ||
} | ||
return Object.keys(obj).every(function (k) { | ||
@@ -96,1 +77,32 @@ return env[k] === obj[k] | ||
} | ||
function checkPR (vendor) { | ||
switch (typeof vendor.pr) { | ||
case 'string': | ||
// "pr": "CIRRUS_PR" | ||
return !!env[vendor.pr] | ||
case 'object': | ||
if ('env' in vendor.pr) { | ||
if ('any' in vendor.pr) { | ||
// "pr": { "env": "CODEBUILD_WEBHOOK_EVENT", "any": ["PULL_REQUEST_CREATED", "PULL_REQUEST_UPDATED"] } | ||
return vendor.pr.any.some(function (key) { | ||
return env[vendor.pr.env] === key | ||
}) | ||
} else { | ||
// "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" } | ||
return vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne | ||
} | ||
} else if ('any' in vendor.pr) { | ||
// "pr": { "any": ["ghprbPullId", "CHANGE_ID"] } | ||
return vendor.pr.any.some(function (key) { | ||
return !!env[key] | ||
}) | ||
} else { | ||
// "pr": { "DRONE_BUILD_EVENT": "pull_request" } | ||
return checkEnv(vendor.pr) | ||
} | ||
default: | ||
// PR detection not supported for this vendor | ||
return null | ||
} | ||
} |
{ | ||
"name": "ci-info", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Get details about the current Continuous Integration environment", | ||
@@ -12,2 +12,14 @@ "main": "index.js", | ||
"homepage": "https://github.com/watson/ci-info", | ||
"contributors": [ | ||
{ | ||
"name": "Sibiraj", | ||
"url": "https://github.com/sibiraj-s" | ||
} | ||
], | ||
"funding": [ | ||
{ | ||
"type": "github", | ||
"url": "https://github.com/sponsors/sibiraj-s" | ||
} | ||
], | ||
"keywords": [ | ||
@@ -26,18 +38,12 @@ "ci", | ||
], | ||
"funding": [ | ||
{ | ||
"type": "github", | ||
"url": "https://github.com/sponsors/sibiraj-s" | ||
} | ||
], | ||
"scripts": { | ||
"lint:fix": "standard --fix", | ||
"test": "standard && node test.js", | ||
"prepare": "husky install" | ||
"prepare": "husky install || true" | ||
}, | ||
"devDependencies": { | ||
"clear-module": "^4.1.2", | ||
"husky": "^8.0.3", | ||
"standard": "^17.1.0", | ||
"tape": "^5.7.0" | ||
"husky": "^9.1.6", | ||
"standard": "^17.1.2", | ||
"tape": "^5.9.0" | ||
}, | ||
@@ -44,0 +50,0 @@ "engines": { |
@@ -38,5 +38,5 @@ # ci-info | ||
| [Agola CI](https://agola.io/) | `ci.AGOLA` | ✅ | | ||
| [Appcircle](https://appcircle.io/) | `ci.APPCIRCLE` | 🚫 | | ||
| [Appcircle](https://appcircle.io/) | `ci.APPCIRCLE` | ✅ | | ||
| [AppVeyor](http://www.appveyor.com) | `ci.APPVEYOR` | ✅ | | ||
| [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` | 🚫 | | ||
| [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` | ✅ | | ||
| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | `ci.AZURE_PIPELINES` | ✅ | | ||
@@ -43,0 +43,0 @@ | [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` | 🚫 | |
@@ -11,3 +11,7 @@ [ | ||
"constant": "APPCIRCLE", | ||
"env": "AC_APPCIRCLE" | ||
"env": "AC_APPCIRCLE", | ||
"pr": { | ||
"env": "AC_GIT_PR", | ||
"ne": "false" | ||
} | ||
}, | ||
@@ -23,3 +27,11 @@ { | ||
"constant": "CODEBUILD", | ||
"env": "CODEBUILD_BUILD_ARN" | ||
"env": "CODEBUILD_BUILD_ARN", | ||
"pr": { | ||
"env": "CODEBUILD_WEBHOOK_EVENT", | ||
"any": [ | ||
"PULL_REQUEST_CREATED", | ||
"PULL_REQUEST_UPDATED", | ||
"PULL_REQUEST_REOPENED" | ||
] | ||
} | ||
}, | ||
@@ -26,0 +38,0 @@ { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28509
518