@virmator/plugin-testing 13.7.0 → 13.8.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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/test-plugin.d.ts +1 -1
- package/dist/test-plugin.js +1 -2
- package/package.json +6 -6
- package/dist/augments/fs/dir-contents.d.ts +0 -13
- package/dist/augments/fs/dir-contents.js +0 -59
- package/dist/augments/index.d.ts +0 -1
- package/dist/augments/index.js +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/test-plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LogOutputType, type MaybePromise, type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type DirContents } from '@augment-vir/node';
|
|
2
3
|
import { type UniversalTestContext } from '@augment-vir/test';
|
|
3
4
|
import { type VirmatorPlugin } from '@virmator/core';
|
|
4
|
-
import { type DirContents } from './augments/index.js';
|
|
5
5
|
/** Log string transformer. */
|
|
6
6
|
export type LogTransform = (logType: LogOutputType, arg: string) => string;
|
|
7
7
|
/** Results of a plugin test. */
|
package/dist/test-plugin.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { addSuffix, createLogger, diffObjects, getOrSet, LogOutputType, mapObjectValues, removeColor, RuntimeEnv, wrapInTry, wrapString, } from '@augment-vir/common';
|
|
2
|
-
import { toPosixPath } from '@augment-vir/node';
|
|
2
|
+
import { readAllDirContents, resetDirContents, toPosixPath, } from '@augment-vir/node';
|
|
3
3
|
import { assertTestContext } from '@augment-vir/test';
|
|
4
4
|
import { executeVirmatorCommand, findClosestPackageDir, hideNoTraceTraces, VirmatorNoTraceError, } from '@virmator/core';
|
|
5
5
|
import { relative, sep } from 'node:path';
|
|
6
|
-
import { readAllDirContents, resetDirContents } from './augments/index.js';
|
|
7
6
|
import { monoRepoDir } from './file-paths.js';
|
|
8
7
|
function handleWrite(logs, logType, text) {
|
|
9
8
|
const fixed = removeColor(text).replaceAll(addSuffix({ value: monoRepoDir, suffix: '/' }), '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/plugin-testing",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.8.1",
|
|
4
4
|
"description": "Testing for virmator plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"virmator",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"test:update": "npm test update"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@augment-vir/assert": "^30.
|
|
34
|
-
"@augment-vir/common": "^30.
|
|
35
|
-
"@augment-vir/node": "^30.
|
|
36
|
-
"@virmator/core": "^13.
|
|
33
|
+
"@augment-vir/assert": "^30.7.0",
|
|
34
|
+
"@augment-vir/common": "^30.7.0",
|
|
35
|
+
"@augment-vir/node": "^30.7.0",
|
|
36
|
+
"@virmator/core": "^13.8.1",
|
|
37
37
|
"cli-args-vir": "^1.0.0",
|
|
38
38
|
"type-fest": "^4.26.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@augment-vir/test": "^30.
|
|
41
|
+
"@augment-vir/test": "^30.7.0",
|
|
42
42
|
"@types/node": "^22.9.0",
|
|
43
43
|
"c8": "^10.1.2",
|
|
44
44
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Nested contents read from a file system directory. */
|
|
2
|
-
export type DirContents = {
|
|
3
|
-
[Path in string]: string | DirContents;
|
|
4
|
-
};
|
|
5
|
-
/** Read all contents within a directory and store them in an object. Optionally recursive. */
|
|
6
|
-
export declare function readAllDirContents(dir: string, { recursive, excludeList, }: {
|
|
7
|
-
recursive?: boolean;
|
|
8
|
-
excludeList?: ReadonlyArray<string | RegExp> | undefined;
|
|
9
|
-
}): Promise<DirContents>;
|
|
10
|
-
/** Deletes and entire directory and resets it to the given contents. */
|
|
11
|
-
export declare function resetDirContents(rootDir: string, contents: Readonly<DirContents>): Promise<void>;
|
|
12
|
-
/** Write {@link DirContents} to a directory. */
|
|
13
|
-
export declare function writeDirContents(rootDir: string, contents: Readonly<DirContents>): Promise<void>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { getObjectTypedEntries } from '@augment-vir/common';
|
|
3
|
-
import { writeFileAndDir } from '@augment-vir/node';
|
|
4
|
-
import { readdir, readFile, rm, stat } from 'node:fs/promises';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
/** Read all contents within a directory and store them in an object. Optionally recursive. */
|
|
7
|
-
export async function readAllDirContents(dir, { recursive = false, excludeList, }) {
|
|
8
|
-
const fileNames = (await readdir(dir)).sort();
|
|
9
|
-
const allFileContents = await Promise.all(fileNames.map(async (fileName) => {
|
|
10
|
-
const filePath = join(dir, fileName);
|
|
11
|
-
if (excludeList?.some((excludeItem) => {
|
|
12
|
-
if (check.isString(excludeItem)) {
|
|
13
|
-
return filePath.includes(excludeItem);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return filePath.match(excludeItem);
|
|
17
|
-
}
|
|
18
|
-
})) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
const isFile = (await stat(filePath)).isFile();
|
|
22
|
-
const contents = isFile
|
|
23
|
-
? (await readFile(filePath)).toString()
|
|
24
|
-
: recursive
|
|
25
|
-
? await readAllDirContents(filePath, { recursive, excludeList })
|
|
26
|
-
: undefined;
|
|
27
|
-
if (check.isObject(contents) && !Object.keys(contents).length) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
return contents;
|
|
31
|
-
}));
|
|
32
|
-
return fileNames.reduce((accum, fileName, index) => {
|
|
33
|
-
if (allFileContents[index] != undefined) {
|
|
34
|
-
const fileContents = allFileContents[index];
|
|
35
|
-
accum[fileName] = fileContents;
|
|
36
|
-
}
|
|
37
|
-
return accum;
|
|
38
|
-
}, {});
|
|
39
|
-
}
|
|
40
|
-
/** Deletes and entire directory and resets it to the given contents. */
|
|
41
|
-
export async function resetDirContents(rootDir, contents) {
|
|
42
|
-
await rm(rootDir, {
|
|
43
|
-
force: true,
|
|
44
|
-
recursive: true,
|
|
45
|
-
});
|
|
46
|
-
await writeDirContents(rootDir, contents);
|
|
47
|
-
}
|
|
48
|
-
/** Write {@link DirContents} to a directory. */
|
|
49
|
-
export async function writeDirContents(rootDir, contents) {
|
|
50
|
-
await Promise.all(getObjectTypedEntries(contents).map(async ([relativePath, content,]) => {
|
|
51
|
-
const fullPath = join(rootDir, relativePath);
|
|
52
|
-
if (check.isString(content)) {
|
|
53
|
-
await writeFileAndDir(fullPath, content);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
await writeDirContents(fullPath, content);
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
}
|
package/dist/augments/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './fs/dir-contents.js';
|
package/dist/augments/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './fs/dir-contents.js';
|