Skip to content

Commit

Permalink
build: update prettier API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Jul 5, 2023
1 parent 995b43d commit 0497035
Show file tree
Hide file tree
Showing 9 changed files with 14,499 additions and 20,420 deletions.
4 changes: 2 additions & 2 deletions bin/extract-common-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ function assertHasRequiredProperties(
);
}

const writeNewCommonSchema = (name: string, schema: JSONSchema7) => {
const writeNewCommonSchema = async (name: string, schema: JSONSchema7) => {
const pathToSchema = `${pathToSchemas}/common/${name}.schema.json`;

assertHasRequiredProperties(schema);

fs.writeFileSync(
pathToSchema,
format(
await format(
JSON.stringify(schema, (key, value: unknown) => {
if (
key === "$ref" &&
Expand Down
4 changes: 2 additions & 2 deletions bin/format-with-prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
const [, { check: checkOnly }] = parseArgv(__filename, [], ["check"]);

const formatJsonInDirectory = (pathToJsons: string) => {
forEachJsonFile(pathToJsons, (filePath) => {
forEachJsonFile(pathToJsons, async (filePath) => {
const contentsBefore = fs.readFileSync(filePath, "utf-8");
const contentsAfter = format(
const contentsAfter = await format(
JSON.stringify(JSON.parse(contentsBefore) as JSONSchema7),
{ parser: "json" },
);
Expand Down
2 changes: 1 addition & 1 deletion bin/octokit-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function run() {

fs.writeFileSync(
"./payload-schemas/schema.json",
format(
await format(
JSON.stringify(schema, (key, value: unknown) => {
if (key === "$id") {
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion bin/octokit-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const run = async () => {

await fs.writeFile(
"./payload-types/schema.d.ts",
format(ts, { parser: "typescript" }),
await format(ts, { parser: "typescript" }),
);
};

Expand Down
4 changes: 2 additions & 2 deletions bin/optimize-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ const addNullToObject = (object: JSONSchema7) => {
}
};

forEachJsonFile(pathToSchemas, (pathToSchema) => {
forEachJsonFile(pathToSchemas, async (pathToSchema) => {
const contents = JSON.parse(fs.readFileSync(pathToSchema, "utf-8"));

fs.writeFileSync(
pathToSchema,
format(
await format(
JSON.stringify(contents, (key, value: unknown | JSONSchema7) => {
if (!isJsonSchemaObject(value)) {
return value;
Expand Down
4 changes: 2 additions & 2 deletions bin/ref-common-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const splitIntoObjectAndNull = (

let count = 0;

forEachJsonFile(pathToSchemas, (filePath) => {
forEachJsonFile(pathToSchemas, async (filePath) => {
if (filePath.includes("/common/")) {
return;
}
Expand All @@ -65,7 +65,7 @@ forEachJsonFile(pathToSchemas, (filePath) => {

fs.writeFileSync(
filePath,
format(
await format(
JSON.stringify(schema, (key, value) => {
if (typeof value === "object" && value !== null) {
const [object, nullType] = splitIntoObjectAndNull(value);
Expand Down

0 comments on commit 0497035

Please sign in to comment.