@aneuhold/core-ts-lib 2.2.6 → 2.2.7
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 +3 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/index.ts +5 -7
- package/lib/interfaces/ITracer.d.ts.map +1 -1
- package/lib/interfaces/ITracer.js.map +1 -1
- package/lib/interfaces/ITracer.ts +8 -2
- package/lib/services/ArrayService.d.ts.map +1 -1
- package/lib/services/ArrayService.js.map +1 -1
- package/lib/services/ArrayService.ts +4 -1
- package/lib/services/DateService/DateService.d.ts.map +1 -1
- package/lib/services/DateService/DateService.js +3 -1
- package/lib/services/DateService/DateService.js.map +1 -1
- package/lib/services/DateService/DateService.spec.ts +98 -0
- package/lib/services/DateService/DateService.ts +25 -7
- package/lib/services/DependencyService.d.ts.map +1 -1
- package/lib/services/DependencyService.js +3 -1
- package/lib/services/DependencyService.js.map +1 -1
- package/lib/services/DependencyService.ts +32 -10
- package/lib/services/FileSystemService/FileSystemService.d.ts +12 -38
- package/lib/services/FileSystemService/FileSystemService.d.ts.map +1 -1
- package/lib/services/FileSystemService/FileSystemService.js +26 -83
- package/lib/services/FileSystemService/FileSystemService.js.map +1 -1
- package/lib/services/FileSystemService/FileSystemService.spec.ts +133 -0
- package/lib/services/FileSystemService/FileSystemService.ts +53 -138
- package/lib/services/PackageService.d.ts +4 -60
- package/lib/services/PackageService.d.ts.map +1 -1
- package/lib/services/PackageService.js +43 -182
- package/lib/services/PackageService.js.map +1 -1
- package/lib/services/PackageService.ts +119 -241
- package/lib/utils/ErrorUtils.d.ts.map +1 -1
- package/lib/utils/ErrorUtils.js.map +1 -1
- package/lib/utils/ErrorUtils.ts +3 -1
- package/package.json +1 -1
- package/lib/services/FileSystemService/GlobMatchingService.d.ts +0 -48
- package/lib/services/FileSystemService/GlobMatchingService.d.ts.map +0 -1
- package/lib/services/FileSystemService/GlobMatchingService.js +0 -129
- package/lib/services/FileSystemService/GlobMatchingService.js.map +0 -1
- package/lib/services/FileSystemService/GlobMatchingService.ts +0 -153
|
@@ -5,7 +5,6 @@ import { promisify } from 'util';
|
|
|
5
5
|
import ErrorUtils from '../../utils/ErrorUtils.js';
|
|
6
6
|
import { DR } from '../DependencyRegistry.js';
|
|
7
7
|
import StringService from '../StringService.js';
|
|
8
|
-
import GlobMatchingService from './GlobMatchingService.js';
|
|
9
8
|
const execAsync = promisify(exec);
|
|
10
9
|
/**
|
|
11
10
|
* A service which can be used to interact with the file system, only in build
|
|
@@ -19,8 +18,8 @@ export default class FileSystemService {
|
|
|
19
18
|
*
|
|
20
19
|
* @param folderPath the path to the folder which contains the file that should
|
|
21
20
|
* be updated
|
|
22
|
-
* @param fileName
|
|
23
|
-
* @param textToInsert
|
|
21
|
+
* @param fileName
|
|
22
|
+
* @param textToInsert
|
|
24
23
|
*/
|
|
25
24
|
static async findAndInsertText(folderPath, fileName, textToInsert) {
|
|
26
25
|
const filePath = path.join(folderPath, fileName);
|
|
@@ -44,8 +43,8 @@ export default class FileSystemService {
|
|
|
44
43
|
/**
|
|
45
44
|
* Copies the contents of one folder to another folder.
|
|
46
45
|
*
|
|
47
|
-
* @param sourceFolderPath
|
|
48
|
-
* @param targetFolderPath
|
|
46
|
+
* @param sourceFolderPath
|
|
47
|
+
* @param targetFolderPath
|
|
49
48
|
* @param ignoreExtensions is an array with extensions that should be
|
|
50
49
|
* ignored. For example, if you want to ignore all .ts files, you would pass
|
|
51
50
|
* in ['.ts']. Multi-part extensions like '.spec.ts' are also supported.
|
|
@@ -66,12 +65,32 @@ export default class FileSystemService {
|
|
|
66
65
|
const sourceFile = path.join(sourceFolderPath, sourceFilePath);
|
|
67
66
|
const targetFile = path.join(targetFolderPath, sourceFilePath);
|
|
68
67
|
// Check if the file should be ignored based on extensions
|
|
69
|
-
if (ignoreExtensions &&
|
|
68
|
+
if (ignoreExtensions &&
|
|
69
|
+
FileSystemService.shouldIgnoreFile(sourceFile, ignoreExtensions)) {
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
await cp(sourceFile, targetFile, { recursive: true });
|
|
73
73
|
}));
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Checks if a file should be ignored based on the provided extensions.
|
|
77
|
+
* Supports both simple extensions (e.g., '.ts') and multi-part extensions (e.g., '.spec.ts').
|
|
78
|
+
*
|
|
79
|
+
* @param filePath the path to the file to check
|
|
80
|
+
* @param ignoreExtensions array of extensions to ignore
|
|
81
|
+
*/
|
|
82
|
+
static shouldIgnoreFile(filePath, ignoreExtensions) {
|
|
83
|
+
const fileName = path.basename(filePath);
|
|
84
|
+
return ignoreExtensions.some((extension) => {
|
|
85
|
+
// Handle multi-part extensions like '.spec.ts'
|
|
86
|
+
if (extension.includes('.', 1)) {
|
|
87
|
+
return fileName.endsWith(extension);
|
|
88
|
+
}
|
|
89
|
+
// Handle simple extensions like '.ts'
|
|
90
|
+
const fileExtension = StringService.getFileNameExtension(filePath);
|
|
91
|
+
return fileExtension === extension;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
75
94
|
static async checkOrCreateFolder(folderPath) {
|
|
76
95
|
try {
|
|
77
96
|
await access(folderPath);
|
|
@@ -127,11 +146,7 @@ export default class FileSystemService {
|
|
|
127
146
|
static async getAllFilePathsRelative(dirPath) {
|
|
128
147
|
const filePaths = await this.getAllFilePaths(dirPath);
|
|
129
148
|
return filePaths.map((filePath) => {
|
|
130
|
-
|
|
131
|
-
// Remove leading path separator if present
|
|
132
|
-
return relativePath.startsWith('/') || relativePath.startsWith('\\')
|
|
133
|
-
? relativePath.slice(1)
|
|
134
|
-
: relativePath;
|
|
149
|
+
return filePath.replace(dirPath, '');
|
|
135
150
|
});
|
|
136
151
|
}
|
|
137
152
|
/**
|
|
@@ -178,59 +193,6 @@ export default class FileSystemService {
|
|
|
178
193
|
return this.traverseDirectoryTree(startDir, fileName, stopAt, false // findFirst = false
|
|
179
194
|
);
|
|
180
195
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Replaces all occurrences of a string in files within a directory.
|
|
183
|
-
* Supports glob patterns for including/excluding files and handles URL encoding.
|
|
184
|
-
*
|
|
185
|
-
* @param options Configuration object for the replacement operation
|
|
186
|
-
*/
|
|
187
|
-
static async replaceInFiles(options) {
|
|
188
|
-
const { searchString, replaceString, rootPath, includePatterns = ['**/*'], excludePatterns = ['**/node_modules/**', '**/.*/**'], includeUrlEncoded = true, dryRun = false } = options;
|
|
189
|
-
DR.logger.info(`Replacing "${searchString}" with "${replaceString}" in ${rootPath}`);
|
|
190
|
-
if (dryRun) {
|
|
191
|
-
DR.logger.info('DRY RUN MODE - No files will be modified');
|
|
192
|
-
}
|
|
193
|
-
const allFiles = await this.getAllFilePaths(rootPath);
|
|
194
|
-
const filesToProcess = GlobMatchingService.getMatchingFiles(allFiles, rootPath, includePatterns, excludePatterns);
|
|
195
|
-
let processedCount = 0;
|
|
196
|
-
let modifiedCount = 0;
|
|
197
|
-
for (const filePath of filesToProcess) {
|
|
198
|
-
try {
|
|
199
|
-
const content = await readFile(filePath, 'utf8');
|
|
200
|
-
let hasChanges = false;
|
|
201
|
-
let updatedContent = content;
|
|
202
|
-
// Replace the main string
|
|
203
|
-
if (content.includes(searchString)) {
|
|
204
|
-
updatedContent = updatedContent.replaceAll(searchString, replaceString);
|
|
205
|
-
hasChanges = true;
|
|
206
|
-
}
|
|
207
|
-
// Replace URL-encoded version if requested
|
|
208
|
-
if (includeUrlEncoded) {
|
|
209
|
-
const encodedSearchString = encodeURIComponent(searchString);
|
|
210
|
-
const encodedReplaceString = encodeURIComponent(replaceString);
|
|
211
|
-
if (updatedContent.includes(encodedSearchString)) {
|
|
212
|
-
updatedContent = updatedContent.replaceAll(encodedSearchString, encodedReplaceString);
|
|
213
|
-
hasChanges = true;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (hasChanges) {
|
|
217
|
-
const relativePath = path.relative(rootPath, filePath);
|
|
218
|
-
DR.logger.info(`${dryRun ? 'Would update' : 'Updating'} ${relativePath}...`);
|
|
219
|
-
if (!dryRun) {
|
|
220
|
-
await writeFile(filePath, updatedContent, 'utf8');
|
|
221
|
-
}
|
|
222
|
-
modifiedCount++;
|
|
223
|
-
}
|
|
224
|
-
processedCount++;
|
|
225
|
-
}
|
|
226
|
-
catch (error) {
|
|
227
|
-
// Skip binary files or files we can't read
|
|
228
|
-
DR.logger.verbose.info(`Skipping ${filePath}: ${ErrorUtils.getErrorString(error)}`);
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
DR.logger.info(`${dryRun ? 'Would process' : 'Processed'} ${processedCount} files, ${dryRun ? 'would modify' : 'modified'} ${modifiedCount} files`);
|
|
233
|
-
}
|
|
234
196
|
/**
|
|
235
197
|
* Internal helper method that traverses up the directory tree looking for files.
|
|
236
198
|
*
|
|
@@ -273,24 +235,5 @@ export default class FileSystemService {
|
|
|
273
235
|
}
|
|
274
236
|
return results;
|
|
275
237
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Checks if a file should be ignored based on the provided extensions.
|
|
278
|
-
* Supports both simple extensions (e.g., '.ts') and multi-part extensions (e.g., '.spec.ts').
|
|
279
|
-
*
|
|
280
|
-
* @param filePath the path to the file to check
|
|
281
|
-
* @param ignoreExtensions array of extensions to ignore
|
|
282
|
-
*/
|
|
283
|
-
static shouldIgnoreFile(filePath, ignoreExtensions) {
|
|
284
|
-
const fileName = path.basename(filePath);
|
|
285
|
-
return ignoreExtensions.some((extension) => {
|
|
286
|
-
// Handle multi-part extensions like '.spec.ts'
|
|
287
|
-
if (extension.includes('.', 1)) {
|
|
288
|
-
return fileName.endsWith(extension);
|
|
289
|
-
}
|
|
290
|
-
// Handle simple extensions like '.ts'
|
|
291
|
-
const fileExtension = StringService.getFileNameExtension(filePath);
|
|
292
|
-
return fileExtension === extension;
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
238
|
}
|
|
296
239
|
//# sourceMappingURL=FileSystemService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystemService.js","sourceRoot":"","sources":["../../../src/services/FileSystemService/FileSystemService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"FileSystemService.js","sourceRoot":"","sources":["../../../src/services/FileSystemService/FileSystemService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EACL,MAAM,EACN,UAAU,EACV,EAAE,EACF,KAAK,EACL,QAAQ,EACR,OAAO,EACP,EAAE,EACF,IAAI,EACJ,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAC5B,UAAkB,EAClB,QAAgB,EAChB,YAAoB;QAEpB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEjD,MAAM,iBAAiB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAExD,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;YACvB,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;g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AAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;QAE5E,OAAO,UAAU,KAAK,OAAO,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YAEjD,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACvB,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,OAAO,CAAC;gBACjB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,yCAAyC;YAC3C,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC3C,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;gBAC7B,6BAA6B;gBAC7B,MAAM;YACR,CAAC;YACD,UAAU,GAAG,SAAS,CAAC;QACzB,CAAC;QAED,wCAAwC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
}
|
|
@@ -1,34 +1,23 @@
|
|
|
1
1
|
import { exec } from 'child_process';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
access,
|
|
4
|
+
appendFile,
|
|
5
|
+
cp,
|
|
6
|
+
mkdir,
|
|
7
|
+
readFile,
|
|
8
|
+
readdir,
|
|
9
|
+
rm,
|
|
10
|
+
stat,
|
|
11
|
+
writeFile
|
|
12
|
+
} from 'fs/promises';
|
|
3
13
|
import path from 'path';
|
|
4
14
|
import { promisify } from 'util';
|
|
5
15
|
import ErrorUtils from '../../utils/ErrorUtils.js';
|
|
6
16
|
import { DR } from '../DependencyRegistry.js';
|
|
7
17
|
import StringService from '../StringService.js';
|
|
8
|
-
import GlobMatchingService from './GlobMatchingService.js';
|
|
9
18
|
|
|
10
19
|
const execAsync = promisify(exec);
|
|
11
20
|
|
|
12
|
-
/**
|
|
13
|
-
* Options for the replaceInFiles method
|
|
14
|
-
*/
|
|
15
|
-
export type ReplaceInFilesOptions = {
|
|
16
|
-
/** The string to search for */
|
|
17
|
-
searchString: string;
|
|
18
|
-
/** The string to replace it with */
|
|
19
|
-
replaceString: string;
|
|
20
|
-
/** The root directory to search in */
|
|
21
|
-
rootPath: string;
|
|
22
|
-
/** Array of glob-like patterns to include (defaults to all files) */
|
|
23
|
-
includePatterns?: string[];
|
|
24
|
-
/** Array of glob-like patterns to exclude (defaults to common ignore patterns) */
|
|
25
|
-
excludePatterns?: string[];
|
|
26
|
-
/** Whether to also replace URL-encoded versions of the strings */
|
|
27
|
-
includeUrlEncoded?: boolean;
|
|
28
|
-
/** If true, only shows what would be changed without making changes */
|
|
29
|
-
dryRun?: boolean;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
21
|
/**
|
|
33
22
|
* A service which can be used to interact with the file system, only in build
|
|
34
23
|
* steps.
|
|
@@ -41,8 +30,8 @@ export default class FileSystemService {
|
|
|
41
30
|
*
|
|
42
31
|
* @param folderPath the path to the folder which contains the file that should
|
|
43
32
|
* be updated
|
|
44
|
-
* @param fileName
|
|
45
|
-
* @param textToInsert
|
|
33
|
+
* @param fileName
|
|
34
|
+
* @param textToInsert
|
|
46
35
|
*/
|
|
47
36
|
static async findAndInsertText(
|
|
48
37
|
folderPath: string,
|
|
@@ -73,8 +62,8 @@ export default class FileSystemService {
|
|
|
73
62
|
/**
|
|
74
63
|
* Copies the contents of one folder to another folder.
|
|
75
64
|
*
|
|
76
|
-
* @param sourceFolderPath
|
|
77
|
-
* @param targetFolderPath
|
|
65
|
+
* @param sourceFolderPath
|
|
66
|
+
* @param targetFolderPath
|
|
78
67
|
* @param ignoreExtensions is an array with extensions that should be
|
|
79
68
|
* ignored. For example, if you want to ignore all .ts files, you would pass
|
|
80
69
|
* in ['.ts']. Multi-part extensions like '.spec.ts' are also supported.
|
|
@@ -94,7 +83,8 @@ export default class FileSystemService {
|
|
|
94
83
|
await FileSystemService.checkOrCreateFolder(targetFolderPath);
|
|
95
84
|
|
|
96
85
|
// Get the files in the source directory
|
|
97
|
-
const sourceFilePaths =
|
|
86
|
+
const sourceFilePaths =
|
|
87
|
+
await FileSystemService.getAllFilePathsRelative(sourceFolderPath);
|
|
98
88
|
|
|
99
89
|
await Promise.all(
|
|
100
90
|
sourceFilePaths.map(async (sourceFilePath) => {
|
|
@@ -102,7 +92,10 @@ export default class FileSystemService {
|
|
|
102
92
|
const targetFile = path.join(targetFolderPath, sourceFilePath);
|
|
103
93
|
|
|
104
94
|
// Check if the file should be ignored based on extensions
|
|
105
|
-
if (
|
|
95
|
+
if (
|
|
96
|
+
ignoreExtensions &&
|
|
97
|
+
FileSystemService.shouldIgnoreFile(sourceFile, ignoreExtensions)
|
|
98
|
+
) {
|
|
106
99
|
return;
|
|
107
100
|
}
|
|
108
101
|
|
|
@@ -111,11 +104,38 @@ export default class FileSystemService {
|
|
|
111
104
|
);
|
|
112
105
|
}
|
|
113
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Checks if a file should be ignored based on the provided extensions.
|
|
109
|
+
* Supports both simple extensions (e.g., '.ts') and multi-part extensions (e.g., '.spec.ts').
|
|
110
|
+
*
|
|
111
|
+
* @param filePath the path to the file to check
|
|
112
|
+
* @param ignoreExtensions array of extensions to ignore
|
|
113
|
+
*/
|
|
114
|
+
private static shouldIgnoreFile(
|
|
115
|
+
filePath: string,
|
|
116
|
+
ignoreExtensions: string[]
|
|
117
|
+
): boolean {
|
|
118
|
+
const fileName = path.basename(filePath);
|
|
119
|
+
|
|
120
|
+
return ignoreExtensions.some((extension) => {
|
|
121
|
+
// Handle multi-part extensions like '.spec.ts'
|
|
122
|
+
if (extension.includes('.', 1)) {
|
|
123
|
+
return fileName.endsWith(extension);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Handle simple extensions like '.ts'
|
|
127
|
+
const fileExtension = StringService.getFileNameExtension(filePath);
|
|
128
|
+
return fileExtension === extension;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
114
132
|
static async checkOrCreateFolder(folderPath: string): Promise<void> {
|
|
115
133
|
try {
|
|
116
134
|
await access(folderPath);
|
|
117
135
|
} catch {
|
|
118
|
-
DR.logger.verbose.info(
|
|
136
|
+
DR.logger.verbose.info(
|
|
137
|
+
`Directory "${folderPath}" does not exist. Creating it now...`
|
|
138
|
+
);
|
|
119
139
|
await mkdir(folderPath, { recursive: true });
|
|
120
140
|
}
|
|
121
141
|
}
|
|
@@ -171,11 +191,7 @@ export default class FileSystemService {
|
|
|
171
191
|
static async getAllFilePathsRelative(dirPath: string): Promise<string[]> {
|
|
172
192
|
const filePaths = await this.getAllFilePaths(dirPath);
|
|
173
193
|
return filePaths.map((filePath) => {
|
|
174
|
-
|
|
175
|
-
// Remove leading path separator if present
|
|
176
|
-
return relativePath.startsWith('/') || relativePath.startsWith('\\')
|
|
177
|
-
? relativePath.slice(1)
|
|
178
|
-
: relativePath;
|
|
194
|
+
return filePath.replace(dirPath, '');
|
|
179
195
|
});
|
|
180
196
|
}
|
|
181
197
|
|
|
@@ -190,7 +206,9 @@ export default class FileSystemService {
|
|
|
190
206
|
const { stdout } = await execAsync('git status --porcelain');
|
|
191
207
|
return stdout.trim().length > 0;
|
|
192
208
|
} catch (error) {
|
|
193
|
-
DR.logger.error(
|
|
209
|
+
DR.logger.error(
|
|
210
|
+
`Failed to check for pending changes: ${ErrorUtils.getErrorString(error)}`
|
|
211
|
+
);
|
|
194
212
|
return false;
|
|
195
213
|
}
|
|
196
214
|
}
|
|
@@ -241,87 +259,6 @@ export default class FileSystemService {
|
|
|
241
259
|
);
|
|
242
260
|
}
|
|
243
261
|
|
|
244
|
-
/**
|
|
245
|
-
* Replaces all occurrences of a string in files within a directory.
|
|
246
|
-
* Supports glob patterns for including/excluding files and handles URL encoding.
|
|
247
|
-
*
|
|
248
|
-
* @param options Configuration object for the replacement operation
|
|
249
|
-
*/
|
|
250
|
-
static async replaceInFiles(options: ReplaceInFilesOptions): Promise<void> {
|
|
251
|
-
const {
|
|
252
|
-
searchString,
|
|
253
|
-
replaceString,
|
|
254
|
-
rootPath,
|
|
255
|
-
includePatterns = ['**/*'],
|
|
256
|
-
excludePatterns = ['**/node_modules/**', '**/.*/**'],
|
|
257
|
-
includeUrlEncoded = true,
|
|
258
|
-
dryRun = false
|
|
259
|
-
} = options;
|
|
260
|
-
|
|
261
|
-
DR.logger.info(`Replacing "${searchString}" with "${replaceString}" in ${rootPath}`);
|
|
262
|
-
|
|
263
|
-
if (dryRun) {
|
|
264
|
-
DR.logger.info('DRY RUN MODE - No files will be modified');
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const allFiles = await this.getAllFilePaths(rootPath);
|
|
268
|
-
const filesToProcess = GlobMatchingService.getMatchingFiles(
|
|
269
|
-
allFiles,
|
|
270
|
-
rootPath,
|
|
271
|
-
includePatterns,
|
|
272
|
-
excludePatterns
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
let processedCount = 0;
|
|
276
|
-
let modifiedCount = 0;
|
|
277
|
-
|
|
278
|
-
for (const filePath of filesToProcess) {
|
|
279
|
-
try {
|
|
280
|
-
const content = await readFile(filePath, 'utf8');
|
|
281
|
-
let hasChanges = false;
|
|
282
|
-
let updatedContent = content;
|
|
283
|
-
|
|
284
|
-
// Replace the main string
|
|
285
|
-
if (content.includes(searchString)) {
|
|
286
|
-
updatedContent = updatedContent.replaceAll(searchString, replaceString);
|
|
287
|
-
hasChanges = true;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Replace URL-encoded version if requested
|
|
291
|
-
if (includeUrlEncoded) {
|
|
292
|
-
const encodedSearchString = encodeURIComponent(searchString);
|
|
293
|
-
const encodedReplaceString = encodeURIComponent(replaceString);
|
|
294
|
-
|
|
295
|
-
if (updatedContent.includes(encodedSearchString)) {
|
|
296
|
-
updatedContent = updatedContent.replaceAll(encodedSearchString, encodedReplaceString);
|
|
297
|
-
hasChanges = true;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (hasChanges) {
|
|
302
|
-
const relativePath = path.relative(rootPath, filePath);
|
|
303
|
-
DR.logger.info(`${dryRun ? 'Would update' : 'Updating'} ${relativePath}...`);
|
|
304
|
-
|
|
305
|
-
if (!dryRun) {
|
|
306
|
-
await writeFile(filePath, updatedContent, 'utf8');
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
modifiedCount++;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
processedCount++;
|
|
313
|
-
} catch (error) {
|
|
314
|
-
// Skip binary files or files we can't read
|
|
315
|
-
DR.logger.verbose.info(`Skipping ${filePath}: ${ErrorUtils.getErrorString(error)}`);
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
DR.logger.info(
|
|
321
|
-
`${dryRun ? 'Would process' : 'Processed'} ${processedCount} files, ${dryRun ? 'would modify' : 'modified'} ${modifiedCount} files`
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
262
|
/**
|
|
326
263
|
* Internal helper method that traverses up the directory tree looking for files.
|
|
327
264
|
*
|
|
@@ -372,26 +309,4 @@ export default class FileSystemService {
|
|
|
372
309
|
|
|
373
310
|
return results;
|
|
374
311
|
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Checks if a file should be ignored based on the provided extensions.
|
|
378
|
-
* Supports both simple extensions (e.g., '.ts') and multi-part extensions (e.g., '.spec.ts').
|
|
379
|
-
*
|
|
380
|
-
* @param filePath the path to the file to check
|
|
381
|
-
* @param ignoreExtensions array of extensions to ignore
|
|
382
|
-
*/
|
|
383
|
-
private static shouldIgnoreFile(filePath: string, ignoreExtensions: string[]): boolean {
|
|
384
|
-
const fileName = path.basename(filePath);
|
|
385
|
-
|
|
386
|
-
return ignoreExtensions.some((extension) => {
|
|
387
|
-
// Handle multi-part extensions like '.spec.ts'
|
|
388
|
-
if (extension.includes('.', 1)) {
|
|
389
|
-
return fileName.endsWith(extension);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// Handle simple extensions like '.ts'
|
|
393
|
-
const fileExtension = StringService.getFileNameExtension(filePath);
|
|
394
|
-
return fileExtension === extension;
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
312
|
}
|
|
@@ -8,53 +8,15 @@ export default class PackageService {
|
|
|
8
8
|
* project has any pending changes first, then update the version of the
|
|
9
9
|
* jsr.json to match the package.json file, then run the
|
|
10
10
|
* `jsr publish --dry-run` command, and finally cleanup the changes made.
|
|
11
|
-
*
|
|
12
|
-
* @param alternativePackageNames Optional array of alternative package names to validate publishing under
|
|
13
|
-
*
|
|
14
|
-
* **Warning:** This method uses simple string replacement for package names, which may have unintended effects
|
|
15
|
-
* if the package name appears in unexpected places. Use with caution.
|
|
16
|
-
*/
|
|
17
|
-
static validateJsrPublish(alternativePackageNames?: string[]): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Publishes the current project to JSR.
|
|
20
|
-
*
|
|
21
|
-
* @param alternativePackageNames Optional array of alternative package names to publish under
|
|
22
|
-
*
|
|
23
|
-
* **Warning:** This method uses simple string replacement for package names, which may have unintended effects
|
|
24
|
-
* if the package name appears in unexpected places. Use with caution.
|
|
25
11
|
*/
|
|
26
|
-
static
|
|
12
|
+
static validateJsrPublish(): Promise<void>;
|
|
13
|
+
static publishToJsr(): Promise<void>;
|
|
27
14
|
/**
|
|
28
15
|
* Validates the current project for publishing to npm. This will run
|
|
29
16
|
* `npm publish --access public --dry-run` and check for version conflicts
|
|
30
17
|
* on the npm registry.
|
|
31
|
-
*
|
|
32
|
-
* @param alternativePackageNames Optional array of alternative package names to validate publishing under
|
|
33
|
-
*
|
|
34
|
-
* **Warning:** This method uses simple string replacement for package names, which may have unintended effects
|
|
35
|
-
* if the package name appears in unexpected places. Use with caution.
|
|
36
|
-
*/
|
|
37
|
-
static validateNpmPublish(alternativePackageNames?: string[]): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Publishes the current project to npm.
|
|
40
|
-
*
|
|
41
|
-
* @param alternativePackageNames Optional array of alternative package names to publish under
|
|
42
|
-
*
|
|
43
|
-
* **Warning:** This method uses simple string replacement for package names, which may have unintended effects
|
|
44
|
-
* if the package name appears in unexpected places. Use with caution.
|
|
45
18
|
*/
|
|
46
|
-
static
|
|
47
|
-
/**
|
|
48
|
-
* Test method for string replacement functionality. This method allows testing
|
|
49
|
-
* the string replacement behavior without performing actual publishing operations.
|
|
50
|
-
*
|
|
51
|
-
* @param originalString The original string to replace
|
|
52
|
-
* @param newString The new string to replace it with
|
|
53
|
-
*
|
|
54
|
-
* **Warning:** This method uses simple string replacement, which may have unintended effects
|
|
55
|
-
* if the string appears in unexpected places. Use with caution.
|
|
56
|
-
*/
|
|
57
|
-
static testStringReplacement(originalString: string, newString: string): Promise<void>;
|
|
19
|
+
static validateNpmPublish(): Promise<void>;
|
|
58
20
|
/**
|
|
59
21
|
* Updates the jsr.json file from the package.json file and resolves wildcard
|
|
60
22
|
* dependencies in package.json for JSR compatibility.
|
|
@@ -119,6 +81,7 @@ export default class PackageService {
|
|
|
119
81
|
* ```
|
|
120
82
|
*/
|
|
121
83
|
private static replaceMonorepoImportsWithNpmSpecifiers;
|
|
84
|
+
private static revertGitChanges;
|
|
122
85
|
/**
|
|
123
86
|
* Checks for version conflicts on JSR by looking up the current package
|
|
124
87
|
* and comparing versions. Throws an error if the current version already
|
|
@@ -136,24 +99,5 @@ export default class PackageService {
|
|
|
136
99
|
* @param registryName The name of the registry (for error messages)
|
|
137
100
|
*/
|
|
138
101
|
private static checkVersionConflict;
|
|
139
|
-
/**
|
|
140
|
-
* Replaces the package name in package.json and jsr.json files with a new name.
|
|
141
|
-
* Uses FileSystemService.replaceInFiles to perform the replacement.
|
|
142
|
-
*
|
|
143
|
-
* @param originalPackageName The original package name to replace
|
|
144
|
-
* @param newPackageName The new package name to use
|
|
145
|
-
*/
|
|
146
|
-
private static replacePackageName;
|
|
147
|
-
/**
|
|
148
|
-
* Performs a git reset to discard all changes in the working directory.
|
|
149
|
-
* This is used between alternative package name operations.
|
|
150
|
-
*/
|
|
151
|
-
private static resetGitChanges;
|
|
152
|
-
/**
|
|
153
|
-
* Publishes the current project to npm.
|
|
154
|
-
*
|
|
155
|
-
* @returns true if the publish was successful, false otherwise.
|
|
156
|
-
*/
|
|
157
|
-
private static publishNpm;
|
|
158
102
|
}
|
|
159
103
|
//# sourceMappingURL=PackageService.d.ts.map
|