monoid
8fece9090f
다시 작업. 디자인도 바꾸고 서버도 바꿈. Co-authored-by: monoid <jaeung@prelude.duckdns.org> Reviewed-on: https://git.prelude.duckdns.org/monoid/ionian/pulls/6
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
// import { promises } from "fs";
|
|
// const { readdir, writeFile } = promises;
|
|
// import { dirname, join } from "path";
|
|
// import { createGenerator } from "ts-json-schema-generator";
|
|
|
|
// async function genSchema(path: string, typename: string) {
|
|
// const gen = createGenerator({
|
|
// path: path,
|
|
// type: typename,
|
|
// tsconfig: "tsconfig.json",
|
|
// });
|
|
// const schema = gen.createSchema(typename);
|
|
// if (schema.definitions != undefined) {
|
|
// const definitions = schema.definitions;
|
|
// const definition = definitions[typename];
|
|
// if (typeof definition == "object") {
|
|
// let property = definition.properties;
|
|
// if (property) {
|
|
// property["$schema"] = {
|
|
// type: "string",
|
|
// };
|
|
// }
|
|
// }
|
|
// }
|
|
// const text = JSON.stringify(schema);
|
|
// await writeFile(join(dirname(path), `${typename}.schema.json`), text);
|
|
// }
|
|
// function capitalize(s: string) {
|
|
// return s.charAt(0).toUpperCase() + s.slice(1);
|
|
// }
|
|
// async function setToALL(path: string) {
|
|
// console.log(`scan ${path}`);
|
|
// const direntry = await readdir(path, { withFileTypes: true });
|
|
// const works = direntry
|
|
// .filter((x) => x.isFile() && x.name.endsWith("Config.ts"))
|
|
// .map((x) => {
|
|
// const name = x.name;
|
|
// const m = /(.+)\.ts/.exec(name);
|
|
// if (m !== null) {
|
|
// const typename = m[1];
|
|
// return genSchema(join(path, typename), capitalize(typename));
|
|
// }
|
|
// });
|
|
// await Promise.all(works);
|
|
// const subdir = direntry.filter((x) => x.isDirectory()).map((x) => x.name);
|
|
// for (const x of subdir) {
|
|
// await setToALL(join(path, x));
|
|
// }
|
|
// }
|
|
// setToALL("src");
|