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 extends YeomanGenerator { #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; /** * Utility method to get typed objects for autocomplete. */ asAnyTaskGroup>>(taskGroup: T): Record>; /** * 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; _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(gen: G, options?: ComposeOptions): Promise; dependsOnJHipster(gen: string, options?: ComposeOptions): Promise; /** * Compose with a jhipster bootstrap generator using default jhipster config, but queue it immediately. */ dependsOnBootstrap(gen: G, options?: ComposeOptions): Promise; /** * Compose with a jhipster generator using default jhipster config. * @return {object} the composed generator */ composeWithJHipster(gen: G, options?: ComposeOptions): Promise; composeWithJHipster(gen: string, options?: ComposeOptions): Promise; /** * 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[2], copyOptions?: Parameters[3]): void; /** * write the given files using provided options. */ writeFiles(options: WriteFileOptions): Promise; /** * 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[]): CascatedEditFileCallback; editFile(file: string, options: EditFileOptions | NeedleInsertion, ...transformCallbacks: EditFileCallback[]): CascatedEditFileCallback; /** * Convert value to a yaml and write to destination */ writeDestinationYaml(filepath: string, value: Record): 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): void; /** * Merge value to an existing json and write to destination */ mergeDestinationJson(filepath: string, value: Record): void; /** * Shallow clone or convert dependencies to placeholder if needed. */ prepareDependencies(map: Record, valuePlaceholder?: 'java' | 'docker' | ((value: string) => string)): Record; loadNodeDependencies(destination: Record, source: Record): 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, gradleCatalogFile?: string): void; loadJavaDependenciesFromGradleCatalog(javaDependencies: Record, mainGenerator: boolean): void; readResourcesPackageJson(packageJsonFile?: string): Omit & Record<'dependencies' | 'devDependencies', Record>; loadNodeDependenciesFromPackageJson(destination: Record, 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; /** * Create a simple-git instance using current destinationPath as baseDir. */ createGit(options?: Parameters[0]): import("simple-git").SimpleGit; } export declare class CommandCoreGenerator extends CoreGenerator, CoreOptions & ExportGeneratorOptionsFromCommand & AdditionalOptions, CoreFeatures & AdditionalFeatures> { }