up
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled

This commit is contained in:
StellaOps Bot
2025-11-24 09:07:40 +02:00
parent 150b3730ef
commit e6119cbe91
59 changed files with 1827 additions and 204 deletions

View File

@@ -0,0 +1,36 @@
# Post-process Scaffold (SDKGEN-62-002)
These hooks are invoked via OpenAPI Generator's `--enable-post-process-file` option. They are deliberately minimal and deterministic:
- Normalise line endings to LF and strip trailing whitespace.
- Preserve file mode 0644.
- Inject a deterministic banner for supported languages (TS/JS/Go/Java/C#/Python/Ruby) when enabled (default on).
- Language-specific rewrites (auth/retry/pagination/telemetry) will be added as SDKGEN-62-002 progresses.
## Usage
Set the generator's post-process command to this script (example for Bash):
```bash
export STELLA_SDK_POSTPROCESS="$PWD/postprocess/postprocess.sh"
export JAVA_OPTS="${JAVA_OPTS} -Dorg.openapitools.codegen.utils.postProcessFile=$STELLA_SDK_POSTPROCESS"
```
Or pass via CLI where supported:
```bash
--global-property "postProcessFile=$PWD/postprocess/postprocess.sh"
```
## Determinism
- Uses only POSIX tools (`sed`, `perl`) available in build containers.
- Does not reorder content; only whitespace/line-ending normalization.
- Safe to run multiple times (idempotent).
## Configuration (optional)
- `STELLA_POSTPROCESS_ADD_BANNER` (default `1`): when enabled, injects `Generated by StellaOps SDK generator — do not edit.` at the top of supported source files, idempotently.
- Future flags (placeholders until implemented): `STELLA_POSTPROCESS_ENABLE_AUTH`, `STELLA_POSTPROCESS_ENABLE_RETRY`, `STELLA_POSTPROCESS_ENABLE_PAGINATION`, `STELLA_POSTPROCESS_ENABLE_TELEMETRY`.
## Next steps
- Add language-specific post steps (auth helper injection, retry/pagination utilities, telemetry headers) behind flags per language template.
- Wire into CI to enforce post-processed trees are clean.

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail
file="$1"
# Normalize line endings to LF and strip trailing whitespace deterministically
perl -0777 -pe 's/\r\n/\n/g; s/[ \t]+$//mg' "$file" > "$file.tmp"
perm=$(stat -c "%a" "$file" 2>/dev/null || echo 644)
mv "$file.tmp" "$file"
chmod "$perm" "$file"
# Optional banner injection for traceability (idempotent)
ADD_BANNER="${STELLA_POSTPROCESS_ADD_BANNER:-1}"
if [ "$ADD_BANNER" = "1" ]; then
ext="${file##*.}"
case "$ext" in
ts|js) prefix="//" ;;
go) prefix="//" ;;
java) prefix="//" ;;
cs) prefix="//" ;;
py) prefix="#" ;;
rb) prefix="#" ;;
*) prefix="" ;;
esac
if [ -n "$prefix" ]; then
banner="$prefix Generated by StellaOps SDK generator — do not edit."
first_line="$(head -n 1 "$file" || true)"
if [ "$first_line" != "$banner" ]; then
printf "%s\n" "$banner" > "$file.tmp"
cat "$file" >> "$file.tmp"
mv "$file.tmp" "$file"
chmod "$perm" "$file"
fi
fi
fi