@aneuhold/core-ts-lib 2.2.7 → 2.2.9
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/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/index.ts +7 -5
- package/lib/interfaces/ITracer.d.ts.map +1 -1
- package/lib/interfaces/ITracer.js.map +1 -1
- package/lib/interfaces/ITracer.ts +2 -8
- package/lib/services/ArrayService.d.ts.map +1 -1
- package/lib/services/ArrayService.js.map +1 -1
- package/lib/services/ArrayService.ts +1 -4
- package/lib/services/DateService/DateService.d.ts.map +1 -1
- package/lib/services/DateService/DateService.js +1 -3
- package/lib/services/DateService/DateService.js.map +1 -1
- package/lib/services/DateService/DateService.ts +7 -25
- package/lib/services/DependencyService.d.ts.map +1 -1
- package/lib/services/DependencyService.js +1 -3
- package/lib/services/DependencyService.js.map +1 -1
- package/lib/services/DependencyService.ts +10 -32
- package/lib/services/FileSystemService/FileSystemService.d.ts +38 -12
- package/lib/services/FileSystemService/FileSystemService.d.ts.map +1 -1
- package/lib/services/FileSystemService/FileSystemService.js +83 -26
- package/lib/services/FileSystemService/FileSystemService.js.map +1 -1
- package/lib/services/FileSystemService/FileSystemService.ts +138 -53
- package/lib/services/FileSystemService/GlobMatchingService.d.ts +48 -0
- package/lib/services/FileSystemService/GlobMatchingService.d.ts.map +1 -0
- package/lib/services/FileSystemService/GlobMatchingService.js +129 -0
- package/lib/services/FileSystemService/GlobMatchingService.js.map +1 -0
- package/lib/services/FileSystemService/GlobMatchingService.ts +153 -0
- package/lib/services/PackageService.d.ts +60 -4
- package/lib/services/PackageService.d.ts.map +1 -1
- package/lib/services/PackageService.js +182 -43
- package/lib/services/PackageService.js.map +1 -1
- package/lib/services/PackageService.ts +241 -119
- package/lib/utils/ErrorUtils.d.ts.map +1 -1
- package/lib/utils/ErrorUtils.js.map +1 -1
- package/lib/utils/ErrorUtils.ts +1 -3
- package/package.json +3 -2
- package/lib/services/DateService/DateService.spec.ts +0 -98
- package/lib/services/FileSystemService/FileSystemService.spec.ts +0 -133
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { writeFile } from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import FileSystemService from './FileSystemService.js';
|
|
4
|
-
|
|
5
|
-
const TEST_FOLDER_NAME = '__fileSystemService-tests__';
|
|
6
|
-
|
|
7
|
-
describe('FileSystemService', () => {
|
|
8
|
-
afterAll(async () => {
|
|
9
|
-
await deleteTestFolder();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('copyFolderContents', () => {
|
|
13
|
-
it('should successfully copy all contents when target folder doesnt exist', async () => {
|
|
14
|
-
// Make a test folder with a folder and a couple files in it
|
|
15
|
-
const testName = 'copyFolderContents-1';
|
|
16
|
-
const sourceFolderName = `${testName}-source`;
|
|
17
|
-
const sourceFolderPath = await createTestFolder(sourceFolderName);
|
|
18
|
-
await createTestFiles(sourceFolderPath, {
|
|
19
|
-
'file1.txt': 'test text',
|
|
20
|
-
'file2.txt': 'test text',
|
|
21
|
-
subFolder: {
|
|
22
|
-
'subFile1.txt': 'sub test text',
|
|
23
|
-
'subFile2.txt': 'sub test text'
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const targetFolderPath = path.join(
|
|
28
|
-
TEST_FOLDER_NAME,
|
|
29
|
-
`${testName}-target`
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// Execute
|
|
33
|
-
await FileSystemService.copyFolderContents(
|
|
34
|
-
sourceFolderPath,
|
|
35
|
-
targetFolderPath
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
// Assert
|
|
39
|
-
const expectedContents = (
|
|
40
|
-
await FileSystemService.getAllFilePathsRelative(sourceFolderPath)
|
|
41
|
-
).sort();
|
|
42
|
-
const actualContents = (
|
|
43
|
-
await FileSystemService.getAllFilePathsRelative(targetFolderPath)
|
|
44
|
-
).sort();
|
|
45
|
-
expect(actualContents).toEqual(expectedContents);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should successfully copy only files that arent ignored', async () => {
|
|
49
|
-
// Make a test folder with a folder and a couple files in it
|
|
50
|
-
const testName = 'copyFolderContents-2';
|
|
51
|
-
const sourceFolderName = `${testName}-source`;
|
|
52
|
-
const sourceFolderPath = await createTestFolder(sourceFolderName);
|
|
53
|
-
await createTestFiles(sourceFolderPath, {
|
|
54
|
-
'file1.txt': 'test text',
|
|
55
|
-
'file2.txt': 'test text',
|
|
56
|
-
subFolder: {
|
|
57
|
-
'subFile1.txt': 'sub test text',
|
|
58
|
-
'subFile2.txt': 'sub test text'
|
|
59
|
-
},
|
|
60
|
-
javascript: {
|
|
61
|
-
'file1.js': 'test text',
|
|
62
|
-
'file2.js': 'test text'
|
|
63
|
-
},
|
|
64
|
-
typescript: {
|
|
65
|
-
'file1.ts': 'test text',
|
|
66
|
-
'file2.ts': 'test text'
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const targetFolderPath = path.join(
|
|
71
|
-
TEST_FOLDER_NAME,
|
|
72
|
-
`${testName}-target`
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
// Execute
|
|
76
|
-
await FileSystemService.copyFolderContents(
|
|
77
|
-
sourceFolderPath,
|
|
78
|
-
targetFolderPath,
|
|
79
|
-
['ts']
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
// Assert
|
|
83
|
-
const expectedContents = (
|
|
84
|
-
await FileSystemService.getAllFilePathsRelative(sourceFolderPath)
|
|
85
|
-
)
|
|
86
|
-
.filter((sourceFilePath) => !sourceFilePath.endsWith('.ts'))
|
|
87
|
-
.sort();
|
|
88
|
-
const actualContents = (
|
|
89
|
-
await FileSystemService.getAllFilePathsRelative(targetFolderPath)
|
|
90
|
-
).sort();
|
|
91
|
-
expect(actualContents).toEqual(expectedContents);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Creates test files and folders based on the provided structure
|
|
98
|
-
*
|
|
99
|
-
* @param folderPath The path where the files and folders should be created
|
|
100
|
-
* @param fileStructure An object representing the file structure to create
|
|
101
|
-
*/
|
|
102
|
-
async function createTestFiles(folderPath: string, fileStructure: object) {
|
|
103
|
-
await FileSystemService.checkOrCreateFolder(folderPath);
|
|
104
|
-
|
|
105
|
-
await Promise.all(
|
|
106
|
-
Object.entries(fileStructure).map(async ([key, value]) => {
|
|
107
|
-
if (typeof value === 'string') {
|
|
108
|
-
await writeFile(path.join(folderPath, key), value);
|
|
109
|
-
} else if (typeof value === 'object') {
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
111
|
-
await createTestFiles(path.join(folderPath, key), value);
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Creates a test folder within the main test directory
|
|
119
|
-
*
|
|
120
|
-
* @param folderName The name of the folder to create
|
|
121
|
-
*/
|
|
122
|
-
async function createTestFolder(folderName: string): Promise<string> {
|
|
123
|
-
const testFolderPath = path.join(TEST_FOLDER_NAME, folderName);
|
|
124
|
-
await FileSystemService.checkOrCreateFolder(testFolderPath);
|
|
125
|
-
return testFolderPath;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Deletes the main test folder and all its contents
|
|
130
|
-
*/
|
|
131
|
-
async function deleteTestFolder(): Promise<void> {
|
|
132
|
-
await FileSystemService.deleteFolder(TEST_FOLDER_NAME);
|
|
133
|
-
}
|