Skip to content

Commit

Permalink
chore: cleanups + install typedoc
Browse files Browse the repository at this point in the history
  • Loading branch information
chenasraf committed Nov 19, 2023
1 parent 557b4c8 commit a7d7a57
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ dist

# Build
build/
docs/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@
"author": "Chen Asraf <chenasrafil@gmail.com>",
"license": "Apache",
"scripts": {
"clean": "rm -rf build",
"build": "echo $(pwd); yarn clean && tsc -p tsconfig.build.json && cp package.json README.md build",
"develop": "tsc --watch",
"test": "jest"
"build": "tsc -p tsconfig.build.json && cp package.json README.md build",
"dev": "tsc --watch",
"example": "ts-node src/example.ts",
"test": "jest",
"docs": "typedoc --out docs src --plugin typedoc-plugin-zod --theme default"
},
"devDependencies": {
"@types/jest": "^29.5.8",
"@types/node": "^20.9.2",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.3",
"typedoc-plugin-zod": "^1.1.0",
"typescript": "^5.2.2"
},
"dependencies": {
Expand Down
76 changes: 76 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,31 @@ import { setOrPush } from "./utils"

export const CommandConfig = <RunArgs extends z.ZodType>(args: RunArgs) =>
z.object({
/** Command name */
name: z.string(),
/** Command description, displayed in the help output */
description: z.string(),
/** Command aliases */
aliases: z.string().array().optional(),
/**
* Function used when invoking this command. It receives the parsed options and the primary
* instance of Massarg used to invoke this command (the top-level instance)
*/
run: z
.function()
.args(args, z.any())
.returns(z.union([z.promise(z.void()), z.void()])) as z.ZodType<Runner<z.infer<RunArgs>>>,
/**
* Whether to bind the help command to this command
*
* Set this to `true` to automatically add a `help` command to this command's subcommands.
*/
bindHelpCommand: z.boolean().optional(),
/**
* Whether to bind the help option to this command
*
* Set this to `true` to automatically add a `--help` option to this command's options.
*/
bindHelpOption: z.boolean().optional(),
// argsHint: z.string().optional(),
})
Expand Down Expand Up @@ -138,7 +155,6 @@ export default class MassargCommand<Args extends ArgsObject = ArgsObject> {
}
const defaultOption = this.options.find((o) => o.isDefault)
if (defaultOption) {
console.log("Parsing default option")
_argv = this.parseOption(`--${defaultOption.name}`, [arg, ..._argv])
continue
}
Expand All @@ -157,7 +173,6 @@ export default class MassargCommand<Args extends ArgsObject = ArgsObject> {
message: "Unknown option",
})
}
console.log("parseOption", [arg, ...argv])
const res = option._parseDetails([arg, ...argv])
this.args[res.key as keyof Args] = setOrPush<Args[keyof Args]>(
res.value,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
/* Module Resolution Options */
"moduleResolution": "node", // /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "Node16", // /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
Expand Down

0 comments on commit a7d7a57

Please sign in to comment.