Skip to content

Commit 153f684

Browse files
authored
feat: Add in debug option, and log out short sha for commit being uploaded (#117)
Add in bundler plugin config option to enable debug level logs.
1 parent ff552dc commit 153f684

File tree

10 files changed

+28
-1
lines changed

10 files changed

+28
-1
lines changed

.changeset/popular-chicken-confess.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@codecov/bundler-plugin-core": patch
3+
"@codecov/webpack-plugin": patch
4+
"@codecov/rollup-plugin": patch
5+
"@codecov/vite-plugin": patch
6+
---
7+
8+
Add in debug option that will enable more in-depth logs

packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe("bundleAnalysisPluginFactory", () => {
1010
enableBundleAnalysis: true,
1111
retryCount: 3,
1212
uploadToken: "test-token",
13+
debug: false,
1314
},
1415
bundleAnalysisUploadPlugin: () => ({
1516
version: "1",

packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getPreSignedURL } from "../utils/getPreSignedURL.ts";
99
import { type NormalizedOptions } from "../utils/normalizeOptions.ts";
1010
import { detectProvider } from "../utils/provider.ts";
1111
import { uploadStats } from "../utils/uploadStats.ts";
12+
import { debug } from "../utils/logging.ts";
1213

1314
interface BundleAnalysisUploadPluginArgs {
1415
options: NormalizedOptions;
@@ -55,6 +56,10 @@ export const bundleAnalysisPluginFactory = ({
5556
const inputs: ProviderUtilInputs = { envs, args };
5657
const provider = await detectProvider(inputs);
5758

59+
if (options.debug) {
60+
debug(`Uploading stats for commit: ${provider.commit.slice(0, 7)}`);
61+
}
62+
5863
let url = "";
5964
try {
6065
url = await getPreSignedURL({

packages/bundler-plugin-core/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ export interface Options {
105105

106106
/** Override values for passing custom information to API. */
107107
uploadOverrides?: UploadOverrides;
108+
109+
/** Option to enable debug logs for the plugin. */
110+
debug?: boolean;
108111
}
109112

110113
export type BundleAnalysisUploadPlugin = (

packages/bundler-plugin-core/src/utils/__tests__/normalizeOptions.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const tests: Test[] = [
2828
dryRun: false,
2929
retryCount: 3,
3030
enableBundleAnalysis: false,
31+
debug: false,
3132
},
3233
},
3334
},
@@ -48,6 +49,7 @@ const tests: Test[] = [
4849
slug: "test-slug",
4950
pr: "1234",
5051
},
52+
debug: true,
5153
},
5254
},
5355
expected: {
@@ -66,6 +68,7 @@ const tests: Test[] = [
6668
slug: "test-slug",
6769
pr: "1234",
6870
},
71+
debug: true,
6972
},
7073
},
7174
},

packages/bundler-plugin-core/src/utils/normalizeOptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ const optionsSchemaFactory = (options: Options) =>
8080
.string({ invalid_type_error: "`uploadToken` must be a string." })
8181
.optional(),
8282
uploadOverrides: UploadOverridesSchema.optional(),
83+
debug: z
84+
.boolean({
85+
invalid_type_error: "`debug` must be a boolean.",
86+
})
87+
.default(false),
8388
});
8489

8590
interface NormalizedOptionsFailure {

packages/bundler-plugin-core/src/utils/providers/GitHubActions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ function _getSHA(inputs: ProviderUtilInputs): string {
126126
const mergeCommit = mergeCommitMessage.split(" ")[1];
127127

128128
commit = mergeCommit;
129-
} else if (mergeCommitMessage === "") {
130129
}
131130
}
132131

packages/rollup-plugin/src/rollup-bundle-analysis/__tests__/rollupBundleAnalysisPlugin.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("rollupBundleAnalysisPlugin", () => {
1313
dryRun: true,
1414
enableBundleAnalysis: true,
1515
retryCount: 1,
16+
debug: false,
1617
},
1718
});
1819

packages/vite-plugin/src/vite-bundle-analysis/__tests__/viteBundleAnalysisPlugin.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("viteBundleAnalysisPlugin", () => {
1313
dryRun: true,
1414
enableBundleAnalysis: true,
1515
retryCount: 1,
16+
debug: false,
1617
},
1718
});
1819

packages/webpack-plugin/src/webpack-bundle-analysis/__tests__/webpackBundleAnalysisPlugin.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("webpackBundleAnalysisPlugin", () => {
1313
dryRun: true,
1414
enableBundleAnalysis: true,
1515
retryCount: 1,
16+
debug: false,
1617
},
1718
});
1819

0 commit comments

Comments
 (0)