yeoman-test 11.4.2 → 11.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers.d.ts +8 -5
- package/dist/helpers.js +7 -3
- package/dist/run-context.d.ts +2 -2
- package/dist/run-result.d.ts +1 -1
- package/package.json +1 -1
package/dist/helpers.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type Dependency = string | Parameters<DefaultEnvironmentApi['register']>;
|
|
|
21
21
|
export declare class YeomanTest {
|
|
22
22
|
settings?: RunContextSettings;
|
|
23
23
|
environmentOptions?: EnvironmentOptions;
|
|
24
|
-
generatorOptions?: GeneratorOptions
|
|
24
|
+
generatorOptions?: Partial<Omit<GeneratorOptions, 'env' | 'resolved' | 'namespace'>>;
|
|
25
25
|
adapterOptions?: Omit<TestAdapterOptions, 'mockedAnswers'>;
|
|
26
26
|
defaultGenerator?: string;
|
|
27
27
|
importMeta?: Pick<ImportMeta, 'resolve'>;
|
|
@@ -136,21 +136,22 @@ export declare class YeomanTest {
|
|
|
136
136
|
* @return {RunContext}
|
|
137
137
|
*/
|
|
138
138
|
getRunContextType(): typeof RunContext;
|
|
139
|
+
createRunContext<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): RunContext<GeneratorType>;
|
|
139
140
|
/**
|
|
140
141
|
* Run the provided Generator
|
|
141
142
|
* @param GeneratorOrNamespace - Generator constructor or namespace
|
|
142
143
|
*/
|
|
143
|
-
run<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions):
|
|
144
|
+
run<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): ReturnType<typeof this.createRunContext<GeneratorType>>;
|
|
144
145
|
/**
|
|
145
146
|
* Run the default generator
|
|
146
147
|
*/
|
|
147
|
-
runDefault<GeneratorType extends BaseGenerator = BaseGenerator>(settings?: RunContextSettings, environmentOptions?: EnvironmentOptions):
|
|
148
|
+
runDefault<GeneratorType extends BaseGenerator = BaseGenerator>(settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): ReturnType<typeof this.createRunContext<GeneratorType>>;
|
|
148
149
|
/**
|
|
149
150
|
* Prepare a run context
|
|
150
151
|
* @param {String|Function} GeneratorOrNamespace - Generator constructor or namespace
|
|
151
152
|
* @return {RunContext}
|
|
152
153
|
*/
|
|
153
|
-
create<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions):
|
|
154
|
+
create<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): ReturnType<typeof this.createRunContext<GeneratorType>>;
|
|
154
155
|
/**
|
|
155
156
|
* Prepare temporary dir without generator support.
|
|
156
157
|
* Generator and environment will be undefined.
|
|
@@ -159,4 +160,6 @@ export declare class YeomanTest {
|
|
|
159
160
|
}
|
|
160
161
|
declare const defaultHelpers: YeomanTest;
|
|
161
162
|
export default defaultHelpers;
|
|
162
|
-
export declare const createHelpers: (options: Partial<
|
|
163
|
+
export declare const createHelpers: <T extends YeomanTest = YeomanTest>(options: Partial<T> & {
|
|
164
|
+
factory?: () => T;
|
|
165
|
+
}) => T;
|
package/dist/helpers.js
CHANGED
|
@@ -249,6 +249,10 @@ export class YeomanTest {
|
|
|
249
249
|
getRunContextType() {
|
|
250
250
|
return RunContext;
|
|
251
251
|
}
|
|
252
|
+
createRunContext(GeneratorOrNamespace, settings, environmentOptions) {
|
|
253
|
+
const RunContext = this.getRunContextType();
|
|
254
|
+
return new RunContext(GeneratorOrNamespace, settings, environmentOptions, this);
|
|
255
|
+
}
|
|
252
256
|
/**
|
|
253
257
|
* Run the provided Generator
|
|
254
258
|
* @param GeneratorOrNamespace - Generator constructor or namespace
|
|
@@ -256,7 +260,6 @@ export class YeomanTest {
|
|
|
256
260
|
run(GeneratorOrNamespace, settings, environmentOptions) {
|
|
257
261
|
const contextSettings = cloneDeep(this.settings ?? {});
|
|
258
262
|
const generatorOptions = cloneDeep(this.generatorOptions ?? {});
|
|
259
|
-
const RunContext = this.getRunContextType();
|
|
260
263
|
if (typeof GeneratorOrNamespace === 'string') {
|
|
261
264
|
if (GeneratorOrNamespace.startsWith('.')) {
|
|
262
265
|
if (!this.importMeta) {
|
|
@@ -268,7 +271,7 @@ export class YeomanTest {
|
|
|
268
271
|
GeneratorOrNamespace = fileURLToPath(GeneratorOrNamespace);
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
|
-
const runContext =
|
|
274
|
+
const runContext = this.createRunContext(GeneratorOrNamespace, { ...contextSettings, ...settings }, environmentOptions).withOptions(generatorOptions);
|
|
272
275
|
if (settings?.autoCleanup !== false) {
|
|
273
276
|
testContext.startNewContext(runContext);
|
|
274
277
|
}
|
|
@@ -306,7 +309,8 @@ export class YeomanTest {
|
|
|
306
309
|
const defaultHelpers = new YeomanTest();
|
|
307
310
|
export default defaultHelpers;
|
|
308
311
|
export const createHelpers = (options) => {
|
|
309
|
-
const
|
|
312
|
+
const { factory = () => new YeomanTest() } = options;
|
|
313
|
+
const helpers = factory();
|
|
310
314
|
Object.assign(helpers, options);
|
|
311
315
|
return helpers;
|
|
312
316
|
};
|
package/dist/run-context.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
|
|
|
53
53
|
private args;
|
|
54
54
|
private options;
|
|
55
55
|
private answers?;
|
|
56
|
-
private readonly adapterOptions
|
|
56
|
+
private readonly adapterOptions;
|
|
57
57
|
private keepFsState?;
|
|
58
58
|
private readonly onGeneratorCallbacks;
|
|
59
59
|
private readonly onTargetDirectoryCallbacks;
|
|
@@ -153,7 +153,7 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
|
|
|
153
153
|
* @param {Function} [cb] - callback who'll receive the folder path as argument
|
|
154
154
|
* @return {this} run context instance
|
|
155
155
|
*/
|
|
156
|
-
withEnvironment(callback:
|
|
156
|
+
withEnvironment(callback: (this: this, environment: DefaultEnvironmentApi) => DefaultEnvironmentApi | void): this;
|
|
157
157
|
/**
|
|
158
158
|
* Customize enviroment run method.
|
|
159
159
|
*
|
package/dist/run-result.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export type RunResultOptions<GeneratorType extends BaseGenerator> = {
|
|
|
44
44
|
* This class provides utilities for testing generated content.
|
|
45
45
|
*/
|
|
46
46
|
export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerator> {
|
|
47
|
-
env:
|
|
47
|
+
env: DefaultEnvironmentApi;
|
|
48
48
|
generator: GeneratorType;
|
|
49
49
|
cwd: string;
|
|
50
50
|
oldCwd: string;
|