UNPKG

gen-jhipster

Version:

VHipster - Spring Boot + Angular/React/Vue in one handy generator

222 lines (221 loc) 10.2 kB
import type { GeneratorMeta } from '@yeoman/types'; import { simpleGit } from 'simple-git'; import type { PackageJson } from 'type-fest'; import type Environment from 'yeoman-environment'; import YeomanGenerator, { type ComposeOptions, type Storage } from 'yeoman-generator'; import type { ExportGeneratorOptionsFromCommand, ExportStoragePropertiesFromCommand, JHipsterArguments, JHipsterCommandDefinition, ParsableCommand } from '../../lib/command/index.ts'; import { type Logger } from '../../lib/utils/index.ts'; import type GeneratorsByNamespace from '../types.ts'; import type { GeneratorsWithBootstrap } from '../types.ts'; import type { CascatedEditFileCallback, EditFileCallback, EditFileOptions, ValidationResult, WriteFileOptions } from './api.ts'; import { type NeedleInsertion } from './support/index.ts'; import type { Config as CoreConfig, Features as CoreFeatures, GenericTask, Options as CoreOptions } from './types.ts'; /** * This is the base class for a generator for every generator. */ export default class CoreGenerator<Config extends CoreConfig = CoreConfig, Options extends CoreOptions = CoreOptions, Features extends CoreFeatures = CoreFeatures> extends YeomanGenerator<Config, Options, Features> { #private; static asPriority: (priorityName: string) => string; static INITIALIZING: string; static PROMPTING: string; static CONFIGURING: string; static COMPOSING: string; static COMPOSING_COMPONENT: string; static LOADING: string; static PREPARING: string; static POST_PREPARING: string; static DEFAULT: string; static WRITING: string; static POST_WRITING: string; static INSTALL: string; static POST_INSTALL: string; static END: string; useVersionPlaceholders?: boolean; skipChecks?: boolean; ignoreNeedlesError?: boolean; experimental?: boolean; debugEnabled?: boolean; relativeDir: (from: string, to: string) => string; relative: (from: string, to: string) => string; readonly logger: Logger; jhipsterConfig: Config; /** * @deprecated */ jhipsterTemplatesFolders: string[]; blueprintStorage?: Storage; /** Allow to use a specific definition at current command operations */ generatorCommand?: JHipsterCommandDefinition; /** * @experimental * Additional commands to be considered */ generatorsToCompose: string[]; env: Environment; log: Logger; _meta?: GeneratorMeta; constructor(args?: string[], options?: Options, features?: Features); get context(): any; /** * Override yeoman generator's usage function to fine tune --help message. */ usage(): string; /** * JHipster config with default values fallback */ get jhipsterConfigWithDefaults(): Readonly<Config>; /** * Utility method to get typed objects for autocomplete. */ asAnyTaskGroup<const T extends Record<string, GenericTask<this, any>>>(taskGroup: T): Record<keyof T, GenericTask<any, any>>; /** * Warn or throws check failure based on current skipChecks option. * @param message */ handleCheckFailure(message: string): void; /** * Wrapper for `semver.lt` to check if the oldVersion exists and is less than the newVersion. * Can be used by blueprints. */ isVersionLessThan(oldVersion: string | null, newVersion: string): boolean; /** * Get arguments for the priority */ getArgsForPriority(_priorityName: string): {}[]; /** * Check if the generator should ask for prompts. */ shouldAskForPrompts(_firstArg: any): boolean; /** * Override yeoman-generator method that gets methods to be queued, filtering the result. */ getTaskNames(): string[]; _queueCurrentJHipsterCommandTasks(): void; /** * Load the current JHipster command storage configuration into the context. * Blueprints with command override takes precedence. */ loadCurrentJHipsterCommandConfig(context: any): Promise<void>; _parseJHipsterArguments(jhipsterArguments?: JHipsterArguments): void; /** * Alternative templatePath that fetches from the blueprinted generator, instead of the blueprint. */ jhipsterTemplatePath(...path: string[]): string; /** * Returns the resources path in the blueprinted jhipster generator */ jhipsterResourcesPath(...path: string[]): string; /** * Reads a resource file from the generator */ readResource(path: string): string | null; /** * Join a path to the source root. * @param dest - path parts * @return joined path */ resourcesPath(...dest: string[]): string; /** * Reads a resource file from the blueprinted jhipster generator */ readJHipsterResource(path: string): string | null; /** * Compose with a jhipster generator using default jhipster config, but queue it immediately. */ dependsOnJHipster<const G extends keyof GeneratorsByNamespace>(gen: G, options?: ComposeOptions<GeneratorsByNamespace[G]>): Promise<GeneratorsByNamespace[G]>; dependsOnJHipster(gen: string, options?: ComposeOptions<CoreGenerator>): Promise<CoreGenerator>; /** * Compose with a jhipster bootstrap generator using default jhipster config, but queue it immediately. */ dependsOnBootstrap<const G extends GeneratorsWithBootstrap>(gen: G, options?: ComposeOptions<GeneratorsByNamespace[`jhipster:${G}:bootstrap`]>): Promise<GeneratorsByNamespace[`jhipster:${G}:bootstrap`]>; /** * Compose with a jhipster generator using default jhipster config. * @return {object} the composed generator */ composeWithJHipster<const G extends keyof GeneratorsByNamespace>(gen: G, options?: ComposeOptions<GeneratorsByNamespace[G]>): Promise<GeneratorsByNamespace[G]>; composeWithJHipster(gen: string, options?: ComposeOptions<CoreGenerator>): Promise<CoreGenerator>; /** * Remove File */ removeFile(...path: string[]): string; /** * Remove Folder * @param path */ removeFolder(...path: string[]): void; /** * Fetch files from the generator-jhipster instance installed */ fetchFromInstalledJHipster(...path: string[]): string; /** * Utility function to write file. * * @param source * @param destination - destination * @param data - template data * @param copyOptions */ writeFile(source: string, destination: string, data?: Parameters<CoreGenerator['renderTemplate']>[2], copyOptions?: Parameters<CoreGenerator['renderTemplate']>[3]): void; /** * write the given files using provided options. */ writeFiles<DataType = any>(options: WriteFileOptions<DataType, this>): Promise<string[]>; /** * Edit file content. * Edits an empty file if `options.create` is truthy or no callback is passed. * @example * // Throws if `foo.txt` doesn't exists or append the content. * editFile('foo.txt', content => content + 'foo.txt content'); * @example * // Appends `foo.txt` content if whether exists or not. * editFile('foo.txt', { create: true }, content => content + 'foo.txt content'); * @example * // Appends `foo.txt` content if whether exists or not using the returned cascaded callback. * editFile('foo.txt')(content => content + 'foo.txt content'); */ editFile(file: string, ...transformCallbacks: EditFileCallback<this>[]): CascatedEditFileCallback<this>; editFile(file: string, options: EditFileOptions | NeedleInsertion, ...transformCallbacks: EditFileCallback<this>[]): CascatedEditFileCallback<this>; /** * Convert value to a yaml and write to destination */ writeDestinationYaml(filepath: string, value: Record<string | number, any>): void; /** * Merge value to an existing yaml and write to destination * Removes every comment (due to parsing/merging process) except the at the top of the file. */ mergeDestinationYaml(filepath: string, value: Record<string | number, any>): void; /** * Merge value to an existing json and write to destination */ mergeDestinationJson(filepath: string, value: Record<string | number, any>): void; /** * Shallow clone or convert dependencies to placeholder if needed. */ prepareDependencies(map: Record<string, string>, valuePlaceholder?: 'java' | 'docker' | ((value: string) => string)): Record<string, string>; loadNodeDependencies(destination: Record<string, string>, source: Record<string, string>): void; /** * Load Java dependencies from a gradle catalog file. * @param javaDependencies * @param gradleCatalog Gradle catalog file path, true for generator-jhipster's generator catalog of falsy for blueprint catalog */ loadJavaDependenciesFromGradleCatalog(javaDependencies: Record<string, string>, gradleCatalogFile?: string): void; loadJavaDependenciesFromGradleCatalog(javaDependencies: Record<string, string>, mainGenerator: boolean): void; readResourcesPackageJson(packageJsonFile?: string): Omit<PackageJson.PackageJsonStandard, 'dependencies' | 'devDependencies'> & Record<'dependencies' | 'devDependencies', Record<string, string>>; loadNodeDependenciesFromPackageJson(destination: Record<string, string>, packageJsonFile?: string): void; /** * Print ValidationResult info/warnings or throw result Error. */ validateResult(result: ValidationResult, { throwOnError }?: { throwOnError?: boolean | undefined; }): void; /** * Checks if there is a newer JHipster version available. */ protected checkForNewVersion(): Promise<void>; /** * Create a simple-git instance using current destinationPath as baseDir. */ createGit(options?: Parameters<typeof simpleGit>[0]): import("simple-git").SimpleGit; } export declare class CommandCoreGenerator<Command extends ParsableCommand, AdditionalOptions = unknown, AdditionalFeatures = unknown> extends CoreGenerator<CoreConfig & ExportStoragePropertiesFromCommand<Command>, CoreOptions & ExportGeneratorOptionsFromCommand<Command> & AdditionalOptions, CoreFeatures & AdditionalFeatures> { }