@quo0/stiletto
Version:
With stiletto library you will be able to mock requests and choose between preconfigured responses right on the fly via UI
66 lines • 3.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewStilettoWorkflow = void 0;
const tslib_1 = require("tslib");
const inversify_1 = require("inversify");
const new_setup_questions_1 = require("./new-setup-questions");
const constants_1 = require("../../constants");
const ioc_1 = require("../../../ioc");
const defaultStilettoPath = '/stiletto';
let NewStilettoWorkflow = class NewStilettoWorkflow {
constructor(promptService, structureService) {
this.promptService = promptService;
this.structureService = structureService;
}
start() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
this.initConfig = yield this.promptService.ask(new_setup_questions_1.newSetupQuestions);
this.setupStructure = yield this.structureService.setCurrent(this.initConfig);
yield this.ensureNewSetupPath();
yield this.updateSetupsListInRootConfig();
yield this.lauchAfterCreationIfRequired();
});
}
ensureNewSetupPath() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
const { SETUP_FOLDER, SETUP_SETTINGS_CONFIG, ROUTES_FOLDER, ROUTES_CONFIG, EXTENSIONS_FOLDER, } = this.structureService.current;
const { setupName, launchPersistentContext } = this.initConfig;
const setupConfig = Object.assign(Object.assign({}, constants_1.DEFAULT_FILE_DATA.SETUP_SETTINGS_CONFIG), { setupName,
launchPersistentContext });
yield SETUP_FOLDER.create();
yield SETUP_SETTINGS_CONFIG.create(setupConfig);
yield ROUTES_FOLDER.create();
yield ROUTES_CONFIG.create();
yield EXTENSIONS_FOLDER.create();
});
}
updateSetupsListInRootConfig() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
if (this.initConfig.setupPath === defaultStilettoPath) {
return;
}
const currentConfig = yield this.setupStructure.ROOT_CONFIG.read();
if (currentConfig) {
const newConfig = {
setups: [...new Set([...currentConfig.setups, this.initConfig.setupPath])],
};
yield this.setupStructure.ROOT_CONFIG.update(newConfig);
}
});
}
lauchAfterCreationIfRequired() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
// TODO:IMPLEMENTATION add an option for laucnhing setup after creation
// if (this.initConfig.launchAfterCreation) {
// }
});
}
};
NewStilettoWorkflow = (0, tslib_1.__decorate)([
(0, inversify_1.injectable)(),
(0, tslib_1.__param)(0, (0, inversify_1.inject)(ioc_1.TOKENS.promptService)),
(0, tslib_1.__param)(1, (0, inversify_1.inject)(ioc_1.TOKENS.structureService)),
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object])
], NewStilettoWorkflow);
exports.NewStilettoWorkflow = NewStilettoWorkflow;
//# sourceMappingURL=new-stiletto.js.map