2025-01-11 10:20:49 +08:00
|
|
|
import styleText from "node-style-text";
|
2023-12-17 19:34:12 +00:00
|
|
|
import outdent from "outdent";
|
2025-12-01 07:25:25 +08:00
|
|
|
import { fetchText, logPromise, writeFile } from "../utilities.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() {
|
2025-12-01 07:25:25 +08:00
|
|
|
const { generateSchema } = await import("../../utilities/generate-schema.js");
|
2024-01-22 00:02:31 +08:00
|
|
|
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`
|
2025-11-28 22:58:44 +08:00
|
|
|
The schema in ${styleText.bold.yellow("SchemaStore")} needs an update.
|
2025-01-11 10:20:49 +08:00
|
|
|
- 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`
|
2025-01-11 10:20:49 +08:00
|
|
|
${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 }) {
|
2025-01-11 10:20:49 +08:00
|
|
|
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`
|
2025-10-14 19:30:07 +08:00
|
|
|
${styleText.yellow.bold`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
|
|
|
}
|