yeoman-test 11.3.1 → 11.4.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/adapter.js +1 -0
- package/dist/helpers.d.ts +19 -8
- package/dist/helpers.js +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/run-context.js +3 -2
- package/dist/run-result.d.ts +5 -5
- package/dist/test-context.d.ts +2 -0
- package/dist/test-context.js +1 -0
- package/package.json +18 -14
package/dist/adapter.js
CHANGED
package/dist/helpers.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { mock } from 'node:test';
|
|
2
2
|
import type { BaseEnvironment, BaseEnvironmentOptions, BaseGenerator, BaseGeneratorConstructor, BaseGeneratorOptions, GetGeneratorConstructor, InstantiateOptions, PromptAnswers } from '@yeoman/types';
|
|
3
|
+
import type { IsAny } from 'type-fest';
|
|
3
4
|
import type { DefaultEnvironmentApi, DefaultGeneratorApi } from '../types/type-helpers.js';
|
|
4
5
|
import { type DummyPromptOptions, TestAdapter, type TestAdapterOptions } from './adapter.js';
|
|
5
6
|
import RunContext, { BasicRunContext, type RunContextSettings } from './run-context.js';
|
|
7
|
+
type YeomanGeneratorOptions = import('yeoman-generator').BaseOptions;
|
|
8
|
+
type GeneratorOptions = IsAny<YeomanGeneratorOptions> extends true ? BaseGeneratorOptions : YeomanGeneratorOptions;
|
|
9
|
+
type YeomanEnvironmentOptions = import('yeoman-environment').EnvironmentOptions;
|
|
10
|
+
type EnvironmentOptions = IsAny<YeomanEnvironmentOptions> extends true ? BaseEnvironmentOptions : YeomanEnvironmentOptions;
|
|
6
11
|
export declare const setDefaultDummyParentClass: (parentClass: any) => void;
|
|
7
|
-
export type CreateEnv = (options:
|
|
12
|
+
export type CreateEnv = (options: EnvironmentOptions) => Promise<BaseEnvironment>;
|
|
8
13
|
/**
|
|
9
14
|
* Dependencies can be path (autodiscovery) or an array [<generator>, <name>]
|
|
10
15
|
*/
|
|
@@ -15,9 +20,11 @@ export type Dependency = string | Parameters<DefaultEnvironmentApi['register']>;
|
|
|
15
20
|
*/
|
|
16
21
|
export declare class YeomanTest {
|
|
17
22
|
settings?: RunContextSettings;
|
|
18
|
-
environmentOptions?:
|
|
19
|
-
generatorOptions?:
|
|
23
|
+
environmentOptions?: EnvironmentOptions;
|
|
24
|
+
generatorOptions?: GeneratorOptions;
|
|
20
25
|
adapterOptions?: Omit<TestAdapterOptions, 'mockedAnswers'>;
|
|
26
|
+
defaultGenerator?: string;
|
|
27
|
+
importMeta?: Pick<ImportMeta, 'resolve'>;
|
|
21
28
|
/**
|
|
22
29
|
* @deprecated
|
|
23
30
|
* Create a function that will clean up the test directory,
|
|
@@ -111,7 +118,7 @@ export declare class YeomanTest {
|
|
|
111
118
|
* createEnv.restore();
|
|
112
119
|
* });
|
|
113
120
|
*/
|
|
114
|
-
createEnv(options:
|
|
121
|
+
createEnv(options: EnvironmentOptions): Promise<DefaultEnvironmentApi>;
|
|
115
122
|
/**
|
|
116
123
|
* Creates a test environment.
|
|
117
124
|
*
|
|
@@ -119,7 +126,7 @@ export declare class YeomanTest {
|
|
|
119
126
|
* @param {Object} - Options to be passed to the environment
|
|
120
127
|
* const env = createTestEnv(require('yeoman-environment').createEnv);
|
|
121
128
|
*/
|
|
122
|
-
createTestEnv(environmentContructor?: CreateEnv, options?:
|
|
129
|
+
createTestEnv(environmentContructor?: CreateEnv, options?: EnvironmentOptions): Promise<BaseEnvironment>;
|
|
123
130
|
/**
|
|
124
131
|
* Creates a TestAdapter using helpers default options.
|
|
125
132
|
*/
|
|
@@ -133,13 +140,17 @@ export declare class YeomanTest {
|
|
|
133
140
|
* Run the provided Generator
|
|
134
141
|
* @param GeneratorOrNamespace - Generator constructor or namespace
|
|
135
142
|
*/
|
|
136
|
-
run<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?:
|
|
143
|
+
run<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): RunContext<GeneratorType>;
|
|
144
|
+
/**
|
|
145
|
+
* Run the default generator
|
|
146
|
+
*/
|
|
147
|
+
runDefault<GeneratorType extends BaseGenerator = BaseGenerator>(settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): RunContext<GeneratorType>;
|
|
137
148
|
/**
|
|
138
149
|
* Prepare a run context
|
|
139
150
|
* @param {String|Function} GeneratorOrNamespace - Generator constructor or namespace
|
|
140
151
|
* @return {RunContext}
|
|
141
152
|
*/
|
|
142
|
-
create<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?:
|
|
153
|
+
create<GeneratorType extends BaseGenerator = DefaultGeneratorApi>(GeneratorOrNamespace: string | GetGeneratorConstructor<GeneratorType>, settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): RunContext<GeneratorType>;
|
|
143
154
|
/**
|
|
144
155
|
* Prepare temporary dir without generator support.
|
|
145
156
|
* Generator and environment will be undefined.
|
|
@@ -148,4 +159,4 @@ export declare class YeomanTest {
|
|
|
148
159
|
}
|
|
149
160
|
declare const defaultHelpers: YeomanTest;
|
|
150
161
|
export default defaultHelpers;
|
|
151
|
-
export declare const createHelpers: (options:
|
|
162
|
+
export declare const createHelpers: (options: Partial<YeomanTest>) => YeomanTest;
|
package/dist/helpers.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import process from 'node:process';
|
|
5
5
|
import { mock } from 'node:test';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
6
7
|
import { cloneDeep } from 'lodash-es';
|
|
7
8
|
import { TestAdapter } from './adapter.js';
|
|
8
9
|
import RunContext, { BasicRunContext } from './run-context.js';
|
|
@@ -25,6 +26,8 @@ export class YeomanTest {
|
|
|
25
26
|
environmentOptions;
|
|
26
27
|
generatorOptions;
|
|
27
28
|
adapterOptions;
|
|
29
|
+
defaultGenerator;
|
|
30
|
+
importMeta;
|
|
28
31
|
/**
|
|
29
32
|
* @deprecated
|
|
30
33
|
* Create a function that will clean up the test directory,
|
|
@@ -254,12 +257,30 @@ export class YeomanTest {
|
|
|
254
257
|
const contextSettings = cloneDeep(this.settings ?? {});
|
|
255
258
|
const generatorOptions = cloneDeep(this.generatorOptions ?? {});
|
|
256
259
|
const RunContext = this.getRunContextType();
|
|
260
|
+
if (typeof GeneratorOrNamespace === 'string' && GeneratorOrNamespace.startsWith('.')) {
|
|
261
|
+
if (!this.importMeta) {
|
|
262
|
+
throw new Error('importMeta is required to resolve relative generator paths');
|
|
263
|
+
}
|
|
264
|
+
GeneratorOrNamespace = this.importMeta.resolve(GeneratorOrNamespace);
|
|
265
|
+
if (URL.canParse(GeneratorOrNamespace)) {
|
|
266
|
+
GeneratorOrNamespace = fileURLToPath(GeneratorOrNamespace);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
257
269
|
const runContext = new RunContext(GeneratorOrNamespace, { ...contextSettings, ...settings }, environmentOptions, this).withOptions(generatorOptions);
|
|
258
270
|
if (settings?.autoCleanup !== false) {
|
|
259
271
|
testContext.startNewContext(runContext);
|
|
260
272
|
}
|
|
261
273
|
return runContext;
|
|
262
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Run the default generator
|
|
277
|
+
*/
|
|
278
|
+
runDefault(settings, environmentOptions) {
|
|
279
|
+
if (!this.defaultGenerator) {
|
|
280
|
+
throw new Error('No default generator defined');
|
|
281
|
+
}
|
|
282
|
+
return this.run(this.defaultGenerator, settings, environmentOptions);
|
|
283
|
+
}
|
|
263
284
|
/**
|
|
264
285
|
* Prepare a run context
|
|
265
286
|
* @param {String|Function} GeneratorOrNamespace - Generator constructor or namespace
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default, createHelpers, YeomanTest, type Dependency } from './helpers.js';
|
|
2
2
|
export { default as RunContext, RunContextBase, type RunContextSettings } from './run-context.js';
|
|
3
3
|
export { default as RunResult, type RunResultOptions } from './run-result.js';
|
|
4
|
-
export { default as context, result } from './test-context.js';
|
|
4
|
+
export { default as context, result, typedResult } from './test-context.js';
|
|
5
5
|
export { TestAdapter } from './adapter.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default, createHelpers, YeomanTest } from './helpers.js';
|
|
2
2
|
export { default as RunContext, RunContextBase } from './run-context.js';
|
|
3
3
|
export { default as RunResult } from './run-result.js';
|
|
4
|
-
export { default as context, result } from './test-context.js';
|
|
4
|
+
export { default as context, result, typedResult } from './test-context.js';
|
|
5
5
|
export { TestAdapter } from './adapter.js';
|
package/dist/run-context.js
CHANGED
|
@@ -10,8 +10,9 @@ import { camelCase, kebabCase, merge as lodashMerge, set as lodashSet } from 'lo
|
|
|
10
10
|
import { resetFileCommitStates } from 'mem-fs-editor/state';
|
|
11
11
|
import { create as createMemFs } from 'mem-fs';
|
|
12
12
|
import { create as createMemFsEditor } from 'mem-fs-editor';
|
|
13
|
-
import RunResult from './run-result.js';
|
|
14
|
-
import defaultHelpers from './helpers.js';
|
|
13
|
+
import RunResult, {} from './run-result.js';
|
|
14
|
+
import defaultHelpers, {} from './helpers.js';
|
|
15
|
+
import {} from './adapter.js';
|
|
15
16
|
import testContext from './test-context.js';
|
|
16
17
|
const tempDirectory = realpathSync(tmpdir());
|
|
17
18
|
export class RunContextBase extends EventEmitter {
|
package/dist/run-result.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { mock } from 'node:test';
|
|
2
2
|
import type { Store } from 'mem-fs';
|
|
3
3
|
import { type MemFsEditor, type MemFsEditorFile } from 'mem-fs-editor';
|
|
4
4
|
import type { BaseEnvironmentOptions, BaseGenerator, GetGeneratorConstructor } from '@yeoman/types';
|
|
5
5
|
import type { DefaultEnvironmentApi } from '../types/type-helpers.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ValueOf } from 'type-fest';
|
|
6
|
+
import type { RunContextSettings } from './run-context.js';
|
|
7
|
+
import type { YeomanTest } from './helpers.js';
|
|
8
|
+
import type { AskedQuestions } from './adapter.js';
|
|
9
|
+
import type { ValueOf } from 'type-fest';
|
|
10
10
|
type MemFsEditorDumpFile = ValueOf<ReturnType<MemFsEditor['dump']>>;
|
|
11
11
|
/**
|
|
12
12
|
* Provides options for `RunResult`s.
|
package/dist/test-context.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BaseGenerator } from '@yeoman/types';
|
|
1
2
|
import type RunContext from './run-context.js';
|
|
2
3
|
import type RunResult from './run-result.js';
|
|
3
4
|
declare class TestContext {
|
|
@@ -14,3 +15,4 @@ export default testContext;
|
|
|
14
15
|
* Provides a proxy for last executed context result.
|
|
15
16
|
*/
|
|
16
17
|
export declare const result: RunResult;
|
|
18
|
+
export declare const typedResult: <GeneratorType extends BaseGenerator>() => RunResult<GeneratorType>;
|
package/dist/test-context.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-test",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.4.1",
|
|
4
4
|
"description": "Test utilities for Yeoman generators",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yeoman",
|
|
7
7
|
"unit test"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "http://yeoman.io/authoring/testing.html",
|
|
10
|
-
"repository":
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/yeoman/yeoman-test.git"
|
|
13
|
+
},
|
|
11
14
|
"license": "MIT",
|
|
12
15
|
"author": "The Yeoman Team",
|
|
13
16
|
"type": "module",
|
|
@@ -44,26 +47,27 @@
|
|
|
44
47
|
"doc_path": "../yeoman-test-doc"
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
|
-
"lodash-es": "^4.
|
|
48
|
-
"mem-fs-editor": "^12.0.
|
|
50
|
+
"lodash-es": "^4.18.1",
|
|
51
|
+
"mem-fs-editor": "^12.0.3",
|
|
49
52
|
"signal-exit": "^4.1.0",
|
|
50
|
-
"type-fest": "^5.
|
|
53
|
+
"type-fest": "^5.6.0"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"@types/lodash-es": "^4.17.12",
|
|
54
|
-
"@types/node": "^
|
|
55
|
-
"@
|
|
57
|
+
"@types/node": "^22.19.17",
|
|
58
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
59
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
56
60
|
"@yeoman/adapter": "^4.0.2",
|
|
57
61
|
"@yeoman/eslint": "^1.0.0",
|
|
58
62
|
"husky": "^9.1.7",
|
|
59
63
|
"jsdoc": "^4.0.5",
|
|
60
|
-
"lint-staged": "^16.
|
|
61
|
-
"prettier": "^3.8.
|
|
62
|
-
"prettier-plugin-packagejson": "^3.0.
|
|
63
|
-
"typescript": "^
|
|
64
|
-
"vitest": "^4.
|
|
65
|
-
"yeoman-environment": "^6.0.
|
|
66
|
-
"yeoman-generator": "^8.
|
|
64
|
+
"lint-staged": "^16.4.0",
|
|
65
|
+
"prettier": "^3.8.3",
|
|
66
|
+
"prettier-plugin-packagejson": "^3.0.2",
|
|
67
|
+
"typescript": "^6.0.3",
|
|
68
|
+
"vitest": "^4.1.4",
|
|
69
|
+
"yeoman-environment": "^6.0.1",
|
|
70
|
+
"yeoman-generator": "^8.1.2"
|
|
67
71
|
},
|
|
68
72
|
"peerDependencies": {
|
|
69
73
|
"@yeoman/adapter": "^1.6.0 || ^2.0.0 || ^3.0.0 || ^4.0.1",
|