UNPKG

gen-jhipster

Version:

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

158 lines (157 loc) 8.36 kB
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<GeneratorType extends BaseCoreGenerator = BaseCoreGenerator> = Omit<RunResult<GeneratorType>, 'env'> & { env: Environment; /** * First argument of mocked source calls. */ sourceCallsArg: Record<string, unknown[]>; /** * Composed generators that were mocked. */ composedMockedGenerators: string[]; createJHipster: (ns: string) => JHipsterRunContext; application?: ApplicationAll; entities?: Record<string, Entity>; }; type HelpersDefaults = { /** Blueprint namespace */ blueprint?: string; /** Path where blueprint's generators folder is located */ blueprintPackagePath?: string; entrypointGenerator?: string; }; declare const runResult: JHipsterRunResult<BaseApplicationGenerator>; declare const coreRunResult: JHipsterRunResult; export declare const resultWithGenerator: <T extends BaseCoreGenerator>() => JHipsterRunResult<T>; 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<string, any>) => Record<string, any>; } & HelpersDefaults) => Promise<void>; export declare const createJHipsterConfigFiles: (configuration: Record<string, unknown>, entities?: Entity[]) => Record<string, any>; export type FakeBlueprintOptions = { packageJson?: any; generator?: string | string[]; generatorContent?: string; files?: Record<string, unknown>; }; export declare const createBlueprintFiles: (blueprintPackage: string, { packageJson, generator, generatorContent, files }?: FakeBlueprintOptions) => { [x: string]: any; }; declare class JHipsterRunContext extends RunContext<BaseCoreGenerator> { sharedSource: Record<string, any>; private sharedApplication; private readonly workspaceApplications; private commonWorkspacesConfig; private generateApplicationsSet; withOptions(options: Partial<Omit<OptionsAll, 'env' | 'resolved' | 'namespace'> & Record<string, any>>): this; withJHipsterConfig<Config extends EmptyObject>(configuration?: Readonly<Partial<Config & ApplicationConfiguration>>, entities?: Entity[]): this; withSkipWritingPriorities(): this; withWorkspacesCommonConfig(commonWorkspacesConfig: Record<string, unknown>): this; withWorkspaceApplicationAtFolder(workspaceFolder: string, configuration: Record<string, unknown>, entities?: Entity[]): this; withWorkspaceApplication(configuration: Record<string, unknown>, entities?: Entity[]): this; withWorkspacesSamples(...appNames: string[]): this; withGenerateWorkspaceApplications(generateWorkspaces?: boolean): this; withBlueprintConfig(config: Record<string, any>): this; /** * Use configured default blueprint. */ withConfiguredBlueprint(): this; withFakeTestBlueprint(blueprintPackage: string, { packageJson, generator }?: FakeBlueprintOptions): this; withMockedSource(options?: { except?: string[]; }): this; withSharedApplication(sharedApplication: Record<string, any>): 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<RunResult<BaseCoreGenerator>>; 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<GeneratorType extends YeomanGenerator<GeneratorTestOptions> = YeomanGenerator<GeneratorTestOptions>>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, 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<string, CliCommand>; 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<GeneratorType extends YeomanGenerator<GeneratorTestOptions> = YeomanGenerator<GeneratorTestOptions>>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, envOptions?: EnvironmentOptions): JHipsterRunContext; generateDeploymentWorkspaces(commonConfig?: Record<string, unknown>): JHipsterRunContext; instantiateDummyBaseCoreGenerator(): Promise<BaseCoreGenerator>; createEnv(options: EnvironmentOptions): Promise<Environment>; } 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;