Skip to content

Commit

Permalink
Fix schema generation, remove QUESTION_TYPES
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Jun 23, 2022
1 parent b08890e commit 6ce2f6d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: clippy
# Build script in previous action should build js,
# so we don't need to run pnpm build here.
- run: pnpm test && pnpm lint
working-directory: js
12 changes: 3 additions & 9 deletions js/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as tsSchema from "ts-json-schema-generator";
import { SchemaGenerator } from "ts-json-schema-generator";
import fs from "fs/promises";
import path from "path";
import { QUESTION_TYPES } from "./lib/question-types.mjs";

// Ensures that "format": "markdown" is added to Markdown types
class MarkdownFormatter {
Expand Down Expand Up @@ -36,14 +35,9 @@ async function generateSchemas() {
let program = tsSchema.createProgram(config);
let parser = tsSchema.createParser(program, config);
let generator = new SchemaGenerator(program, parser, formatter);

let ps = QUESTION_TYPES.map(async (questionType) => {
let schema = generator.createSchema(questionType);
let outPath = path.join("dist", `${questionType}.schema.json`);
await fs.writeFile(outPath, JSON.stringify(schema));
});

await Promise.all(ps);
let schema = generator.createSchema("Quiz");
let outPath = path.join("dist", "Quiz.schema.json");
await fs.writeFile(outPath, JSON.stringify(schema));
}

async function main() {
Expand Down
1 change: 0 additions & 1 deletion js/lib/question-types.d.mts

This file was deleted.

2 changes: 0 additions & 2 deletions js/lib/question-types.mjs

This file was deleted.

0 comments on commit 6ce2f6d

Please sign in to comment.