gen-jhipster
Version:
Spring Boot + Angular/React/Vue in one handy generator
160 lines (159 loc) • 7.92 kB
TypeScript
import type { RunContextSettings, RunResult } from 'yeoman-test';
import { RunContext, YeomanTest } from 'yeoman-test';
import type Environment from 'yeoman-environment';
import type { BaseEnvironmentOptions, GetGeneratorConstructor, BaseGenerator as YeomanGenerator } from '@yeoman/types';
import type { EmptyObject } from 'type-fest';
import type { JHipsterGeneratorOptions } from '../../generators/base/api.js';
import type CoreGenerator from '../../generators/base-core/generator.js';
import type { ApplicationConfiguration } from '../types/application/yo-rc.js';
import type { Entity } from '../types/base/entity.js';
import type { CliCommand } from '../../cli/types.js';
type GeneratorTestType = YeomanGenerator<JHipsterGeneratorOptions>;
type GeneratorTestOptions = JHipsterGeneratorOptions;
type WithJHipsterGenerators = {
/**
* Apply default mocks.
*/
useDefaultMocks?: boolean;
/**
* List of generators to don't mock.
*/
actualGeneratorsList?: string[];
/**
* Filter to mock a generator.
*/
useMock?: (ns: string) => boolean;
};
type RunJHipster = WithJHipsterGenerators & {
/**
* Use the EnviromentBuilder default preparation to create the environment.
* Includes local and dev blueprints.
*/
useEnvironmentBuilder?: boolean;
};
type JHipsterRunResult<GeneratorType extends CoreGenerator = CoreGenerator> = 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, options?: WithJHipsterGenerators) => JHipsterRunContext;
};
type HelpersDefaults = {
/** Blueprint namespace */
blueprint?: string;
/** Path where blueprint's generators folder is located */
blueprintPackagePath?: string;
entrypointGenerator?: string;
};
declare const runResult: JHipsterRunResult;
export { 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<GeneratorTestType> {
sharedSource: Record<string, any>;
private sharedData;
private sharedApplication;
private sharedControl;
private workspaceApplications;
private commonWorkspacesConfig;
private generateApplicationsSet;
withOptions(options: Partial<Omit<JHipsterGeneratorOptions, '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;
/** @deprecated use withJHipsterGenerators */
withJHipsterLookup(): this;
withBlueprintConfig(config: Record<string, any>): this;
/**
* Use configured default blueprint.
*/
withConfiguredBlueprint(): this;
/**
* Lookup generators at gen-jhipster's parent at a npm repository
* @param lookups generators relative folder
* @returns
*/
withParentBlueprintLookup(lookups?: string[]): this;
withFakeTestBlueprint(blueprintPackage: string, { packageJson, generator }?: FakeBlueprintOptions): this;
withMockedSource(options?: {
except?: string[];
}): this;
withControl(sharedControl: Record<string, any>): this;
withSharedApplication(sharedApplication: Record<string, any>): this;
withMockedNodeDependencies(): this;
/**
* Mock every built-in generators except the ones in the except and bootstrap-* generators.
* Note: Boostrap 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?: string[] | {
except?: string[];
filter?: (string: any) => boolean;
}): this;
withJHipsterGenerators(options?: WithJHipsterGenerators): this;
withGradleBuildTool(): this;
private withSharedData;
run(): Promise<RunResult<GeneratorTestType>>;
}
declare class JHipsterTest extends YeomanTest {
constructor();
run<GeneratorType extends YeomanGenerator<GeneratorTestOptions> = YeomanGenerator<GeneratorTestOptions>>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings | undefined, envOptions?: (BaseEnvironmentOptions & {
createEnv?: any;
}) | undefined): JHipsterRunContext;
runJHipster(jhipsterGenerator: string, settings?: RunContextSettings | undefined, envOptions?: BaseEnvironmentOptions | undefined): JHipsterRunContext;
runJHipster(jhipsterGenerator: string, options?: RunJHipster): JHipsterRunContext;
runCli(command: string | string[], options?: {
commands?: Record<string, CliCommand>;
useEnvironmentBuilder?: boolean;
entrypointGenerator?: string;
}): JHipsterRunContext;
/**
* Run a generator in current application context.
*/
runJHipsterInApplication(jhipsterGenerator: string, settings?: RunContextSettings | undefined, envOptions?: BaseEnvironmentOptions | undefined): JHipsterRunContext;
runJDL(jdl: string, settings?: RunContextSettings | undefined, envOptions?: BaseEnvironmentOptions | undefined): JHipsterRunContext;
/**
* Run the JDL generator in current application context.
*/
runJDLInApplication(jdl: string, settings?: RunContextSettings | undefined, envOptions?: BaseEnvironmentOptions | undefined): JHipsterRunContext;
runTestBlueprintGenerator(): JHipsterRunContext;
create<GeneratorType extends YeomanGenerator<GeneratorTestOptions> = YeomanGenerator<GeneratorTestOptions>>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings | undefined, envOptions?: BaseEnvironmentOptions | undefined): JHipsterRunContext;
/** @deprecated */
createJHipster(jhipsterGenerator: string, settings?: RunContextSettings | undefined, envOptions?: BaseEnvironmentOptions | undefined): JHipsterRunContext;
generateDeploymentWorkspaces(commonConfig?: Record<string, unknown>): JHipsterRunContext;
}
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;