UNPKG

@manuth/generator-wsc-package

Version:

A Generator for WoltLab Suite Core Packages.

89 lines 2.45 kB
import { join } from "node:path"; import { FileUploadComponentBase } from "../../../Components/FileUploadComponentBase.js"; import { PackageComponentType } from "../Settings/PackageComponentType.js"; /** * Provides a component for uploading files. * * @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 FileUploadComponent extends FileUploadComponentBase { /** * Initializes a new instance of the {@link FileUploadComponent `FileUploadComponent<TSettings, TOptions, TComponentOptions>`} class. * * @param generator * The generator of the component. */ constructor(generator) { super(generator); } /** * @inheritdoc */ get ID() { return PackageComponentType.FileUpload; } /** * @inheritdoc */ get DisplayName() { return "Files to Upload"; } /** * @inheritdoc */ get FileMappings() { return [ ...super.FileMappings, this.ExampleFileMapping ]; } /** * Gets the default name of the folder to suggest in the {@link TemplateComponent.SourceQuestion `SourceQuestion`}. */ get DefaultSourceBaseName() { return "files"; } /** * @inheritdoc */ get AppQuestion() { return Object.assign(Object.assign({}, super.AppQuestion), { message: "What application do you want to upload the files to?" }); } /** * @inheritdoc */ get SourceQuestion() { return Object.assign(Object.assign({}, super.SourceQuestion), { message: "Where do you want to store the files?" }); } /** * Gets the file-mapping for creating the example-file. */ get ExampleFileMapping() { return { Destination: join(this.ComponentOptions.Source, "Place files here"), Processor: (target, generator) => { generator.fs.write(target.Destination, ""); } }; } /** * @inheritdoc * * @param options * The options which have been provided by the user. * * @returns * The name of the instruction-class. */ GetClassName(options) { return "ApplicationFileSystemInstruction"; } } //# sourceMappingURL=FileUploadComponent.js.map