@enspirit/emb
Version:
A replacement for our Makefile-for-monorepos
37 lines (36 loc) • 1.27 kB
JavaScript
import { getContext } from '../../../index.js';
import { Flags } from '@oclif/core';
import { BaseCommand } from '../../index.js';
import { pruneImages } from '../../../docker/index.js';
export default class ImagesPrune extends BaseCommand {
static description = 'Prune project images.';
static enableJsonFlag = true;
static examples = ['<%= config.bin %> <%= command.id %>'];
static flags = {
all: Flags.boolean({
char: 'a',
default: false,
description: 'Prune all images. When set to true all images will be pruned, not only dangling ones',
name: 'all',
required: false,
}),
};
async run() {
const { flags } = await this.parse(ImagesPrune);
const context = await getContext();
const info = await pruneImages({
dangling: !flags.all,
label: [`emb/project=${context.monorepo.name}`],
});
info.ImagesDeleted?.forEach((d) => {
if (d.Deleted) {
this.log('Deleted', d.Deleted);
}
if (d.Untagged) {
this.log('Untagged', d.Untagged);
}
});
this.log('Space reclaimed', info.SpaceReclaimed);
return info;
}
}