Skip to content

Commit 536809c

Browse files
committed
Revert to single repo composer.json
1 parent 506fdda commit 536809c

File tree

12 files changed

+233
-43
lines changed

12 files changed

+233
-43
lines changed

bin/publish-ver.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
VERSION=$1
4+
REPO="cognesy/instructor-php" # Replace with your repo name
5+
6+
if [ -z "$VERSION" ]; then
7+
echo "Please provide version number"
8+
exit 1
9+
fi
10+
11+
# Remove 'v' prefix if present
12+
VERSION=${VERSION#v}
13+
14+
# Check if release notes exist
15+
NOTES_FILE="docs/release-notes/v$VERSION.md"
16+
if [ ! -f "$NOTES_FILE" ]; then
17+
echo "Error: Release notes file not found at $NOTES_FILE"
18+
echo "Please create release notes file before proceeding"
19+
exit 1
20+
fi
21+
22+
echo "Creating release for version $VERSION..."
23+
echo "Using release notes from: $NOTES_FILE"
24+
25+
# 1. Update package versions
26+
./bin/sync-ver.sh "$VERSION"
27+
28+
# 2. Commit changes
29+
git commit -am "Release version $VERSION"
30+
31+
# 3. Create git tag
32+
git tag "v$VERSION"
33+
34+
# 4. Push changes and tag
35+
git push && git push --tags
36+
37+
# 5. Create GitHub release using notes from file
38+
gh release create "v$VERSION" \
39+
--title "$VERSION" \
40+
--notes-file "$NOTES_FILE" \
41+
--repo "$REPO"
42+
43+
echo "Release v$VERSION completed!"

bin/sync-ver.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
# Get the new version from tag
4+
VERSION=$1
5+
6+
if [ -z "$VERSION" ]; then
7+
echo "Please provide version number"
8+
exit 1
9+
fi
10+
11+
# Remove 'v' prefix if present
12+
VERSION=${VERSION#v}
13+
14+
# Define packages and their sections based on composer.json
15+
declare -A REQUIRE_PACKAGES=(
16+
["src-utils"]="cognesy/utils"
17+
["src-addons"]="cognesy/instructor-php-addons"
18+
["src-llm"]="cognesy/llm"
19+
)
20+
21+
declare -A REQUIRE_DEV_PACKAGES=(
22+
["src-aux"]="cognesy/aux-tools"
23+
["src-experimental"]="cognesy/experimental"
24+
["src-hub"]="cognesy/instructor-php-hub"
25+
["src-setup"]="cognesy/instructor-php-setup"
26+
["src-tell"]="cognesy/tell"
27+
)
28+
29+
# Update version in each package's composer.json
30+
update_package_version() {
31+
local package_dir=$1
32+
if [ -f "$package_dir/composer.json" ]; then
33+
# Update version while preserving the rest of the file
34+
jq --arg version "$VERSION" '. + {version: $version}' "$package_dir/composer.json" > "$package_dir/composer.json.tmp"
35+
mv "$package_dir/composer.json.tmp" "$package_dir/composer.json"
36+
echo "Updated $package_dir to version $VERSION"
37+
fi
38+
}
39+
40+
# Function to update package versions in composer.json sections
41+
update_main_composer() {
42+
local section=$1
43+
local package_name=$2
44+
local new_content
45+
46+
echo "Attempting to update $package_name in $section..."
47+
48+
# Create a temporary file with updated content
49+
new_content=$(jq --arg section "$section" \
50+
--arg pkg "$package_name" \
51+
--arg ver "^$VERSION" \
52+
'setpath([$section, $pkg]; $ver)' \
53+
composer.json)
54+
55+
# Check if the content actually changed
56+
if [ "$new_content" != "$(cat composer.json)" ]; then
57+
echo "$new_content" > composer.json
58+
echo "Updated $package_name to version $VERSION in $section"
59+
else
60+
echo "Package $package_name not found in $section"
61+
fi
62+
}
63+
64+
# First, let's check what packages are actually in composer.json
65+
echo "Checking current package versions in composer.json..."
66+
echo "In require:"
67+
jq -r '.require | keys[]' composer.json | grep '^cognesy/'
68+
echo "In require-dev:"
69+
jq -r '."require-dev" | keys[]' composer.json | grep '^cognesy/'
70+
71+
# Update package versions
72+
echo "Updating package versions..."
73+
for dir in "${!REQUIRE_PACKAGES[@]}"; do
74+
update_package_version "$dir"
75+
done
76+
77+
for dir in "${!REQUIRE_DEV_PACKAGES[@]}"; do
78+
update_package_version "$dir"
79+
done
80+
81+
# Update main composer.json
82+
echo "Updating main composer.json..."
83+
84+
# Update require section
85+
for dir in "${!REQUIRE_PACKAGES[@]}"; do
86+
pkg_name="${REQUIRE_PACKAGES[$dir]}"
87+
update_main_composer "require" "$pkg_name"
88+
done
89+
90+
# Update require-dev section
91+
for dir in "${!REQUIRE_DEV_PACKAGES[@]}"; do
92+
pkg_name="${REQUIRE_DEV_PACKAGES[$dir]}"
93+
update_main_composer "require-dev" "$pkg_name"
94+
done
95+
96+
echo "Version sync complete"

composer.json

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@
5757
"ext-curl": "*",
5858
"ext-dom": "*",
5959
"cebe/markdown": "^1.2",
60-
"cognesy/aux-tools": "^0.12.0",
61-
"cognesy/experimental": "^0.12.0",
62-
"cognesy/instructor-php-hub": "^0.12.0",
63-
"cognesy/instructor-php-setup": "^0.12.0",
64-
"cognesy/tell": "^0.12.0",
6560
"duzun/hquery": "^3.1",
6661
"eftec/bladeone": "^4.16",
6762
"gioni06/gpt3-tokenizer": "^1.2",
@@ -104,9 +99,6 @@
10499
"ext-xmlreader": "*",
105100
"adbario/php-dot-notation": "^3.3",
106101
"aimeos/map": "^3.8",
107-
"cognesy/utils": "^0.12.0",
108-
"cognesy/instructor-php-addons": "^0.12.0",
109-
"cognesy/llm": "^0.12.0",
110102
"guzzlehttp/guzzle": "^7.8",
111103
"phpdocumentor/reflection-docblock": "^5.4",
112104
"phpstan/phpdoc-parser": "^1.29",
@@ -127,39 +119,5 @@
127119
"phpstan": "@php vendor/bin/phpstan -c phpstan.neon",
128120
"psalm": "@php vendor/bin/psalm",
129121
"instructor": "php ./bin/instructor"
130-
},
131-
"repositories": [
132-
{
133-
"type": "path",
134-
"url": "./src-addons"
135-
},
136-
{
137-
"type": "path",
138-
"url": "./src-aux"
139-
},
140-
{
141-
"type": "path",
142-
"url": "./src-experimental"
143-
},
144-
{
145-
"type": "path",
146-
"url": "./src-hub"
147-
},
148-
{
149-
"type": "path",
150-
"url": "./src-llm"
151-
},
152-
{
153-
"type": "path",
154-
"url": "./src-setup"
155-
},
156-
{
157-
"type": "path",
158-
"url": "./src-tell"
159-
},
160-
{
161-
"type": "path",
162-
"url": "./src-utils"
163-
}
164-
]
122+
}
165123
}

