@tsed/cli
Version:
CLI to bootstrap your Ts.ED project
54 lines (53 loc) • 1.74 kB
JavaScript
import { __decorate } from "tslib";
import { CliPlugins, Command, createSubTasks, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
let AddCmd = class AddCmd {
constructor() {
this.cliPlugins = inject(CliPlugins);
this.packageJson = inject(ProjectPackageJson);
this.packageManagers = inject(PackageManagersModule);
}
$prompt(initialOptions) {
return [
{
type: "autocomplete",
name: "name",
message: "Which cli plugin ?",
default: initialOptions.name,
when: !initialOptions.name,
source: (state, keyword) => {
return this.cliPlugins.searchPlugins(keyword);
}
}
];
}
$exec(ctx) {
this.packageJson.addDevDependency(ctx.name, "latest");
return [
{
title: "Install plugins",
task: createSubTasks(() => this.packageManagers.install(ctx), { ...ctx, concurrent: false })
},
{
title: "Load plugins",
task: () => this.cliPlugins.loadPlugins()
},
{
title: "Install plugins dependencies",
task: createSubTasks(() => this.cliPlugins.addPluginsDependencies(ctx), { ...ctx, concurrent: false })
}
];
}
};
AddCmd = __decorate([
Command({
name: "add",
description: "Add cli plugin to the current project",
args: {
name: {
description: "Npm package name of the cli plugin",
type: String
}
}
})
], AddCmd);
export { AddCmd };