Skip to content

Commit

Permalink
chore: update json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Oct 9, 2024
1 parent 308031b commit d1d8a44
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
20 changes: 1 addition & 19 deletions scripts/generate-json-schemas-all.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import { existsSync, mkdirSync } from 'fs';
import { dirname as _dirname, resolve } from 'path';
import { writeFile } from 'fs/promises';

import prettier from 'prettier';
import { createGenerator } from 'ts-json-schema-generator';

const { format, resolveConfig } = prettier;

const __dirname = _dirname(new URL(import.meta.url).pathname);

/** @type {import('ts-json-schema-generator/dist/src/Config').Config} */
Expand All @@ -17,22 +14,7 @@ const config = {
tsconfig: resolve(__dirname, '../tsconfig.build.json'),
};

const prettierConfigFile = await prettier.resolveConfigFile();

let prettierConfig = {};
if (prettierConfigFile) {
const result = await resolveConfig(prettierConfigFile);
if (result) {
prettierConfig = result;
}
}

async function usePrettier(schema) {
return format(schema, {
parser: 'json',
...prettierConfig,
});
}

const generator = createGenerator(config);

Expand All @@ -53,7 +35,7 @@ async function createTypeSchema(type, name) {
`${name}.schema.json`,
);
ensureDirSync(output_path);
await writeFile(output_path, await usePrettier(schemaString));
await writeFile(output_path, schemaString);
}

createTypeSchema('AppSetting', 'app-settings');
Expand Down
2 changes: 1 addition & 1 deletion src/api/controllers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function route(hono: THono) {
let useQueue = false;
if (!useQueue) {
useQueue = await Switches.instance().isEnableFor(
KnownSwitches.enableQueue,
KnownSwitches.EnableQueue,
id,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/kv/switches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface SwitchesItem {
}

export const KnownSwitches = {
enableQueue: 'cfworker_enableQueue',
EnableQueue: 'cfworker_enableQueue',
};

export class Switches {
Expand Down

0 comments on commit d1d8a44

Please sign in to comment.