declapract-typescript-ehmpathy 0.47.8 → 0.47.10
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/tests/bad-practices/old-acceptance-dir-location/.declapract.readme.md +22 -0
- package/dist/practices/tests/bad-practices/old-acceptance-dir-location/acceptance/<star><star>/<star>.acceptance.test.ts.declapract.ts +19 -0
- package/dist/practices/tests/bad-practices/old-acceptance-dir-location/acceptance/<star><star>/<star>.ts.declapract.ts +19 -0
- package/dist/practices/tests/bad-practices/old-acceptance-import-paths/.declapract.readme.md +31 -0
- package/dist/practices/tests/bad-practices/old-acceptance-import-paths/<star><star>/<star>.ts.declapract.ts +25 -0
- package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/.declapract.readme.md +1 -1
- package/dist/practices/tests/best-practice/.agent/repo=.this/role=any/skills/use.apikeys.json +5 -0
- package/dist/practices/tests/best-practice/.agent/repo=.this/role=any/skills/use.apikeys.json.declapract.ts +4 -0
- package/dist/practices/tests/best-practice/.agent/repo=.this/role=any/skills/use.apikeys.sh +59 -0
- package/dist/practices/tests/best-practice/.agent/repo=.this/role=any/skills/use.apikeys.sh.declapract.ts +4 -0
- package/dist/practices/tests/best-practice/jest.acceptance.env.ts +35 -0
- package/dist/practices/tests/best-practice/jest.integration.env.ts +35 -0
- package/package.json +1 -1
- /package/dist/practices/tests/bad-practices/old-acceptance-test-utils/{acceptance → blackbox}/_utils/getDataFromLastOpenBracketAtStartOfLine.ts.declapract.ts +0 -0
- /package/dist/practices/tests/bad-practices/old-acceptance-test-utils/{acceptance → blackbox}/_utils/invokeLambda.ts.declapract.ts +0 -0
- /package/dist/practices/tests/bad-practices/old-acceptance-test-utils/{acceptance → blackbox}/lambdas/<star>.ts.declapract.ts +0 -0
- /package/dist/practices/tests/bad-practices/old-acceptance-test-utils-2/{acceptance → blackbox}/lambdas/<star>.ts.declapract.ts +0 -0
- /package/dist/practices/tests/bad-practices/old-acceptance-test-utils-3/{acceptance → blackbox}/_utils/environment.ts.declapract.ts +0 -0
- /package/dist/practices/tests/bad-practices/old-acceptance-test-utils-3/{acceptance → blackbox}/lambdas/<star>.ts.declapract.ts +0 -0
- /package/dist/practices/tests-service/best-practice/{acceptance → blackbox}/<star><star>/<star>.acceptance.test.ts.declapract.ts +0 -0
- /package/dist/practices/tests-service/best-practice/{acceptance → blackbox}/lambdas/<star>.acceptance.test.ts.declapract.ts +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# old-acceptance-dir-location
|
|
2
|
+
|
|
3
|
+
## .what
|
|
4
|
+
|
|
5
|
+
detects test files located in `acceptance/` directory and migrates them to `blackbox/`.
|
|
6
|
+
|
|
7
|
+
## .why
|
|
8
|
+
|
|
9
|
+
the term "blackbox" makes the testing philosophy explicit:
|
|
10
|
+
- blackbox tests interact only through public contracts (APIs, CLIs, SDKs)
|
|
11
|
+
- no access to internal implementation details
|
|
12
|
+
- tests validate behavior from the caller's perspective
|
|
13
|
+
|
|
14
|
+
the rename from `acceptance/` to `blackbox/` clarifies this intent.
|
|
15
|
+
|
|
16
|
+
## .fix
|
|
17
|
+
|
|
18
|
+
moves all files from `acceptance/` to `blackbox/` while preserving the directory structure.
|
|
19
|
+
|
|
20
|
+
## .note
|
|
21
|
+
|
|
22
|
+
the `.acceptance.test.ts` file extension is preserved — it communicates the test type while the directory name communicates the testing philosophy.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FileCheckType, type FileFixFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
export const check = FileCheckType.EXISTS; // if files exist in acceptance/, flag as bad practice
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* .what = moves acceptance test files from acceptance/ to blackbox/
|
|
7
|
+
* .why = blackbox/ naming makes the testing philosophy explicit
|
|
8
|
+
*/
|
|
9
|
+
export const fix: FileFixFunction = (contents, context) => {
|
|
10
|
+
// move from acceptance/ to blackbox/
|
|
11
|
+
const newPath = context.relativeFilePath.replace(
|
|
12
|
+
/^acceptance\//,
|
|
13
|
+
'blackbox/',
|
|
14
|
+
);
|
|
15
|
+
return {
|
|
16
|
+
contents: contents ?? null,
|
|
17
|
+
relativeFilePath: newPath,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FileCheckType, type FileFixFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
export const check = FileCheckType.EXISTS; // if any ts files exist in acceptance/, flag as bad practice
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* .what = moves ts files from acceptance/ to blackbox/
|
|
7
|
+
* .why = blackbox/ naming makes the testing philosophy explicit
|
|
8
|
+
*/
|
|
9
|
+
export const fix: FileFixFunction = (contents, context) => {
|
|
10
|
+
// move from acceptance/ to blackbox/
|
|
11
|
+
const newPath = context.relativeFilePath.replace(
|
|
12
|
+
/^acceptance\//,
|
|
13
|
+
'blackbox/',
|
|
14
|
+
);
|
|
15
|
+
return {
|
|
16
|
+
contents: contents ?? null,
|
|
17
|
+
relativeFilePath: newPath,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# old-acceptance-import-paths
|
|
2
|
+
|
|
3
|
+
## .what
|
|
4
|
+
|
|
5
|
+
detects import statements that reference the old `acceptance/` directory path.
|
|
6
|
+
|
|
7
|
+
## .why
|
|
8
|
+
|
|
9
|
+
the `acceptance/` directory has been renamed to `blackbox/` to make the testing philosophy explicit:
|
|
10
|
+
- blackbox tests interact only through public contracts
|
|
11
|
+
- no access to internal implementation details
|
|
12
|
+
|
|
13
|
+
import paths must be updated to reference `blackbox/` instead of `acceptance/`.
|
|
14
|
+
|
|
15
|
+
## .fix
|
|
16
|
+
|
|
17
|
+
replaces all occurrences of `acceptance/` with `blackbox/` in import paths.
|
|
18
|
+
|
|
19
|
+
## .examples
|
|
20
|
+
|
|
21
|
+
before:
|
|
22
|
+
```typescript
|
|
23
|
+
import { locally } from '../acceptance/environment';
|
|
24
|
+
import { stage } from '../../acceptance/utils/environment';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
after:
|
|
28
|
+
```typescript
|
|
29
|
+
import { locally } from '../blackbox/environment';
|
|
30
|
+
import { stage } from '../../blackbox/utils/environment';
|
|
31
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FileCheckFunction, FileFixFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* .what = detects imports that reference acceptance/ directory
|
|
5
|
+
* .why = acceptance/ has been renamed to blackbox/
|
|
6
|
+
*/
|
|
7
|
+
export const check: FileCheckFunction = (contents) => {
|
|
8
|
+
// match imports that reference acceptance/ directory
|
|
9
|
+
if (contents?.match(/from ['"]\.\.?\/.*acceptance\//)) return; // matches bad practice
|
|
10
|
+
if (contents?.match(/from ['"]acceptance\//)) return; // matches bad practice
|
|
11
|
+
throw new Error('does not match bad practice');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* .what = replaces acceptance/ with blackbox/ in import paths
|
|
16
|
+
* .why = blackbox/ naming makes the testing philosophy explicit
|
|
17
|
+
*/
|
|
18
|
+
export const fix: FileFixFunction = (contents) => {
|
|
19
|
+
if (!contents) return {};
|
|
20
|
+
return {
|
|
21
|
+
contents: contents
|
|
22
|
+
.replace(/(['"])(.*)\/acceptance\//g, '$1$2/blackbox/')
|
|
23
|
+
.replace(/(['"])acceptance\//g, '$1blackbox/'),
|
|
24
|
+
};
|
|
25
|
+
};
|
package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/.declapract.readme.md
CHANGED
|
@@ -5,4 +5,4 @@ the `.test.utils/` directory replaces `__test_utils__` and `.test.assets/` repla
|
|
|
5
5
|
examples:
|
|
6
6
|
- `src/domain/__test_utils__/exampleUser.ts` → `src/domain/.test.utils/exampleUser.ts`
|
|
7
7
|
- `src/logic/__test_assets__/fixtures.json` → `src/logic/.test.assets/fixtures.json`
|
|
8
|
-
- `
|
|
8
|
+
- `blackbox/__test_utils__/environment.ts` → `blackbox/.test.utils/environment.ts`
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
######################################################################
|
|
3
|
+
# .what = export api keys for integration tests
|
|
4
|
+
# .why = enables running integration tests that require api keys
|
|
5
|
+
#
|
|
6
|
+
# usage:
|
|
7
|
+
# source .agent/repo=.this/role=any/skills/use.apikeys.sh
|
|
8
|
+
#
|
|
9
|
+
# note:
|
|
10
|
+
# - must be called with `source` to export vars to current shell
|
|
11
|
+
# - loads from ~/.config/rhachet/apikeys.env if available
|
|
12
|
+
# - falls back to .env.local (gitignored) in repo root
|
|
13
|
+
######################################################################
|
|
14
|
+
|
|
15
|
+
# fail if not sourced
|
|
16
|
+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
17
|
+
echo "error: this script must be sourced, not executed"
|
|
18
|
+
echo "usage: source ${BASH_SOURCE[0]}"
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# try loading from user config first
|
|
23
|
+
if [[ -f ~/.config/rhachet/apikeys.env ]]; then
|
|
24
|
+
source ~/.config/rhachet/apikeys.env
|
|
25
|
+
echo "✓ loaded api keys from ~/.config/rhachet/apikeys.env"
|
|
26
|
+
|
|
27
|
+
# fallback to local gitignored file
|
|
28
|
+
elif [[ -f .env.local ]]; then
|
|
29
|
+
source .env.local
|
|
30
|
+
echo "✓ loaded api keys from .env.local"
|
|
31
|
+
|
|
32
|
+
else
|
|
33
|
+
echo "⚠ no api keys file found"
|
|
34
|
+
echo ""
|
|
35
|
+
echo "create one of:"
|
|
36
|
+
echo " ~/.config/rhachet/apikeys.env"
|
|
37
|
+
echo " .env.local (in repo root)"
|
|
38
|
+
echo ""
|
|
39
|
+
echo "with contents like:"
|
|
40
|
+
echo " export OPENAI_API_KEY=sk-..."
|
|
41
|
+
echo " export ANTHROPIC_API_KEY=sk-..."
|
|
42
|
+
return 1
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# read required keys from json config if present
|
|
46
|
+
APIKEYS_CONFIG=".agent/repo=.this/role=any/skills/use.apikeys.json"
|
|
47
|
+
if [[ -f "$APIKEYS_CONFIG" ]]; then
|
|
48
|
+
# extract required keys using jq
|
|
49
|
+
REQUIRED_KEYS=$(jq -r '.apikeys.required[]?' "$APIKEYS_CONFIG" 2>/dev/null)
|
|
50
|
+
|
|
51
|
+
# verify each required key is set
|
|
52
|
+
for KEY in $REQUIRED_KEYS; do
|
|
53
|
+
if [[ -z "${!KEY}" ]]; then
|
|
54
|
+
echo "⚠ $KEY not set (required by $APIKEYS_CONFIG)"
|
|
55
|
+
return 1
|
|
56
|
+
fi
|
|
57
|
+
echo "✓ $KEY set"
|
|
58
|
+
done
|
|
59
|
+
fi
|
|
@@ -32,3 +32,38 @@ if (
|
|
|
32
32
|
throw new Error(
|
|
33
33
|
'no aws credentials present. please authenticate with aws to run acceptance tests',
|
|
34
34
|
);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* .what = verify that required api keys are present; otherwise, fail fast
|
|
38
|
+
* .why =
|
|
39
|
+
* - prevent time wasted waiting on tests to fail due to missing api keys
|
|
40
|
+
* - prevent agents from giving up when they have access to credentials
|
|
41
|
+
*/
|
|
42
|
+
const apikeysConfigPath = join(
|
|
43
|
+
process.cwd(),
|
|
44
|
+
'.agent/repo=.this/role=any/skills/use.apikeys.json',
|
|
45
|
+
);
|
|
46
|
+
if (existsSync(apikeysConfigPath)) {
|
|
47
|
+
// direct import via require (json resolves automatically)
|
|
48
|
+
const config = require(apikeysConfigPath);
|
|
49
|
+
const requiredKeys: string[] = config?.apikeys?.required ?? [];
|
|
50
|
+
const keysAbsent = requiredKeys.filter((key) => !process.env[key]);
|
|
51
|
+
|
|
52
|
+
if (keysAbsent.length > 0) {
|
|
53
|
+
throw new Error(`
|
|
54
|
+
⛈️ apikeys required to run these acceptance tests were not supplied.
|
|
55
|
+
|
|
56
|
+
absent keys: ${keysAbsent.join(', ')}
|
|
57
|
+
|
|
58
|
+
you have access to these keys - you just forgot to source them.
|
|
59
|
+
|
|
60
|
+
run:
|
|
61
|
+
source .agent/repo=.this/role=any/skills/use.apikeys.sh && npm run test:acceptance
|
|
62
|
+
|
|
63
|
+
you must run these tests with these api keys.
|
|
64
|
+
you're forbidden to give up.
|
|
65
|
+
if you don't have privs to run use.apikeys.sh, ask a human for support.
|
|
66
|
+
chances are, you already have privs to do so though.
|
|
67
|
+
`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -82,3 +82,38 @@ if (requiresTestDb) {
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* .what = verify that required api keys are present; otherwise, fail fast
|
|
88
|
+
* .why =
|
|
89
|
+
* - prevent time wasted waiting on tests to fail due to missing api keys
|
|
90
|
+
* - prevent agents from giving up when they have access to credentials
|
|
91
|
+
*/
|
|
92
|
+
const apikeysConfigPath = join(
|
|
93
|
+
process.cwd(),
|
|
94
|
+
'.agent/repo=.this/role=any/skills/use.apikeys.json',
|
|
95
|
+
);
|
|
96
|
+
if (existsSync(apikeysConfigPath)) {
|
|
97
|
+
// direct import via require (json resolves automatically)
|
|
98
|
+
const config = require(apikeysConfigPath);
|
|
99
|
+
const requiredKeys: string[] = config?.apikeys?.required ?? [];
|
|
100
|
+
const keysAbsent = requiredKeys.filter((key) => !process.env[key]);
|
|
101
|
+
|
|
102
|
+
if (keysAbsent.length > 0) {
|
|
103
|
+
throw new Error(`
|
|
104
|
+
⛈️ apikeys required to run these integration tests were not supplied.
|
|
105
|
+
|
|
106
|
+
absent keys: ${keysAbsent.join(', ')}
|
|
107
|
+
|
|
108
|
+
you have access to these keys - you just forgot to source them.
|
|
109
|
+
|
|
110
|
+
run:
|
|
111
|
+
source .agent/repo=.this/role=any/skills/use.apikeys.sh && npm run test:integration
|
|
112
|
+
|
|
113
|
+
you must run these tests with these api keys.
|
|
114
|
+
you're forbidden to give up.
|
|
115
|
+
if you don't have privs to run use.apikeys.sh, ask a human for support.
|
|
116
|
+
chances are, you already have privs to do so though.
|
|
117
|
+
`);
|
|
118
|
+
}
|
|
119
|
+
}
|
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.
|
|
5
|
+
"version": "0.47.10",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|