Skip to content

Commit b6e9f34

Browse files
authored
ref(core): Remove customHeader conversion in internal options (#98)
Previously, we coverted the user-facing `customHeader` option, typed as string to an internal option typed `Record<string, string>`. This was handy for adding the header to our outgoing API requests. Since we don't do these ourselves anymore but rely on Sentry CLI, it's just easier to pass this option through to the CLI which also expects the string representation.
1 parent 8a7fa93 commit b6e9f34

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

packages/bundler-plugin-core/src/options-mapping.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ type RequiredInternalOptions = Required<
2020
>;
2121

2222
type OptionalInternalOptions = Partial<
23-
Pick<UserOptions, "dist" | "errorHandler" | "setCommits" | "deploy" | "configFile">
23+
Pick<
24+
UserOptions,
25+
"dist" | "errorHandler" | "setCommits" | "deploy" | "configFile" | "customHeader"
26+
>
2427
>;
2528

2629
type NormalizedInternalOptions = {
2730
entries: (string | RegExp)[] | ((filePath: string) => boolean) | undefined;
2831
include: InternalIncludeEntry[];
29-
customHeader: Record<string, string>;
3032
};
3133

3234
export type InternalOptions = RequiredInternalOptions &
@@ -84,7 +86,7 @@ export function normalizeUserOptions(userOptions: UserOptions): InternalOptions
8486
finalize: userOptions.finalize ?? true,
8587
validate: userOptions.validate ?? false,
8688
vcsRemote: userOptions.vcsRemote ?? "origin",
87-
customHeader: normalizeCustomHeader(userOptions.customHeader),
89+
customHeader: userOptions.customHeader,
8890
dryRun: userOptions.dryRun ?? false,
8991
debug: userOptions.debug ?? false,
9092
silent: userOptions.silent ?? false,
@@ -134,13 +136,3 @@ function normalizeIncludeEntry(
134136
rewrite: includeEntry.rewrite ?? userOptions.rewrite ?? true,
135137
};
136138
}
137-
138-
function normalizeCustomHeader(
139-
userCustomHeader: UserOptions["customHeader"]
140-
): InternalOptions["customHeader"] {
141-
if (!userCustomHeader || !userCustomHeader.includes(":")) {
142-
return {};
143-
}
144-
const [key, value] = userCustomHeader.split(/:(.*)/, 2).map((s) => s.trim()) as [string, string];
145-
return { [key]: value };
146-
}

packages/bundler-plugin-core/src/sentry/cli.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ export type SentryCLILike = SentryCli | SentryDryRunCLI;
1212
* that makes no-ops out of most CLI operations
1313
*/
1414
export function getSentryCli(internalOptions: InternalOptions, logger: Logger): SentryCLILike {
15+
const { silent, org, project, authToken, url, vcsRemote, customHeader } = internalOptions;
1516
const cli = new SentryCli(internalOptions.configFile, {
16-
silent: internalOptions.silent,
17-
org: internalOptions.org,
18-
project: internalOptions.project,
19-
authToken: internalOptions.authToken,
20-
url: internalOptions.url,
21-
vcsRemote: internalOptions.vcsRemote,
17+
silent,
18+
org,
19+
project,
20+
authToken,
21+
url,
22+
vcsRemote,
23+
customHeader,
2224
});
2325

2426
if (internalOptions.dryRun) {

packages/bundler-plugin-core/test/option-mappings.test.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ describe("normalizeUserOptions()", () => {
1414
expect(normalizeUserOptions(userOptions)).toEqual({
1515
authToken: "my-auth-token",
1616
cleanArtifacts: false,
17-
customHeader: {},
1817
debug: false,
1918
dryRun: false,
2019
finalize: true,
@@ -58,7 +57,6 @@ describe("normalizeUserOptions()", () => {
5857
expect(normalizeUserOptions(userOptions)).toEqual({
5958
authToken: "my-auth-token",
6059
cleanArtifacts: false,
61-
customHeader: {},
6260
debug: false,
6361
dryRun: false,
6462
finalize: true,
@@ -82,19 +80,4 @@ describe("normalizeUserOptions()", () => {
8280
vcsRemote: "origin",
8381
});
8482
});
85-
86-
test("should convert string customHeader to internal representation", () => {
87-
const userOptions: Options = {
88-
org: "my-org",
89-
project: "my-project",
90-
authToken: "my-auth-token",
91-
release: "my-release",
92-
include: "dist",
93-
customHeader: "customKey: CustomValue",
94-
};
95-
96-
expect(normalizeUserOptions(userOptions)).toEqual(
97-
expect.objectContaining({ customHeader: { customKey: "CustomValue" } })
98-
);
99-
});
10083
});

0 commit comments

Comments
 (0)