@@ -19,35 +19,50 @@ function getCurrentDirectory() {
1919 return "$(pwd)" ;
2020}
2121
22- // NOTE: First do some cleanup before starting the generation
23- console . log ( "Cleanup old files..." ) ;
24- execSync (
25- "rm -rf node_modules/@scicatproject/scicat-sdk-ts && rm -rf @scicatproject/scicat-sdk-ts" ,
26- { encoding : "utf-8" } ,
27- ) ;
28-
29- console . log ( "Generating the new sdk..." ) ;
30- const generationOutput = execSync (
31- `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` ,
32- { encoding : "utf-8" } ,
33- ) ;
34- console . log ( generationOutput ) ;
35-
36- console . log ( "Installing dependencies and building the sdk..." ) ;
37- const installBuildOutput = execSync (
38- "cd @scicatproject/scicat-sdk-ts && npm install && npm run build" ,
39- { encoding : "utf-8" } ,
40- ) ;
41- console . log ( installBuildOutput ) ;
42-
43- console . log ( "Copying the build files in node_modules..." ) ;
44- const copyToNodeModulesOutput = execSync (
45- "cp -r @scicatproject/scicat-sdk-ts/dist node_modules/@scicatproject/scicat-sdk-ts" ,
46- { encoding : "utf-8" } ,
47- ) ;
48- console . log ( copyToNodeModulesOutput ) ;
49-
50- console . log ( "Final cleanup..." ) ;
51- execSync ( "rm -rf @scicatproject" , {
52- encoding : "utf-8" ,
53- } ) ;
22+ if ( isWindows ( ) ) {
23+
24+ // NOTE: First do some cleanup before starting the generation
25+ console . log ( "Cleanup old files..." ) ;
26+ execSync (
27+ "rm -rf node_modules/@scicatproject/scicat-sdk-ts && rm -rf @scicatproject/scicat-sdk-ts" ,
28+ { encoding : "utf-8" } ,
29+ ) ;
30+
31+ console . log ( "Generating the new sdk..." ) ;
32+ const generationOutput = execSync (
33+ `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` ,
34+ { encoding : "utf-8" } ,
35+ ) ;
36+ console . log ( generationOutput ) ;
37+
38+ console . log ( "Installing dependencies and building the sdk..." ) ;
39+ const installBuildOutput = execSync (
40+ "cd @scicatproject/scicat-sdk-ts && npm install && npm run build" ,
41+ { encoding : "utf-8" } ,
42+ ) ;
43+ console . log ( installBuildOutput ) ;
44+
45+ console . log ( "Copying the build files in node_modules..." ) ;
46+ const copyToNodeModulesOutput = execSync (
47+ "cp -r @scicatproject/scicat-sdk-ts/dist node_modules/@scicatproject/scicat-sdk-ts" ,
48+ { encoding : "utf-8" } ,
49+ ) ;
50+ console . log ( copyToNodeModulesOutput ) ;
51+
52+ console . log ( "Final cleanup..." ) ;
53+ execSync ( "rm -rf @scicatproject" , {
54+ encoding : "utf-8" ,
55+ } ) ;
56+
57+ console . log ( "Local SDK generation completed" ) ;
58+
59+ } else {
60+ console . log ( "Your environment is a linux/unix" ) ;
61+ console . log ( "Please run the following command on your terminal:" ) ;
62+ console . log ( "> sudo -E ./scripts/generate-nestjs-sdk.bash" ) ;
63+ console . log ( "" ) ;
64+ console . log ( "IMPORTANT: the script runs under sudo. You will be asked your password." ) ;
65+ console . log ( "" ) ;
66+
67+ }
68+
0 commit comments