-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
…835) Move the `parse-openapi-spec` and `generate-mock-data` scripts to just node executables, rather than bash scripts which install dependencies and then execute using `ts-node`. Additionally refactor to use a single entry point with subcommands so we need only ship a single javascript bundle, rather than one for each script.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env node | ||
import { parse } from "ts-command-line-args"; | ||
import generateMockData from "./custom/mock-data/generate-mock-data"; | ||
import parseOpenapiSpec from "./parser/parse-openapi-spec"; | ||
import generate from "./generators/generate-next"; | ||
import * as path from "path"; | ||
|
||
interface SubCommandArgs { | ||
readonly command: string; | ||
} | ||
|
||
void (async () => { | ||
const subCommandArgs = parse<SubCommandArgs>({ | ||
command: { type: String, defaultOption: true }, | ||
}, { stopAtFirstUnknown: true }); | ||
|
||
const argv = (subCommandArgs as any)._unknown as string[]; | ||
|
||
switch (subCommandArgs.command) { | ||
case "generate-mock-data": | ||
return await generateMockData(argv); | ||
case "parse-openapi-spec": | ||
return await parseOpenapiSpec(argv); | ||
case "generate": | ||
return await generate(argv, path.resolve(__dirname)); | ||
default: | ||
throw new Error(`Unknown subcommand ${subCommandArgs.command}`); | ||
} | ||
})(); |