Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run setup script with ts-node #659

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"typescript": "^4.4.4"
},
"scripts": {
"start": "node ./notice.js && node ./setup.js && craco start",
"build": "node ./setup.js && craco build",
"test": "node ./setup.js && craco test",
"start": "node ./notice.js && ts-node ./scripts/setup.ts && craco start",
"build": "ts-node ./scripts/setup.ts && craco build",
"test": "ts-node ./scripts/setup.ts && craco test",
"eject": "craco eject",
"desktop-release": "ts-node ./scripts/setup.ts && tauri build",
"desktop": "node ./notice.js && ts-node ./scripts/setup.ts && tauri dev",
"test:report": "npm run test -- --coverage .",
"desktop-release": "node ./setup.js && tauri build",
"desktop": "node ./notice.js && node ./setup.js && tauri dev",
"tauri": "tauri",
"schema-generate": "node ./setup.js",
"lint": "eslint ./src --ext ts,js,tsx,jsx --max-warnings=0 && prettier -c .",
Expand Down
8 changes: 4 additions & 4 deletions setup.js → scripts/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const tsj = require('ts-json-schema-generator')
const fs = require('fs')
import { createGenerator } from 'ts-json-schema-generator'
import fs from 'fs'

const config = {
path: 'src/redux/data.ts',
Expand All @@ -9,8 +9,8 @@ const config = {

const outputPath = 'src/redux/validation.json'

const schema = tsj.createGenerator(config).createSchema(config.type)
const schema = createGenerator(config).createSchema(config.type)
const schemaString = JSON.stringify(schema, null, 2)
fs.writeFile(outputPath, schemaString, (err) => {
fs.writeFile(outputPath, schemaString, (err): void => {
if (err) throw err
})