UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

73 lines 2.53 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const validateAndNormalize_utility_1 = __importDefault(require("./validateAndNormalize.utility")); const VersionResolver_1 = __importDefault(require("./VersionResolver")); class AbstractAction { commandAliases = []; parent; features; cwd; templates; ui; emitter; serviceFactory; storeFactory; writerFactory; apiClientFactory; actionExecuter; constructor(options) { this.cwd = options.cwd; this.templates = options.templates; this.parent = options.parent; this.storeFactory = options.storeFactory; this.serviceFactory = options.serviceFactory; this.features = options.featureInstaller; this.ui = options.ui; this.writerFactory = options.writerFactory; this.apiClientFactory = options.apiClientFactory; this.emitter = options.emitter; this.actionExecuter = options.actionExecuter; } Action(featureCode, actionCode) { return this.actionExecuter.Action(featureCode, actionCode); } Service(type, cwd) { return this.serviceFactory.Service(cwd ?? this.cwd, type); } Store(code, options) { return this.storeFactory.Store(code, { cwd: this.cwd, ...options, }); } Writer(code, options) { return this.writerFactory.Writer(code, { fileDescriptions: this.parent.fileDescriptions, linter: this.Service('lint'), ...options, }); } getFeature(code) { return this.features.getFeature(code); } getFeatureCodes() { return this.features.getAllCodes(); } validateAndNormalizeOptions(options) { const schema = this.optionsSchema; return validateAndNormalize_utility_1.default.validateAndNormalize(schema, options); } async resolveVersion(userSuppliedVersion, resolvedDestination) { const versions = VersionResolver_1.default.Resolver(this.ui, this.serviceFactory.Service(this.cwd, 'pkg')); const version = await versions.resolveVersion(resolvedDestination, userSuppliedVersion); return version; } async connectToApi(options) { return this.apiClientFactory(options); } } exports.default = AbstractAction; //# sourceMappingURL=AbstractAction.js.map