mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
fmt
This commit is contained in:
+15
-17
@@ -28,7 +28,7 @@ const MAX_CHARACTERS_PER_MESSAGE = 60000;
|
|||||||
|
|
||||||
const createRelease = async (
|
const createRelease = async (
|
||||||
octokit: Octokit,
|
octokit: Octokit,
|
||||||
{ pkg, tagName }: { pkg: Package; tagName: string },
|
{ pkg, tagName }: { pkg: Package; tagName: string }
|
||||||
) => {
|
) => {
|
||||||
let changelog;
|
let changelog;
|
||||||
try {
|
try {
|
||||||
@@ -45,7 +45,7 @@ const createRelease = async (
|
|||||||
// we can find a changelog but not the entry for this version
|
// we can find a changelog but not the entry for this version
|
||||||
// if this is true, something has probably gone wrong
|
// if this is true, something has probably gone wrong
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Could not find changelog entry for ${pkg.packageJson.name}@${pkg.packageJson.version}`,
|
`Could not find changelog entry for ${pkg.packageJson.name}@${pkg.packageJson.version}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ export async function runPublish({
|
|||||||
let changesetPublishOutput = await getExecOutput(
|
let changesetPublishOutput = await getExecOutput(
|
||||||
publishCommand,
|
publishCommand,
|
||||||
publishArgs,
|
publishArgs,
|
||||||
{ cwd, env: { ...process.env, GITHUB_TOKEN: githubToken } },
|
{ cwd, env: { ...process.env, GITHUB_TOKEN: githubToken } }
|
||||||
);
|
);
|
||||||
|
|
||||||
let { packages, tool } = await getPackages(cwd);
|
let { packages, tool } = await getPackages(cwd);
|
||||||
@@ -111,7 +111,7 @@ export async function runPublish({
|
|||||||
if (pkg === undefined) {
|
if (pkg === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Package "${pkgName}" not found.` +
|
`Package "${pkgName}" not found.` +
|
||||||
"This is probably a bug in the action, please open an issue",
|
"This is probably a bug in the action, please open an issue"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
releasedPackages.push(pkg);
|
releasedPackages.push(pkg);
|
||||||
@@ -123,14 +123,14 @@ export async function runPublish({
|
|||||||
const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`;
|
const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`;
|
||||||
await git.pushTag(tagName);
|
await git.pushTag(tagName);
|
||||||
await createRelease(octokit, { pkg, tagName });
|
await createRelease(octokit, { pkg, tagName });
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (packages.length === 0) {
|
if (packages.length === 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No package found.` +
|
`No package found.` +
|
||||||
"This is probably a bug in the action, please open an issue",
|
"This is probably a bug in the action, please open an issue"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let pkg = packages[0];
|
let pkg = packages[0];
|
||||||
@@ -166,16 +166,14 @@ export async function runPublish({
|
|||||||
|
|
||||||
const requireChangesetsCliPkgJson = (cwd: string) => {
|
const requireChangesetsCliPkgJson = (cwd: string) => {
|
||||||
try {
|
try {
|
||||||
return require(
|
return require(require.resolve("@changesets/cli/package.json", {
|
||||||
require.resolve("@changesets/cli/package.json", {
|
paths: [cwd],
|
||||||
paths: [cwd],
|
}));
|
||||||
}),
|
|
||||||
);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (isErrorWithCode(err, "MODULE_NOT_FOUND")) {
|
if (isErrorWithCode(err, "MODULE_NOT_FOUND")) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`,
|
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`,
|
||||||
{ cause: err },
|
{ cause: err }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
@@ -311,7 +309,7 @@ export async function runVersion({
|
|||||||
{
|
{
|
||||||
cwd,
|
cwd,
|
||||||
env,
|
env,
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +318,7 @@ export async function runVersion({
|
|||||||
changedPackages.map(async (pkg) => {
|
changedPackages.map(async (pkg) => {
|
||||||
let changelogContents = await fs.readFile(
|
let changelogContents = await fs.readFile(
|
||||||
path.join(pkg.dir, "CHANGELOG.md"),
|
path.join(pkg.dir, "CHANGELOG.md"),
|
||||||
"utf8",
|
"utf8"
|
||||||
);
|
);
|
||||||
|
|
||||||
let entry = getChangelogEntry(changelogContents, pkg.packageJson.version);
|
let entry = getChangelogEntry(changelogContents, pkg.packageJson.version);
|
||||||
@@ -330,7 +328,7 @@ export async function runVersion({
|
|||||||
content: entry.content,
|
content: entry.content,
|
||||||
header: `## ${pkg.packageJson.name}@${pkg.packageJson.version}`,
|
header: `## ${pkg.packageJson.name}@${pkg.packageJson.version}`,
|
||||||
};
|
};
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const finalPrTitle = `${prTitle}${!!preState ? ` (${preState.tag})` : ""}`;
|
const finalPrTitle = `${prTitle}${!!preState ? ` (${preState.tag})` : ""}`;
|
||||||
@@ -355,8 +353,8 @@ export async function runVersion({
|
|||||||
`Existing pull requests: ${JSON.stringify(
|
`Existing pull requests: ${JSON.stringify(
|
||||||
existingPullRequests.data,
|
existingPullRequests.data,
|
||||||
null,
|
null,
|
||||||
2,
|
2
|
||||||
)}`,
|
)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
await git.pushChanges({ branch: versionBranch, message: finalCommitMessage });
|
await git.pushChanges({ branch: versionBranch, message: finalCommitMessage });
|
||||||
|
|||||||
Reference in New Issue
Block a user