yeoman-test 11.5.2 → 11.6.0
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/run-context.d.ts +12 -11
- package/dist/run-context.js +5 -2
- package/dist/run-result.d.ts +5 -5
- package/dist/run-result.js +2 -2
- package/package.json +1 -1
package/dist/run-context.d.ts
CHANGED
|
@@ -31,13 +31,13 @@ export type RunContextSettings = {
|
|
|
31
31
|
*/
|
|
32
32
|
namespace?: string;
|
|
33
33
|
};
|
|
34
|
-
type PromiseRunResult<GeneratorType extends BaseGenerator
|
|
34
|
+
type PromiseRunResult<GeneratorType extends BaseGenerator, ResultType = RunResult<GeneratorType>> = Promise<ResultType>;
|
|
35
35
|
type MockedGeneratorFactory<GenParameter extends BaseGenerator = DefaultGeneratorApi> = (GeneratorClass?: GetGeneratorConstructor<GenParameter>) => GetGeneratorConstructor<GenParameter>;
|
|
36
36
|
type EnvironmentOptions = BaseEnvironmentOptions & {
|
|
37
37
|
createEnv?: CreateEnvironment;
|
|
38
38
|
};
|
|
39
|
-
export declare class RunContextBase<GeneratorType extends BaseGenerator = DefaultGeneratorApi
|
|
40
|
-
readonly mockedGenerators: Record<string,
|
|
39
|
+
export declare class RunContextBase<GeneratorType extends BaseGenerator = DefaultGeneratorApi, ResultType = RunResult<GeneratorType>> extends EventEmitter {
|
|
40
|
+
readonly mockedGenerators: Record<string, unknown>;
|
|
41
41
|
env: DefaultEnvironmentApi;
|
|
42
42
|
generator: GeneratorType;
|
|
43
43
|
readonly settings: RunContextSettings;
|
|
@@ -81,11 +81,12 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
|
|
|
81
81
|
* @return {this}
|
|
82
82
|
*/
|
|
83
83
|
constructor(generatorType?: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions, helpers?: YeomanTest);
|
|
84
|
+
createRunResult(): ResultType;
|
|
84
85
|
/**
|
|
85
86
|
* Run the generator on the environment and promises a RunResult instance.
|
|
86
87
|
* @return {PromiseRunResult} Promise a RunResult instance.
|
|
87
88
|
*/
|
|
88
|
-
run(): PromiseRunResult<GeneratorType>;
|
|
89
|
+
run(): PromiseRunResult<GeneratorType, ResultType>;
|
|
89
90
|
on(eventName: string | symbol, listener: (...arguments_: any[]) => void): this;
|
|
90
91
|
/**
|
|
91
92
|
* @deprecated
|
|
@@ -153,14 +154,14 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
|
|
|
153
154
|
* @param {Function} [cb] - callback who'll receive the folder path as argument
|
|
154
155
|
* @return {this} run context instance
|
|
155
156
|
*/
|
|
156
|
-
withEnvironment(callback: (this: this, environment: DefaultEnvironmentApi) => DefaultEnvironmentApi | void): this;
|
|
157
|
+
withEnvironment(callback: (this: this, environment: DefaultEnvironmentApi) => DefaultEnvironmentApi | void | Promise<DefaultEnvironmentApi | void>): this;
|
|
157
158
|
/**
|
|
158
159
|
* Customize enviroment run method.
|
|
159
160
|
*
|
|
160
161
|
* @param callback
|
|
161
162
|
* @return {this} run context instance
|
|
162
163
|
*/
|
|
163
|
-
withEnvironmentRun(callback: (this: this, env: DefaultEnvironmentApi, gen: GeneratorType) => void): this;
|
|
164
|
+
withEnvironmentRun(callback: (this: this, env: DefaultEnvironmentApi, gen: GeneratorType) => void | Promise<void>): this;
|
|
164
165
|
/**
|
|
165
166
|
* Run lookup on the environment.
|
|
166
167
|
*
|
|
@@ -306,7 +307,7 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
|
|
|
306
307
|
* Return a promise representing the generator run process
|
|
307
308
|
* @return Promise resolved on end or rejected on error
|
|
308
309
|
*/
|
|
309
|
-
protected toPromise(): PromiseRunResult<GeneratorType>;
|
|
310
|
+
protected toPromise(): PromiseRunResult<GeneratorType, ResultType>;
|
|
310
311
|
protected _createRunResultOptions(): RunResultOptions<GeneratorType>;
|
|
311
312
|
/**
|
|
312
313
|
* Keeps compatibility with events
|
|
@@ -321,10 +322,10 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
|
|
|
321
322
|
*/
|
|
322
323
|
private setDir;
|
|
323
324
|
}
|
|
324
|
-
export default class RunContext<GeneratorType extends BaseGenerator = BaseGenerator
|
|
325
|
-
then<TResult1 =
|
|
326
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined): Promise<
|
|
327
|
-
finally(onfinally?: (() => void) | undefined): Promise<
|
|
325
|
+
export default class RunContext<GeneratorType extends BaseGenerator = BaseGenerator, ResultType = RunResult<GeneratorType>> extends RunContextBase<GeneratorType, ResultType> implements Promise<ResultType> {
|
|
326
|
+
then<TResult1 = ResultType, TResult2 = never>(onfulfilled?: ((value: ResultType) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
327
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<ResultType | TResult>;
|
|
328
|
+
finally(onfinally?: (() => void) | null | undefined): Promise<ResultType>;
|
|
328
329
|
get [Symbol.toStringTag](): string;
|
|
329
330
|
}
|
|
330
331
|
export declare class BasicRunContext<GeneratorType extends BaseGenerator = BaseGenerator> extends RunContext<GeneratorType> {
|
package/dist/run-context.js
CHANGED
|
@@ -74,6 +74,9 @@ export class RunContextBase extends EventEmitter {
|
|
|
74
74
|
this.memFs = settings?.memFs ?? createMemFs();
|
|
75
75
|
this.mockedGeneratorFactory = this.helpers.createMockedGenerator;
|
|
76
76
|
}
|
|
77
|
+
createRunResult() {
|
|
78
|
+
return new RunResult(this._createRunResultOptions());
|
|
79
|
+
}
|
|
77
80
|
/**
|
|
78
81
|
* Run the generator on the environment and promises a RunResult instance.
|
|
79
82
|
* @return {PromiseRunResult} Promise a RunResult instance.
|
|
@@ -91,7 +94,7 @@ export class RunContextBase extends EventEmitter {
|
|
|
91
94
|
this.helpers.restorePrompt(this.env);
|
|
92
95
|
this.completed = true;
|
|
93
96
|
}
|
|
94
|
-
const runResult =
|
|
97
|
+
const runResult = this.createRunResult();
|
|
95
98
|
testContext.runResult = runResult;
|
|
96
99
|
return runResult;
|
|
97
100
|
}
|
|
@@ -582,7 +585,7 @@ export class RunContextBase extends EventEmitter {
|
|
|
582
585
|
* @return Promise resolved on end or rejected on error
|
|
583
586
|
*/
|
|
584
587
|
async toPromise() {
|
|
585
|
-
return this.environmentPromise ?? this.run();
|
|
588
|
+
return (this.environmentPromise ?? this.run());
|
|
586
589
|
}
|
|
587
590
|
_createRunResultOptions() {
|
|
588
591
|
return {
|
package/dist/run-result.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type RunResultOptions<GeneratorType extends BaseGenerator> = {
|
|
|
34
34
|
/**
|
|
35
35
|
* The mocked generators of the context.
|
|
36
36
|
*/
|
|
37
|
-
mockedGenerators: Record<string,
|
|
37
|
+
mockedGenerators: Record<string, unknown>;
|
|
38
38
|
spawnStub?: any;
|
|
39
39
|
settings: RunContextSettings;
|
|
40
40
|
helpers: YeomanTest;
|
|
@@ -50,7 +50,7 @@ export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerat
|
|
|
50
50
|
oldCwd: string;
|
|
51
51
|
memFs: Store<MemFsEditorFile>;
|
|
52
52
|
fs: MemFsEditor;
|
|
53
|
-
mockedGenerators: Record<string,
|
|
53
|
+
mockedGenerators: Record<string, unknown>;
|
|
54
54
|
options: RunResultOptions<GeneratorType>;
|
|
55
55
|
spawnStub?: any;
|
|
56
56
|
readonly askedQuestions: AskedQuestions;
|
|
@@ -59,7 +59,7 @@ export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerat
|
|
|
59
59
|
* Create another RunContext reusing the settings.
|
|
60
60
|
* See helpers.create api
|
|
61
61
|
*/
|
|
62
|
-
create<G extends BaseGenerator = GeneratorType>(GeneratorOrNamespace: string | GetGeneratorConstructor<G>, settings?: RunContextSettings, environmentOptions?: BaseEnvironmentOptions): import("./run-context.js").default<G
|
|
62
|
+
create<G extends BaseGenerator = GeneratorType>(GeneratorOrNamespace: string | GetGeneratorConstructor<G>, settings?: RunContextSettings, environmentOptions?: BaseEnvironmentOptions): import("./run-context.js").default<G, RunResult<G>>;
|
|
63
63
|
getSpawnArgsUsingDefaultImplementation(): unknown[][];
|
|
64
64
|
/**
|
|
65
65
|
* Return an object with fs changes.
|
|
@@ -217,9 +217,9 @@ export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerat
|
|
|
217
217
|
/**
|
|
218
218
|
* Get the generator mock
|
|
219
219
|
* @param generator - the namespace of the mocked generator
|
|
220
|
-
* @returns the generator mock
|
|
220
|
+
* @returns the generator mock, by default is the mock property of node:test's mock.
|
|
221
221
|
*/
|
|
222
|
-
getGeneratorMock
|
|
222
|
+
getGeneratorMock<MockType = ReturnType<typeof mock.fn>['mock']>(generator: string): MockType;
|
|
223
223
|
/**
|
|
224
224
|
* Get the number of times a mocked generator was composed
|
|
225
225
|
* @param generator - the namespace of the mocked generator
|
package/dist/run-result.js
CHANGED
|
@@ -271,14 +271,14 @@ export default class RunResult {
|
|
|
271
271
|
/**
|
|
272
272
|
* Get the generator mock
|
|
273
273
|
* @param generator - the namespace of the mocked generator
|
|
274
|
-
* @returns the generator mock
|
|
274
|
+
* @returns the generator mock, by default is the mock property of node:test's mock.
|
|
275
275
|
*/
|
|
276
276
|
getGeneratorMock(generator) {
|
|
277
277
|
const mockedGenerator = this.mockedGenerators[generator];
|
|
278
278
|
if (!mockedGenerator) {
|
|
279
279
|
throw new Error(`Generator ${generator} is not mocked`);
|
|
280
280
|
}
|
|
281
|
-
return mockedGenerator.mock;
|
|
281
|
+
return (mockedGenerator.mock ?? mockedGenerator);
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
284
|
* Get the number of times a mocked generator was composed
|