UNPKG

@enspirit/emb

Version:

A replacement for our Makefile-for-monorepos

42 lines (41 loc) 1.47 kB
import { getContext } from '../../index.js'; import { Flags } from '@oclif/core'; import { Listr } from 'listr2'; import { BaseCommand } from '../abstract/BaseCommand.js'; /** * For now, only cleans the stores (logs/sentinels) * But this should permit to clean everytning (via flags) * * Eg: --containers --volumes --images --networks * Or: --all */ export default class CleanCommand extends BaseCommand { static description = 'Clean the project.'; static enableJsonFlag = true; static examples = ['<%= config.bin %> <%= command.id %>']; static flags = { force: Flags.boolean({ name: 'force', char: 'f', description: 'Force the deletion of containers & images', }), }; async run() { const { monorepo } = getContext(); const { flags } = await this.parse(CleanCommand); await this.config.runCommand('down'); await this.config.runCommand('containers:prune'); await this.config.runCommand('images:delete', flags.force ? ['--force'] : undefined); await this.config.runCommand('images:prune', flags.force ? ['-a'] : undefined); const runner = new Listr([ { rendererOptions: { persistentOutput: true }, async task() { await monorepo.store.trash(); }, title: 'Cleaning project', }, ]); await runner.run(); } }