@aneuhold/core-ts-lib 2.2.3 → 2.2.5

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.
Files changed (37) hide show
  1. package/lib/index.d.ts +4 -3
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +2 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/index.ts +7 -5
  6. package/lib/interfaces/ITracer.d.ts.map +1 -1
  7. package/lib/interfaces/ITracer.js.map +1 -1
  8. package/lib/interfaces/ITracer.ts +2 -8
  9. package/lib/services/ArrayService.d.ts.map +1 -1
  10. package/lib/services/ArrayService.js.map +1 -1
  11. package/lib/services/ArrayService.ts +1 -4
  12. package/lib/services/DateService/DateService.d.ts.map +1 -1
  13. package/lib/services/DateService/DateService.js +1 -3
  14. package/lib/services/DateService/DateService.js.map +1 -1
  15. package/lib/services/DateService/DateService.ts +7 -25
  16. package/lib/services/DependencyService.d.ts.map +1 -1
  17. package/lib/services/DependencyService.js +1 -3
  18. package/lib/services/DependencyService.js.map +1 -1
  19. package/lib/services/DependencyService.ts +10 -32
  20. package/lib/services/FileSystemService/FileSystemService.d.ts +30 -4
  21. package/lib/services/FileSystemService/FileSystemService.d.ts.map +1 -1
  22. package/lib/services/FileSystemService/FileSystemService.js +64 -7
  23. package/lib/services/FileSystemService/FileSystemService.js.map +1 -1
  24. package/lib/services/FileSystemService/FileSystemService.ts +117 -32
  25. package/lib/services/FileSystemService/GlobMatchingService.d.ts +48 -0
  26. package/lib/services/FileSystemService/GlobMatchingService.d.ts.map +1 -0
  27. package/lib/services/FileSystemService/GlobMatchingService.js +129 -0
  28. package/lib/services/FileSystemService/GlobMatchingService.js.map +1 -0
  29. package/lib/services/FileSystemService/GlobMatchingService.ts +153 -0
  30. package/lib/services/PackageService.d.ts.map +1 -1
  31. package/lib/services/PackageService.js +4 -8
  32. package/lib/services/PackageService.js.map +1 -1
  33. package/lib/services/PackageService.ts +27 -90
  34. package/lib/utils/ErrorUtils.d.ts.map +1 -1
  35. package/lib/utils/ErrorUtils.js.map +1 -1
  36. package/lib/utils/ErrorUtils.ts +1 -3
  37. package/package.json +2 -1
