declapract-typescript-ehmpathy 0.47.27 → 0.47.28
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-common/best-practice/.agent/repo=.this/role=any/skills/use.apikeys.sh
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
#!/
|
|
1
|
+
#!/bin/sh
|
|
2
2
|
######################################################################
|
|
3
3
|
# .what = export api keys for integration tests
|
|
4
|
-
# .why = enables
|
|
4
|
+
# .why = enables tests that require api keys to run
|
|
5
5
|
#
|
|
6
6
|
# usage:
|
|
7
|
-
#
|
|
7
|
+
# . .agent/repo=.this/role=any/skills/use.apikeys.sh
|
|
8
8
|
#
|
|
9
9
|
# note:
|
|
10
|
-
# - must be called with `source` to export vars to current shell
|
|
10
|
+
# - must be called with `.` or `source` to export vars to current shell
|
|
11
11
|
# - loads from ~/.config/rhachet/apikeys.env if available
|
|
12
12
|
# - falls back to .env.local (gitignored) in repo root
|
|
13
13
|
######################################################################
|
|
14
14
|
|
|
15
|
-
# fail if not sourced
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
# fail if not sourced (check if $0 matches this file)
|
|
16
|
+
case "$0" in
|
|
17
|
+
*use.apikeys.sh)
|
|
18
|
+
echo "error: this file must be sourced, not executed"
|
|
19
|
+
echo "usage: source $0"
|
|
20
|
+
exit 1
|
|
21
|
+
;;
|
|
22
|
+
esac
|
|
23
|
+
|
|
24
|
+
# alias source to `.` for posix compat
|
|
25
|
+
source() { . "$@"; }
|
|
21
26
|
|
|
22
|
-
# try
|
|
23
|
-
if [
|
|
27
|
+
# try to load from user config first
|
|
28
|
+
if [ -f ~/.config/rhachet/apikeys.env ]; then
|
|
24
29
|
source ~/.config/rhachet/apikeys.env
|
|
25
30
|
echo "✓ loaded api keys from ~/.config/rhachet/apikeys.env"
|
|
26
31
|
|
|
27
32
|
# fallback to local gitignored file
|
|
28
|
-
elif [
|
|
33
|
+
elif [ -f .env.local ]; then
|
|
29
34
|
source .env.local
|
|
30
35
|
echo "✓ loaded api keys from .env.local"
|
|
31
36
|
|
|
@@ -39,20 +44,21 @@ else
|
|
|
39
44
|
echo "with contents like:"
|
|
40
45
|
echo " export OPENAI_API_KEY=sk-..."
|
|
41
46
|
echo " export ANTHROPIC_API_KEY=sk-..."
|
|
42
|
-
return 1
|
|
47
|
+
return 1 2>/dev/null || exit 1
|
|
43
48
|
fi
|
|
44
49
|
|
|
45
50
|
# read required keys from json config if present
|
|
46
51
|
APIKEYS_CONFIG=".agent/repo=.this/role=any/skills/use.apikeys.json"
|
|
47
|
-
if [
|
|
48
|
-
# extract required keys
|
|
52
|
+
if [ -f "$APIKEYS_CONFIG" ]; then
|
|
53
|
+
# extract required keys via jq
|
|
49
54
|
REQUIRED_KEYS=$(jq -r '.apikeys.required[]?' "$APIKEYS_CONFIG" 2>/dev/null)
|
|
50
55
|
|
|
51
56
|
# verify each required key is set
|
|
52
57
|
for KEY in $REQUIRED_KEYS; do
|
|
53
|
-
|
|
58
|
+
VALUE=$(eval "echo \"\$$KEY\"")
|
|
59
|
+
if [ -z "$VALUE" ]; then
|
|
54
60
|
echo "⚠ $KEY not set (required by $APIKEYS_CONFIG)"
|
|
55
|
-
return 1
|
|
61
|
+
return 1 2>/dev/null || exit 1
|
|
56
62
|
fi
|
|
57
63
|
echo "✓ $KEY set"
|
|
58
64
|
done
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"@swc/jest": "@declapract{check.minVersion('0.2.39')}"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test:auth": "[ \"$ECHO\" = 'true' ] && echo '
|
|
12
|
+
"test:auth": "[ \"$ECHO\" = 'true' ] && echo '. .agent/repo=.this/role=any/skills/use.apikeys.sh' || . .agent/repo=.this/role=any/skills/use.apikeys.sh",
|
|
13
13
|
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
14
14
|
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
15
15
|
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
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.28",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|