docs/release-notes/v0.12.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
- Redesigned directory structure to separate the essential code from the addons, aux tools, etc.
2+
- Directory 'src' to hold Instructor structured outputs code
3+
- New directory `src-llm` to hold the LLM connectivity code (required for Instructor)
4+
- New directory `src-utils` to hold the utility classes (required for Instructor)
5+
- Directory `src-setup` to hold the Instructor setup tool
6+
- Directory `src-hub` to hold the CLI tool for executing examples and generating documentation
7+
- Directory 'src-tell' to hold a simple tool for prompting LLMs from CLI
8+
- New directory `src-addons` to hold the additional capabilities (optional)
9+
- New directory `src-aux` to hold the auxiliary tools used, e.g. by examples (optional)
10+
- New directory `src-experimental` to hold the not yet ready, experimental work (not distributed)
11+
- Moved package-specific events to their respective directories
12+
- Moved embeddings API support to 'src-llm'
13+
- Added version sync script and Github release automation

src-addons/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "cognesy/instructor-php-addons",
3+
"description": "Optional addons for Instructor library",
4+
"autoload": {
5+
"psr-4": {
6+
"Cognesy\\Addons\\": "/"
7+
}
8+
},
9+
"version": "0.12.0"
10+
}

src-aux/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "cognesy/aux-tools",
3+
"description": "Collection of auxiliary services and integrations",
4+
"autoload": {
5+
"psr-4": {
6+
"Cognesy\\LLM\\": "/"
7+
}
8+
},
9+
"version": "0.12.0"
10+
}

src-experimental/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "cognesy/experimental",
3+
"description": "Experimental code used by Cognesy Instructor and LLM libraries",
4+
"autoload": {
5+
"psr-4": {
6+
"Cognesy\\LLM\\": "/"
7+
}
8+
},
9+
"version": "0.12.0"
10+
}

src-hub/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "cognesy/instructor-php-hub",
3+
"description": "CLI tool to work with Instructor PHP code examples and docs",
4+
"autoload": {
5+
"psr-4": {
6+
"Cognesy\\InstructorHub\\": "/"
7+
}
8+
},
9+
"version": "0.12.0"
10+
}

src-llm/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "cognesy/llm",
3+
"description": "Unified API for various LLM providers",
4+
"autoload": {
5+
"psr-4": {
6+
"Cognesy\\LLM\\": "/"
7+
}
8+
},
9+
"version": "0.12.0"
10+
}

src-setup/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "cognesy/instructor-php-setup",
3+
"description": "Setup tool for Instructor PHP library",
4+
"autoload": {
5+
"psr-4": {
6+
"Cognesy\\Setup\\": "/"
7+
}
8+
},
9+
"version": "0.12.0"
10+
}

0 commit comments

Comments
 (0)