declapract-typescript-ehmpathy 0.43.4 → 0.43.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/conventional-commits/bad-practices/commitlint/package.json +5 -0
- package/dist/practices/conventional-commits/bad-practices/commitlint/package.json.declapract.ts +19 -0
- package/dist/practices/conventional-commits/best-practice/.husky/check.commit.sh +7 -1
- package/dist/practices/conventional-commits/best-practice/package.json +2 -2
- package/dist/practices/husky/best-practice/.husky/check.yalc.sh +4 -2
- package/dist/practices/lint/best-practice/package.json +2 -2
- package/dist/practices/package-json-order/best-practice/package.json.declapract.ts +1 -1
- package/dist/practices/tests/best-practice/jest.integration.env.ts +39 -3
- package/package.json +1 -1
package/dist/practices/conventional-commits/bad-practices/commitlint/package.json.declapract.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import { FileCheckType, type FileFixFunction } from 'declapract';
|
|
3
|
+
|
|
4
|
+
export const check = FileCheckType.CONTAINS;
|
|
5
|
+
|
|
6
|
+
export const fix: FileFixFunction = (contents) => {
|
|
7
|
+
if (!contents) return { contents }; // do nothing if no contents
|
|
8
|
+
const packageJSON = JSON.parse(contents);
|
|
9
|
+
const updatedPackageJSON = {
|
|
10
|
+
...packageJSON,
|
|
11
|
+
devDependencies: {
|
|
12
|
+
...packageJSON.devDependencies,
|
|
13
|
+
commitlint: undefined,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
contents: JSON.stringify(updatedPackageJSON, null, 2),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@commitlint/cli": "@declapract{check.minVersion('19.
|
|
8
|
-
"@commitlint/config-conventional": "@declapract{check.minVersion('
|
|
7
|
+
"@commitlint/cli": "@declapract{check.minVersion('19.5.0')}",
|
|
8
|
+
"@commitlint/config-conventional": "@declapract{check.minVersion('19.5.0')}",
|
|
9
9
|
"cz-conventional-changelog": "@declapract{check.minVersion('3.3.0')}",
|
|
10
10
|
"husky": "@declapract{check.minVersion('7.0.2')}"
|
|
11
11
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
3
|
# https://github.com/wclr/yalc
|
|
4
|
-
if
|
|
5
|
-
|
|
4
|
+
if command -v npx &> /dev/null; then
|
|
5
|
+
if [ "$(npx yalc check 2>/dev/null)" ]; then
|
|
6
|
+
echo "✋ package.json has yalc references. Run 'npx yalc remove --all' to remove these local testing references."
|
|
7
|
+
fi
|
|
6
8
|
fi
|
|
7
9
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
"fix:format:biome": "biome check --write src",
|
|
8
8
|
"fix:lint": "biome check --write src",
|
|
9
9
|
"test:format:biome": "biome format src",
|
|
10
|
-
"test:lint:biome": "biome check src",
|
|
11
|
-
"test:lint:
|
|
10
|
+
"test:lint:biome": "biome check src --diagnostic-level=error",
|
|
11
|
+
"test:lint:biome:all": "biome check src",
|
|
12
12
|
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
13
13
|
"test:lint": "npm run test:lint:biome && npm run test:lint:deps"
|
|
14
14
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
1
2
|
import { existsSync, readFileSync } from 'fs';
|
|
2
3
|
import { join } from 'path';
|
|
3
4
|
import util from 'util';
|
|
@@ -36,9 +37,10 @@ if (
|
|
|
36
37
|
* - prevent time wasted debugging tests which are failing due to hard-to-read missed credential errors
|
|
37
38
|
*/
|
|
38
39
|
const declapractUsePath = join(process.cwd(), 'declapract.use.yml');
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const declapractUseContent = existsSync(declapractUsePath)
|
|
41
|
+
? readFileSync(declapractUsePath, 'utf8')
|
|
42
|
+
: '';
|
|
43
|
+
const requiresAwsAuth = declapractUseContent.includes('awsAccountId');
|
|
42
44
|
if (
|
|
43
45
|
requiresAwsAuth &&
|
|
44
46
|
!(process.env.AWS_PROFILE || process.env.AWS_ACCESS_KEY_ID)
|
|
@@ -46,3 +48,37 @@ if (
|
|
|
46
48
|
throw new Error(
|
|
47
49
|
'no aws credentials present. please authenticate with aws to run integration tests',
|
|
48
50
|
);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* .what = verify that the testdb has been provisioned if a databaseUserName is declared
|
|
54
|
+
* .why =
|
|
55
|
+
* - prevent time wasted waiting on tests to fail due to missing testdb
|
|
56
|
+
* - prevent confusing "password authentication failed" errors when testdb isn't running or was provisioned for a different repo
|
|
57
|
+
*/
|
|
58
|
+
const requiresTestDb = declapractUseContent.includes('databaseUserName');
|
|
59
|
+
if (requiresTestDb) {
|
|
60
|
+
const testConfigPath = join(process.cwd(), 'config', 'test.json');
|
|
61
|
+
if (!existsSync(testConfigPath))
|
|
62
|
+
throw new Error(
|
|
63
|
+
'config/test.json not found but serviceUser is declared in declapract.use.yml',
|
|
64
|
+
);
|
|
65
|
+
const testConfig = JSON.parse(readFileSync(testConfigPath, 'utf8'));
|
|
66
|
+
if (
|
|
67
|
+
!testConfig.database?.tunnel?.local ||
|
|
68
|
+
!testConfig.database?.role?.crud ||
|
|
69
|
+
!testConfig.database?.target?.database
|
|
70
|
+
)
|
|
71
|
+
throw new Error(
|
|
72
|
+
'config/test.json database.tunnel.local, database?.role?.crud, or database?.target?.database not found but expected',
|
|
73
|
+
);
|
|
74
|
+
try {
|
|
75
|
+
execSync(
|
|
76
|
+
`PGPASSWORD="${testConfig.database.role.crud.password}" psql -h ${testConfig.database.tunnel.local.host} -p ${testConfig.database.tunnel.local.port} -U ${testConfig.database.role.crud.username} -d ${testConfig.database.target.database} -c "SELECT 1" > /dev/null 2>&1`,
|
|
77
|
+
{ timeout: 3000 },
|
|
78
|
+
);
|
|
79
|
+
} catch {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`did you forget to \`npm run start:testdb\`? cant connect to database`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
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.43.
|
|
5
|
+
"version": "0.43.5",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|