Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:added deno commands #43

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Dagger from "./plugins/dagger.ts";
import Helm from "./plugins/helm.ts";
import Devbox from "./plugins/devbox.ts";
import Kubectl from "./plugins/kubectl.ts";
import Deno from "./plugins/deno.js";

const plugins = [
new Docker(),
Expand All @@ -32,6 +33,7 @@ const plugins = [
new Helm(),
new Devbox(),
new Kubectl(),
new Deno(),
];

const history: string[] = [];
Expand Down
60 changes: 60 additions & 0 deletions plugins/deno.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { spawn } from "../src/helpers.ts";
import Plugin from "../src/plugin.ts";

class Deno implements Plugin {
name = "deno";
commands: Record<string, (params: string[]) => Promise<void>>;
constructor() {
this.commands = {
bundle: (args: string[]) => spawn(this.name, ["bundle", ...args]),
cache: (args: string[]) => spawn(this.name, ["cache", ...args]),
completions: (args: string[]) =>
spawn(this.name, ["completions", ...args]),
doc: (args: string[]) => spawn(this.name, ["doc", ...args]),
eval: (args: string[]) => spawn(this.name, ["eval", ...args]),
fmt: (args: string[]) => spawn(this.name, ["fmt", ...args]),
info: (args: string[]) => spawn(this.name, ["info", ...args]),
install: (args: string[]) => spawn(this.name, ["install", ...args]),
repl: (args: string[]) => spawn(this.name, ["repl", ...args]),
run: (args: string[]) => spawn(this.name, ["run", ...args]),
test: (args: string[]) => spawn(this.name, ["test", ...args]),
types: (args: string[]) => spawn(this.name, ["types", ...args]),
check: (args: string[]) => spawn(this.name, ["check", ...args]),
upgrade: (args: string[]) => spawn(this.name, ["upgrade", ...args]),
version: (args: string[]) => spawn(this.name, ["--version", ...args]),
help: () => {
console.log(` Common Commands:
bundle Bundle module and dependencies into single file
cache Cache the dependencies
completions Generate shell completions
doc Show documentation for a module
eval Eval script
fmt Format source files
info Show info about cache or info related to source file
install Install script as an executable
repl Read Eval Print Loop
run Run a program given a filename or url to the module
test Run tests
types Print runtime TypeScript declarations
check Type-check your code without executing it
upgrade Upgrade deno executable to newest version
`);
return Promise.resolve();
},
};
}

async evaluate(command: string): Promise<void> {
const [cmd, ...params] = command.split(" ");
if (this.commands[cmd]) {
await this.commands[cmd](params);
return;
}
if (cmd === "") {
return;
}
console.log("Command not found");
}
}

export default Deno;