@@ -28,12 +28,26 @@ usage() {
2828 exit 1
2929}
3030
31- if [ -z " $1 " ] || [ -z " $2 " ]; then
31+ if [ " ${1:- } " = " --list-integrations" ] && [ " $# " -eq 1 ]; then
32+ printf " %s\n" " ${VALID_INTEGRATIONS[@]} "
33+ exit 0
34+ fi
35+
36+ VALIDATE_ONLY=false
37+ if [ " ${1:- } " = " --validate-only" ]; then
38+ VALIDATE_ONLY=true
39+ shift
40+ if [ -z " ${1:- } " ] || [ " $# " -ne 1 ]; then
41+ usage
42+ fi
43+ fi
44+
45+ if [ -z " $1 " ] || { [ " $VALIDATE_ONLY " = false ] && [ -z " $2 " ]; }; then
3246 usage
3347fi
3448
3549INTEGRATION=$1
36- VERSION_ARG=$2
50+ VERSION_ARG=${2 :- }
3751
3852# Validate integration name
3953VALID=false
@@ -77,6 +91,54 @@ bump_version() {
7791 esac
7892}
7993
94+ validate_manifest_version_field () {
95+ local manifest=$1
96+ python3 - " $manifest " << 'PY '
97+ import json
98+ import sys
99+ from pathlib import Path
100+
101+ path = Path(sys.argv[1])
102+ if path.name == "pyproject.toml":
103+ import tomllib
104+
105+ data = tomllib.loads(path.read_text())
106+ version = data.get("project", {}).get("version")
107+ else:
108+ data = json.loads(path.read_text())
109+ version = data.get("version")
110+
111+ if not isinstance(version, str) or not version:
112+ raise SystemExit(f"Could not read a top-level release version from {path}")
113+ PY
114+ }
115+
116+ INTEGRATION_DIR=" hindsight-integrations/$INTEGRATION "
117+
118+ if [ ! -d " $INTEGRATION_DIR " ]; then
119+ print_error " Integration directory not found: $INTEGRATION_DIR "
120+ exit 1
121+ fi
122+
123+ if [ -f " $INTEGRATION_DIR /pyproject.toml" ]; then
124+ MANIFEST_PATH=" $INTEGRATION_DIR /pyproject.toml"
125+ elif [ -f " $INTEGRATION_DIR /package.json" ]; then
126+ MANIFEST_PATH=" $INTEGRATION_DIR /package.json"
127+ elif [ -f " $INTEGRATION_DIR /.claude-plugin/plugin.json" ]; then
128+ MANIFEST_PATH=" $INTEGRATION_DIR /.claude-plugin/plugin.json"
129+ elif [ -f " $INTEGRATION_DIR /settings.json" ] && grep -q ' "version"' " $INTEGRATION_DIR /settings.json" ; then
130+ MANIFEST_PATH=" $INTEGRATION_DIR /settings.json"
131+ else
132+ print_error " No pyproject.toml, package.json, plugin.json, or versioned settings.json found in $INTEGRATION_DIR "
133+ exit 1
134+ fi
135+
136+ if [ " $VALIDATE_ONLY " = true ]; then
137+ validate_manifest_version_field " $MANIFEST_PATH "
138+ print_info " Validated $INTEGRATION release path via $MANIFEST_PATH "
139+ exit 0
140+ fi
141+
80142# Resolve version: either an explicit semver or a bump keyword
81143if [[ " $VERSION_ARG " =~ ^(patch| minor| major)$ ]]; then
82144 CURRENT_VERSION=$( get_current_version)
@@ -135,14 +197,6 @@ if [ -z "$OPENAI_API_KEY" ]; then
135197 exit 1
136198fi
137199
138- # Determine integration type and update version
139- INTEGRATION_DIR=" hindsight-integrations/$INTEGRATION "
140-
141- if [ ! -d " $INTEGRATION_DIR " ]; then
142- print_error " Integration directory not found: $INTEGRATION_DIR "
143- exit 1
144- fi
145-
146200if [ -f " $INTEGRATION_DIR /pyproject.toml" ]; then
147201 print_info " Updating version in $INTEGRATION_DIR /pyproject.toml"
148202 sed -i.bak " s/^version = \" .*\" /version = \" $VERSION \" /" " $INTEGRATION_DIR /pyproject.toml"
@@ -159,9 +213,6 @@ elif [ -f "$INTEGRATION_DIR/settings.json" ] && grep -q '"version"' "$INTEGRATIO
159213 print_info " Updating version in $INTEGRATION_DIR /settings.json"
160214 sed -i.bak " s/\" version\" : \" .*\" /\" version\" : \" $VERSION \" /" " $INTEGRATION_DIR /settings.json"
161215 rm " $INTEGRATION_DIR /settings.json.bak"
162- else
163- print_error " No pyproject.toml, package.json, plugin.json, or versioned settings.json found in $INTEGRATION_DIR "
164- exit 1
165216fi
166217
167218# Generate changelog entry using LLM
0 commit comments