mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Use GitHub API for pushes by default and require explicit github-token when using custom tokens (#692)
* Ensure `github-token` wins for `git-cli` pushes * more shenanigans * Default to GitHub API commit mode * e2e auth tests * push missing utils * rename input * refactor * refactor * refactor * refactor * refactor * refactor * reuse helpers * refactor * refactor * simplify * add tests * refactor * improve comments * shift helper * add comments * extract test helpers * update docs and changesets * update one thing
This commit is contained in:
@@ -119,6 +119,22 @@ export function isErrorWithCode(err: unknown, code: string) {
|
||||
);
|
||||
}
|
||||
|
||||
export type WithAsyncDispose<T> = T & {
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
};
|
||||
|
||||
export function moveDisposable<T extends object>(
|
||||
stack: AsyncDisposableStack,
|
||||
value: T,
|
||||
): WithAsyncDispose<T> {
|
||||
const moved = stack.move();
|
||||
return Object.assign(value, {
|
||||
async [Symbol.asyncDispose]() {
|
||||
await moved.disposeAsync();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function getOptionalInput(name: string) {
|
||||
// normalize empty string default return value of `core.getInput` to undefined
|
||||
return core.getInput(name) || undefined;
|
||||
@@ -130,6 +146,23 @@ export function getRequiredInput(name: string) {
|
||||
return core.getInput(name, { required: true });
|
||||
}
|
||||
|
||||
export function throwOnRemovedCommitModeInput() {
|
||||
for (const inputName of ["commit-mode", "commitMode"]) {
|
||||
const value = getOptionalInput(inputName);
|
||||
if (value === undefined) continue;
|
||||
|
||||
const migration =
|
||||
value === "git-cli"
|
||||
? 'Replace it with "push-with-git-cli: true".'
|
||||
: value === "github-api"
|
||||
? 'Remove it or replace it with "push-with-git-cli: false"; GitHub API pushes are now the default.'
|
||||
: 'Set "push-with-git-cli" to true for Git CLI pushes or false for GitHub API pushes.';
|
||||
throw new Error(
|
||||
`The "${inputName}" input has been replaced by the boolean "push-with-git-cli" input. ${migration}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function throwOnRenamedInputs(renames: Record<string, string>) {
|
||||
const references: Record<string, string> = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user