-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
112 additions
and
40 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
npm run generate:api-docs | ||
npm run lint | ||
npm run build | ||
npm run test |
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,36 @@ | ||
# API - @godot-js/ts | ||
|
||
CLI for using GodotJS with TypeScript | ||
|
||
## init | ||
|
||
Creates a new GodotJS project with TypeScript support | ||
|
||
| long | short | description | required | defaultValue | | ||
| :-------------- | :---: | :----------------------------------------------------- | :------: | :----------- | | ||
| `--name` | `-n` | The name of your project | `✅` | `MyGame` | | ||
| `--out` | `-o` | Relative path where project is written | `✅` | `.` | | ||
| `--forceDelete` | `-f` | Removes project dir if it's already there | `❌` | `false` | | ||
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `❌` | `false` | | ||
|
||
## build | ||
|
||
Build typescript files | ||
|
||
| long | short | description | required | defaultValue | | ||
| :---------------- | :---: | :----------------------------------------------------- | :------: | :----------------------- | | ||
| `--src` | `-s` | Relative path where *.ts files located | `✅` | `./src` | | ||
| `--out` | `-o` | Relative path where *.ts files are written | `✅` | `./scripts/js/generated` | | ||
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `❌` | `false` | | ||
| `--minifyClasses` | `-mc` | Minifies GodotJS classes | `❌` | `true` | | ||
|
||
## watch | ||
|
||
Watch typescript files | ||
|
||
| long | short | description | required | defaultValue | | ||
| :------ | :---: | :----------------------------------------------------- | :------: | :----------------------- | | ||
| `--src` | `-s` | Relative path where *.ts files located | `✅` | `./src` | | ||
| `--out` | `-o` | Relative path where *.ts files are written | `✅` | `./scripts/js/generated` | | ||
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `❌` | `false` | | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,44 @@ | ||
import { getProgram } from "./program"; | ||
import { programDescription, programName } from "./data"; | ||
import { markdownTable } from "markdown-table"; | ||
import { writeFileSync } from "node:fs"; | ||
|
||
const getBooleanValue = (value: unknown): string => { | ||
if (String(value) === "true") { | ||
return "✅"; | ||
} else if (String(value) === "false") { | ||
return "❌"; | ||
} | ||
|
||
return String(value); | ||
}; | ||
|
||
export const generateApiDocs = (name: string, description: string) => { | ||
const mProgram = getProgram(name, description); | ||
let result = `# API - ${mProgram.name()}\n\n`; | ||
result += `${mProgram.description()}\n\n`; | ||
|
||
mProgram.commands.forEach((command) => { | ||
result += `## ${command.name()}\n\n`; | ||
result += `${command.description()}\n\n`; | ||
const mTable: string[][] = [ | ||
["long", "short", "description", "required", "defaultValue"], | ||
]; | ||
command.options.forEach( | ||
({ description, required, short, long, defaultValue }) => { | ||
mTable.push([ | ||
`\`${long}\``, | ||
`\`${short}\``, | ||
description, | ||
`\`${getBooleanValue(required)}\``, | ||
`\`${defaultValue}\``, | ||
]); | ||
}, | ||
); | ||
result += `${markdownTable(mTable, { align: ["l", "c", "l", "c", "l"] })}\n\n`; | ||
}); | ||
|
||
writeFileSync("./docs/API.md", result); | ||
}; | ||
|
||
generateApiDocs(programName, programDescription); |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import startProgram from "./program"; | ||
import { startProgram } from "./program"; | ||
import {programDescription, programName} from "./data"; | ||
|
||
startProgram("@godot-js/ts", "CLI for using GodotJS with TypeScript"); | ||
startProgram(programName, programDescription); |
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