@enspirit/emb
Version:
A replacement for our Makefile-for-monorepos
39 lines (38 loc) • 1.31 kB
JavaScript
import { Args, Flags } from '@oclif/core';
import { BaseCommand, getContext } from '../index.js';
import { ComposeRestartOperation } from '../../docker/index.js';
export default class RestartComand extends BaseCommand {
static description = 'Restart the whole project.';
static enableJsonFlag = true;
static examples = ['<%= config.bin %> <%= command.id %>'];
static flags = {
'no-deps': Flags.boolean({
char: 'f',
default: false,
description: "Don't restart depdendent components",
name: 'no-deps',
}),
};
static args = {
component: Args.string({
name: 'component',
description: 'The component(s) to restart',
}),
};
static strict = false;
async run() {
const { flags, argv } = await this.parse(RestartComand);
const { monorepo } = getContext();
let components;
if (argv.length > 0) {
components =
argv.length > 0
? argv.map((name) => monorepo.component(name))
: monorepo.components;
}
await monorepo.run(new ComposeRestartOperation(), {
noDeps: flags['no-deps'],
services: components?.map((c) => c.name),
});
}
}