Skip to content

Commit

Permalink
Add schema schema interface compilation script
Browse files Browse the repository at this point in the history
Format twice as a workaround to palantir/tslint#4844
  • Loading branch information
MaximeKjaer committed Aug 29, 2019
1 parent a6023a4 commit f885930
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 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 <path>");
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);
}
6 changes: 6 additions & 0 deletions package.json
Expand Up @@ -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",
Expand Down
125 changes: 125 additions & 0 deletions 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<BlockHashml | BlockString | BlockDate | BlockUrl>;
}
export interface BlockBody {
$tag: "body";
props: BlockProp[];
}
export interface BlockProp {
$tag: "prop";
content: Array<BlockOptional | BlockOne | BlockOneOrMore | BlockZeroOrMore>;
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<BlockHashml | BlockString | BlockDate | BlockUrl>;
}
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;
}

0 comments on commit f885930

Please sign in to comment.