-
Notifications
You must be signed in to change notification settings - Fork 19
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
5 changed files
with
108 additions
and
12 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env node | ||
import { defineCommand, runMain, ArgsDef } from "citty"; | ||
import pkg from "../package.json"; | ||
import { addDependency, installDependencies, removeDependency } from "./api"; | ||
|
||
const operationArgs = { | ||
cwd: { | ||
type: "string", | ||
description: "Current working directory", | ||
}, | ||
workspace: { | ||
type: "boolean", | ||
description: "Add to workspace", | ||
}, | ||
silent: { | ||
type: "boolean", | ||
description: "Run in silent mode", | ||
}, | ||
} as const satisfies ArgsDef; | ||
|
||
const install = defineCommand({ | ||
meta: { | ||
description: "Install dependencies", | ||
}, | ||
args: { | ||
...operationArgs, | ||
name: { | ||
type: "positional", | ||
description: "Dependency name", | ||
required: false, | ||
}, | ||
dev: { | ||
type: "boolean", | ||
alias: "D", | ||
description: "Add as dev dependency", | ||
}, | ||
}, | ||
run: async ({ args }) => { | ||
await (args.name | ||
? addDependency(args.name, args) | ||
: installDependencies(args)); | ||
}, | ||
}); | ||
|
||
const remove = defineCommand({ | ||
meta: { | ||
description: "Remove dependencies", | ||
}, | ||
args: { | ||
name: { | ||
type: "positional", | ||
description: "Dependency name", | ||
required: true, | ||
}, | ||
...operationArgs, | ||
}, | ||
run: async ({ args }) => { | ||
await removeDependency(args.name, args); | ||
}, | ||
}); | ||
|
||
const main = defineCommand({ | ||
meta: { | ||
name: pkg.name, | ||
version: pkg.version, | ||
description: pkg.description, | ||
}, | ||
subCommands: { | ||
install, | ||
i: install, | ||
add: install, | ||
remove, | ||
}, | ||
}); | ||
|
||
runMain(main); |
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