UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

61 lines 2.24 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const schema_1 = require("@sprucelabs/schema"); const SpruceError_1 = __importDefault(require("../../../errors/SpruceError")); const AbstractAction_1 = __importDefault(require("../../AbstractAction")); const constants_1 = require("../constants"); class EnableCacheAction extends AbstractAction_1.default { optionsSchema = optionsSchema; commandAliases = [ 'enable.cache', 'start.cache', 'enable.caching', 'start.caching', ]; invocationMessage = 'Enabling cache... 💪'; async execute(_options) { try { await this.Service('command').execute('which docker'); await this.Action('cache', 'disable').execute({}); await this.Service('command').execute(constants_1.ENABLE_NPM_CACHE_COMMAND); return { headline: 'Starting cache', summaryLines: ['Booting cache systems now. Give it a sec!'], }; } catch (err) { let error = err; if (err.options?.cmd?.includes('which')) { error = new SpruceError_1.default({ code: 'MISSING_DEPENDENCIES', originalError: err, dependencies: [ { name: 'Docker', hint: 'Get Docker here: https://www.docker.com/products/docker-desktop', }, ], }); } else { error = new SpruceError_1.default({ code: 'DOCKER_NOT_STARTED', originalError: err, }); } return { errors: [error], }; } } } exports.default = EnableCacheAction; const optionsSchema = (0, schema_1.buildSchema)({ id: 'enableCacheAction', description: 'Enable npm caching so pulling node_modules is much faster.', fields: {}, }); //# sourceMappingURL=EnableAction.js.map