From 6ddd5cbb0adc33fb26d771a143e8ecde9ad9233a Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Tue, 5 Nov 2024 15:27:22 +0100 Subject: [PATCH 1/2] fixed sdk local generation for linux --- scripts/generate-nestjs-sdk.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/generate-nestjs-sdk.js b/scripts/generate-nestjs-sdk.js index fdfcb63268..db232c286c 100644 --- a/scripts/generate-nestjs-sdk.js +++ b/scripts/generate-nestjs-sdk.js @@ -15,7 +15,8 @@ execSync( console.log("Generating the new sdk..."); const generationOutput = execSync( - 'docker run --rm -v "%cd%:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true', + // 'docker run --rm -v "%cd%:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true', + 'docker run --rm --add-host host.docker.internal:host-gateway -v "./node_modules:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true', { encoding: "utf-8" }, ); console.log(generationOutput); From 0d897af3afca6a829e51f59afed9c57a8b570b4e Mon Sep 17 00:00:00 2001 From: martintrajanovski Date: Wed, 6 Nov 2024 10:58:43 +0100 Subject: [PATCH 2/2] detect the OS and use the right current directory path --- scripts/generate-nestjs-sdk.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/generate-nestjs-sdk.js b/scripts/generate-nestjs-sdk.js index db232c286c..b27e689f8a 100644 --- a/scripts/generate-nestjs-sdk.js +++ b/scripts/generate-nestjs-sdk.js @@ -5,6 +5,19 @@ */ const execSync = require("child_process").execSync; +const os = require("os"); + +function isWindows() { + return os.platform() === "win32"; +} + +function getCurrentDirectory() { + if (isWindows()) { + return "%cd%"; + } + + return "$(pwd)"; +} // NOTE: First do some cleanup before starting the generation console.log("Cleanup old files..."); @@ -15,8 +28,7 @@ execSync( console.log("Generating the new sdk..."); const generationOutput = execSync( - // 'docker run --rm -v "%cd%:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true', - 'docker run --rm --add-host host.docker.internal:host-gateway -v "./node_modules:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true', + `docker run --rm --add-host host.docker.internal:host-gateway -v "${getCurrentDirectory()}:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true`, { encoding: "utf-8" }, ); console.log(generationOutput);