|
58 | 58 | # |
59 | 59 | # Output log: generate-client.log (overwritten on each run) |
60 | 60 | # |
61 | | -# Prerequisites: Node.js/npm, Java 25, Maven, Perl |
| 61 | +# Prerequisites: Java 25, Maven, Perl (Node.js/npm optional — JAR fallback used if absent) |
62 | 62 | # |
63 | 63 |
|
64 | 64 | set -euo pipefail |
@@ -92,24 +92,16 @@ LOG_FILE="$SCRIPT_DIR/generate-client.log" |
92 | 92 | # Log everything to file and stdout |
93 | 93 | exec > >(tee "$LOG_FILE") 2>&1 |
94 | 94 |
|
95 | | -# Initialize nvm if available |
96 | | -NVM_DIR="$HOME/.nvm" |
97 | | -if [ -s "$NVM_DIR/nvm.sh" ]; then |
98 | | - . "$NVM_DIR/nvm.sh" |
99 | | -fi |
100 | | - |
101 | | -# Ensure openapi-generator-cli is available |
102 | | -if ! command -v openapi-generator-cli &> /dev/null; then |
103 | | - echo "openapi-generator-cli not found. Installing via npm..." |
104 | | - |
105 | | - if ! command -v npm &> /dev/null; then |
106 | | - echo "Error: npm is not installed. Please install Node.js/npm first." |
107 | | - exit 1 |
108 | | - fi |
| 95 | +OPENAPI_GENERATOR_VERSION="7.20.0" |
| 96 | +GENERATOR_JAR="$SCRIPT_DIR/.cache/openapi-generator-cli-${OPENAPI_GENERATOR_VERSION}.jar" |
109 | 97 |
|
110 | | - npm install -g @openapitools/openapi-generator-cli |
111 | | - echo "openapi-generator-cli installed successfully." |
| 98 | +if [ ! -f "$GENERATOR_JAR" ]; then |
| 99 | + echo "Downloading openapi-generator-cli ${OPENAPI_GENERATOR_VERSION}..." |
| 100 | + mkdir -p "$SCRIPT_DIR/.cache" |
| 101 | + curl -fSL -o "$GENERATOR_JAR" \ |
| 102 | + "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${OPENAPI_GENERATOR_VERSION}/openapi-generator-cli-${OPENAPI_GENERATOR_VERSION}.jar" |
112 | 103 | fi |
| 104 | +openapi-generator-cli() { java -jar "$GENERATOR_JAR" "$@"; } |
113 | 105 |
|
114 | 106 | generate() { |
115 | 107 | local edition="$1" |
|
0 commit comments