declapract-typescript-ehmpathy 0.47.8 → 0.47.9
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/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
|
@@ -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.9",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|