yeoman-test 11.4.0 → 11.4.2
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 +13 -8
- package/dist/helpers.js +10 -4
- package/dist/run-context.js +3 -2
- package/dist/run-result.d.ts +5 -5
- package/package.json +1 -1
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,8 +20,8 @@ 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'>;
|
|
21
26
|
defaultGenerator?: string;
|
|
22
27
|
importMeta?: Pick<ImportMeta, 'resolve'>;
|
|
@@ -113,7 +118,7 @@ export declare class YeomanTest {
|
|
|
113
118
|
* createEnv.restore();
|
|
114
119
|
* });
|
|
115
120
|
*/
|
|
116
|
-
createEnv(options:
|
|
121
|
+
createEnv(options: EnvironmentOptions): Promise<DefaultEnvironmentApi>;
|
|
117
122
|
/**
|
|
118
123
|
* Creates a test environment.
|
|
119
124
|
*
|
|
@@ -121,7 +126,7 @@ export declare class YeomanTest {
|
|
|
121
126
|
* @param {Object} - Options to be passed to the environment
|
|
122
127
|
* const env = createTestEnv(require('yeoman-environment').createEnv);
|
|
123
128
|
*/
|
|
124
|
-
createTestEnv(environmentContructor?: CreateEnv, options?:
|
|
129
|
+
createTestEnv(environmentContructor?: CreateEnv, options?: EnvironmentOptions): Promise<BaseEnvironment>;
|
|
125
130
|
/**
|
|
126
131
|
* Creates a TestAdapter using helpers default options.
|
|
127
132
|
*/
|
|
@@ -135,17 +140,17 @@ export declare class YeomanTest {
|
|
|
135
140
|
* Run the provided Generator
|
|
136
141
|
* @param GeneratorOrNamespace - Generator constructor or namespace
|
|
137
142
|
*/
|
|
138
|
-
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>;
|
|
139
144
|
/**
|
|
140
145
|
* Run the default generator
|
|
141
146
|
*/
|
|
142
|
-
runDefault<GeneratorType extends BaseGenerator = BaseGenerator>(settings?: RunContextSettings, environmentOptions?:
|
|
147
|
+
runDefault<GeneratorType extends BaseGenerator = BaseGenerator>(settings?: RunContextSettings, environmentOptions?: EnvironmentOptions): RunContext<GeneratorType>;
|
|
143
148
|
/**
|
|
144
149
|
* Prepare a run context
|
|
145
150
|
* @param {String|Function} GeneratorOrNamespace - Generator constructor or namespace
|
|
146
151
|
* @return {RunContext}
|
|
147
152
|
*/
|
|
148
|
-
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>;
|
|
149
154
|
/**
|
|
150
155
|
* Prepare temporary dir without generator support.
|
|
151
156
|
* Generator and environment will be undefined.
|
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';
|
|
@@ -256,11 +257,16 @@ export class YeomanTest {
|
|
|
256
257
|
const contextSettings = cloneDeep(this.settings ?? {});
|
|
257
258
|
const generatorOptions = cloneDeep(this.generatorOptions ?? {});
|
|
258
259
|
const RunContext = this.getRunContextType();
|
|
259
|
-
if (typeof GeneratorOrNamespace === 'string'
|
|
260
|
-
if (
|
|
261
|
-
|
|
260
|
+
if (typeof GeneratorOrNamespace === 'string') {
|
|
261
|
+
if (GeneratorOrNamespace.startsWith('.')) {
|
|
262
|
+
if (!this.importMeta) {
|
|
263
|
+
throw new Error('importMeta is required to resolve relative generator paths');
|
|
264
|
+
}
|
|
265
|
+
GeneratorOrNamespace = this.importMeta.resolve(GeneratorOrNamespace);
|
|
266
|
+
}
|
|
267
|
+
if (GeneratorOrNamespace.startsWith('file://')) {
|
|
268
|
+
GeneratorOrNamespace = fileURLToPath(GeneratorOrNamespace);
|
|
262
269
|
}
|
|
263
|
-
GeneratorOrNamespace = this.importMeta.resolve(GeneratorOrNamespace);
|
|
264
270
|
}
|
|
265
271
|
const runContext = new RunContext(GeneratorOrNamespace, { ...contextSettings, ...settings }, environmentOptions, this).withOptions(generatorOptions);
|
|
266
272
|
if (settings?.autoCleanup !== false) {
|
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.
|