From e378b42654c7e31090488bb2a49ab3c2e9e1cc59 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Thu, 29 Aug 2019 15:40:16 +0200 Subject: [PATCH] Add schema schema interface compilation script Format twice as a workaround to palantir/tslint#4844 --- compileSchemaSchema.ts | 18 ++++ package.json | 6 ++ src/schema/schemaSchemaInterface.d.ts | 125 ++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 compileSchemaSchema.ts create mode 100644 src/schema/schemaSchemaInterface.d.ts diff --git a/compileSchemaSchema.ts b/compileSchemaSchema.ts new file mode 100644 index 0000000..0cc0632 --- /dev/null +++ b/compileSchemaSchema.ts @@ -0,0 +1,18 @@ +// tslint:disable:no-console +import { writeFileSync } from "fs"; +import { convertSchemaToTypescript, Schema, schemaSchema } from "./src"; + +const path = process.argv[2]; +if (!path) { + console.error("Usage: ts-node compileSchemaSchema.ts "); + console.error("Expected a path argument"); + process.exit(1); +} + +try { + const output = convertSchemaToTypescript(new Schema(schemaSchema)); + writeFileSync(path, output); +} catch (e) { + console.error(e); + process.exit(1); +} diff --git a/package.json b/package.json index 2ba1870..824f25d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,13 @@ "tslint": "^5.18.0", "typedoc": "^0.15.0" }, + "config": { + "schema_interface": "src/schema/schemaSchemaInterface.d.ts" + }, "scripts": { + "schema:compile": "ts-node compileSchemaSchema.ts $npm_package_config_schema_interface", + "schema:format": "prettier --write $npm_package_config_schema_interface && tslint --project tsconfig.json --config tslint.json --force --quiet --fix $npm_package_config_schema_interface", + "schema": "npm run schema:compile && npm run schema:format && npm run schema:format", "format": "prettier --write {src,test,benchmark}/**/*.ts *.json", "format:check": "prettier --check {src,test,benchmark}/**/*.ts *.json", "tslint": "tslint --project tsconfig.json", diff --git a/src/schema/schemaSchemaInterface.d.ts b/src/schema/schemaSchemaInterface.d.ts new file mode 100644 index 0000000..ec161b1 --- /dev/null +++ b/src/schema/schemaSchemaInterface.d.ts @@ -0,0 +1,125 @@ +/* This file was generated by Hashml https://github.com/hashml/hashml */ +export interface Root { + $tag: "root"; + root: BlockRoot; + blocks: BlockBlock[]; + inline: BlockInline[]; +} +export type Tag = BlockTag | InlineTag; +export type BlockTag = + | BlockRoot + | BlockBlock + | BlockDefault + | BlockHead + | BlockBody + | BlockProp + | BlockOptional + | BlockOne + | BlockOneOrMore + | BlockZeroOrMore + | BlockInline + | BlockArgs + | BlockHashml + | BlockItem + | BlockString + | BlockDate + | BlockUrl + | BlockSugar + | BlockStart + | BlockSeparator + | BlockEnd; +export type InlineTag = never; +export interface BlockRoot { + $tag: "root"; + defaultTag: BlockDefault | null; + body: BlockBody; +} +export interface BlockBlock { + $tag: "block"; + defaultTag: BlockDefault | null; + head: BlockHead | null; + body: BlockBody | null; + name: string[]; +} +export interface BlockDefault { + $tag: "default"; + name: string[]; +} +export interface BlockHead { + $tag: "head"; + type: Array; +} +export interface BlockBody { + $tag: "body"; + props: BlockProp[]; +} +export interface BlockProp { + $tag: "prop"; + content: Array; + name: string[]; +} +export interface BlockOptional { + $tag: "optional"; + target: string[]; +} +export interface BlockOne { + $tag: "one"; + target: string[]; +} +export interface BlockOneOrMore { + $tag: "oneOrMore"; + target: string[]; +} +export interface BlockZeroOrMore { + $tag: "zeroOrMore"; + target: string[]; +} +export interface BlockInline { + $tag: "inline"; + args: BlockArgs; + sugar: BlockSugar | null; + name: string[]; +} +export interface BlockArgs { + $tag: "args"; + args: Array; +} +export interface BlockHashml { + $tag: "hashml"; + content: BlockItem[]; + propName: string[]; +} +export interface BlockItem { + $tag: "item"; + target: string[]; +} +export interface BlockString { + $tag: "string"; + propName: string[]; +} +export interface BlockDate { + $tag: "date"; + propName: string[]; +} +export interface BlockUrl { + $tag: "url"; + propName: string[]; +} +export interface BlockSugar { + $tag: "sugar"; + start: BlockStart; + separator: BlockSeparator | null; + end: BlockEnd; +} +export interface BlockStart { + $tag: "start"; + token: string; +} +export interface BlockSeparator { + $tag: "separator"; + token: string; +} +export interface BlockEnd { + $tag: "end"; + token: string; +}