UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

42 lines 1.8 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const syncEventOptions_schema_1 = __importDefault(require("./../../../.spruce/schemas/spruceCli/v2020_07_22/syncEventOptions.schema")); const action_utility_1 = __importDefault(require("../../../utilities/action.utility")); const AbstractAction_1 = __importDefault(require("../../AbstractAction")); class SyncAction extends AbstractAction_1.default { commandAliases = ['sync.events']; optionsSchema = syncEventOptions_schema_1.default; invocationMessage = 'Syncing event contracts... 🜒'; async execute(options) { const builder = this.ContractBuilder(); await builder.fetchAndWriteContracts({ ...options, shouldOnlySyncRemoteEvents: true, }); this.Service('eventCache').setLastSyncCache({ ...options, shouldOnlySyncRemoteEvents: true, }); await this.Action('schema', 'sync').execute({ shouldFetchLocalSchemas: false, }); const results = await builder.fetchAndWriteContracts(options); if (results.errors) { return { errors: results.errors, }; } this.Service('eventCache').setLastSyncCache(options); const schemaSyncResults = await this.Action('schema', 'sync').execute({}); const mergedResults = action_utility_1.default.mergeActionResults(schemaSyncResults, results); return mergedResults; } ContractBuilder() { return this.parent.getEventContractBuilder(); } } exports.default = SyncAction; //# sourceMappingURL=SyncAction.js.map