declapract-typescript-ehmpathy 0.45.3 → 0.45.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.
- package/dist/practices/cicd-package/best-practice/.github/workflows/provision.yml +1 -1
- package/dist/practices/cicd-service/best-practice/.github/workflows/provision.yml +1 -1
- package/dist/practices/provision-github/bad-practices/old-declastruct-resources-path/provision/github/declastruct.resources.ts.declapract.ts +7 -0
- package/dist/practices/typescript/bad-practices/relative-imports/src/<star><star>/<star>.ts.declapract.ts +11 -5
- package/dist/practices/typescript/best-practice/package.json +1 -1
- package/package.json +1 -1
- /package/dist/practices/provision-github/best-practice/provision/{github/declastruct.resources.ts → github.repo/resources.ts} +0 -0
|
@@ -18,7 +18,7 @@ jobs:
|
|
|
18
18
|
github:
|
|
19
19
|
uses: ./.github/workflows/.declastruct.yml
|
|
20
20
|
with:
|
|
21
|
-
wish-path: provision/github/
|
|
21
|
+
wish-path: provision/github.repo/resources.ts
|
|
22
22
|
github-environment: prod
|
|
23
23
|
creds-github-app-owner: ehmpathy
|
|
24
24
|
creds-github-app-id: ${{ vars.DECLASTRUCT_GITHUB_CONFORMER_APP_ID }}
|
|
@@ -43,7 +43,7 @@ jobs:
|
|
|
43
43
|
github:
|
|
44
44
|
uses: ./.github/workflows/.declastruct.yml
|
|
45
45
|
with:
|
|
46
|
-
wish-path: provision/github/
|
|
46
|
+
wish-path: provision/github.repo/resources.ts
|
|
47
47
|
github-environment: prod
|
|
48
48
|
creds-github-app-owner: ehmpathy
|
|
49
49
|
creds-github-app-id: ${{ vars.DECLASTRUCT_GITHUB_CONFORMER_APP_ID }}
|
|
@@ -54,18 +54,24 @@ export const fix: FileFixFunction = (contents, { relativeFilePath }) => {
|
|
|
54
54
|
const pathParts = relativeFilePath.split('/');
|
|
55
55
|
const srcIndex = pathParts.indexOf('src');
|
|
56
56
|
|
|
57
|
-
//
|
|
57
|
+
// get the directories between src/ and the current file
|
|
58
|
+
const currentDirParts = pathParts.slice(srcIndex + 1, -1);
|
|
59
|
+
|
|
60
|
+
// replace relative imports with @src imports (only if they stay within src/)
|
|
58
61
|
const fixed = contents.replace(
|
|
59
62
|
/from\s+['"]((\.\.\/)+)(.*?)['"]/g,
|
|
60
63
|
(match, dots, _, importPath) => {
|
|
61
64
|
// count how many ../ we have
|
|
62
65
|
const upCount = (dots.match(/\.\.\//g) || []).length;
|
|
63
66
|
|
|
64
|
-
//
|
|
65
|
-
|
|
67
|
+
// if going up more levels than we have directories within src/, it goes OUTSIDE src
|
|
68
|
+
// leave these imports unchanged (e.g., ../../package.json from src/utils/index.ts)
|
|
69
|
+
if (upCount > currentDirParts.length) {
|
|
70
|
+
return match;
|
|
71
|
+
}
|
|
66
72
|
|
|
67
|
-
// if going up
|
|
68
|
-
if (upCount
|
|
73
|
+
// if going up exactly as many levels as we have directories, target is at src root
|
|
74
|
+
if (upCount === currentDirParts.length) {
|
|
69
75
|
return `from '@src/${importPath}'`;
|
|
70
76
|
}
|
|
71
77
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build:clean": "rm dist/ -rf",
|
|
11
11
|
"build:compile": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
12
|
-
"build": "npm run build:clean && npm run build:compile && npm run build:artifact",
|
|
12
|
+
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present && npm run build:artifact",
|
|
13
13
|
"test:types": "tsc -p ./tsconfig.json --noEmit"
|
|
14
14
|
}
|
|
15
15
|
}
|
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.45.
|
|
5
|
+
"version": "0.45.5",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|