UNPKG

@manuth/generator-wsc-package

Version:

A Generator for WoltLab Suite Core Packages.

107 lines 3.32 kB
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()); }); }; import { PackageComponentType } from "../Settings/PackageComponentType.js"; import { TemplateComponent } from "./TemplateComponent.js"; /** * Provides a component for generating acp-templates. * * @template TSettings * The type of the settings of the generator. * * @template TOptions * The type of the options of the generator. * * @template TComponentOptions * The type of the options of the component. */ export class ACPTemplateComponent extends TemplateComponent { /** * Initializes a new instance of the {@link ACPTemplateComponent `ACPTemplateComponent<TSettings, TOptions, TComponentOptions>`} class. * * @param generator * The generator of the component. */ constructor(generator) { super(generator); } /** * @inheritdoc */ get ID() { return PackageComponentType.ACPTemplate; } /** * @inheritdoc */ get DisplayName() { return "ACP-Templates"; } /** * @inheritdoc */ get DefaultSourceBaseName() { return "acpTemplates"; } /** * @inheritdoc */ get AppQuestion() { let question = super.AppQuestion; this.TransformQuestion(question); return question; } /** * @inheritdoc */ get SourceQuestion() { let question = super.SourceQuestion; this.TransformQuestion(question); return question; } /** * @inheritdoc */ get TemplateFileMapping() { return Object.assign(Object.assign({}, super.TemplateFileMapping), { Source: this.Generator.templatePath("acpTemplate.tpl") }); } /** * Transforms the message of the question accordingly. * * @param question * The question to transform. */ TransformQuestion(question) { let originalMessage = question.message; let processor = (question) => { return question.replace("templates", "Admin Control Panel-templates"); }; question.message = (answers) => __awaiter(this, void 0, void 0, function* () { if (typeof originalMessage === "function") { return processor(yield originalMessage(answers)); } else { return processor(yield originalMessage); } }); } /** * @inheritdoc * * @param options * The options which have been provided by the user. * * @returns * The name of the instruction-class. */ GetClassName(options) { return "ACPTemplateInstruction"; } } //# sourceMappingURL=ACPTemplateComponent.js.map