Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add schema schema interface compilation script
Format twice as a workaround to palantir/tslint#4844
- Loading branch information
1 parent
a6023a4
commit f885930
Showing
3 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |