diff --git a/.changeset/serious-olives-add.md b/.changeset/serious-olives-add.md new file mode 100644 index 00000000..100f80c1 --- /dev/null +++ b/.changeset/serious-olives-add.md @@ -0,0 +1,14 @@ +--- +"@codecov/bundler-plugin-core": minor +"@codecov/bundle-analyzer": minor +"@codecov/nextjs-webpack-plugin": minor +"@codecov/nuxt-plugin": minor +"@codecov/remix-vite-plugin": minor +"@codecov/rollup-plugin": minor +"@codecov/solidstart-plugin": minor +"@codecov/sveltekit-plugin": minor +"@codecov/vite-plugin": minor +"@codecov/webpack-plugin": minor +--- + +Add in debug logs for each param for each provider for better debugging. diff --git a/examples/bundle-analyzer-cli/package.json b/examples/bundle-analyzer-cli/package.json index 185f79b4..6b8e2ce8 100644 --- a/examples/bundle-analyzer-cli/package.json +++ b/examples/bundle-analyzer-cli/package.json @@ -18,7 +18,7 @@ }, "type": "module", "scripts": { - "build": "rollup -c && pnpm bundle-analyzer ./dist --bundle-name=@codecov/example-bundle-analyzer-cli --upload-token=$BUNDLE_ANALYZER_UPLOAD_TOKEN --config-file=./baconfig.json" + "build": "rollup -c && pnpm bundle-analyzer ./dist -v --bundle-name=@codecov/example-bundle-analyzer-cli --upload-token=$BUNDLE_ANALYZER_UPLOAD_TOKEN --api-url=$BUNDLE_ANALYZER_API_URL --config-file=./baconfig.json" }, "devDependencies": { "@codecov/bundle-analyzer": "workspace:^", diff --git a/examples/bundle-analyzer-lib-cjs/analyze.js b/examples/bundle-analyzer-lib-cjs/analyze.js index b4ed3246..87f24aed 100644 --- a/examples/bundle-analyzer-lib-cjs/analyze.js +++ b/examples/bundle-analyzer-lib-cjs/analyze.js @@ -6,7 +6,7 @@ const coreOpts = { dryRun: false, uploadToken: process.env.BUNDLE_ANALYZER_UPLOAD_TOKEN, retryCount: 3, - apiUrl: "https://api.codecov.io", + apiUrl: process.env.BUNDLE_ANALYZER_API_URL, bundleName: "@codecov/example-bundle-analyzer-cjs", enableBundleAnalysis: true, debug: true, diff --git a/examples/bundle-analyzer-lib-esm/analyze.ts b/examples/bundle-analyzer-lib-esm/analyze.ts index a8f9fe72..593d85a1 100644 --- a/examples/bundle-analyzer-lib-esm/analyze.ts +++ b/examples/bundle-analyzer-lib-esm/analyze.ts @@ -10,7 +10,7 @@ const coreOpts: Options = { dryRun: false, uploadToken: process.env.BUNDLE_ANALYZER_UPLOAD_TOKEN, retryCount: 3, - apiUrl: "https://api.codecov.io", + apiUrl: process.env.BUNDLE_ANALYZER_API_URL, bundleName: "@codecov/example-bundle-analyzer-esm", enableBundleAnalysis: true, debug: true, diff --git a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts index 6467be66..6ae81f19 100644 --- a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts +++ b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts @@ -22,6 +22,7 @@ export const fetchWithRetry = async ({ try { debug(`Attempting to fetch ${name}, attempt: ${i + 1}`); await delay(DEFAULT_RETRY_DELAY * i); + response = await fetch(url, requestData); if (!response.ok) { @@ -33,7 +34,7 @@ export const fetchWithRetry = async ({ const isLastAttempt = i + 1 === retryCount; if (isLastAttempt) { - red(`${name} failed after ${i} attempts`); + red(`${name} failed after ${i + 1} attempts`); if (!(err instanceof BadResponseError)) { throw err; diff --git a/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts b/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts index 0bb51c9b..cc26ca35 100644 --- a/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts +++ b/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts @@ -95,6 +95,7 @@ export const getPreSignedURL = async ({ let response: Response; try { + const body = preProcessBody(requestBody); response = await fetchWithRetry({ retryCount, url: `${apiUrl}${API_ENDPOINT}`, @@ -102,7 +103,7 @@ export const getPreSignedURL = async ({ requestData: { method: "POST", headers: headers, - body: JSON.stringify(preProcessBody(requestBody)), + body: JSON.stringify(body), }, }); } catch (e) { diff --git a/packages/bundler-plugin-core/src/utils/providers/AppVeyorCI.ts b/packages/bundler-plugin-core/src/utils/providers/AppVeyorCI.ts index a001226f..6c7f844d 100644 --- a/packages/bundler-plugin-core/src/utils/providers/AppVeyorCI.ts +++ b/packages/bundler-plugin-core/src/utils/providers/AppVeyorCI.ts @@ -13,56 +13,87 @@ export function detect(envs: ProviderEnvs): boolean { ); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.APPVEYOR_JOB_ID ?? null; + + const build = envs?.APPVEYOR_BUILD_ID ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { const { envs } = inputs; + let buildUrl: string | null = null; + if ( envs?.APPVEYOR_URL && envs?.APPVEYOR_REPO_NAME && envs?.APPVEYOR_BUILD_ID && envs?.APPVEYOR_JOB_ID ) { - return `${envs?.APPVEYOR_URL}/project/${envs?.APPVEYOR_REPO_NAME}/builds/${envs?.APPVEYOR_BUILD_ID}/job/${envs?.APPVEYOR_JOB_ID}`; + buildUrl = `${envs?.APPVEYOR_URL}/project/${envs?.APPVEYOR_REPO_NAME}/builds/${envs?.APPVEYOR_BUILD_ID}/job/${envs?.APPVEYOR_JOB_ID}`; } - return null; + + debug(`Using build URL: ${buildUrl}`, { enabled: output.debug }); + return buildUrl; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.APPVEYOR_REPO_BRANCH ?? null; + const branch = envs?.APPVEYOR_REPO_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { +function _getJob( + envs: ProviderEnvs, + output: Output, +): ProviderServiceParams["job"] { + let job: string | null = null; + if ( envs?.APPVEYOR_ACCOUNT_NAME && envs?.APPVEYOR_PROJECT_SLUG && envs?.APPVEYOR_BUILD_VERSION ) { - return `${envs?.APPVEYOR_ACCOUNT_NAME}/${envs?.APPVEYOR_PROJECT_SLUG}/${envs?.APPVEYOR_BUILD_VERSION}`; + job = `${envs.APPVEYOR_ACCOUNT_NAME}/${envs.APPVEYOR_PROJECT_SLUG}/${envs.APPVEYOR_BUILD_VERSION}`; } - return null; + + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using PR number: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.APPVEYOR_PULL_REQUEST_NUMBER ?? null; + + const pr = envs?.APPVEYOR_PULL_REQUEST_NUMBER ?? null; + debug(`Using PR number: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -86,19 +117,24 @@ function _getSHA( const commitSha = envs?.APPVEYOR_PULL_REQUEST_HEAD_COMMIT ?? envs?.APPVEYOR_REPO_COMMIT; - debug(`Using commit: ${commitSha ?? ""}`, { - enabled: output.debug, - }); + debug(`Using commit: ${commitSha}`, { enabled: output.debug }); return commitSha ?? null; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return envs?.APPVEYOR_REPO_NAME ?? null; + + const slug = envs?.APPVEYOR_REPO_NAME ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -107,14 +143,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs.envs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/AzurePipelines.ts b/packages/bundler-plugin-core/src/utils/providers/AzurePipelines.ts index f44193cb..b223ec18 100644 --- a/packages/bundler-plugin-core/src/utils/providers/AzurePipelines.ts +++ b/packages/bundler-plugin-core/src/utils/providers/AzurePipelines.ts @@ -12,54 +12,78 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.SYSTEM_TEAMFOUNDATIONSERVERURI); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.BUILD_BUILDNUMBER ?? null; + + const build = envs?.BUILD_BUILDNUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { const { envs } = inputs; + let buildURL: string | null = null; if (envs?.SYSTEM_TEAMPROJECT && envs?.BUILD_BUILDID) { - return `${envs?.SYSTEM_TEAMFOUNDATIONSERVERURI}${envs?.SYSTEM_TEAMPROJECT}/_build/results?buildId=${envs?.BUILD_BUILDID}`; + buildURL = `${envs?.SYSTEM_TEAMFOUNDATIONSERVERURI}${envs?.SYSTEM_TEAMPROJECT}/_build/results?buildId=${envs?.BUILD_BUILDID}`; } - return null; + debug(`Using build URL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } + let branch: string | null = null; if (envs?.BUILD_SOURCEBRANCH) { - return envs?.BUILD_SOURCEBRANCH.toString().replace("refs/heads/", ""); + branch = envs?.BUILD_SOURCEBRANCH.toString().replace("refs/heads/", ""); } - return null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { - return envs?.BUILD_BUILDID ?? null; +function _getJob( + envs: ProviderEnvs, + output: Output, +): ProviderServiceParams["job"] { + const job = envs?.BUILD_BUILDID ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using PR: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return ( + const pr = envs?.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER ?? envs?.SYSTEM_PULLREQUEST_PULLREQUESTID ?? - null - ); + null; + debug(`Using PR: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -84,7 +108,7 @@ function _getSHA( let commit = envs?.BUILD_SOURCEVERSION ?? null; - if (_getPR(inputs)) { + if (_getPR(inputs, output)) { const mergeCommitRegex = /^[a-z0-9]{40} [a-z0-9]{40}$/; const mergeCommitMessage = childProcess .execFileSync("git", ["show", "--no-patch", "--format=%P"]) @@ -105,20 +129,24 @@ function _getSHA( } } - debug(`Using commit: ${commit}`, { - enabled: output.debug, - }); - + debug(`Using commit: ${commit}`, { enabled: output.debug }); return commit; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return envs?.BUILD_REPOSITORY_NAME ?? parseSlugFromRemoteAddr("") ?? null; + const slug = + envs?.BUILD_REPOSITORY_NAME ?? parseSlugFromRemoteAddr("") ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -127,14 +155,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs.envs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Bitbucket.ts b/packages/bundler-plugin-core/src/utils/providers/Bitbucket.ts index 55beb4b3..bfbec37d 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Bitbucket.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Bitbucket.ts @@ -12,39 +12,61 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.CI) && Boolean(envs?.BITBUCKET_BUILD_NUMBER); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.BITBUCKET_BUILD_NUMBER ?? null; + const build = envs?.BITBUCKET_BUILD_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { // TODO: https://github.com/codecov/uploader/issues/267 + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args?.branch !== "") { + debug(`Using branch: ${args?.branch}`, { enabled: output.debug }); return args?.branch; } - return envs?.BITBUCKET_BRANCH ?? null; + const branch = envs?.BITBUCKET_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { - return envs?.BITBUCKET_BUILD_NUMBER ?? null; +function _getJob( + envs: ProviderEnvs, + output: Output, +): ProviderServiceParams["job"] { + const job = envs?.BITBUCKET_BUILD_NUMBER ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using PR: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.BITBUCKET_PR_ID ?? null; + const pr = envs?.BITBUCKET_PR_ID ?? null; + debug(`Using PR: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -74,12 +96,18 @@ function _getSHA( return commit ?? null; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return envs?.BITBUCKET_REPO_FULL_NAME ?? null; + const slug = envs?.BITBUCKET_REPO_FULL_NAME ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -88,14 +116,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs.envs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Bitrise.ts b/packages/bundler-plugin-core/src/utils/providers/Bitrise.ts index f48a0776..a808435c 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Bitrise.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Bitrise.ts @@ -11,41 +11,59 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.CI) && Boolean(envs?.BITRISE_IO); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { return args.build; } - return envs?.BITRISE_BUILD_NUMBER ?? null; + const build = envs?.BITRISE_BUILD_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { const { envs } = inputs; - return envs?.BITRISE_BUILD_URL ?? null; + const buildURL = envs?.BITRISE_BUILD_URL ?? null; + debug(`Using buildURL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { return args.branch; } - return envs?.BITRISE_GIT_BRANCH ?? null; + const branch = envs?.BITRISE_GIT_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.BITRISE_PULL_REQUEST ?? null; + const pr = envs?.BITRISE_PULL_REQUEST ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -73,12 +91,18 @@ function _getSHA( return envs?.GIT_CLONE_COMMIT_HASH ?? null; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return parseSlugFromRemoteAddr("") ?? null; + const slug = parseSlugFromRemoteAddr("") ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -87,14 +111,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Buildkite.ts b/packages/bundler-plugin-core/src/utils/providers/Buildkite.ts index d179e13e..18423414 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Buildkite.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Buildkite.ts @@ -11,37 +11,63 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.BUILDKITE); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.BUILDKITE_BUILD_NUMBER ?? null; + const build = envs?.BUILDKITE_BUILD_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { - return inputs.envs?.BUILDKITE_BUILD_URL ?? null; + const { envs } = inputs; + const buildURL = envs?.BUILDKITE_BUILD_URL ?? null; + debug(`Using buildURL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.BUILDKITE_BRANCH ?? null; + + const branch = envs?.BUILDKITE_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { - return envs?.BUILDKITE_JOB_ID ?? null; +function _getJob( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["job"] { + const { envs } = inputs; + const job = envs?.BUILDKITE_JOB_ID ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + const pr = args?.pr ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } export function _getService(): ProviderServiceParams["service"] { @@ -68,13 +94,18 @@ function _getSHA( return envs?.BUILDKITE_COMMIT ?? null; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; - return setSlug( + const slug = setSlug( args?.slug, envs?.BUILDKITE_ORGANIZATION_SLUG, envs?.BUILDKITE_PIPELINE_SLUG, ); + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -83,14 +114,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/CircleCI.ts b/packages/bundler-plugin-core/src/utils/providers/CircleCI.ts index 953ab389..aa96ca5c 100644 --- a/packages/bundler-plugin-core/src/utils/providers/CircleCI.ts +++ b/packages/bundler-plugin-core/src/utils/providers/CircleCI.ts @@ -11,19 +11,28 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.CI) && Boolean(envs?.CIRCLECI); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.CIRCLE_BUILD_NUM ?? null; + const build = envs?.CIRCLE_BUILD_NUM ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { - return inputs.envs?.CIRCLE_BUILD_URL ?? null; + const buildURL = inputs.envs?.CIRCLE_BUILD_URL ?? null; + debug(`Using buildURL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } // This is the value that gets passed to the Codecov uploader @@ -38,13 +47,16 @@ export function getServiceName(): string { function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - - return envs?.CIRCLE_BRANCH ?? null; + const branch = envs?.CIRCLE_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } function _getSHA( @@ -61,31 +73,46 @@ function _getSHA( return envs?.CIRCLE_SHA1 ?? null; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; - const slug = setSlug( + let slug = setSlug( args?.slug, envs?.CIRCLE_PROJECT_USERNAME, envs?.CIRCLE_PROJECT_REPONAME, ); if (envs?.CIRCLE_REPOSITORY_URL && envs?.CIRCLE_REPOSITORY_URL !== "") { - return `${envs?.CIRCLE_REPOSITORY_URL?.split(":")[1]?.split(".git")[0]}`; + slug = `${envs?.CIRCLE_REPOSITORY_URL?.split(":")[1]?.split(".git")[0]}`; } + debug(`Using slug: ${slug}`, { enabled: output.debug }); return slug; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.CIRCLE_PR_NUMBER ?? null; + const pr = envs?.CIRCLE_PR_NUMBER ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { - return envs?.CIRCLE_NODE_INDEX ?? null; +function _getJob( + envs: ProviderEnvs, + output: Output, +): ProviderServiceParams["job"] { + const job = envs?.CIRCLE_NODE_INDEX ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } // eslint-disable-next-line @typescript-eslint/require-await @@ -94,14 +121,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs.envs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Cirrus.ts b/packages/bundler-plugin-core/src/utils/providers/Cirrus.ts index 125895f4..e0a1e054 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Cirrus.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Cirrus.ts @@ -11,38 +11,55 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.CIRRUS_CI); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.CIRRUS_BUILD_ID ?? null; + const build = envs?.CIRRUS_BUILD_ID ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.CIRRUS_BRANCH ?? null; + const branch = envs?.CIRRUS_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { return envs?.CIRRUS_TASK_ID ?? null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.CIRRUS_PR ?? null; + const pr = envs?.CIRRUS_PR ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -67,9 +84,18 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; - return setSlug(args?.slug, envs?.CIRRUS_REPO_OWNER, envs?.CIRRUS_REPO_NAME); + const slug = setSlug( + args?.slug, + envs?.CIRRUS_REPO_OWNER, + envs?.CIRRUS_REPO_NAME, + ); + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -78,14 +104,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), job: _getJob(inputs.envs), - pr: _getPR(inputs), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/CloudflarePages.ts b/packages/bundler-plugin-core/src/utils/providers/CloudflarePages.ts index 826a908f..308cfbac 100644 --- a/packages/bundler-plugin-core/src/utils/providers/CloudflarePages.ts +++ b/packages/bundler-plugin-core/src/utils/providers/CloudflarePages.ts @@ -10,32 +10,54 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.CF_PAGES); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args } = inputs; - return args?.build ?? null; + if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); + return args.build; + } + debug(`Using build: ${null}`, { enabled: output.debug }); + return null; } -function _getBuildURL() { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.CF_PAGES_BRANCH ?? null; + + const branch = envs?.CF_PAGES_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; + } + return null; } function _getService(): ProviderServiceParams["service"] { @@ -62,9 +84,17 @@ function _getSHA( return envs?.CF_PAGES_COMMIT_SHA ?? null; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args } = inputs; - return args?.slug ?? null; + if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); + return args.slug; + } + debug(`Using slug: ${null}`, { enabled: output.debug }); + return null; } // eslint-disable-next-line @typescript-eslint/require-await @@ -73,14 +103,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/CodeBuild.ts b/packages/bundler-plugin-core/src/utils/providers/CodeBuild.ts index 057ecc5b..b6decf58 100644 --- a/packages/bundler-plugin-core/src/utils/providers/CodeBuild.ts +++ b/packages/bundler-plugin-core/src/utils/providers/CodeBuild.ts @@ -10,44 +10,68 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.CODEBUILD_CI); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.CODEBUILD_BUILD_ID ?? null; + const build = envs?.CODEBUILD_BUILD_ID ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.CODEBUILD_WEBHOOK_HEAD_REF + + const branch = envs?.CODEBUILD_WEBHOOK_HEAD_REF ? envs?.CODEBUILD_WEBHOOK_HEAD_REF.replace(/^refs\/heads\//, "") : null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { - return envs?.CODEBUILD_BUILD_ID ?? null; +function _getJob( + envs: ProviderEnvs, + output: Output, +): ProviderServiceParams["job"] { + const job = envs?.CODEBUILD_BUILD_ID ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.CODEBUILD_SOURCE_VERSION && + const pr = + envs?.CODEBUILD_SOURCE_VERSION && envs?.CODEBUILD_SOURCE_VERSION.startsWith("pr/") - ? envs?.CODEBUILD_SOURCE_VERSION.replace(/^pr\//, "") - : null; + ? envs?.CODEBUILD_SOURCE_VERSION.replace(/^pr\//, "") + : null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -73,17 +97,23 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args?.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args?.slug; } - return envs?.CODEBUILD_SOURCE_REPO_URL + const slug = envs?.CODEBUILD_SOURCE_REPO_URL ? envs?.CODEBUILD_SOURCE_REPO_URL.toString() .replace(/^.*github.com\//, "") // lgtm [js/incomplete-hostname-regexp] - We want this to match all subdomains. .replace(/\.git$/, "") : null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -92,14 +122,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs.envs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Drone.ts b/packages/bundler-plugin-core/src/utils/providers/Drone.ts index 3474445e..bcc9b05f 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Drone.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Drone.ts @@ -10,46 +10,65 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.DRONE); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.DRONE_BUILD_NUMBER ?? null; + const build = envs?.DRONE_BUILD_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { const { envs } = inputs; - return ( + const buildURL = envs?.DRONE_BUILD_LINK ?? envs?.DRONE_BUILD_URL ?? envs?.CI_BUILD_URL ?? - null - ); + null; + debug(`Using buildURL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { - return args?.branch; + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); + return args.branch; } - return envs?.DRONE_BRANCH ?? null; + const branch = envs?.DRONE_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { - return args?.pr; + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; } - return envs?.DRONE_PULL_REQUEST ?? null; + const pr = envs?.DRONE_PULL_REQUEST ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -75,12 +94,19 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args?.slug !== "") { - return args?.slug; + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); + return args.slug; } - return envs?.DRONE_REPO ?? null; + + const slug = envs?.DRONE_REPO ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -89,14 +115,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/GitHubActions.ts b/packages/bundler-plugin-core/src/utils/providers/GitHubActions.ts index 9fa433ec..a13e6027 100644 --- a/packages/bundler-plugin-core/src/utils/providers/GitHubActions.ts +++ b/packages/bundler-plugin-core/src/utils/providers/GitHubActions.ts @@ -13,18 +13,28 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.GITHUB_ACTIONS); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.GITHUB_RUN_ID ?? null; + const build = envs?.GITHUB_RUN_ID ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -async function _getJobURL(inputs: ProviderUtilInputs): Promise { +async function _getJobURL( + inputs: ProviderUtilInputs, + output: Output, +): Promise { const url = `https://api.github.com/repos/${_getSlug( inputs, - )}/actions/runs/${_getBuild(inputs)}/jobs`; + output, + )}/actions/runs/${_getBuild(inputs, output)}/jobs`; const res = await fetch(url, { headers: { "User-Agent": "Awesome-Octocat-App", @@ -32,6 +42,7 @@ async function _getJobURL(inputs: ProviderUtilInputs): Promise { }); if (res.status !== 200) { + debug(`Failed to get job URL: ${res.status}`, { enabled: output.debug }); return null; } @@ -54,34 +65,42 @@ async function _getJobURL(inputs: ProviderUtilInputs): Promise { "html_url" in job && typeof job?.html_url === "string" ) { + debug(`Using job URL: ${job?.html_url}`, { enabled: output.debug }); return job?.html_url; } } } + debug(`Using job URL: ${null}`, { enabled: output.debug }); return null; } async function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): Promise { const { envs } = inputs; - const url = await _getJobURL(inputs); + const url = await _getJobURL(inputs, output); if (url !== null) { return url; } - return `${envs?.GITHUB_SERVER_URL}/${_getSlug( + const buildUrl = `${envs?.GITHUB_SERVER_URL}/${_getSlug( inputs, - )}/actions/runs/${_getBuild(inputs)}`; + output, + )}/actions/runs/${_getBuild(inputs, output)}`; + debug(`Using build URL: ${buildUrl}`, { enabled: output.debug }); + return buildUrl; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } @@ -110,16 +129,26 @@ function _getBranch( branch = isFork ? payload.pull_request.head.label : branch; } + debug(`Using branch: ${branch ?? null}`, { enabled: output.debug }); return branch ?? null; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { - return envs?.GITHUB_WORKFLOW ?? null; +function _getJob( + envs: ProviderEnvs, + output: Output, +): ProviderServiceParams["job"] { + const job = envs?.GITHUB_WORKFLOW ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } @@ -131,6 +160,7 @@ function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { match = matches[1]; } } + debug(`Using pr: ${match ?? null}`, { enabled: output.debug }); return match ?? null; } @@ -153,7 +183,6 @@ function _getSHA( } const context = GitHub.context; - let commit = envs?.GITHUB_SHA; if (["pull_request", " pull_request_target"].includes(context.eventName)) { const payload = context.payload as PullRequestEvent; @@ -161,7 +190,6 @@ function _getSHA( } debug(`Using commit: ${commit ?? null}`, { enabled: output.debug }); - return commit ?? null; } @@ -182,17 +210,24 @@ function _getCompareSHA( compareSha = payload.pull_request.base.sha; } - debug(`Using compareSha: ${compareSha ?? null}`, { enabled: output.debug }); + debug(`Using compareSha: ${compareSha}`, { enabled: output.debug }); - return compareSha ?? null; + return compareSha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return envs?.GITHUB_REPOSITORY ?? null; + + const slug = envs?.GITHUB_REPOSITORY ?? null; + debug(`Using slug: ${slug ?? null}`, { enabled: output.debug }); + return slug ?? null; } export async function getServiceParams( @@ -200,15 +235,15 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: await _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: await _getBuildURL(inputs, output), commit: _getSHA(inputs, output), compareSha: _getCompareSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs.envs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/GitLabCI.ts b/packages/bundler-plugin-core/src/utils/providers/GitLabCI.ts index c6f2613d..3ec39801 100644 --- a/packages/bundler-plugin-core/src/utils/providers/GitLabCI.ts +++ b/packages/bundler-plugin-core/src/utils/providers/GitLabCI.ts @@ -11,35 +11,55 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.GITLAB_CI); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.CI_BUILD_ID ?? envs?.CI_JOB_ID ?? null; + const build = envs?.CI_BUILD_ID ?? envs?.CI_JOB_ID ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.CI_BUILD_REF_NAME ?? envs?.CI_COMMIT_REF_NAME ?? null; + const branch = envs?.CI_BUILD_REF_NAME ?? envs?.CI_COMMIT_REF_NAME ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; + } + debug(`Using pr: ${null}`, { enabled: output.debug }); + return null; } function _getService(): ProviderServiceParams["service"] { @@ -69,13 +89,21 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args?.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args?.slug; } + const remoteAddr = envs?.CI_BUILD_REPO ?? envs?.CI_REPOSITORY_URL ?? ""; - return envs?.CI_PROJECT_PATH ?? parseSlugFromRemoteAddr(remoteAddr) ?? null; + const slug = + envs?.CI_PROJECT_PATH ?? parseSlugFromRemoteAddr(remoteAddr) ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -84,14 +112,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/HerokuCI.ts b/packages/bundler-plugin-core/src/utils/providers/HerokuCI.ts index e3fc716c..097c39a3 100644 --- a/packages/bundler-plugin-core/src/utils/providers/HerokuCI.ts +++ b/packages/bundler-plugin-core/src/utils/providers/HerokuCI.ts @@ -11,35 +11,54 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.CI) && Boolean(envs?.HEROKU_TEST_RUN_BRANCH); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { return args.build; } - return envs?.HEROKU_TEST_RUN_ID ?? null; + const build = envs?.HEROKU_TEST_RUN_ID ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.HEROKU_TEST_RUN_BRANCH ?? null; + const branch = envs?.HEROKU_TEST_RUN_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; + } + debug(`Using pr: ${null}`, { enabled: output.debug }); + return null; } function _getService(): ProviderServiceParams["service"] { @@ -65,12 +84,18 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args?.slug; } - return parseSlugFromRemoteAddr(""); + const slug = parseSlugFromRemoteAddr(""); + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -79,14 +104,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/JenkinsCI.ts b/packages/bundler-plugin-core/src/utils/providers/JenkinsCI.ts index 29ed4fdf..220da326 100644 --- a/packages/bundler-plugin-core/src/utils/providers/JenkinsCI.ts +++ b/packages/bundler-plugin-core/src/utils/providers/JenkinsCI.ts @@ -11,47 +11,67 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.JENKINS_URL); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.BUILD_NUMBER ?? null; + const build = envs?.BUILD_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { const { envs } = inputs; - return envs?.BUILD_URL ? envs?.BUILD_URL : null; + const buildURL = envs?.BUILD_URL ? envs?.BUILD_URL : null; + debug(`Using buildURL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return ( + + const branch = envs?.ghprbSourceBranch ?? envs?.CHANGE_BRANCH ?? envs?.GIT_BRANCH ?? envs?.BRANCH_NAME ?? - null - ); + null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.ghprbPullId ?? envs?.CHANGE_ID ?? null; + const pr = envs?.ghprbPullId ?? envs?.CHANGE_ID ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -80,12 +100,18 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args } = inputs; if (args?.slug && args?.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args?.slug; } - return parseSlugFromRemoteAddr(""); + const slug = parseSlugFromRemoteAddr(""); + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -94,14 +120,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Local.ts b/packages/bundler-plugin-core/src/utils/providers/Local.ts index 73bd6b93..f3a721b3 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Local.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Local.ts @@ -13,21 +13,32 @@ export function detect(): boolean { return isProgramInstalled("git"); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args } = inputs; - return args?.build ?? null; + let build: string | null = null; + if (args?.build && args?.build !== "") { + build = args.build; + } + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; const branch = args?.branch ?? envs?.GIT_BRANCH ?? envs?.BRANCH_NAME ?? null; if (branch !== "") { + debug(`Using branch: ${branch}`, { enabled: output.debug }); return branch; } @@ -37,6 +48,7 @@ function _getBranch( "--abbrev-ref", "HEAD", ]); + debug(`Using branch: ${branchName}`, { enabled: output.debug }); return branchName; } catch (error) { throw new Error( @@ -45,18 +57,27 @@ function _getBranch( } } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + let pr: string | null = null; + if (args?.pr && args?.pr !== "") { + pr = args.pr; + } + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } // This is the value that gets passed to the Codecov uploader function _getService(): ProviderServiceParams["service"] { - return ""; + return "local"; } // This is the name that gets printed @@ -86,9 +107,13 @@ function _getSHA( } } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args } = inputs; if (args?.slug && args?.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } @@ -99,7 +124,9 @@ function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { "remote.origin.url", ]); - return parseSlug(slug); + const parsedSlug = parseSlug(slug); + debug(`Using slug: ${parsedSlug}`, { enabled: output.debug }); + return parsedSlug; } catch (error) { throw new Error(`There was an error getting the slug from git: ${error}`); } @@ -111,14 +138,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Netlify.ts b/packages/bundler-plugin-core/src/utils/providers/Netlify.ts index 74bd9cbe..478a151c 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Netlify.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Netlify.ts @@ -10,35 +10,55 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.NETLIFY); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.BUILD_ID ?? null; + const build = envs?.BUILD_ID ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args?.branch; } - return envs?.BRANCH ?? null; + const branch = envs?.BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args?.pr; + } + debug(`Using pr: ${null}`, { enabled: output.debug }); + return null; } function _getService(): ProviderServiceParams["service"] { @@ -64,9 +84,17 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args } = inputs; - return args?.slug ?? null; + if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); + return args.slug; + } + debug(`Using slug: ${null}`, { enabled: output.debug }); + return null; } // eslint-disable-next-line @typescript-eslint/require-await @@ -75,14 +103,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Render.ts b/packages/bundler-plugin-core/src/utils/providers/Render.ts index 34c89503..8c54832b 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Render.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Render.ts @@ -10,32 +10,54 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.RENDER); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args } = inputs; - return args?.build ?? null; + if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); + return args.build; + } + debug(`Using build: ${null}`, { enabled: output.debug }); + return null; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.RENDER_GIT_BRANCH ?? null; + const branch = envs?.RENDER_GIT_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; + } + debug(`Using pr: ${null}`, { enabled: output.debug }); + return null; } function _getService(): ProviderServiceParams["service"] { @@ -61,12 +83,18 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args?.slug !== "") { - return args?.slug; + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); + return args.slug; } - return envs?.RENDER_GIT_REPO_SLUG ?? null; + const slug = envs?.RENDER_GIT_REPO_SLUG ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -75,14 +103,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/TeamCity.ts b/packages/bundler-plugin-core/src/utils/providers/TeamCity.ts index 630ae5e9..e44c55d3 100644 --- a/packages/bundler-plugin-core/src/utils/providers/TeamCity.ts +++ b/packages/bundler-plugin-core/src/utils/providers/TeamCity.ts @@ -11,7 +11,8 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.TEAMCITY_VERSION); } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } @@ -27,12 +28,16 @@ export function getServiceName(): string { function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.BRANCH_NAME ?? null; + const branch = envs?.BRANCH_NAME ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } function _getSHA( @@ -50,28 +55,49 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return parseSlugFromRemoteAddr("") ?? null; + const slug = parseSlugFromRemoteAddr("") ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.BUILD_NUMBER ?? null; + const build = envs?.BUILD_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; + } + debug(`Using pr: ${null}`, { enabled: output.debug }); + return null; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } @@ -81,14 +107,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/TravisCI.ts b/packages/bundler-plugin-core/src/utils/providers/TravisCI.ts index 26e9ff00..1bc03930 100644 --- a/packages/bundler-plugin-core/src/utils/providers/TravisCI.ts +++ b/packages/bundler-plugin-core/src/utils/providers/TravisCI.ts @@ -14,23 +14,32 @@ export function detect(envs: ProviderEnvs): boolean { ); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.TRAVIS_JOB_NUMBER ?? null; + const build = envs?.TRAVIS_JOB_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } @@ -38,19 +47,31 @@ function _getBranch( if (envs?.TRAVIS_BRANCH !== envs?.TRAVIS_TAG) { branch = envs?.TRAVIS_PULL_REQUEST_BRANCH ?? envs?.TRAVIS_BRANCH ?? null; } + debug(`Using branch: ${branch}`, { enabled: output.debug }); return branch; } -function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] { - return envs?.TRAVIS_JOB_ID ?? null; +function _getJob( + envs: ProviderEnvs, + output: Output, +): ProviderServiceParams["job"] { + const job = envs?.TRAVIS_JOB_ID ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.TRAVIS_PULL_REQUEST ?? null; + const pr = envs?.TRAVIS_PULL_REQUEST ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -75,12 +96,18 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return envs?.TRAVIS_REPO_SLUG ?? null; + const slug = envs?.TRAVIS_REPO_SLUG ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -89,14 +116,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(inputs.envs), - pr: _getPR(inputs), + job: _getJob(inputs.envs, output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Vercel.ts b/packages/bundler-plugin-core/src/utils/providers/Vercel.ts index f101866d..ab48ca0f 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Vercel.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Vercel.ts @@ -13,32 +13,54 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.VERCEL); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args } = inputs; - return args?.build ?? null; + if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); + return args.build; + } + debug(`Using build: ${null}`, { enabled: output.debug }); + return null; } -function _getBuildURL(): ProviderServiceParams["buildURL"] { +function _getBuildURL(output: Output): ProviderServiceParams["buildURL"] { + debug(`Using buildURL: ${null}`, { enabled: output.debug }); return null; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.VERCEL_GIT_COMMIT_REF ?? null; + const branch = envs?.VERCEL_GIT_COMMIT_REF ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; + } + debug(`Using pr: ${null}`, { enabled: output.debug }); + return null; } function _getService(): ProviderServiceParams["service"] { @@ -63,9 +85,13 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } @@ -75,7 +101,7 @@ function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { if (owner && repo) { slug = `${owner}/${repo}`; } - + debug(`Using slug: ${slug}`, { enabled: output.debug }); return slug; } @@ -85,14 +111,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Wercker.ts b/packages/bundler-plugin-core/src/utils/providers/Wercker.ts index 0e8ec17e..5119bc1b 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Wercker.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Wercker.ts @@ -11,38 +11,60 @@ export function detect(envs: ProviderEnvs): boolean { return Boolean(envs?.WERCKER_MAIN_PIPELINE_STARTED); } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.WERCKER_MAIN_PIPELINE_STARTED ?? null; + const build = envs?.WERCKER_MAIN_PIPELINE_STARTED ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { const { envs } = inputs; - return envs?.WERCKER_BUILD_URL ?? null; + const buildURL = envs?.WERCKER_BUILD_URL ?? null; + debug(`Using buildURL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - return envs?.WERCKER_GIT_BRANCH ?? null; + const branch = envs?.WERCKER_GIT_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(): ProviderServiceParams["job"] { +function _getJob(output: Output): ProviderServiceParams["job"] { + debug(`Using job: ${null}`, { enabled: output.debug }); return null; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args } = inputs; - return args?.pr ?? null; + if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); + return args.pr; + } + debug(`Using pr: ${null}`, { enabled: output.debug }); + return null; } function _getService(): ProviderServiceParams["service"] { @@ -67,13 +89,23 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; - return setSlug( + if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); + return args.slug; + } + + const slug = setSlug( args?.slug, envs?.WERCKER_GIT_OWNER, envs?.WERCKER_GIT_REPOSITORY, ); + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -82,14 +114,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - job: _getJob(), - pr: _getPR(inputs), + job: _getJob(output), + pr: _getPR(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/Woodpecker.ts b/packages/bundler-plugin-core/src/utils/providers/Woodpecker.ts index 4cb54c00..355ea604 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Woodpecker.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Woodpecker.ts @@ -10,43 +10,67 @@ export function detect(envs: ProviderEnvs): boolean { return envs?.CI === "woodpecker"; } -function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] { +function _getBuild( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["build"] { const { args, envs } = inputs; if (args?.build && args.build !== "") { + debug(`Using build: ${args.build}`, { enabled: output.debug }); return args.build; } - return envs?.CI_BUILD_NUMBER ?? null; + const build = envs?.CI_BUILD_NUMBER ?? null; + debug(`Using build: ${build}`, { enabled: output.debug }); + return build; } function _getBuildURL( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["buildURL"] { const { envs } = inputs; - return envs?.CI_BUILD_LINK ?? null; + const buildURL = envs?.CI_BUILD_LINK ?? null; + debug(`Using buildURL: ${buildURL}`, { enabled: output.debug }); + return buildURL; } function _getBranch( inputs: ProviderUtilInputs, + output: Output, ): ProviderServiceParams["branch"] { const { args, envs } = inputs; if (args?.branch && args.branch !== "") { + debug(`Using branch: ${args.branch}`, { enabled: output.debug }); return args.branch; } - - return envs?.CI_COMMIT_SOURCE_BRANCH ?? envs?.CI_COMMIT_BRANCH ?? null; + const branch = + envs?.CI_COMMIT_SOURCE_BRANCH ?? envs?.CI_COMMIT_BRANCH ?? null; + debug(`Using branch: ${branch}`, { enabled: output.debug }); + return branch; } -function _getJob(inputs: ProviderUtilInputs): ProviderServiceParams["job"] { +function _getJob( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["job"] { const { envs } = inputs; - return envs?.CI_JOB_NUMBER ?? null; + const job = envs?.CI_JOB_NUMBER ?? null; + debug(`Using job: ${job}`, { enabled: output.debug }); + return job; } -function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] { +function _getPR( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["pr"] { const { args, envs } = inputs; if (args?.pr && args.pr !== "") { + debug(`Using pr: ${args.pr}`, { enabled: output.debug }); return args.pr; } - return envs?.CI_COMMIT_PULL_REQUEST ?? null; + const pr = envs?.CI_COMMIT_PULL_REQUEST ?? null; + debug(`Using pr: ${pr}`, { enabled: output.debug }); + return pr; } function _getService(): ProviderServiceParams["service"] { @@ -71,12 +95,18 @@ function _getSHA( return sha; } -function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] { +function _getSlug( + inputs: ProviderUtilInputs, + output: Output, +): ProviderServiceParams["slug"] { const { args, envs } = inputs; if (args?.slug && args.slug !== "") { + debug(`Using slug: ${args.slug}`, { enabled: output.debug }); return args.slug; } - return envs?.CI_REPO ?? null; + const slug = envs?.CI_REPO ?? null; + debug(`Using slug: ${slug}`, { enabled: output.debug }); + return slug; } // eslint-disable-next-line @typescript-eslint/require-await @@ -85,14 +115,14 @@ export async function getServiceParams( output: Output, ): Promise { return { - branch: _getBranch(inputs), - build: _getBuild(inputs), - buildURL: _getBuildURL(inputs), + branch: _getBranch(inputs, output), + build: _getBuild(inputs, output), + buildURL: _getBuildURL(inputs, output), commit: _getSHA(inputs, output), - pr: _getPR(inputs), - job: _getJob(inputs), + pr: _getPR(inputs, output), + job: _getJob(inputs, output), service: _getService(), - slug: _getSlug(inputs), + slug: _getSlug(inputs, output), }; } diff --git a/packages/bundler-plugin-core/src/utils/providers/__tests__/AppVeyorCI.test.ts b/packages/bundler-plugin-core/src/utils/providers/__tests__/AppVeyorCI.test.ts index 6c5f6669..132b6a9c 100644 --- a/packages/bundler-plugin-core/src/utils/providers/__tests__/AppVeyorCI.test.ts +++ b/packages/bundler-plugin-core/src/utils/providers/__tests__/AppVeyorCI.test.ts @@ -72,7 +72,7 @@ describe("AppveyorCI Params", () => { }; const expected: ProviderServiceParams = { branch: "main", - build: "1", + build: "2", buildURL: "https://appveyor.com/project/testOrg/testRepo/builds/2/job/1", commit: "testingsha", job: "testOrg/testRepo/3", @@ -114,7 +114,7 @@ describe("AppveyorCI Params", () => { }; const expected: ProviderServiceParams = { branch: "main", - build: "1", + build: "2", buildURL: "https://appveyor.com/project/testOrg/testRepo/builds/2/job/1", commit: "testingsha", job: "testOrg/testRepo/3", diff --git a/packages/bundler-plugin-core/src/utils/providers/__tests__/Local.test.ts b/packages/bundler-plugin-core/src/utils/providers/__tests__/Local.test.ts index a8bc17a4..d75ca300 100644 --- a/packages/bundler-plugin-core/src/utils/providers/__tests__/Local.test.ts +++ b/packages/bundler-plugin-core/src/utils/providers/__tests__/Local.test.ts @@ -58,7 +58,7 @@ describe("Local Params", () => { commit: "testingsha", job: null, pr: "1", - service: "", + service: "local", slug: "owner/repo", }; @@ -96,7 +96,7 @@ describe("Local Params", () => { commit: "testingsha", job: null, pr: "1", - service: "", + service: "local", slug: "owner/repo", };