Files
test-repo/scripts/release/steps/post-publish-steps.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
2.0 KiB
JavaScript
Raw Normal View History

import styleText from "node-style-text";
import outdent from "outdent";
2024-01-22 00:02:31 +08:00
import { fetchText, logPromise, writeFile } from "../utils.js";
2018-06-05 16:37:52 -03:00
const SCHEMA_REPO = "SchemaStore/schemastore";
const SCHEMA_PATH = "src/schemas/json/prettierrc.json";
const RAW_URL = `https://raw.githubusercontent.com/${SCHEMA_REPO}/master/${SCHEMA_PATH}`;
const EDIT_URL = `https://github.com/${SCHEMA_REPO}/edit/master/${SCHEMA_PATH}`;
// Any optional or manual step can be warned in this script.
async function checkSchema() {
2024-01-22 00:02:31 +08:00
const { generateSchema } = await import("../../utils/generate-schema.js");
const schema = await generateSchema();
2018-06-05 16:37:52 -03:00
const remoteSchema = await logPromise(
"Checking current schema in SchemaStore",
2021-04-21 22:15:12 +08:00
fetchText(RAW_URL),
2018-06-05 16:37:52 -03:00
);
2024-01-22 00:02:31 +08:00
if (schema.trim() === remoteSchema.trim()) {
2018-06-05 16:37:52 -03:00
return;
}
2024-01-22 00:02:31 +08:00
writeFile(
new URL("../../../.tmp/schema/prettierrc.json", import.meta.url),
schema,
);
2022-10-14 17:17:47 +08:00
return outdent`
${styleText.bold.underline(
2022-10-14 17:17:47 +08:00
"The schema in {yellow SchemaStore",
)} needs an update.}
- Open ${styleText.cyan.underline(EDIT_URL)}
- Open ${styleText.cyan.underline("/.tmp/schema/prettierrc.json")} file and copy the content
2018-06-05 16:37:52 -03:00
- Paste it on GitHub interface
- Open a PR
2022-10-14 17:17:47 +08:00
`;
2018-06-05 16:37:52 -03:00
}
function twitterAnnouncement() {
2022-10-14 17:17:47 +08:00
return outdent`
${styleText.bold.underline("Announce on Twitter")}
- Open ${styleText.cyan.underline("https://tweetdeck.twitter.com")}
2025-02-22 12:18:52 +08:00
- Make sure you are tweeting from the ${styleText.yellow("@PrettierCode")} account.
2018-06-05 16:37:52 -03:00
- Tweet about the release, including the blog post URL.
2022-10-14 17:17:47 +08:00
`;
2018-06-05 16:37:52 -03:00
}
2023-12-17 22:51:37 +09:00
export default async function postPublishSteps({ dry, next }) {
console.log(styleText.bold.green("The script has finished!\n"));
2018-06-05 16:37:52 -03:00
2023-12-17 22:51:37 +09:00
if (dry || next) {
2018-06-05 16:37:52 -03:00
return;
}
2022-10-14 17:17:47 +08:00
const steps = [await checkSchema(), twitterAnnouncement()].filter(Boolean);
2018-06-05 16:37:52 -03:00
console.log(
2022-10-14 17:17:47 +08:00
outdent`
${styleText.yellow.bold(
2022-10-14 17:17:47 +08:00
`The following ${
steps.length === 1 ? "step is" : "steps are"
} optional.`,
)}
2018-06-05 16:37:52 -03:00
${steps.join("\n\n")}
2022-10-14 17:17:47 +08:00
`,
2018-06-05 16:37:52 -03:00
);
2021-07-26 09:24:44 +08:00
}