import type { BaseGenerator as YeomanGenerator, GetGeneratorConstructor } from '@yeoman/types'; import type { EmptyObject } from 'type-fest'; import type Environment from 'yeoman-environment'; import type { EnvironmentOptions } from 'yeoman-environment'; import { RunContext, YeomanTest } from 'yeoman-test'; import type { RunContextSettings, RunResult } from 'yeoman-test'; import type { CliCommand } from '../../cli/types.ts'; import type BaseApplicationGenerator from '../../generators/base-application/generator.ts'; import type { PRIORITY_NAMES as APPLICATION_PRIORITY_NAMES } from '../../generators/base-application/priorities.ts'; import BaseCoreGenerator from '../../generators/base-core/index.ts'; import type { PRIORITY_NAMES as WORKSPACES_PRIORITY_NAMES } from '../../generators/base-workspaces/priorities.ts'; import type GeneratorsByNamespace from '../../generators/types.ts'; import type { Entity } from '../jhipster/types/entity.ts'; import type { ApplicationAll } from '../types/application-all.ts'; import type { ConfigAll as ApplicationConfiguration, OptionsAll } from '../types/command-all.ts'; type GeneratorTestOptions = OptionsAll; type WithJHipsterGenerators = { /** * Apply default mocks. */ useDefaultMocks?: boolean; /** * Filter to mock a generator. */ useMock?: (ns: string) => boolean; }; type RunJHipster = WithJHipsterGenerators & { /** * Use the EnvironmentBuilder default preparation to create the environment. * Includes local and dev blueprints. */ prepareEnvironment?: boolean; }; type JHipsterRunResult = Omit, 'env'> & { env: Environment; /** * First argument of mocked source calls. */ sourceCallsArg: Record; /** * Composed generators that were mocked. */ composedMockedGenerators: string[]; createJHipster: (ns: string) => JHipsterRunContext; application?: ApplicationAll; entities?: Record; }; type HelpersDefaults = { /** Blueprint namespace */ blueprint?: string; /** Path where blueprint's generators folder is located */ blueprintPackagePath?: string; entrypointGenerator?: string; }; declare const runResult: JHipsterRunResult; declare const coreRunResult: JHipsterRunResult; export declare const resultWithGenerator: () => JHipsterRunResult; export { coreRunResult, runResult, runResult as result }; export declare const resetDefaults: () => void; export declare const defineDefaults: (defaults?: { /** @deprecated mock from `node:test` is used internally */ mockFactory?: any; /** @deprecated mock from `node:test` is used internally */ accumulateMockArgs?: (mock: Record) => Record; } & HelpersDefaults) => Promise; export declare const createJHipsterConfigFiles: (configuration: Record, entities?: Entity[]) => Record; export type FakeBlueprintOptions = { packageJson?: any; generator?: string | string[]; generatorContent?: string; files?: Record; }; export declare const createBlueprintFiles: (blueprintPackage: string, { packageJson, generator, generatorContent, files }?: FakeBlueprintOptions) => { [x: string]: any; }; declare class JHipsterRunContext extends RunContext { sharedSource: Record; private sharedApplication; private readonly workspaceApplications; private commonWorkspacesConfig; private generateApplicationsSet; withOptions(options: Partial & Record>): this; withJHipsterConfig(configuration?: Readonly>, entities?: Entity[]): this; withSkipWritingPriorities(): this; withWorkspacesCommonConfig(commonWorkspacesConfig: Record): this; withWorkspaceApplicationAtFolder(workspaceFolder: string, configuration: Record, entities?: Entity[]): this; withWorkspaceApplication(configuration: Record, entities?: Entity[]): this; withWorkspacesSamples(...appNames: string[]): this; withGenerateWorkspaceApplications(generateWorkspaces?: boolean): this; withBlueprintConfig(config: Record): this; /** * Use configured default blueprint. */ withConfiguredBlueprint(): this; withFakeTestBlueprint(blueprintPackage: string, { packageJson, generator }?: FakeBlueprintOptions): this; withMockedSource(options?: { except?: string[]; }): this; withSharedApplication(sharedApplication: Record): this; withMockedNodeDependencies(): this; /** * Mock every built-in generators except the ones in the except and bootstrap-* generators. * Note: Bootstrap generator is mocked by default. * @example * withMockedJHipsterGenerators({ except: ['jhipster:bootstrap'] }) * @example * withMockedJHipsterGenerators({ except: ['bootstrap', 'server'] }) * @example * // Mock every generator including bootstrap-* * withMockedJHipsterGenerators({ filter: () => true }) */ withMockedJHipsterGenerators(options?: (keyof GeneratorsByNamespace)[] | { except?: (keyof GeneratorsByNamespace)[]; filter?: (gen: keyof GeneratorsByNamespace) => boolean; }): this; withJHipsterGenerators(options?: WithJHipsterGenerators): this; withGradleBuildTool(): this; private withContextData; withJHipsterContextOptions(opts?: RunJHipster): this; withCommandName(): this; prepareEnvironment(): this; run(): Promise>; withTask(priorityName: (typeof APPLICATION_PRIORITY_NAMES)[keyof typeof APPLICATION_PRIORITY_NAMES] | (typeof WORKSPACES_PRIORITY_NAMES)[keyof typeof WORKSPACES_PRIORITY_NAMES], method: (this: BaseCoreGenerator, ...args: any[]) => any): this; } declare class JHipsterTest extends YeomanTest { constructor(); run = YeomanGenerator>(GeneratorOrNamespace: string | GetGeneratorConstructor, settings?: RunContextSettings, envOptions?: EnvironmentOptions & { createEnv?: any; }): JHipsterRunContext; runJHipster(jhipsterGenerator: string, settings?: RunContextSettings, envOptions?: EnvironmentOptions): JHipsterRunContext; runJHipster(jhipsterGenerator: string, options?: RunJHipster): JHipsterRunContext; runCli(command: string | string[], options?: { commands?: Record; prepareEnvironment?: boolean; entrypointGenerator?: string; }): JHipsterRunContext; runJHipsterDeployment(jhipsterGenerator: string, settings?: RunContextSettings, envOptions?: EnvironmentOptions): JHipsterRunContext; /** * Run a generator in current application context. */ runJHipsterInApplication(jhipsterGenerator: string, settings?: RunContextSettings, envOptions?: EnvironmentOptions): JHipsterRunContext; runJDL(jdl: string, settings?: RunContextSettings, envOptions?: EnvironmentOptions): JHipsterRunContext; /** * Run the JDL generator in current application context. */ runJDLInApplication(jdl: string, settings?: RunContextSettings, envOptions?: EnvironmentOptions): JHipsterRunContext; runTestBlueprintGenerator(): JHipsterRunContext; create = YeomanGenerator>(GeneratorOrNamespace: string | GetGeneratorConstructor, settings?: RunContextSettings, envOptions?: EnvironmentOptions): JHipsterRunContext; generateDeploymentWorkspaces(commonConfig?: Record): JHipsterRunContext; instantiateDummyBaseCoreGenerator(): Promise; createEnv(options: EnvironmentOptions): Promise; } export declare function createTestHelpers(options?: any): JHipsterTest; export declare const basicHelpers: JHipsterTest; export declare const defaultHelpers: JHipsterTest; export declare const skipPrettierHelpers: JHipsterTest; export declare const dryRunHelpers: JHipsterTest;