declapract-typescript-ehmpathy 0.47.65 → 0.47.66

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.
@@ -10,11 +10,37 @@ export const fix: FileFixFunction = (contents, context) => {
10
10
  .replace(/\/domain\/objects\//g, '/domain.objects/')
11
11
  .replace(/\/domain\//g, '/domain.objects/');
12
12
 
13
+ let fixedContents = contents;
14
+
15
+ // fix relative imports for files DIRECTLY in domain/objects/ that move to domain.objects/
16
+ // these files move UP one directory level, so reduce ../ by one
17
+ // note: nested files (domain/objects/nested/Deep.ts) stay at same depth, no transform
18
+ const isDirectChildOfDomainObjects = /\/domain\/objects\/[^/]+$/.test(
19
+ context.relativeFilePath,
20
+ );
21
+ if (fixedContents && isDirectChildOfDomainObjects) {
22
+ fixedContents = fixedContents.replace(
23
+ /((?:import|export)[^'"]*['"])((?:\.\.\/)+)/g,
24
+ (match, importPrefix, dotDots) => {
25
+ const count = dotDots.split('../').length - 1;
26
+ if (count === 1) {
27
+ // '../X' → './X'
28
+ return `${importPrefix}./`;
29
+ }
30
+ // '../../X' → '../X', '../../../X' → '../../X', etc.
31
+ return `${importPrefix}${'../'.repeat(count - 1)}`;
32
+ },
33
+ );
34
+ }
35
+
13
36
  // fix internal export paths in index files
14
37
  // when domain/index.ts moves to domain.objects/index.ts,
15
38
  // exports like './objects/User' should become './User'
16
- let fixedContents = contents;
17
- if (fixedContents && context.relativeFilePath.includes('/domain/index.ts')) {
39
+ if (
40
+ fixedContents &&
41
+ context.relativeFilePath.includes('/domain/') &&
42
+ context.relativeFilePath.endsWith('/index.ts')
43
+ ) {
18
44
  fixedContents = fixedContents
19
45
  // export * from './objects' → remove (objects dir flattened to root)
20
46
  .replace(/export\s+\*\s+from\s+['"]\.\/objects['"];?\n?/g, '')
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.47.65",
5
+ "version": "0.47.66",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",