@manuth/generator-wsc-package
Version:
A Generator for WoltLab Suite Core Packages.
85 lines • 2.61 kB
JavaScript
import { ComponentOptions } from "@manuth/extended-yo-generator";
import { PathPrompt, QuestionSetPrompt } from "@manuth/generator-ts-project";
import { WoltLabComponentSettingKey } from "../Settings/WoltLabComponentSettingKey.js";
import { WoltLabSettingKey } from "../Settings/WoltLabSettingKey.js";
/**
* Represents a woltlab-component.
*
* @template TSettings
* The type of the generator-settings.
*
* @template TOptions
* The type of the generator-options.
*
* @template TComponentOptions
* The type of the component-options.
*/
export class WoltLabComponent extends ComponentOptions {
/**
* Initializes a new instance of the {@link WoltLabComponent `WoltLabComponent<TSettings, TOptions, TComponentOptions>`} class.
*
* @param generator
* The generator of the component.
*/
constructor(generator) {
super(generator);
this.woltLabGenerator = generator;
}
/**
* Gets the generator of the component.
*/
get Generator() {
return this.woltLabGenerator;
}
/**
* A question for asking for the component-path.
*/
get PathQuestion() {
return {
type: PathPrompt.TypeName,
message: "Where do you want to store the component?",
name: WoltLabComponentSettingKey.Path
};
}
/**
* Gets the questions for the component-options.
*/
get ComponentOptionQuestionCollection() {
return [
this.PathQuestion
];
}
/**
* Gets the prompt-types to register for asking the {@link WoltLabComponent.ComponentOptionQuestionCollection `ComponentOptionQuestionCollection`}.
*/
get PromptTypes() {
return this.Generator.env.adapter.promptModule.prompts;
}
/**
* Gets the questions for asking for the component-options.
*/
get ComponentOptionQuestion() {
return {
type: QuestionSetPrompt.TypeName,
name: `${WoltLabSettingKey.ComponentOptions}[${this.ID}]`,
promptTypes: this.PromptTypes,
questions: this.ComponentOptionQuestionCollection
};
}
/**
* Gets the questions of the component.
*/
get Questions() {
return [
this.ComponentOptionQuestion
];
}
/**
* Gets the component-options that were provided by the user.
*/
get ComponentOptions() {
var _a;
return (_a = this.Generator.Settings[WoltLabSettingKey.ComponentOptions]) === null || _a === void 0 ? void 0 : _a[this.ID];
}
}
//# sourceMappingURL=WoltLabComponent.js.map