@@ -31,10 +31,7 @@ export default class PackageService {
31
31
  await PackageService.replaceMonorepoImportsWithNpmSpecifiers();
32
32
  const { packageName, version: currentVersion } =
33
33
  await PackageService.updateJsrFromPackageJson();
34
- const successfulDryRun = await PackageService.publishJsrDryRun(
35
- packageName,
36
- currentVersion
37
- );
34
+ const successfulDryRun = await PackageService.publishJsrDryRun(packageName, currentVersion);
38
35
  await PackageService.revertGitChanges();
39
36
 
40
37
  if (!successfulDryRun) {
@@ -67,8 +64,7 @@ export default class PackageService {
67
64
  * on the npm registry.
68
65
  */
69
66
  static async validateNpmPublish(): Promise<void> {
70
- const { packageName, version: currentVersion } =
71
- await PackageService.getPackageInfo();
67
+ const { packageName, version: currentVersion } = await PackageService.getPackageInfo();
72
68
 
73
69
  const successfulDryRun = await PackageService.publishNpmDryRun();
74
70
  if (!successfulDryRun) {
@@ -101,9 +97,7 @@ export default class PackageService {
101
97
 
102
98
  try {
103
99
  const { packageName, version } = await PackageService.getPackageInfo();
104
- const packageJsonData = JSON.parse(
105
- await readFile(packageJsonPath, 'utf-8')
106
- ) as PackageJson;
100
+ const packageJsonData = JSON.parse(await readFile(packageJsonPath, 'utf-8')) as PackageJson;
107
101
  const jsrJsonData = JSON.parse(
108
102
  await readFile(jsrJsonPath, 'utf-8')
109
103
  ) as JsonWithVersionProperty;
@@ -112,15 +106,10 @@ export default class PackageService {
112
106
  jsrJsonData.version = version;
113
107
 
114
108
  // Resolve wildcard dependencies in package.json for JSR compatibility
115
- await this.resolveWildcardDependenciesInPackageJson(
116
- packageJsonData,
117
- packageJsonPath
118
- );
109
+ await this.resolveWildcardDependenciesInPackageJson(packageJsonData, packageJsonPath);
119
110
 
120
111
  await writeFile(jsrJsonPath, JSON.stringify(jsrJsonData, null, 2));
121
- DR.logger.info(
122
- 'Updated jsr.json from package.json to version ' + version
123
- );
112
+ DR.logger.info('Updated jsr.json from package.json to version ' + version);
124
113
 
125
114
  return {
126
115
  packageName,
@@ -128,9 +117,7 @@ export default class PackageService {
128
117
  };
129
118
  } catch (error) {
130
119
  const errorString = ErrorUtils.getErrorString(error);
131
- DR.logger.error(
132
- `Failed to update jsr.json from package.json: ${errorString}`
133
- );
120
+ DR.logger.error(`Failed to update jsr.json from package.json: ${errorString}`);
134
121
  throw error;
135
122
  }
136
123
  }
@@ -152,16 +139,13 @@ export default class PackageService {
152
139
  const childPackages = await DependencyService.getChildPackageJsons('../');
153
140
 
154
141
  // Helper function to resolve dependencies
155
- const resolveDependencies = (
156
- deps: Record<string, string> | undefined
157
- ): void => {
142
+ const resolveDependencies = (deps: Record<string, string> | undefined): void => {
158
143
  if (!deps) return;
159
144
 
160
145
  for (const [depName, depVersion] of Object.entries(deps)) {
161
146
  if (depVersion === '*' && depName in childPackages) {
162
147
  // Replace wildcard with "*" + actual version from the monorepo
163
- deps[depName] =
164
- `*${childPackages[depName].packageJsonContents.version}`;
148
+ deps[depName] = `*${childPackages[depName].packageJsonContents.version}`;
165
149
  }
166
150
  }
167
151
  };
@@ -173,19 +157,12 @@ export default class PackageService {
173
157
  resolveDependencies(packageJsonData.optionalDependencies);
174
158
 
175
159
  // Write the updated package.json
176
- await writeFile(
177
- packageJsonPath,
178
- JSON.stringify(packageJsonData, null, 2)
179
- );
160
+ await writeFile(packageJsonPath, JSON.stringify(packageJsonData, null, 2));
180
161
 
181
- DR.logger.info(
182
- 'Resolved wildcard dependencies in package.json for JSR compatibility'
183
- );
162
+ DR.logger.info('Resolved wildcard dependencies in package.json for JSR compatibility');
184
163
  } catch (error) {
185
164
  const errorString = ErrorUtils.getErrorString(error);
186
- DR.logger.error(
187
- `Failed to resolve wildcard dependencies: ${errorString}`
188
- );
165
+ DR.logger.error(`Failed to resolve wildcard dependencies: ${errorString}`);
189
166
  throw error;
190
167
  }
191
168
  }
@@ -208,17 +185,13 @@ export default class PackageService {
208
185
 
209
186
  DR.logger.info('Running `jsr publish --dry-run`');
210
187
  try {
211
- const { stdout, stderr } = await execAsync(
212
- 'jsr publish --allow-dirty --dry-run'
213
- );
188
+ const { stdout, stderr } = await execAsync('jsr publish --allow-dirty --dry-run');
214
189
  if (stderr) {
215
190
  DR.logger.info(stderr);
216
191
  }
217
192
  DR.logger.info(stdout);
218
193
  } catch (error) {
219
- DR.logger.error(
220
- `Failed to run 'jsr publish --dry-run': ${ErrorUtils.getErrorString(error)}`
221
- );
194
+ DR.logger.error(`Failed to run 'jsr publish --dry-run': ${ErrorUtils.getErrorString(error)}`);
222
195
  return false;
223
196
  }
224
197
  return true;
@@ -266,9 +239,7 @@ export default class PackageService {
266
239
  }
267
240
 
268
241
  try {
269
- const packageJsonData = JSON.parse(
270
- await readFile(packageJsonPath, 'utf-8')
271
- ) as PackageJson;
242
+ const packageJsonData = JSON.parse(await readFile(packageJsonPath, 'utf-8')) as PackageJson;
272
243
 
273
244
  return {
274
245
  packageName: packageJsonData.name,
@@ -309,9 +280,7 @@ export default class PackageService {
309
280
  packageName: string,
310
281
  currentVersion: string
311
282
  ): Promise<void> {
312
- DR.logger.info(
313
- `Checking npm registry for existing versions of ${packageName}...`
314
- );
283
+ DR.logger.info(`Checking npm registry for existing versions of ${packageName}...`);
315
284
 
316
285
  try {
317
286
  const { stdout } = await execAsync(`npm view ${packageName}`);
@@ -320,28 +289,19 @@ export default class PackageService {
320
289
  const latestVersionMatch = stdout.match(/latest:\s*([^\s|]+)/);
321
290
  if (latestVersionMatch) {
322
291
  const latestVersion = latestVersionMatch[1];
323
- PackageService.checkVersionConflict(
324
- currentVersion,
325
- latestVersion,
326
- 'npm'
327
- );
292
+ PackageService.checkVersionConflict(currentVersion, latestVersion, 'npm');
328
293
  }
329
294
  } catch (error) {
330
295
  const errorString = ErrorUtils.getErrorString(error);
331
296
 
332
297
  // If the package doesn't exist on npm, that's fine for first publish
333
298
  if (errorString.includes('404') || errorString.includes('not found')) {
334
- DR.logger.info(
335
- 'Package not found on npm - this appears to be a first publish.'
336
- );
299
+ DR.logger.info('Package not found on npm - this appears to be a first publish.');
337
300
  return;
338
301
  }
339
302
 
340
303
  // Re-throw version conflict errors
341
- if (
342
- errorString.includes('already exists') ||
343
- errorString.includes('is lower than')
344
- ) {
304
+ if (errorString.includes('already exists') || errorString.includes('is lower than')) {
345
305
  throw error;
346
306
  }
347
307
 
@@ -415,9 +375,7 @@ export default class PackageService {
415
375
  // Get all TypeScript files in the src directory
416
376
  const allFiles = await FileSystemService.getAllFilePathsRelative(srcDir);
417
377
  const tsFiles = allFiles
418
- .filter(
419
- (filePath) => filePath.endsWith('.ts') && !filePath.endsWith('.spec.ts')
420
- )
378
+ .filter((filePath) => filePath.endsWith('.ts') && !filePath.endsWith('.spec.ts'))
421
379
  .map((filePath) => path.join(srcDir, filePath));
422
380
 
423
381
  DR.logger.info(
@@ -459,9 +417,7 @@ export default class PackageService {
459
417
  );
460
418
  }
461
419
  } catch (error) {
462
- DR.logger.error(
463
- `Failed to process file ${filePath}: ${ErrorUtils.getErrorString(error)}`
464
- );
420
+ DR.logger.error(`Failed to process file ${filePath}: ${ErrorUtils.getErrorString(error)}`);
465
421
  }
466
422
  }
467
423
 
@@ -471,15 +427,11 @@ export default class PackageService {
471
427
  }
472
428
 
473
429
  private static async revertGitChanges(): Promise<void> {
474
- DR.logger.info(
475
- 'Reverting changes made to jsr.json, package.json, and source files'
476
- );
430
+ DR.logger.info('Reverting changes made to jsr.json, package.json, and source files');
477
431
  try {
478
432
  await execAsync('git checkout -- jsr.json package.json src/');
479
433
  } catch (error) {
480
- DR.logger.error(
481
- `Failed to revert changes: ${ErrorUtils.getErrorString(error)}`
482
- );
434
+ DR.logger.error(`Failed to revert changes: ${ErrorUtils.getErrorString(error)}`);
483
435
  }
484
436
  }
485
437
 
@@ -505,31 +457,19 @@ export default class PackageService {
505
457
  if (latestVersionMatch) {
506
458
  const latestVersion = latestVersionMatch[1];
507
459
 
508
- PackageService.checkVersionConflict(
509
- currentVersion,
510
- latestVersion,
511
- 'JSR'
512
- );
460
+ PackageService.checkVersionConflict(currentVersion, latestVersion, 'JSR');
513
461
  }
514
462
  } catch (error) {
515
463
  const errorString = ErrorUtils.getErrorString(error);
516
464
 
517
465
  // If the package doesn't exist on JSR, that's fine for first publish
518
- if (
519
- errorString.includes('Package not found') ||
520
- errorString.includes('404')
521
- ) {
522
- DR.logger.info(
523
- 'Package not found on JSR - this appears to be a first publish.'
524
- );
466
+ if (errorString.includes('Package not found') || errorString.includes('404')) {
467
+ DR.logger.info('Package not found on JSR - this appears to be a first publish.');
525
468
  return;
526
469
  }
527
470
 
528
471
  // Re-throw version conflict errors
529
- if (
530
- errorString.includes('already exists') ||
531
- errorString.includes('is lower than')
532
- ) {
472
+ if (errorString.includes('already exists') || errorString.includes('is lower than')) {
533
473
  throw error;
534
474
  }
535
475
 
@@ -555,10 +495,7 @@ export default class PackageService {
555
495
  );
556
496
 
557
497
  // Compare versions using semver-like comparison
558
- const comparison = StringService.compareSemanticVersions(
559
- currentVersion,
560
- latestVersion
561
- );
498
+ const comparison = StringService.compareSemanticVersions(currentVersion, latestVersion);
562
499
 
563
500
  if (comparison === 0) {
564
501
  throw new Error(
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ErrorUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM;IAUlE;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;IAI/D;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;CAS9C"}
1
+ {"version":3,"file":"ErrorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ErrorUtils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,EAAE,CAAC;YACrC,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"ErrorUtils.js","sourceRoot":"","sources":["../../src/utils/ErrorUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,SAAmB,EAAE,eAAuB;QAChE,IAAI,WAAW,GAAG,EAAE,CAAC;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,WAAW,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QACrC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,YAAoB,EAAE,eAAuB;QAC7D,UAAU,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAc;QAClC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF"}
@@ -13,9 +13,7 @@ export default class ErrorUtils {
13
13
  for (let i = 0; i < errorList.length; i += 1) {
14
14
  errorString += `${errorList[i]}\n`;
15
15
  }
16
- throw new Error(
17
- `${errorString}${JSON.stringify(erroneousObject, null, 2)}`
18
- );
16
+ throw new Error(`${errorString}${JSON.stringify(erroneousObject, null, 2)}`);
19
17
  }
20
18
 
21
19
  /**
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@aneuhold/core-ts-lib",
3
3
  "author": "Anton G. Neuhold Jr.",
4
4
  "license": "MIT",
5
- "version": "2.2.3",
5
+ "version": "2.2.5",
6
6
  "description": "A core library for all of my TypeScript projects",
7
7
  "type": "module",
8
8
  "scripts": {
@@ -14,6 +14,7 @@
14
14
  "npm:validate": "tsx ./scripts/validateNpmPublish.ts",
15
15
  "checkAll": "pnpm build && pnpm lint && pnpm test && pnpm jsr:validate",
16
16
  "jsr:publish": "tsx ./scripts/publishJsr.ts",
17
+ "npm:publish": "npm publish --access public",
17
18
  "upgrade:all": "pnpm up"
18
19
  },
19
20
  "main": "lib/index.js",