fork of hey-api/openapi-ts because I need some additional things

chore: format examples

Lubos b89d51dc edbc1cc3

+73 -26
+1 -1
examples/openapi-ts-next/openapi-ts.config.ts
··· 11 11 plugins: [ 12 12 { 13 13 name: '@hey-api/client-next', 14 - runtimeConfigPath: './src/hey-api.ts', 14 + runtimeConfigPath: '../hey-api', 15 15 }, 16 16 '@hey-api/sdk', 17 17 {
+1 -1
examples/openapi-ts-next/src/client/client.gen.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 + import { createClientConfig } from '../hey-api'; 3 4 import { 4 5 type ClientOptions, 5 6 type Config, 6 7 createClient, 7 8 createConfig, 8 9 } from './client'; 9 - import { createClientConfig } from './src/hey-api.ts'; 10 10 import type { ClientOptions as ClientOptions2 } from './types.gen'; 11 11 12 12 /**
+1 -2
examples/openapi-ts-pinia-colada/.eslintrc.cjs
··· 10 10 ], 11 11 parserOptions: { 12 12 ecmaVersion: 'latest' 13 - }, 14 - root: true 13 + } 15 14 }
+1 -2
examples/openapi-ts-tanstack-vue-query/.eslintrc.cjs
··· 10 10 ], 11 11 parserOptions: { 12 12 ecmaVersion: 'latest' 13 - }, 14 - root: true 13 + } 15 14 }
+69 -20
scripts/examples-generate.sh
··· 9 9 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 10 10 ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" 11 11 12 - echo "Generating client code for all examples..." 12 + echo "⏳ Generating client code for all examples..." 13 + # Find all examples with openapi-ts script and generate code in parallel 14 + # Concurrency control: adjust this number depending on CI machine resources 15 + CONCURRENCY=${CONCURRENCY:-4} 16 + tmpdir=$(mktemp -d) 17 + # Use a simple space-separated list of pids and per-pid files for metadata 18 + PIDS="" 19 + 20 + wait_for_slot() { 21 + # Wait until number of background jobs is less than CONCURRENCY 22 + while [ "$(jobs -rp | wc -l)" -ge "$CONCURRENCY" ]; do 23 + sleep 0.2 24 + done 25 + } 13 26 14 - # Find all examples with openapi-ts script and generate code 15 27 for dir in "$ROOT_DIR"/examples/*/; do 16 - example_name=$(basename "$dir") 17 28 package_json="$dir/package.json" 18 - 19 - # Skip if package.json doesn't exist 20 29 if [ ! -f "$package_json" ]; then 21 30 continue 22 31 fi 23 - 24 - # Check if the example has openapi-ts script 25 - if grep -q "\"openapi-ts\":" "$package_json"; then 26 - echo "" 27 - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" 28 - echo "📦 Generating: $example_name" 29 - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" 30 - 31 - # Run openapi-ts for this example 32 - (cd "$dir" && pnpm openapi-ts) 33 - 34 - echo "✅ Completed: $example_name" 32 + 33 + if ! grep -q "\"openapi-ts\":" "$package_json"; then 34 + continue 35 + fi 36 + 37 + example_name=$(basename "$dir") 38 + echo "📦 Scheduling: $example_name" 39 + 40 + wait_for_slot 41 + 42 + log="$tmpdir/${example_name}.log" 43 + ( 44 + echo "Generating: $example_name" 45 + set -e 46 + cd "$dir" 47 + echo "-> Running pnpm openapi-ts" 48 + pnpm openapi-ts 49 + 50 + # Format generated files in this example only to keep the step fast 51 + if command -v pnpm >/dev/null 2>&1 && pnpm -w -s --version >/dev/null 2>&1; then 52 + pnpm -s exec prettier --write "src/**/*.{ts,tsx,js,jsx,json,md}" || true 53 + pnpm -s exec eslint --fix "src/**/*.{ts,tsx,js,jsx,json,md}" || true 54 + else 55 + if [ -x "node_modules/.bin/prettier" ]; then 56 + ./node_modules/.bin/prettier --write "src/**/*.{ts,tsx,js,jsx,json,md}" || true 57 + fi 58 + if [ -x "node_modules/.bin/eslint" ]; then 59 + ./node_modules/.bin/eslint --fix "src/**/*.{ts,tsx,js,jsx,json,md}" || true 60 + fi 61 + fi 62 + 63 + echo "Completed: $example_name" 64 + ) >"$log" 2>&1 & 65 + 66 + pid=$! 67 + PIDS="$PIDS $pid" 68 + printf '%s' "$example_name" >"$tmpdir/$pid.name" 69 + printf '%s' "$log" >"$tmpdir/$pid.log" 70 + done 71 + 72 + failed=0 73 + for pid in $PIDS; do 74 + if wait "$pid"; then 75 + name=$(cat "$tmpdir/$pid.name" 2>/dev/null || echo "$pid") 76 + echo "✅ $name succeeded" 77 + else 78 + name=$(cat "$tmpdir/$pid.name" 2>/dev/null || echo "$pid") 79 + log=$(cat "$tmpdir/$pid.log" 2>/dev/null || echo "(no log)") 80 + echo "❌ $name failed — see log: $tmpdir/$pid.log" 81 + failed=1 35 82 fi 36 83 done 37 84 38 - echo "" 39 - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" 85 + if [ "$failed" -ne 0 ]; then 86 + echo "One or more examples failed to generate. Logs are in: $tmpdir" 87 + exit 1 88 + fi 89 + 40 90 echo "✨ All examples generated successfully!" 41 - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"