-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
submissionA submission for OpenHackA submission for OpenHack
Description
Submission Details
Type of Submission:
- 3 Pull requests
- Self-initiated open-source project
Links to open-source project:
- Repo: https://github.com/taneliang/tscodegen
- Published: https://npm.im/@elg/tscodegen
Additional information (optional):
(Copied from README)
tscodegen is a minimal TypeScript port of Facebook's Hack Codegen. It provides a fluent API that allows you to build human-readable TypeScript source files from strings of code, with optional manually editable sections and tamper detection.
Sample:
Codegen script
new CodeFile("./file.ts")
.build((builder) =>
builder
.addLine("import path from 'path';")
.addLine("import fs from 'fs'")
.addLine()
.addManualSection("custom_imports", (builder) => builder)
.addLine()
.addBlock("class Steam extends Water", (builder) =>
builder
.addBlock("constructor()", (builder) =>
builder.addLine("this.boil();")
)
.addLine()
.addBlock("boil()", (b) =>
b.addManualSection("boil_body", (builder) =>
builder.add("this.temp = 100;")
)
)
)
.format()
)
.saveToFile();Output
/**
* This file is generated with manually editable sections. Only make
* modifications between BEGIN MANUAL SECTION and END MANUAL SECTION
* designators.
*
* @generated-editable Codelock<<jF8gPj9IVq16NXBAtEzJj0rrD9HR7Q6V>>
*/
import path from "path";
import fs from "fs";
/* BEGIN MANUAL SECTION custom_imports */
/* END MANUAL SECTION */
class Steam extends Water {
constructor() {
this.boil();
}
boil() {
/* BEGIN MANUAL SECTION boil_body */
new Magician().magic(); // This line was retrieved from the original file.ts
/* END MANUAL SECTION */
}
}Metadata
Metadata
Assignees
Labels
submissionA submission for OpenHackA submission for OpenHack