@viewdo/dxp-story-cli
Version:
DXP Story Management CLI
72 lines • 4.5 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScaffoldSceneCommand = void 0;
const app_1 = require("../app");
const CommandBase_1 = require("./support/CommandBase");
const typedi_1 = require("typedi");
let ScaffoldSceneCommand = class ScaffoldSceneCommand extends CommandBase_1.CommandBase {
run(options) {
return __awaiter(this, void 0, void 0, function* () {
const app = new app_1.App(options);
let storyKey = options.storyKey;
if (!storyKey || !app.configuration_manager.story_keys.includes(storyKey)) {
storyKey = yield app.prompt_service.askWhich("Story key:", app.configuration_manager.story_keys);
}
const story_config = app.configuration_manager.getStoryConfig(storyKey);
let episodeKey = options.episodeKey;
if (!episodeKey || !story_config.episode_keys.includes(episodeKey)) {
episodeKey = yield app.prompt_service.askWhich("Episode key:", story_config.episode_keys);
}
// TODO: ensure episode exists if it is provided
let templateKey = options.templateKey;
if (!templateKey ||
!app.template_manager.templateKeys.includes(templateKey)) {
templateKey = yield app.prompt_service.askWhich(`Templates:`, app.template_manager.templateKeys);
}
// Need to declare sceneType. If it doesn't exist, prompt with list of existing scene types
// Use the SceneType.ts model to select which scene type
let templateConfig = app.template_manager.getStoryTemplateConfig(templateKey);
const sceneKeys = templateConfig.scene_templates.map((scene) => scene.key);
// Need to define the SceneType enum as an array?
// Possibly define it in the template manager, like templateKeys are.
let sceneKey = options.sceneKey;
if (!sceneKey || !sceneKeys.includes(sceneKey)) {
sceneKey = yield app.prompt_service.askWhich(`Scenes:`, sceneKeys);
}
let sceneId = options.sceneId;
if (!sceneId) {
sceneId =
options.storyId ||
(yield app.prompt_service.askFor("New scene Id:", null, app.prompt_service.validateKey));
}
// for debuging, add suffix to note that it is going to a specific episode
app.console_service.log(`Scaffolding the new ${sceneKey} scene as '${sceneId}' to the ${storyKey} story`
.blue);
//This line errors expecting 3 arguments. However, I have declared the parameters needed in both the TemplateManager and the src/index.ts
app.template_manager.scaffoldScene(storyKey, episodeKey, templateKey, sceneKey, sceneId);
yield app.init_manager.initStoryFolders([storyKey], true);
app.console_service.log(`Scaffolding successful`.green);
return 0;
});
}
};
exports.ScaffoldSceneCommand = ScaffoldSceneCommand;
exports.ScaffoldSceneCommand = ScaffoldSceneCommand = __decorate([
(0, typedi_1.Service)()
], ScaffoldSceneCommand);
//# sourceMappingURL=scaffold-scene.js.map