mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Upgrade @actions/* dependencies (#123)
* Upgrade `@actions/*` dependencies * bumps deps again * add changeset
This commit is contained in:
+3
-4
@@ -1,5 +1,4 @@
|
||||
import { exec } from "@actions/exec";
|
||||
import { execWithOutput } from "./utils";
|
||||
import { exec, getExecOutput } from "@actions/exec";
|
||||
|
||||
export const setupUser = async () => {
|
||||
await exec("git", [
|
||||
@@ -35,7 +34,7 @@ export const pushTags = async () => {
|
||||
};
|
||||
|
||||
export const switchToMaybeExistingBranch = async (branch: string) => {
|
||||
let { stderr } = await execWithOutput("git", ["checkout", branch], {
|
||||
let { stderr } = await getExecOutput("git", ["checkout", branch], {
|
||||
ignoreReturnCode: true,
|
||||
});
|
||||
let isCreatingBranch = !stderr
|
||||
@@ -59,6 +58,6 @@ export const commitAll = async (message: string) => {
|
||||
};
|
||||
|
||||
export const checkIfClean = async (): Promise<boolean> => {
|
||||
const { stdout } = await execWithOutput("git", ["status", "--porcelain"]);
|
||||
const { stdout } = await getExecOutput("git", ["status", "--porcelain"]);
|
||||
return !stdout.length;
|
||||
};
|
||||
|
||||
+3
-1
@@ -30,7 +30,9 @@ let mockedGithubMethods = {
|
||||
createRelease: jest.fn(),
|
||||
},
|
||||
};
|
||||
(github.getOctokit as any).mockImplementation(() => mockedGithubMethods);
|
||||
(github.getOctokit as any).mockImplementation(() => ({
|
||||
rest: mockedGithubMethods,
|
||||
}));
|
||||
|
||||
let f = fixturez(__dirname);
|
||||
|
||||
|
||||
+8
-9
@@ -1,4 +1,4 @@
|
||||
import { exec } from "@actions/exec";
|
||||
import { exec, getExecOutput } from "@actions/exec";
|
||||
import * as github from "@actions/github";
|
||||
import fs from "fs-extra";
|
||||
import { getPackages, Package } from "@manypkg/get-packages";
|
||||
@@ -7,7 +7,6 @@ import * as semver from "semver";
|
||||
import { PreState } from "@changesets/types";
|
||||
import {
|
||||
getChangelogEntry,
|
||||
execWithOutput,
|
||||
getChangedPackages,
|
||||
sortTheThings,
|
||||
getVersionsByDirectory,
|
||||
@@ -40,14 +39,14 @@ const createRelease = async (
|
||||
);
|
||||
}
|
||||
|
||||
await octokit.repos.createRelease({
|
||||
await octokit.rest.repos.createRelease({
|
||||
name: tagName,
|
||||
tag_name: tagName,
|
||||
body: changelogEntry.content,
|
||||
prerelease: pkg.packageJson.version.includes("-"),
|
||||
...github.context.repo,
|
||||
});
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
// if we can't find a changelog, the user has probably disabled changelogs
|
||||
if (err.code !== "ENOENT") {
|
||||
throw err;
|
||||
@@ -82,7 +81,7 @@ export async function runPublish({
|
||||
let octokit = github.getOctokit(githubToken);
|
||||
let [publishCommand, ...publishArgs] = script.split(/\s+/);
|
||||
|
||||
let changesetPublishOutput = await execWithOutput(
|
||||
let changesetPublishOutput = await getExecOutput(
|
||||
publishCommand,
|
||||
publishArgs,
|
||||
{ cwd }
|
||||
@@ -165,7 +164,7 @@ export async function runPublish({
|
||||
const requireChangesetsCliPkgJson = (cwd: string) => {
|
||||
try {
|
||||
return require(resolveFrom(cwd, "@changesets/cli/package.json"));
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
if (err && err.code === "MODULE_NOT_FOUND") {
|
||||
throw new Error(
|
||||
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`
|
||||
@@ -292,7 +291,7 @@ export async function runVersion({
|
||||
}
|
||||
|
||||
let searchQuery = `repo:${repo}+state:open+head:${versionBranch}+base:${branch}+is:pull-request`;
|
||||
let searchResultPromise = octokit.search.issuesAndPullRequests({
|
||||
let searchResultPromise = octokit.rest.search.issuesAndPullRequests({
|
||||
q: searchQuery,
|
||||
});
|
||||
let changedPackages = await getChangedPackages(cwd, versionsByDirectory);
|
||||
@@ -342,7 +341,7 @@ export async function runVersion({
|
||||
|
||||
if (searchResult.data.items.length === 0) {
|
||||
console.log("creating pull request");
|
||||
const { data: newPullRequest } = await octokit.pulls.create({
|
||||
const { data: newPullRequest } = await octokit.rest.pulls.create({
|
||||
base: branch,
|
||||
head: versionBranch,
|
||||
title: finalPrTitle,
|
||||
@@ -357,7 +356,7 @@ export async function runVersion({
|
||||
const [pullRequest] = searchResult.data.items;
|
||||
|
||||
console.log(`updating found pull request #${pullRequest.number}`);
|
||||
await octokit.pulls.update({
|
||||
await octokit.rest.pulls.update({
|
||||
pull_number: pullRequest.number,
|
||||
title: finalPrTitle,
|
||||
body: prBody,
|
||||
|
||||
@@ -87,32 +87,6 @@ export function getChangelogEntry(changelog: string, version: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function execWithOutput(
|
||||
command: string,
|
||||
args?: string[],
|
||||
options?: { ignoreReturnCode?: boolean; cwd?: string }
|
||||
) {
|
||||
let myOutput = "";
|
||||
let myError = "";
|
||||
|
||||
return {
|
||||
code: await exec(command, args, {
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
myOutput += data.toString();
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
myError += data.toString();
|
||||
},
|
||||
},
|
||||
|
||||
...options,
|
||||
}),
|
||||
stdout: myOutput,
|
||||
stderr: myError,
|
||||
};
|
||||
}
|
||||
|
||||
export function sortTheThings(
|
||||
a: { private: boolean; highestLevel: number },
|
||||
b: { private: boolean; highestLevel: number }
|
||||
|
||||
Reference in New Issue
Block a user