UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

65 lines 2.23 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 InFlightEntertainment_1 = __importDefault(require("../../../InFlightEntertainment")); const AbstractAction_1 = __importDefault(require("../../AbstractAction")); const optionsSchema = (0, schema_1.buildSchema)({ id: 'rebuildOptions', description: 'Clear the build and node_modules folder and start from the top.', fields: { shouldPlayGames: { type: 'boolean', label: 'Play games', defaultValue: true, }, }, }); class RebuildAction extends AbstractAction_1.default { optionsSchema = optionsSchema; commandAliases = ['rebuild']; invocationMessage = 'Rebuilding your skill... ⚡️'; async execute(options) { const { shouldPlayGames } = this.validateAndNormalizeOptions(options); const command = this.Service('command'); try { if (shouldPlayGames) { InFlightEntertainment_1.default.start([ 'Rebuild sequence initiated...', 'The only option is setting a new high score!', ]); } else { this.ui.startLoading('Rebuilding....'); } await command.execute('yarn rebuild', { onData: (data) => { InFlightEntertainment_1.default?.writeStatus(data); }, }); } catch (err) { this.resetUi(); return { errors: [err], }; } this.resetUi(); return { summaryLines: [ '☑️ node_modules cleared.', '☑️ node_modules installed.', '☑️ Build folder cleared.', '☑️ Build complete.', ], }; } resetUi() { InFlightEntertainment_1.default.stop(); this.ui.stopLoading(); } } exports.default = RebuildAction; //# sourceMappingURL=RebuildAction.js.map