yeoman-test 7.4.0 → 8.0.0-alpha.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/helpers.d.ts +2 -2
- package/dist/helpers.js +2 -1
- package/dist/run-context.d.ts +5 -5
- package/dist/run-context.js +7 -7
- package/dist/run-result.d.ts +3 -3
- package/dist/run-result.js +3 -3
- package/dist/test-context.d.ts +1 -1
- package/dist/test-context.js +7 -0
- package/package.json +8 -11
package/dist/helpers.d.ts
CHANGED
|
@@ -149,6 +149,6 @@ export declare class YeomanTest {
|
|
|
149
149
|
*/
|
|
150
150
|
prepareTemporaryDir(settings?: RunContextSettings): BasicRunContext;
|
|
151
151
|
}
|
|
152
|
-
declare const
|
|
153
|
-
export default
|
|
152
|
+
declare const defaultHelpers: YeomanTest;
|
|
153
|
+
export default defaultHelpers;
|
|
154
154
|
export declare const createHelpers: (options: any) => YeomanTest;
|
package/dist/helpers.js
CHANGED
|
@@ -273,7 +273,8 @@ export class YeomanTest {
|
|
|
273
273
|
return context;
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
|
|
276
|
+
const defaultHelpers = new YeomanTest();
|
|
277
|
+
export default defaultHelpers;
|
|
277
278
|
export const createHelpers = options => {
|
|
278
279
|
const helpers = new YeomanTest();
|
|
279
280
|
Object.assign(helpers, options);
|
package/dist/run-context.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { EventEmitter } from 'node:events';
|
|
|
3
3
|
import type Generator from 'yeoman-generator';
|
|
4
4
|
import type Environment from 'yeoman-environment';
|
|
5
5
|
import { type LookupOptions, type Options } from 'yeoman-environment';
|
|
6
|
-
import MemFsEditor from 'mem-fs-editor';
|
|
7
|
-
import
|
|
6
|
+
import { type MemFsEditor, type VinylMemFsEditorFile } from 'mem-fs-editor';
|
|
7
|
+
import { type Store } from 'mem-fs';
|
|
8
8
|
import RunResult, { type RunResultOptions } from './run-result.js';
|
|
9
9
|
import { type GeneratorConstructor, type Dependency, type YeomanTest } from './helpers.js';
|
|
10
10
|
import { type DummyPromptOptions } from './adapter.js';
|
|
@@ -21,7 +21,7 @@ export type RunContextSettings = {
|
|
|
21
21
|
oldCwd?: string;
|
|
22
22
|
forwardCwd?: boolean;
|
|
23
23
|
autoCleanup?: boolean;
|
|
24
|
-
memFs?:
|
|
24
|
+
memFs?: Store;
|
|
25
25
|
/**
|
|
26
26
|
* File path to the generator (only used if Generator is a constructor)
|
|
27
27
|
*/
|
|
@@ -42,8 +42,8 @@ export declare class RunContextBase<GeneratorType extends Generator = Generator>
|
|
|
42
42
|
readonly envOptions: Environment.Options;
|
|
43
43
|
completed: boolean;
|
|
44
44
|
targetDirectory?: string;
|
|
45
|
-
editor: MemFsEditor
|
|
46
|
-
memFs:
|
|
45
|
+
editor: MemFsEditor;
|
|
46
|
+
memFs: Store<VinylMemFsEditorFile>;
|
|
47
47
|
mockedGeneratorFactory: MockedGeneratorFactory;
|
|
48
48
|
protected environmentPromise?: PromiseRunResult<GeneratorType>;
|
|
49
49
|
private args;
|
package/dist/run-context.js
CHANGED
|
@@ -6,9 +6,10 @@ import { EventEmitter } from 'node:events';
|
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
import _ from 'lodash';
|
|
8
8
|
import tempDirectory from 'temp-dir';
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
import
|
|
9
|
+
import { create as createMemFsEditor } from 'mem-fs-editor';
|
|
10
|
+
// eslint-disable-next-line n/file-extension-in-import
|
|
11
|
+
import { resetFileCommitStates } from 'mem-fs-editor/state';
|
|
12
|
+
import { create as createMemFs } from 'mem-fs';
|
|
12
13
|
import RunResult from './run-result.js';
|
|
13
14
|
import defaultHelpers from './helpers.js';
|
|
14
15
|
import testContext from './test-context.js';
|
|
@@ -69,7 +70,7 @@ export class RunContextBase extends EventEmitter {
|
|
|
69
70
|
this.cd(this.settings.cwd);
|
|
70
71
|
}
|
|
71
72
|
this.helpers = helpers;
|
|
72
|
-
this.memFs = settings?.memFs ??
|
|
73
|
+
this.memFs = settings?.memFs ?? createMemFs();
|
|
73
74
|
this.mockedGeneratorFactory = this.helpers.createMockedGenerator;
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
@@ -451,11 +452,10 @@ export class RunContextBase extends EventEmitter {
|
|
|
451
452
|
}
|
|
452
453
|
if (!this.keepFsState) {
|
|
453
454
|
this.memFs.each(file => {
|
|
454
|
-
|
|
455
|
-
delete file[MemFsEditorState.STATE_CLEARED];
|
|
455
|
+
resetFileCommitStates(file);
|
|
456
456
|
});
|
|
457
457
|
}
|
|
458
|
-
this.editor =
|
|
458
|
+
this.editor = createMemFsEditor(this.memFs);
|
|
459
459
|
for (const onTargetDirectory of this.onTargetDirectoryCallbacks) {
|
|
460
460
|
// eslint-disable-next-line no-await-in-loop
|
|
461
461
|
await onTargetDirectory.call(this, this.targetDirectory);
|
package/dist/run-result.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type MemFsEditor } from 'mem-fs-editor';
|
|
2
2
|
import type { Store } from 'mem-fs';
|
|
3
3
|
import type Environment from 'yeoman-environment';
|
|
4
4
|
import type Generator from 'yeoman-generator';
|
|
@@ -26,7 +26,7 @@ export type RunResultOptions<GeneratorType extends Generator> = {
|
|
|
26
26
|
* The file-system of the generator.
|
|
27
27
|
*/
|
|
28
28
|
memFs: Store;
|
|
29
|
-
fs?: MemFsEditor
|
|
29
|
+
fs?: MemFsEditor;
|
|
30
30
|
/**
|
|
31
31
|
* The mocked generators of the context.
|
|
32
32
|
*/
|
|
@@ -43,7 +43,7 @@ export default class RunResult<GeneratorType extends Generator = Generator> {
|
|
|
43
43
|
cwd: string;
|
|
44
44
|
oldCwd: string;
|
|
45
45
|
memFs: Store;
|
|
46
|
-
fs:
|
|
46
|
+
fs: MemFsEditor;
|
|
47
47
|
mockedGenerators: any;
|
|
48
48
|
options: RunResultOptions<GeneratorType>;
|
|
49
49
|
constructor(options: RunResultOptions<GeneratorType>);
|
package/dist/run-result.js
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'node:assert';
|
|
|
2
2
|
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import process from 'node:process';
|
|
5
|
-
import
|
|
5
|
+
import { create as createMemFsEditor } from 'mem-fs-editor';
|
|
6
6
|
const isObject = object => typeof object === 'object' && object !== null && object !== undefined;
|
|
7
7
|
function convertArgs(args) {
|
|
8
8
|
if (args.length > 1) {
|
|
@@ -32,7 +32,7 @@ export default class RunResult {
|
|
|
32
32
|
this.cwd = options.cwd ?? process.cwd();
|
|
33
33
|
this.oldCwd = options.oldCwd;
|
|
34
34
|
this.memFs = options.memFs;
|
|
35
|
-
this.fs = this.memFs &&
|
|
35
|
+
this.fs = this.memFs && createMemFsEditor(this.memFs);
|
|
36
36
|
this.mockedGenerators = options.mockedGenerators || {};
|
|
37
37
|
this.options = options;
|
|
38
38
|
}
|
|
@@ -121,7 +121,7 @@ export default class RunResult {
|
|
|
121
121
|
}
|
|
122
122
|
_readFile(filename, json) {
|
|
123
123
|
filename = this._fileName(filename);
|
|
124
|
-
const file = this.fs ? this.fs.read(filename) : readFileSync(filename, 'utf8');
|
|
124
|
+
const file = (this.fs ? this.fs.read(filename) : undefined) ?? readFileSync(filename, 'utf8');
|
|
125
125
|
return json ? JSON.parse(file) : file;
|
|
126
126
|
}
|
|
127
127
|
_exists(filename) {
|
package/dist/test-context.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type RunResult from './run-result.js';
|
|
|
3
3
|
declare class TestContext {
|
|
4
4
|
runResult?: RunResult;
|
|
5
5
|
private runContext?;
|
|
6
|
-
startNewContext(runContext
|
|
6
|
+
startNewContext(runContext?: RunContext<any>): void;
|
|
7
7
|
}
|
|
8
8
|
declare const testContext: TestContext;
|
|
9
9
|
export default testContext;
|
package/dist/test-context.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
class TestContext {
|
|
2
3
|
runResult;
|
|
3
4
|
runContext;
|
|
@@ -8,6 +9,12 @@ class TestContext {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
const testContext = new TestContext();
|
|
12
|
+
const cleanupTemporaryDir = () => {
|
|
13
|
+
testContext.startNewContext();
|
|
14
|
+
};
|
|
15
|
+
process.on('exit', cleanupTemporaryDir);
|
|
16
|
+
process.on('SIGINT', cleanupTemporaryDir);
|
|
17
|
+
process.on('SIGTERM', cleanupTemporaryDir);
|
|
11
18
|
export default testContext;
|
|
12
19
|
const handler2 = {
|
|
13
20
|
get(_target, prop, receiver) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-test",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-alpha.0",
|
|
4
4
|
"description": "Test utilities for Yeoman generators",
|
|
5
5
|
"homepage": "http://yeoman.io/authoring/testing.html",
|
|
6
6
|
"author": "The Yeoman Team",
|
|
@@ -20,22 +20,20 @@
|
|
|
20
20
|
"repository": "yeoman/yeoman-test",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": "^
|
|
23
|
+
"node": "^16.17.0 || >=18.12.0"
|
|
24
24
|
},
|
|
25
25
|
"config": {
|
|
26
26
|
"doc_path": "../yeoman-test-doc"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@node
|
|
30
|
-
"@types/mocha": "^10.0.0",
|
|
29
|
+
"@types/node": "^16.18.19",
|
|
31
30
|
"@types/sinon": "^10.0.13",
|
|
31
|
+
"c8": "^7.13.0",
|
|
32
32
|
"coveralls": "^3.1.1",
|
|
33
|
+
"esmocha": "^0.1.4",
|
|
33
34
|
"husky": "^8.0.2",
|
|
34
35
|
"jsdoc": "^3.6.10",
|
|
35
36
|
"lint-staged": "^13.0.3",
|
|
36
|
-
"mem-fs": "^2.2.1",
|
|
37
|
-
"mocha": "^10.1.0",
|
|
38
|
-
"mocha-expect-snapshot": "^7.0.0",
|
|
39
37
|
"prettier": "^2.2.1",
|
|
40
38
|
"prettier-plugin-packagejson": "^2.3.0",
|
|
41
39
|
"tui-jsdoc-template": "^1.2.2",
|
|
@@ -46,22 +44,21 @@
|
|
|
46
44
|
},
|
|
47
45
|
"dependencies": {
|
|
48
46
|
"@types/inquirer": "^8.2.5",
|
|
49
|
-
"@types/mem-fs-editor": "^7.0.2",
|
|
50
47
|
"@types/yeoman-environment": "^2.10.8",
|
|
51
48
|
"@types/yeoman-generator": "^5.2.11",
|
|
52
49
|
"inquirer": "^8.2.5",
|
|
53
50
|
"lodash": "^4.17.21",
|
|
54
|
-
"mem-fs
|
|
51
|
+
"mem-fs": "^3.0.0",
|
|
52
|
+
"mem-fs-editor": "^10.0.1",
|
|
55
53
|
"sinon": "^14.0.2",
|
|
56
54
|
"temp-dir": "^3.0.0"
|
|
57
55
|
},
|
|
58
56
|
"peerDependencies": {
|
|
59
|
-
"mem-fs": "^2.2.1",
|
|
60
57
|
"yeoman-environment": "^3.13.0",
|
|
61
58
|
"yeoman-generator": "*"
|
|
62
59
|
},
|
|
63
60
|
"scripts": {
|
|
64
|
-
"test": "
|
|
61
|
+
"test": "c8 esmocha",
|
|
65
62
|
"build": "tsc",
|
|
66
63
|
"prepare": "npm run build",
|
|
67
64
|
"pretest": "xo",
|