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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "devDependencies": {
3
+ "commitlint": "@declapract{check.minVersion('0.0.0')}"
4
+ }
5
+ }
@@ -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
+ };
@@ -1 +1,7 @@
1
- npx --no-install commitlint --edit "$1"
1
+ #!/bin/bash
2
+
3
+ if command -v node > /dev/null 2>&1 && [ -x ./node_modules/.bin/commitlint ]; then
4
+ ./node_modules/.bin/commitlint --edit "$1"
5
+ else
6
+ echo "🟡 commitlint not available, wont check commit message"
7
+ fi
@@ -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.3.0')}",
8
- "@commitlint/config-conventional": "@declapract{check.minVersion('13.1.0')}",
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 [ "$(npx yalc check)" ]; then
5
- echo "✋ package.json has yalc references. Run 'npx yalc remove --all' to remove these local testing references."
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:errors": "biome check src --diagnostic-level=error",
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
  }
@@ -57,7 +57,7 @@ export const desiredRelativeKeyOrder = {
57
57
  'test:format',
58
58
  'test:lint:deps',
59
59
  'test:lint:biome',
60
- 'test:lint:errors',
60
+ 'test:lint:biome:all',
61
61
  'test:lint:eslint',
62
62
  'test:lint',
63
63
  'test:unit',
@@ -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 requiresAwsAuth =
40
- existsSync(declapractUsePath) &&
41
- readFileSync(declapractUsePath, 'utf8').includes('awsAccountId');
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.4",
5
+ "version": "0.43.5",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",