Comparing version 7.3.0 to 7.4.0-beta.1
98
index.js
@@ -1,44 +0,72 @@ | ||
const process = require('process'); | ||
const git = require('./services/git.js'); | ||
import appveyor from "./services/appveyor.js"; | ||
import azurePipelines from "./services/azure-pipelines.js"; | ||
import bamboo from "./services/bamboo.js"; | ||
import bitbucket from "./services/bitbucket.js"; | ||
import bitrise from "./services/bitrise.js"; | ||
import buddy from "./services/buddy.js"; | ||
import buildkite from "./services/buildkite.js"; | ||
import circleci from "./services/circleci.js"; | ||
import cirrus from "./services/cirrus.js"; | ||
import cloudflarePages from "./services/cloudflare-pages.js"; | ||
import codebuild from "./services/codebuild.js"; | ||
import codefresh from "./services/codefresh.js"; | ||
import codeship from "./services/codeship.js"; | ||
import drone from "./services/drone.js"; | ||
import git from "./services/git.js"; | ||
import github from "./services/github.js"; | ||
import gitlab from "./services/gitlab.js"; | ||
import jenkins from "./services/jenkins.js"; | ||
import netlify from "./services/netlify.js"; | ||
import puppet from "./services/puppet.js"; | ||
import sail from "./services/sail.js"; | ||
import scrutinizer from "./services/scrutinizer.js"; | ||
import semaphore from "./services/semaphore.js"; | ||
import shippable from "./services/shippable.js"; | ||
import teamcity from "./services/teamcity.js"; | ||
import travis from "./services/travis.js"; | ||
import vela from "./services/vela.js"; | ||
import vercel from "./services/vercel.js"; | ||
import wercker from "./services/wercker.js"; | ||
import woodpecker from "./services/woodpecker.js"; | ||
const services = { | ||
appveyor: require('./services/appveyor.js'), | ||
azurePipelines: require('./services/azure-pipelines.js'), | ||
bamboo: require('./services/bamboo.js'), | ||
bitbucket: require('./services/bitbucket.js'), | ||
bitrise: require('./services/bitrise.js'), | ||
buddy: require('./services/buddy.js'), | ||
buildkite: require('./services/buildkite.js'), | ||
circleci: require('./services/circleci.js'), | ||
cirrus: require('./services/cirrus.js'), | ||
cloudflarePages: require('./services/cloudflare-pages.js'), | ||
codebuild: require('./services/codebuild.js'), | ||
codefresh: require('./services/codefresh.js'), | ||
codeship: require('./services/codeship.js'), | ||
drone: require('./services/drone.js'), | ||
github: require('./services/github.js'), | ||
gitlab: require('./services/gitlab.js'), | ||
jenkins: require('./services/jenkins.js'), | ||
netlify: require('./services/netlify.js'), | ||
puppet: require('./services/puppet.js'), | ||
sail: require('./services/sail.js'), | ||
scrutinizer: require('./services/scrutinizer.js'), | ||
semaphore: require('./services/semaphore.js'), | ||
shippable: require('./services/shippable.js'), | ||
teamcity: require('./services/teamcity.js'), | ||
travis: require('./services/travis.js'), | ||
vela: require('./services/vela.js'), | ||
vercel: require('./services/vercel.js'), | ||
wercker: require('./services/wercker.js'), | ||
woodpecker: require('./services/woodpecker.js'), | ||
appveyor, | ||
azurePipelines, | ||
bamboo, | ||
bitbucket, | ||
bitrise, | ||
buddy, | ||
buildkite, | ||
circleci, | ||
cirrus, | ||
cloudflarePages, | ||
codebuild, | ||
codefresh, | ||
codeship, | ||
drone, | ||
github, | ||
gitlab, | ||
jenkins, | ||
netlify, | ||
puppet, | ||
sail, | ||
scrutinizer, | ||
semaphore, | ||
shippable, | ||
teamcity, | ||
travis, | ||
vela, | ||
vercel, | ||
wercker, | ||
woodpecker, | ||
}; | ||
module.exports = ({env = process.env, cwd = process.cwd()} = {}) => { | ||
export default ({ env = process.env, cwd = process.cwd() } = {}) => { | ||
for (const name of Object.keys(services)) { | ||
if (services[name].detect({env, cwd})) { | ||
return {isCi: true, ...services[name].configuration({env, cwd})}; | ||
if (services[name].detect({ env, cwd })) { | ||
return { isCi: true, ...services[name].configuration({ env, cwd }) }; | ||
} | ||
} | ||
return {isCi: Boolean(env.CI), ...git.configuration({env, cwd})}; | ||
return { isCi: Boolean(env.CI), ...git.configuration({ env, cwd }) }; | ||
}; |
@@ -1,6 +0,6 @@ | ||
const execa = require('execa'); | ||
import { execaSync } from "execa"; | ||
function head(options) { | ||
export function head(options) { | ||
try { | ||
return execa.sync('git', ['rev-parse', 'HEAD'], options).stdout; | ||
return execaSync("git", ["rev-parse", "HEAD"], options).stdout; | ||
} catch { | ||
@@ -11,12 +11,19 @@ return undefined; | ||
function branch(options) { | ||
export function branch(options) { | ||
try { | ||
const headRef = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], options).stdout; | ||
const headRef = execaSync( | ||
"git", | ||
["rev-parse", "--abbrev-ref", "HEAD"], | ||
options | ||
).stdout; | ||
if (headRef === 'HEAD') { | ||
const branch = execa | ||
.sync('git', ['show', '-s', '--pretty=%d', 'HEAD'], options) | ||
.stdout.replace(/^\(|\)$/g, '') | ||
.split(', ') | ||
.find((branch) => branch.startsWith('origin/')); | ||
if (headRef === "HEAD") { | ||
const branch = execaSync( | ||
"git", | ||
["show", "-s", "--pretty=%d", "HEAD"], | ||
options | ||
) | ||
.stdout.replace(/^\(|\)$/g, "") | ||
.split(", ") | ||
.find((branch) => branch.startsWith("origin/")); | ||
return branch ? branch.match(/^origin\/(?<branch>.+)/)[1] : undefined; | ||
@@ -30,3 +37,1 @@ } | ||
} | ||
module.exports = {head, branch}; |
@@ -1,9 +0,9 @@ | ||
function prNumber(pr) { | ||
export function prNumber(pr) { | ||
return (/\d+(?!.*\d+)/.exec(pr) || [])[0]; | ||
} | ||
function parseBranch(branch) { | ||
return branch ? /^(?:refs\/heads\/)?(?<branch>.+)$/i.exec(branch)[1] : undefined; | ||
export function parseBranch(branch) { | ||
return branch | ||
? /^(?:refs\/heads\/)?(?<branch>.+)$/i.exec(branch)[1] | ||
: undefined; | ||
} | ||
module.exports = {prNumber, parseBranch}; |
{ | ||
"name": "env-ci", | ||
"description": "Get environment variables exposed by CI services", | ||
"version": "7.3.0", | ||
"version": "7.4.0-beta.1", | ||
"author": "Pierre Vanduynslager (https://github.com/pvdlg)", | ||
"ava": { | ||
"files": [ | ||
"test/**/*.test.js" | ||
] | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/semantic-release/env-ci/issues" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"dependencies": { | ||
"execa": "^5.0.0", | ||
"fromentries": "^1.3.2", | ||
"java-properties": "^1.0.0" | ||
"execa": "^6.1.0", | ||
"java-properties": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "4.3.1", | ||
"codecov": "3.8.3", | ||
"file-url": "3.0.0", | ||
"nyc": "15.1.0", | ||
"proxyquire": "2.1.3", | ||
"tempy": "0.7.1", | ||
"xo": "0.50.0" | ||
"ava": "^4.3.3", | ||
"c8": "^7.12.0", | ||
"file-url": "^4.0.0", | ||
"prettier": "^2.7.1", | ||
"tempy": "^3.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=12.20" | ||
"node": "^16.10 || >=18" | ||
}, | ||
@@ -36,3 +27,2 @@ "files": [ | ||
], | ||
"homepage": "https://github.com/semantic-release/env-ci#readme", | ||
"keywords": [ | ||
@@ -72,42 +62,10 @@ "appveyor", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"nyc": { | ||
"include": [ | ||
"index.js", | ||
"lib/**/*.js", | ||
"services/**/*.js" | ||
], | ||
"reporter": [ | ||
"json", | ||
"text", | ||
"html" | ||
], | ||
"all": true | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"trailingComma": "es5" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/semantic-release/env-ci.git" | ||
}, | ||
"repository": "github:semantic-release/env-ci", | ||
"scripts": { | ||
"codecov": "codecov -f coverage/coverage-final.json", | ||
"lint": "xo", | ||
"lint": "prettier --check \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{lib,services,test}/**/*.js\"", | ||
"lint:fix": "prettier --write \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{lib,services,test}/**/*.js\"", | ||
"semantic-release": "semantic-release", | ||
"test": "npm run lint && npm run test:ci", | ||
"test:ci": "nyc ava -v" | ||
"test:ci": "c8 ava --verbose" | ||
}, | ||
"xo": { | ||
"prettier": true, | ||
"space": true, | ||
"rules": { | ||
"unicorn/string-content": "off", | ||
"unicorn/prefer-module": "off" | ||
} | ||
}, | ||
"renovate": { | ||
@@ -114,0 +72,0 @@ "extends": [ |
@@ -19,6 +19,21 @@ # env-ci | ||
```js | ||
const envCi = require("env-ci"); | ||
import envCi from "env-ci"; | ||
const { name, service, isCi, branch, commit, tag, build, buildUrl, job, jobUrl, isPr, pr, prBranch, slug, root } = | ||
envCi(); | ||
const { | ||
name, | ||
service, | ||
isCi, | ||
branch, | ||
commit, | ||
tag, | ||
build, | ||
buildUrl, | ||
job, | ||
jobUrl, | ||
isPr, | ||
pr, | ||
prBranch, | ||
slug, | ||
root, | ||
} = envCi(); | ||
@@ -29,3 +44,5 @@ if (isCI) { | ||
if (isPr) { | ||
console.log(`Building Pull Request #${pr} originating from branch ${prBranch} and targeting branch ${branch}`); | ||
console.log( | ||
`Building Pull Request #${pr} originating from branch ${prBranch} and targeting branch ${branch}` | ||
); | ||
} else { | ||
@@ -32,0 +49,0 @@ console.log(`Building branch ${branch}`); |
// https://www.appveyor.com/docs/environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.APPVEYOR); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = env.APPVEYOR_PULL_REQUEST_NUMBER; | ||
@@ -12,4 +12,4 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Appveyor', | ||
service: 'appveyor', | ||
name: "Appveyor", | ||
service: "appveyor", | ||
commit: env.APPVEYOR_REPO_COMMIT, | ||
@@ -16,0 +16,0 @@ tag: env.APPVEYOR_REPO_TAG_NAME, |
// https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables | ||
// The docs indicate that SYSTEM_PULLREQUEST_SOURCEBRANCH and SYSTEM_PULLREQUEST_TARGETBRANCH are in the long format (e.g `refs/heads/master`) however tests show they are both in the short format (e.g. `master`) | ||
const {parseBranch} = require('../lib/utils.js'); | ||
import { parseBranch } from "../lib/utils.js"; | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.BUILD_BUILDURI); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = env.SYSTEM_PULLREQUEST_PULLREQUESTID; | ||
@@ -14,10 +14,14 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Azure Pipelines', | ||
service: 'azurePipelines', | ||
name: "Azure Pipelines", | ||
service: "azurePipelines", | ||
commit: env.BUILD_SOURCEVERSION, | ||
build: env.BUILD_BUILDNUMBER, | ||
branch: parseBranch(isPr ? env.SYSTEM_PULLREQUEST_TARGETBRANCH : env.BUILD_SOURCEBRANCH), | ||
branch: parseBranch( | ||
isPr ? env.SYSTEM_PULLREQUEST_TARGETBRANCH : env.BUILD_SOURCEBRANCH | ||
), | ||
pr, | ||
isPr, | ||
prBranch: parseBranch(isPr ? env.SYSTEM_PULLREQUEST_SOURCEBRANCH : undefined), | ||
prBranch: parseBranch( | ||
isPr ? env.SYSTEM_PULLREQUEST_SOURCEBRANCH : undefined | ||
), | ||
root: env.BUILD_REPOSITORY_LOCALPATH, | ||
@@ -24,0 +28,0 @@ }; |
// https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.bamboo_agentId); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
return { | ||
name: 'Bamboo', | ||
service: 'bamboo', | ||
name: "Bamboo", | ||
service: "bamboo", | ||
commit: env.bamboo_planRepository_1_revision, | ||
@@ -12,0 +12,0 @@ build: env.bamboo_buildNumber, |
// https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.BITBUCKET_BUILD_NUMBER); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
return { | ||
name: 'Bitbucket Pipelines', | ||
service: 'bitbucket', | ||
name: "Bitbucket Pipelines", | ||
service: "bitbucket", | ||
commit: env.BITBUCKET_COMMIT, | ||
@@ -12,0 +12,0 @@ tag: env.BITBUCKET_TAG, |
// https://devcenter.bitrise.io/builds/available-environment-variables/#exposed-by-bitriseio | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.BITRISE_IO); | ||
}, | ||
configuration({env}) { | ||
const pr = env.BITRISE_PULL_REQUEST === 'false' ? undefined : env.BITRISE_PULL_REQUEST; | ||
configuration({ env }) { | ||
const pr = | ||
env.BITRISE_PULL_REQUEST === "false" | ||
? undefined | ||
: env.BITRISE_PULL_REQUEST; | ||
const isPr = Boolean(pr); | ||
return { | ||
name: 'Bitrise', | ||
service: 'bitrise', | ||
name: "Bitrise", | ||
service: "bitrise", | ||
commit: env.BITRISE_GIT_COMMIT, | ||
@@ -15,0 +18,0 @@ tag: env.BITRISE_GIT_TAG, |
// https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables | ||
const {prNumber} = require('../lib/utils.js'); | ||
import { prNumber } from "../lib/utils.js"; | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.BUDDY_WORKSPACE_ID); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = prNumber(env.BUDDY_EXECUTION_PULL_REQUEST_ID); | ||
@@ -14,4 +14,4 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Buddy', | ||
service: 'buddy', | ||
name: "Buddy", | ||
service: "buddy", | ||
commit: env.BUDDY_EXECUTION_REVISION, | ||
@@ -18,0 +18,0 @@ tag: env.BUDDY_EXECUTION_TAG, |
// https://buildkite.com/docs/builds/environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.BUILDKITE); | ||
}, | ||
configuration({env}) { | ||
const pr = env.BUILDKITE_PULL_REQUEST === 'false' ? undefined : env.BUILDKITE_PULL_REQUEST; | ||
configuration({ env }) { | ||
const pr = | ||
env.BUILDKITE_PULL_REQUEST === "false" | ||
? undefined | ||
: env.BUILDKITE_PULL_REQUEST; | ||
const isPr = Boolean(pr); | ||
return { | ||
name: 'Buildkite', | ||
service: 'buildkite', | ||
name: "Buildkite", | ||
service: "buildkite", | ||
build: env.BUILDKITE_BUILD_NUMBER, | ||
@@ -18,3 +21,5 @@ buildUrl: env.BUILDKITE_BUILD_URL, | ||
tag: env.BUILDKITE_TAG, | ||
branch: isPr ? env.BUILDKITE_PULL_REQUEST_BASE_BRANCH : env.BUILDKITE_BRANCH, | ||
branch: isPr | ||
? env.BUILDKITE_PULL_REQUEST_BASE_BRANCH | ||
: env.BUILDKITE_BRANCH, | ||
slug: `${env.BUILDKITE_ORGANIZATION_SLUG}/${env.BUILDKITE_PROJECT_SLUG}`, | ||
@@ -21,0 +26,0 @@ pr, |
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables | ||
const {prNumber} = require('../lib/utils.js'); | ||
import { prNumber } from "../lib/utils.js"; | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.CIRCLECI); | ||
}, | ||
configuration({env}) { | ||
const pr = env.CIRCLE_PR_NUMBER || prNumber(env.CIRCLE_PULL_REQUEST || env.CI_PULL_REQUEST); | ||
configuration({ env }) { | ||
const pr = | ||
env.CIRCLE_PR_NUMBER || | ||
prNumber(env.CIRCLE_PULL_REQUEST || env.CI_PULL_REQUEST); | ||
const isPr = Boolean(pr); | ||
return { | ||
name: 'CircleCI', | ||
service: 'circleci', | ||
name: "CircleCI", | ||
service: "circleci", | ||
build: env.CIRCLE_BUILD_NUM, | ||
@@ -17,0 +19,0 @@ buildUrl: env.CIRCLE_BUILD_URL, |
// https://cirrus-ci.org/guide/writing-tasks/#environment-variables | ||
const CIRRUS_CI_DASHBOARD = 'https://cirrus-ci.com'; | ||
const CIRRUS_CI_DASHBOARD = "https://cirrus-ci.com"; | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.CIRRUS_CI); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = env.CIRRUS_PR; | ||
@@ -14,4 +14,4 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Cirrus CI', | ||
service: 'cirrus', | ||
name: "Cirrus CI", | ||
service: "cirrus", | ||
commit: env.CIRRUS_CHANGE_IN_REPO, | ||
@@ -18,0 +18,0 @@ tag: env.CIRRUS_TAG, |
// https://developers.cloudflare.com/pages/platform/build-configuration#environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
return env.CF_PAGES === '1'; | ||
export default { | ||
detect({ env }) { | ||
return env.CF_PAGES === "1"; | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
return { | ||
name: 'Cloudflare Pages', | ||
service: 'cloudflarePages', | ||
name: "Cloudflare Pages", | ||
service: "cloudflarePages", | ||
commit: env.CF_PAGES_COMMIT_SHA, | ||
@@ -12,0 +12,0 @@ branch: env.CF_PAGES_BRANCH, |
@@ -1,16 +0,16 @@ | ||
const {head, branch} = require('../lib/git.js'); | ||
import { head, branch } from "../lib/git.js"; | ||
// https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.CODEBUILD_BUILD_ID); | ||
}, | ||
configuration({env, cwd}) { | ||
configuration({ env, cwd }) { | ||
return { | ||
name: 'AWS CodeBuild', | ||
service: 'codebuild', | ||
commit: head({env, cwd}), | ||
name: "AWS CodeBuild", | ||
service: "codebuild", | ||
commit: head({ env, cwd }), | ||
build: env.CODEBUILD_BUILD_ID, | ||
branch: branch({env, cwd}), | ||
branch: branch({ env, cwd }), | ||
buildUrl: `https://console.aws.amazon.com/codebuild/home?region=${env.AWS_REGION}#/builds/${env.CODEBUILD_BUILD_ID}/view/new`, | ||
@@ -17,0 +17,0 @@ root: env.PWD, |
// https://codefresh.io/docs/docs/codefresh-yaml/variables#system-provided-variables | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.CF_BUILD_ID); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = env.CF_PULL_REQUEST_NUMBER; | ||
@@ -12,4 +12,4 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Codefresh', | ||
service: 'codefresh', | ||
name: "Codefresh", | ||
service: "codefresh", | ||
commit: env.CF_REVISION, | ||
@@ -16,0 +16,0 @@ build: env.CF_BUILD_ID, |
// https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables/#default-environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
return env.CI_NAME && env.CI_NAME === 'codeship'; | ||
export default { | ||
detect({ env }) { | ||
return env.CI_NAME && env.CI_NAME === "codeship"; | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
return { | ||
name: 'Codeship', | ||
service: 'codeship', | ||
name: "Codeship", | ||
service: "codeship", | ||
build: env.CI_BUILD_NUMBER, | ||
@@ -12,0 +12,0 @@ buildUrl: env.CI_BUILD_URL, |
// https://readme.drone.io/reference/environ | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.DRONE); | ||
}, | ||
configuration({env}) { | ||
const isPr = env.DRONE_BUILD_EVENT === 'pull_request'; | ||
configuration({ env }) { | ||
const isPr = env.DRONE_BUILD_EVENT === "pull_request"; | ||
return { | ||
name: 'Drone', | ||
service: 'drone', | ||
name: "Drone", | ||
service: "drone", | ||
commit: env.DRONE_COMMIT_SHA, | ||
@@ -14,0 +14,0 @@ tag: env.DRONE_TAG, |
@@ -1,7 +0,7 @@ | ||
const {head, branch} = require('../lib/git.js'); | ||
import { head, branch } from "../lib/git.js"; | ||
module.exports = { | ||
export default { | ||
configuration(options) { | ||
return {commit: head(options), branch: branch(options)}; | ||
return { commit: head(options), branch: branch(options) }; | ||
}, | ||
}; |
@@ -0,11 +1,17 @@ | ||
import { readFileSync } from "node:fs"; | ||
// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables | ||
const {parseBranch} = require('../lib/utils.js'); | ||
import { parseBranch } from "../lib/utils.js"; | ||
const getPrEvent = ({env}) => { | ||
const getPrEvent = ({ env }) => { | ||
try { | ||
const event = env.GITHUB_EVENT_PATH ? require(env.GITHUB_EVENT_PATH) : undefined; | ||
const event = env.GITHUB_EVENT_PATH | ||
? JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, "utf-8")) | ||
: undefined; | ||
if (event && event.pull_request) { | ||
return { | ||
branch: event.pull_request.base ? parseBranch(event.pull_request.base.ref) : undefined, | ||
branch: event.pull_request.base | ||
? parseBranch(event.pull_request.base.ref) | ||
: undefined, | ||
pr: event.pull_request.number, | ||
@@ -18,23 +24,30 @@ }; | ||
return {pr: undefined, branch: undefined}; | ||
return { pr: undefined, branch: undefined }; | ||
}; | ||
const getPrNumber = (env) => { | ||
const event = env.GITHUB_EVENT_PATH ? require(env.GITHUB_EVENT_PATH) : undefined; | ||
const event = env.GITHUB_EVENT_PATH | ||
? JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, "utf-8")) | ||
: undefined; | ||
return event && event.pull_request ? event.pull_request.number : undefined; | ||
}; | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.GITHUB_ACTIONS); | ||
}, | ||
configuration({env, cwd}) { | ||
const isPr = env.GITHUB_EVENT_NAME === 'pull_request' || env.GITHUB_EVENT_NAME === 'pull_request_target'; | ||
configuration({ env, cwd }) { | ||
const isPr = | ||
env.GITHUB_EVENT_NAME === "pull_request" || | ||
env.GITHUB_EVENT_NAME === "pull_request_target"; | ||
const branch = parseBranch( | ||
env.GITHUB_EVENT_NAME === 'pull_request_target' ? `refs/pull/${getPrNumber(env)}/merge` : env.GITHUB_REF | ||
env.GITHUB_EVENT_NAME === "pull_request_target" | ||
? `refs/pull/${getPrNumber(env)}/merge` | ||
: env.GITHUB_REF | ||
); | ||
return { | ||
name: 'GitHub Actions', | ||
service: 'github', | ||
name: "GitHub Actions", | ||
service: "github", | ||
commit: env.GITHUB_SHA, | ||
@@ -47,5 +60,5 @@ build: env.GITHUB_RUN_ID, | ||
root: env.GITHUB_WORKSPACE, | ||
...(isPr ? getPrEvent({env, cwd}) : undefined), | ||
...(isPr ? getPrEvent({ env, cwd }) : undefined), | ||
}; | ||
}, | ||
}; |
// https://docs.gitlab.com/ce/ci/variables/README.html | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.GITLAB_CI); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = env.CI_MERGE_REQUEST_ID; | ||
@@ -12,4 +12,4 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'GitLab CI/CD', | ||
service: 'gitlab', | ||
name: "GitLab CI/CD", | ||
service: "gitlab", | ||
commit: env.CI_COMMIT_SHA, | ||
@@ -21,3 +21,5 @@ tag: env.CI_COMMIT_TAG, | ||
jobUrl: `${env.CI_PROJECT_URL}/-/jobs/${env.CI_JOB_ID}`, | ||
branch: isPr ? env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME : env.CI_COMMIT_REF_NAME, | ||
branch: isPr | ||
? env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME | ||
: env.CI_COMMIT_REF_NAME, | ||
pr, | ||
@@ -24,0 +26,0 @@ isPr, |
@@ -1,19 +0,25 @@ | ||
const {head} = require('../lib/git.js'); | ||
import { head } from "../lib/git.js"; | ||
// https://wiki.jenkins.io/display/JENKINS/Building+a+software+project | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.JENKINS_URL); | ||
}, | ||
configuration({env, cwd}) { | ||
configuration({ env, cwd }) { | ||
const pr = env.ghprbPullId || env.gitlabMergeRequestId || env.CHANGE_ID; | ||
const isPr = Boolean(pr); | ||
const localBranch = env.GIT_LOCAL_BRANCH || env.GIT_BRANCH || env.gitlabBranch || env.BRANCH_NAME; | ||
const localBranch = | ||
env.GIT_LOCAL_BRANCH || | ||
env.GIT_BRANCH || | ||
env.gitlabBranch || | ||
env.BRANCH_NAME; | ||
return { | ||
name: 'Jenkins', | ||
service: 'jenkins', | ||
commit: env.ghprbActualCommit || env.GIT_COMMIT || head({env, cwd}), | ||
branch: isPr ? env.ghprbTargetBranch || env.gitlabTargetBranch : localBranch, | ||
name: "Jenkins", | ||
service: "jenkins", | ||
commit: env.ghprbActualCommit || env.GIT_COMMIT || head({ env, cwd }), | ||
branch: isPr | ||
? env.ghprbTargetBranch || env.gitlabTargetBranch | ||
: localBranch, | ||
build: env.BUILD_NUMBER, | ||
@@ -24,5 +30,7 @@ buildUrl: env.BUILD_URL, | ||
isPr, | ||
prBranch: isPr ? env.ghprbSourceBranch || env.gitlabSourceBranch || localBranch : undefined, | ||
prBranch: isPr | ||
? env.ghprbSourceBranch || env.gitlabSourceBranch || localBranch | ||
: undefined, | ||
}; | ||
}, | ||
}; |
// https://jetbrains.com/help/space/automation-environment-variables.html#automation | ||
const {parseBranch} = require('../lib/utils.js'); | ||
import { parseBranch } from "../lib/utils.js"; | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.JB_SPACE_EXECUTION_NUMBER); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const projectKey = env.JB_SPACE_PROJECT_KEY; | ||
const repositoryName = env.JB_SPACE_GIT_REPOSITORY_NAME; | ||
return { | ||
name: 'JetBrains Space', | ||
service: 'jetbrainsSpace', | ||
name: "JetBrains Space", | ||
service: "jetbrainsSpace", | ||
commit: env.JB_SPACE_GIT_REVISION, | ||
build: env.JB_SPACE_EXECUTION_NUMBER, | ||
branch: parseBranch(env.JB_SPACE_GIT_BRANCH), | ||
slug: projectKey && repositoryName ? `${projectKey.toLowerCase()}/${repositoryName}` : undefined, | ||
slug: | ||
projectKey && repositoryName | ||
? `${projectKey.toLowerCase()}/${repositoryName}` | ||
: undefined, | ||
}; | ||
}, | ||
}; |
// https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables | ||
module.exports = { | ||
detect({env}) { | ||
return env.NETLIFY === 'true'; | ||
export default { | ||
detect({ env }) { | ||
return env.NETLIFY === "true"; | ||
}, | ||
configuration({env}) { | ||
const isPr = env.PULL_REQUEST === 'true'; | ||
configuration({ env }) { | ||
const isPr = env.PULL_REQUEST === "true"; | ||
return { | ||
name: 'Netlify', | ||
service: 'netlify', | ||
name: "Netlify", | ||
service: "netlify", | ||
commit: env.COMMIT_REF, | ||
@@ -14,0 +14,0 @@ build: env.DEPLOY_ID, |
// https://puppet.com/docs/pipelines-for-apps/enterprise/environment-variable.html | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.DISTELLI_APPNAME); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
return { | ||
name: 'Puppet', | ||
service: 'puppet', | ||
name: "Puppet", | ||
service: "puppet", | ||
build: env.DISTELLI_BUILDNUM, | ||
@@ -12,0 +12,0 @@ buildUrl: env.DISTELLI_RELEASE, |
// https://sail.ci/docs/environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.SAILCI); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = env.SAIL_PULL_REQUEST_NUMBER; | ||
@@ -12,4 +12,4 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Sail CI', | ||
service: 'sail', | ||
name: "Sail CI", | ||
service: "sail", | ||
commit: env.SAIL_COMMIT_SHA, | ||
@@ -16,0 +16,0 @@ branch: isPr ? undefined : env.SAIL_COMMIT_BRANCH, |
// https://scrutinizer-ci.com/docs/build/environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.SCRUTINIZER); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
const pr = env.SCRUTINIZER_PR_NUMBER; | ||
@@ -12,4 +12,4 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Scrutinizer', | ||
service: 'scrutinizer', | ||
name: "Scrutinizer", | ||
service: "scrutinizer", | ||
commit: env.SCRUTINIZER_SHA1, | ||
@@ -16,0 +16,0 @@ build: env.SCRUTINIZER_INSPECTION_UUID, |
@@ -1,2 +0,2 @@ | ||
const {head} = require('../lib/git.js'); | ||
import { head } from "../lib/git.js"; | ||
@@ -6,7 +6,7 @@ // 1.0: https://semaphoreci.com/docs/available-environment-variables.html | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.SEMAPHORE); | ||
}, | ||
configuration({env, cwd}) { | ||
configuration({ env, cwd }) { | ||
const pr = env.SEMAPHORE_GIT_PR_NUMBER || env.PULL_REQUEST_NUMBER; | ||
@@ -16,5 +16,5 @@ const isPr = Boolean(pr); | ||
return { | ||
name: 'Semaphore', | ||
service: 'semaphore', | ||
commit: env.SEMAPHORE_GIT_SHA || head({env, cwd}), | ||
name: "Semaphore", | ||
service: "semaphore", | ||
commit: env.SEMAPHORE_GIT_SHA || head({ env, cwd }), | ||
tag: env.SEMAPHORE_GIT_TAG_NAME, | ||
@@ -25,3 +25,4 @@ build: env.SEMAPHORE_JOB_ID || env.SEMAPHORE_BUILD_NUMBER, | ||
isPr, | ||
prBranch: env.SEMAPHORE_GIT_PR_BRANCH || (isPr ? env.BRANCH_NAME : undefined), | ||
prBranch: | ||
env.SEMAPHORE_GIT_PR_BRANCH || (isPr ? env.BRANCH_NAME : undefined), | ||
slug: env.SEMAPHORE_GIT_REPO_SLUG || env.SEMAPHORE_REPO_SLUG, | ||
@@ -28,0 +29,0 @@ root: env.SEMAPHORE_GIT_DIR || env.SEMAPHORE_PROJECT_DIR, |
// http://docs.shippable.com/ci/env-vars/#stdEnv | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.SHIPPABLE); | ||
}, | ||
configuration({env}) { | ||
const pr = env.IS_PULL_REQUEST === 'true' ? env.PULL_REQUEST : undefined; | ||
configuration({ env }) { | ||
const pr = env.IS_PULL_REQUEST === "true" ? env.PULL_REQUEST : undefined; | ||
const isPr = Boolean(pr); | ||
return { | ||
name: 'Shippable', | ||
service: 'shippable', | ||
name: "Shippable", | ||
service: "shippable", | ||
commit: env.COMMIT, | ||
@@ -15,0 +15,0 @@ tag: env.GIT_TAG_NAME, |
// https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters | ||
const javaProperties = require('java-properties'); | ||
const fromEntries = require('fromentries'); | ||
import javaProperties from "java-properties"; | ||
const {branch} = require('../lib/git.js'); | ||
import { branch } from "../lib/git.js"; | ||
const PROPERTIES_MAPPING = {root: 'teamcity.build.workingDir', branch: 'teamcity.build.branch'}; | ||
const PROPERTIES_MAPPING = { | ||
root: "teamcity.build.workingDir", | ||
branch: "teamcity.build.branch", | ||
}; | ||
@@ -18,15 +20,23 @@ const safeReadProperties = (filePath) => { | ||
const getProperties = ({env, cwd}) => { | ||
const getProperties = ({ env, cwd }) => { | ||
const buildProperties = env.TEAMCITY_BUILD_PROPERTIES_FILE | ||
? safeReadProperties(env.TEAMCITY_BUILD_PROPERTIES_FILE) | ||
: undefined; | ||
const configFile = buildProperties ? buildProperties.get('teamcity.configuration.properties.file') : undefined; | ||
const configProperties = configFile ? safeReadProperties(configFile) : configFile; | ||
const configFile = buildProperties | ||
? buildProperties.get("teamcity.configuration.properties.file") | ||
: undefined; | ||
const configProperties = configFile | ||
? safeReadProperties(configFile) | ||
: configFile; | ||
return fromEntries( | ||
return Object.fromEntries( | ||
Object.keys(PROPERTIES_MAPPING).map((key) => [ | ||
key, | ||
(buildProperties ? buildProperties.get(PROPERTIES_MAPPING[key]) : undefined) || | ||
(configProperties ? configProperties.get(PROPERTIES_MAPPING[key]) : undefined) || | ||
(key === 'branch' ? branch({env, cwd}) : undefined), | ||
(buildProperties | ||
? buildProperties.get(PROPERTIES_MAPPING[key]) | ||
: undefined) || | ||
(configProperties | ||
? configProperties.get(PROPERTIES_MAPPING[key]) | ||
: undefined) || | ||
(key === "branch" ? branch({ env, cwd }) : undefined), | ||
]) | ||
@@ -36,16 +46,16 @@ ); | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.TEAMCITY_VERSION); | ||
}, | ||
configuration({env, cwd}) { | ||
configuration({ env, cwd }) { | ||
return { | ||
name: 'TeamCity', | ||
service: 'teamcity', | ||
name: "TeamCity", | ||
service: "teamcity", | ||
commit: env.BUILD_VCS_NUMBER, | ||
build: env.BUILD_NUMBER, | ||
slug: env.TEAMCITY_BUILDCONF_NAME, | ||
...getProperties({env, cwd}), | ||
...getProperties({ env, cwd }), | ||
}; | ||
}, | ||
}; |
// https://docs.travis-ci.com/user/environment-variables#default-environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.TRAVIS); | ||
}, | ||
configuration({env}) { | ||
const pr = env.TRAVIS_PULL_REQUEST === 'false' ? undefined : env.TRAVIS_PULL_REQUEST; | ||
configuration({ env }) { | ||
const pr = | ||
env.TRAVIS_PULL_REQUEST === "false" ? undefined : env.TRAVIS_PULL_REQUEST; | ||
const isPr = Boolean(pr); | ||
return { | ||
name: 'Travis CI', | ||
service: 'travis', | ||
name: "Travis CI", | ||
service: "travis", | ||
commit: env.TRAVIS_COMMIT, | ||
@@ -15,0 +16,0 @@ tag: env.TRAVIS_TAG, |
// https://go-vela.github.io/docs/reference/environment/variables/ | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.VELA); | ||
}, | ||
configuration({env}) { | ||
const isPr = env.VELA_BUILD_EVENT === 'pull_request'; | ||
configuration({ env }) { | ||
const isPr = env.VELA_BUILD_EVENT === "pull_request"; | ||
return { | ||
name: 'Vela', | ||
service: 'vela', | ||
name: "Vela", | ||
service: "vela", | ||
branch: isPr ? env.VELA_PULL_REQUEST_TARGET : env.VELA_BUILD_BRANCH, | ||
@@ -14,0 +14,0 @@ commit: env.VELA_BUILD_COMMIT, |
// https://vercel.com/docs/environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.VERCEL) || Boolean(env.NOW_GITHUB_DEPLOYMENT); | ||
}, | ||
configuration({env}) { | ||
const name = 'Vercel'; | ||
const service = 'vercel'; | ||
configuration({ env }) { | ||
const name = "Vercel"; | ||
const service = "vercel"; | ||
@@ -11,0 +11,0 @@ if (env.VERCEL) { |
// http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name | ||
module.exports = { | ||
detect({env}) { | ||
export default { | ||
detect({ env }) { | ||
return Boolean(env.WERCKER_MAIN_PIPELINE_STARTED); | ||
}, | ||
configuration({env}) { | ||
configuration({ env }) { | ||
return { | ||
name: 'Wercker', | ||
service: 'wercker', | ||
name: "Wercker", | ||
service: "wercker", | ||
commit: env.WERCKER_GIT_COMMIT, | ||
@@ -12,0 +12,0 @@ build: env.WERCKER_MAIN_PIPELINE_STARTED, |
// https://woodpecker-ci.org/docs/usage/environment#built-in-environment-variables | ||
module.exports = { | ||
detect({env}) { | ||
return env.CI && env.CI === 'woodpecker'; | ||
export default { | ||
detect({ env }) { | ||
return env.CI && env.CI === "woodpecker"; | ||
}, | ||
configuration({env}) { | ||
const isPr = env.CI_BUILD_EVENT === 'pull_request'; | ||
configuration({ env }) { | ||
const isPr = env.CI_BUILD_EVENT === "pull_request"; | ||
return { | ||
name: 'Woodpecker CI', | ||
service: 'woodpecker', | ||
name: "Woodpecker CI", | ||
service: "woodpecker", | ||
commit: env.CI_COMMIT_SHA, | ||
@@ -14,0 +14,0 @@ tag: env.CI_COMMIT_TAG, |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
51509
2
5
873
198
2
Yes
1
2
+ Addedexeca@6.1.0(transitive)
+ Addedhuman-signals@3.0.1(transitive)
+ Addedis-stream@3.0.0(transitive)
+ Addedmimic-fn@4.0.0(transitive)
+ Addednpm-run-path@5.3.0(transitive)
+ Addedonetime@6.0.0(transitive)
+ Addedpath-key@4.0.0(transitive)
+ Addedstrip-final-newline@3.0.0(transitive)
- Removedfromentries@^1.3.2
- Removedexeca@5.1.1(transitive)
- Removedfromentries@1.3.2(transitive)
- Removedhuman-signals@2.1.0(transitive)
- Removedis-stream@2.0.1(transitive)
- Removedmimic-fn@2.1.0(transitive)
- Removednpm-run-path@4.0.1(transitive)
- Removedonetime@5.1.2(transitive)
- Removedstrip-final-newline@2.0.0(transitive)
Updatedexeca@^6.1.0
Updatedjava-properties@^1.0.2