@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
77 lines • 2.69 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
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);
}
getProjectLanguage() {
return spruce_skill_utils_1.diskUtil.detectProjectLanguage(this.cwd);
}
async resolveVersion(userSuppliedVersion, resolvedDestination) {
const versions = VersionResolver_1.default.Resolver(this.ui, this.Service('pkg'));
const version = await versions.resolveVersion(resolvedDestination, userSuppliedVersion);
return version;
}
async connectToApi(options) {
return this.apiClientFactory(options);
}
}
exports.default = AbstractAction;
//# sourceMappingURL=AbstractAction.js.map