yeoman-test 8.0.0-beta.7 → 8.0.0-rc.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/adapter.d.ts +10 -2
- package/dist/adapter.js +7 -0
- package/dist/helpers.d.ts +6 -1
- package/dist/helpers.js +8 -1
- package/dist/run-context.js +1 -2
- package/package.json +2 -2
package/dist/adapter.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type AdapterWithProgress } from '@yeoman/adapter';
|
|
2
|
+
import type { PromptAnswers, PromptQuestion, Logger, PromptQuestions, Task } from '@yeoman/types';
|
|
2
3
|
import { type PromptModule } from 'inquirer';
|
|
3
4
|
export type DummyPromptCallback = (answer: any, { question, answers }: {
|
|
4
5
|
question: PromptQuestion;
|
|
@@ -20,12 +21,19 @@ export declare class DummyPrompt {
|
|
|
20
21
|
constructor(question: PromptQuestion, _rl: any, answers: PromptAnswers, options?: DummyPromptOptions);
|
|
21
22
|
run(): Promise<any>;
|
|
22
23
|
}
|
|
23
|
-
export declare class TestAdapter implements
|
|
24
|
+
export declare class TestAdapter implements AdapterWithProgress {
|
|
24
25
|
promptModule: PromptModule;
|
|
25
26
|
diff: any;
|
|
26
27
|
log: Logger;
|
|
27
28
|
registerDummyPrompt: (promptName: string, customPromptOptions?: DummyPromptOptions) => PromptModule;
|
|
28
29
|
constructor(options?: TestAdapterOptions);
|
|
30
|
+
queue<TaskResultType>(fn: Task<TaskResultType>): Promise<void | TaskResultType>;
|
|
31
|
+
progress<ReturnType>(fn: (progress: {
|
|
32
|
+
step: (prefix: string, message: string, ...args: any[]) => void;
|
|
33
|
+
}) => ReturnType, _options?: {
|
|
34
|
+
disabled?: boolean | undefined;
|
|
35
|
+
name?: string | undefined;
|
|
36
|
+
} | undefined): Promise<void | ReturnType>;
|
|
29
37
|
close(): void;
|
|
30
38
|
prompt<A extends PromptAnswers = PromptAnswers>(questions: PromptQuestions<A>, initialAnswers?: Partial<A> | undefined): Promise<A>;
|
|
31
39
|
}
|
package/dist/adapter.js
CHANGED
|
@@ -84,6 +84,13 @@ export class TestAdapter {
|
|
|
84
84
|
this.log[methodName] = sinonStub().returns(this.log);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
async queue(fn) {
|
|
88
|
+
return fn(this);
|
|
89
|
+
}
|
|
90
|
+
async progress(fn, _options) {
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
92
|
+
return fn({ step() { } });
|
|
93
|
+
}
|
|
87
94
|
close() {
|
|
88
95
|
this.promptModule.restoreDefaultPrompts();
|
|
89
96
|
}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BaseEnvironment, BaseEnvironmentOptions, BaseGenerator, BaseGeneratorOptions, GetGeneratorConstructor, InstantiateOptions, PromptAnswers } from '@yeoman/types';
|
|
2
2
|
import type { SinonSpiedInstance } from 'sinon';
|
|
3
3
|
import type { DefaultEnvironmentApi, DefaultGeneratorApi } from '../types/type-helpers.js';
|
|
4
|
-
import { type DummyPromptOptions } from './adapter.js';
|
|
4
|
+
import { type DummyPromptOptions, TestAdapter, type TestAdapterOptions } from './adapter.js';
|
|
5
5
|
import RunContext, { BasicRunContext, type RunContextSettings } from './run-context.js';
|
|
6
6
|
export type CreateEnv = (options: BaseEnvironmentOptions) => Promise<BaseEnvironment>;
|
|
7
7
|
/**
|
|
@@ -16,6 +16,7 @@ export declare class YeomanTest {
|
|
|
16
16
|
settings?: RunContextSettings;
|
|
17
17
|
environmentOptions?: BaseEnvironmentOptions;
|
|
18
18
|
generatorOptions?: BaseGeneratorOptions;
|
|
19
|
+
adapterOptions?: Omit<TestAdapterOptions, 'mockedAnswers'>;
|
|
19
20
|
/**
|
|
20
21
|
* @deprecated
|
|
21
22
|
* Create a function that will clean up the test directory,
|
|
@@ -118,6 +119,10 @@ export declare class YeomanTest {
|
|
|
118
119
|
* const env = createTestEnv(require('yeoman-environment').createEnv);
|
|
119
120
|
*/
|
|
120
121
|
createTestEnv(envContructor?: CreateEnv, options?: BaseEnvironmentOptions): Promise<BaseEnvironment>;
|
|
122
|
+
/**
|
|
123
|
+
* Creates a TestAdapter using helpers default options.
|
|
124
|
+
*/
|
|
125
|
+
createTestAdapter(options?: TestAdapterOptions): TestAdapter;
|
|
121
126
|
/**
|
|
122
127
|
* Get RunContext type
|
|
123
128
|
* @return {RunContext}
|
package/dist/helpers.js
CHANGED
|
@@ -22,6 +22,7 @@ export class YeomanTest {
|
|
|
22
22
|
settings;
|
|
23
23
|
environmentOptions;
|
|
24
24
|
generatorOptions;
|
|
25
|
+
adapterOptions;
|
|
25
26
|
/**
|
|
26
27
|
* @deprecated
|
|
27
28
|
* Create a function that will clean up the test directory,
|
|
@@ -228,7 +229,13 @@ export class YeomanTest {
|
|
|
228
229
|
...options,
|
|
229
230
|
};
|
|
230
231
|
}
|
|
231
|
-
return envContructor({ adapter:
|
|
232
|
+
return envContructor({ adapter: this.createTestAdapter(), ...envOptions });
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Creates a TestAdapter using helpers default options.
|
|
236
|
+
*/
|
|
237
|
+
createTestAdapter(options) {
|
|
238
|
+
return new TestAdapter({ ...this.adapterOptions, ...options });
|
|
232
239
|
}
|
|
233
240
|
/**
|
|
234
241
|
* Get RunContext type
|
package/dist/run-context.js
CHANGED
|
@@ -12,7 +12,6 @@ import tempDirectory from 'temp-dir';
|
|
|
12
12
|
import { create as createMemFsEditor } from 'mem-fs-editor';
|
|
13
13
|
import RunResult from './run-result.js';
|
|
14
14
|
import defaultHelpers from './helpers.js';
|
|
15
|
-
import { TestAdapter } from './adapter.js';
|
|
16
15
|
import testContext from './test-context.js';
|
|
17
16
|
const { camelCase, kebabCase, merge: lodashMerge, set: lodashSet } = _;
|
|
18
17
|
export class RunContextBase extends EventEmitter {
|
|
@@ -490,7 +489,7 @@ export class RunContextBase extends EventEmitter {
|
|
|
490
489
|
force: true,
|
|
491
490
|
skipCache: true,
|
|
492
491
|
skipInstall: true,
|
|
493
|
-
adapter:
|
|
492
|
+
adapter: this.helpers.createTestAdapter({ ...this.adapterOptions, mockedAnswers: this.answers }),
|
|
494
493
|
...this.envOptions,
|
|
495
494
|
});
|
|
496
495
|
this.env = this.envCB ? (await this.envCB(testEnv)) ?? testEnv : testEnv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-test",
|
|
3
|
-
"version": "8.0.0-
|
|
3
|
+
"version": "8.0.0-rc.0",
|
|
4
4
|
"description": "Test utilities for Yeoman generators",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yeoman",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"doc_path": "../yeoman-test-doc"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@yeoman/adapter": "^1.0.
|
|
39
|
+
"@yeoman/adapter": "^1.0.4",
|
|
40
40
|
"inquirer": "^9.2.2",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"mem-fs": "^3.0.0",
|