UNPKG

@enspirit/emb

Version:

A replacement for our Makefile-for-monorepos

43 lines (42 loc) 1.34 kB
import { getContext } from '../../../index.js'; import * as z from 'zod'; import { ExecuteLocalCommandOperation } from '../../../monorepo/index.js'; import { AbstractOperation } from '../../../operations/index.js'; /** * https://docs.docker.com/reference/cli/docker/compose/start/ */ const schema = z .object({ services: z .array(z.string()) .optional() .describe('The list of service to start'), }) .optional(); export class ComposeStartOperation extends AbstractOperation { constructor() { super(schema); } async _run(input) { const { monorepo } = getContext(); const manager = monorepo.taskManager(); const command = ['docker', 'compose', 'start']; if (input?.services) { command.push(...input.services); } manager.add([ { async task(ctx, task) { return monorepo.run(new ExecuteLocalCommandOperation(task.stdout()), { script: command.join(' '), workingDir: monorepo.rootDir, }); }, title: input?.services ? `Starting ${input.services.join(', ')}` : 'Starting project', }, ]); await manager.runAll(); } }