Skip to content

Commit 54878b7

Browse files
committed
Cleanup old types dir
1 parent 6055b8f commit 54878b7

File tree

9 files changed

+49
-985
lines changed

9 files changed

+49
-985
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,23 @@ Both methods will:
8282
Generate both Python and TypeScript types in one command without local dependencies:
8383

8484
```bash
85-
# Generate both Python and TypeScript
86-
./build-types.sh --all --output-dir ./types
85+
# Generate both Python and TypeScript packages
86+
./build-types.sh --all
8787

88-
# Or generate just Python
89-
./build-types.sh --python --output-dir ./types
88+
# Or generate just Python package
89+
./build-types.sh --python
9090

91-
# Or generate just TypeScript
92-
./build-types.sh --typescript --output-dir ./types
91+
# Or generate just TypeScript package
92+
./build-types.sh --typescript
93+
```
94+
95+
The generated files will be placed in the appropriate package directories:
96+
- Python: `./python/api_model/types/models.py`
97+
- TypeScript: `./typescript/src/models.ts` and `./typescript/src/index.ts`
98+
99+
You can optionally specify an additional output directory:
100+
```bash
101+
./build-types.sh --all --output-dir ./my-output-dir
93102
```
94103

95104
This will:

build-types.sh

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ usage() {
2222
# Default values
2323
PYTHON=false
2424
TYPESCRIPT=false
25-
OUTPUT_DIR="./output"
25+
OUTPUT_DIR="" # No default output directory since we have dedicated package directories
2626
OPENAPI_FILE="build/smithyprojections/api-model/openapi/openapi/EqualIQ.openapi.json"
2727

2828
# Parse command-line arguments
@@ -60,8 +60,10 @@ if [[ ! -f "$OPENAPI_FILE" ]]; then
6060
exit 1
6161
fi
6262

63-
# Create output directory
64-
mkdir -p "$OUTPUT_DIR"
63+
# Create output directory if specified
64+
if [[ -n "$OUTPUT_DIR" ]]; then
65+
mkdir -p "$OUTPUT_DIR"
66+
fi
6567

6668
# Generate Python models with a dedicated container build
6769
if [[ "$PYTHON" == "true" ]]; then
@@ -97,17 +99,23 @@ EOF
9799
# Ensure the python package directory exists
98100
mkdir -p "$PYTHON_PACKAGE_DIR"
99101

100-
# Write output to both the specified output directory and the python package
101-
docker run --rm equaliq-python-codegen > "$OUTPUT_DIR/models.py"
102+
# Always write to the python package directory
102103
docker run --rm equaliq-python-codegen > "$PYTHON_PACKAGE_DIR/models.py"
103104

105+
# Write to additional output directory if specified
106+
if [[ -n "$OUTPUT_DIR" ]]; then
107+
mkdir -p "$OUTPUT_DIR"
108+
docker run --rm equaliq-python-codegen > "$OUTPUT_DIR/models.py"
109+
fi
110+
104111
# Clean up
105112
docker rmi equaliq-python-codegen >/dev/null 2>&1
106113
rm -rf "$TEMP_DIR"
107114

108-
echo "✅ Python models generated in:"
109-
echo " - $OUTPUT_DIR/models.py"
110-
echo " - $PYTHON_PACKAGE_DIR/models.py (Python package)"
115+
echo "✅ Python models generated in $PYTHON_PACKAGE_DIR/ package"
116+
if [[ -n "$OUTPUT_DIR" ]]; then
117+
echo " - Additional output written to $OUTPUT_DIR/models.py"
118+
fi
111119
fi
112120

113121
# Generate TypeScript types with a dedicated container build
@@ -185,26 +193,30 @@ EOF
185193
# Ensure the typescript package directory exists
186194
mkdir -p "$TYPESCRIPT_PACKAGE_DIR"
187195

188-
# Create output directory and typescript package directory
189-
mkdir -p "$OUTPUT_DIR"
190-
mkdir -p "$TYPESCRIPT_PACKAGE_DIR"
191-
192-
# Get the models.ts file
193-
docker run --rm equaliq-ts-codegen cat /app/models.ts > "$OUTPUT_DIR/models.ts"
196+
# Always write to the typescript package directory
194197
docker run --rm equaliq-ts-codegen cat /app/models.ts > "$TYPESCRIPT_PACKAGE_DIR/models.ts"
195-
196-
# Get the index.ts file
197-
docker run --rm equaliq-ts-codegen cat /app/index.ts > "$OUTPUT_DIR/index.ts"
198198
docker run --rm equaliq-ts-codegen cat /app/index.ts > "$TYPESCRIPT_PACKAGE_DIR/index.ts"
199199

200+
# Write to additional output directory if specified
201+
if [[ -n "$OUTPUT_DIR" ]]; then
202+
mkdir -p "$OUTPUT_DIR"
203+
docker run --rm equaliq-ts-codegen cat /app/models.ts > "$OUTPUT_DIR/models.ts"
204+
docker run --rm equaliq-ts-codegen cat /app/index.ts > "$OUTPUT_DIR/index.ts"
205+
fi
206+
200207
# Clean up
201208
docker rmi equaliq-ts-codegen >/dev/null 2>&1
202209
rm -rf "$TEMP_DIR"
203210

204-
echo "✅ TypeScript types generated in:"
205-
echo " - $OUTPUT_DIR/models.ts and $OUTPUT_DIR/index.ts"
206-
echo " - $TYPESCRIPT_PACKAGE_DIR/ (TypeScript package)"
211+
echo "✅ TypeScript types generated in $TYPESCRIPT_PACKAGE_DIR/ package"
212+
if [[ -n "$OUTPUT_DIR" ]]; then
213+
echo " - Additional output written to $OUTPUT_DIR/"
214+
fi
207215
echo " - All schema types are automatically exported as top-level types"
208216
fi
209217

210-
echo "Done! Generated files are in $OUTPUT_DIR"
218+
if [[ -n "$OUTPUT_DIR" ]]; then
219+
echo "Done! Generated files are in $OUTPUT_DIR"
220+
else
221+
echo "Done! Generated files are in python/ and typescript/ packages"
222+
fi

python/api_model/types/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: api.json
3-
# timestamp: 2025-04-06T08:20:31+00:00
3+
# timestamp: 2025-04-06T09:43:17+00:00
44

55
from __future__ import annotations
66

types/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
-147 Bytes
Binary file not shown.
-8.39 KB
Binary file not shown.

types/index.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

types/models.py

Lines changed: 0 additions & 195 deletions
This file was deleted.

0 commit comments

Comments
 (0)