Skip to content

Commit 4ddbccb

Browse files
author
Luca Forstner
committed
.
1 parent 62c316c commit 4ddbccb

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,40 @@ export function normalizeUserOptions(userOptions: UserOptions) {
4141
};
4242

4343
if (options.release.setCommits === undefined) {
44-
options.release.setCommits = {
45-
// @ts-expect-error This is fine
46-
auto: true,
47-
isDefault: true,
44+
if (
45+
process.env["VERCEL"] &&
46+
process.env["VERCEL_GIT_COMMIT_SHA"] &&
47+
process.env["VERCEL_GIT_REPO_SLUG"] &&
48+
process.env["VERCEL_GIT_REPO_OWNER"]
49+
) {
50+
options.release.setCommits = {
51+
// @ts-expect-error This is fine
52+
shouldNotThrowOnFailure: true,
53+
commit: process.env["VERCEL_GIT_COMMIT_SHA"],
54+
previousCommit: process.env["VERCEL_GIT_PREVIOUS_SHA"],
55+
repo: `${process.env["VERCEL_GIT_REPO_OWNER"]}/${process.env["VERCEL_GIT_REPO_SLUG"]}`,
56+
ignoreEmpty: true,
57+
ignoreMissing: true,
58+
};
59+
} else {
60+
options.release.setCommits = {
61+
shouldNotThrowOnFailure: true,
62+
// @ts-expect-error This is fine
63+
auto: true,
64+
ignoreEmpty: true,
65+
ignoreMissing: true,
66+
};
67+
}
68+
}
69+
70+
if (
71+
options.release.deploy === undefined &&
72+
process.env["VERCEL"] &&
73+
process.env["VERCEL_TARGET_ENV"]
74+
) {
75+
options.release.deploy = {
76+
env: `vercel-${process.env["VERCEL_TARGET_ENV"]}`,
77+
url: process.env["VERCEL_URL"] ? `https://${process.env["VERCEL_URL"]}` : undefined,
4878
};
4979
}
5080

packages/bundler-plugin-core/src/plugins/release-management.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ export function releaseManagementPlugin({
9191
try {
9292
await cliInstance.releases.setCommits(releaseName, setCommitsOption);
9393
} catch (e) {
94-
// isDefault being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo
95-
if (!("isDefault" in setCommitsOption)) {
94+
// shouldNotThrowOnFailure being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo
95+
if (!("shouldNotThrowOnFailure" in setCommitsOption)) {
9696
throw e;
9797
} else {
9898
logger.debug(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("normalizeUserOptions()", () => {
2525
uploadLegacySourcemaps: "./out",
2626
setCommits: {
2727
auto: true,
28-
isDefault: true,
28+
shouldNotThrowOnFailure: true,
2929
},
3030
},
3131
silent: false,
@@ -80,7 +80,7 @@ describe("normalizeUserOptions()", () => {
8080
},
8181
setCommits: {
8282
auto: true,
83-
isDefault: true,
83+
shouldNotThrowOnFailure: true,
8484
},
8585
},
8686
silent: false,

0 commit comments

Comments
 (0)