-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateAspNetFromCassandraDB.cmd
125 lines (106 loc) · 4.8 KB
/
CreateAspNetFromCassandraDB.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
rem
rem IMPORTANT: do not edit this script file in Visual Studio,
rem use Notepad++.
rem
@echo off
set RedBkgYelFgd=[101;93m
set BlkBkgGrnFgd=[92m
set BlkBkgYelFgd=[42m
set BluBkgWhtFgd=[44m
set BlkBkgRedFgd=[91m
set EndColor=[0m
[0m
if [%1]==[] goto :expl
if [%1]==[-?] goto :expl
if [%1]==[?] goto :expl
if [%1]==[-help] goto :expl
if [%1]==[help] goto :expl
call :CheckIfExists dotnet "Please install dotnet core from https://www.microsoft.com/net/download/windows#core"
if not [%errorlevel%]==[0] goto :oops
call :CheckIfExists npm "Please install npm from https://nodejs.org/en/download/"
if not [%errorlevel%]==[0] goto :oops
call :CheckIfExists nswag "Please install nswag with npm install nswag -g"
if not [%errorlevel%]==[0] goto :oops
set connectionStringOrLocalSettingsJsonFile=%1
set KeySpaceName=%2
set OutputDirectory=%~f3
rem set UpperKeySpaceName=%KeySpaceName%
set csproj=%OutputDirectory%\%KeySpaceName%.csproj
rem call :UpCase UpperKeySpaceName
set EntitiesOutputDirectory=%OutputDirectory%\Entities
set WebOutputDirectory=%OutputDirectory%\Web
set UnitTestOutputDirectory=%OutputDirectory%\UnitTest
set TestOutputDirectory=%OutputDirectory%\Test
set OAuthUrl=%4
set currentFolder=%cd%
set initialSwaggerFile=%OutputDirectory%\swaggerBase.json
set swaggerWithOpsFile=%OutputDirectory%\swagger.json
if not exist %OutputDirectory% md %OutputDirectory%
if not exist %EntitiesOutputDirectory% md %EntitiesOutputDirectory%
if not exist %WebOutputDirectory% md %WebOutputDirectory%
if not exist %UnitTestOutputDirectory% md %UnitTestOutputDirectory%
if not exist %TestOutputDirectory% md %TestOutputDirectory%
pushd .
echo .
echo %BlkBkgYelFgd% %currentFolder%\tools\CassandraDBtoCSharp.exe %connectionStringOrLocalSettingsJsonFile% %KeySpaceName% %OutputDirectory% %EndColor%
echo .
%currentFolder%\tools\CassandraDBtoCSharp.exe %connectionStringOrLocalSettingsJsonFile% %KeySpaceName% %OutputDirectory%
if not errorlevel==0 goto :oops
rem pause
rem pause
call npm install nswag -g
if not errorlevel==0 goto :oops
rem pause
cd "%OutputDirectory%"
dotnet clean
dotnet publish --self-contained --runtime win10-x64 --configuration "Release"
if not errorlevel==0 goto :oops
rem pause
echo .
echo %BlkBkgYelFgd% %currentFolder%\tools\GenerateTypes2SwaggerCall.exe %KeySpaceName% bin\x64\Release\netcoreapp2.0\win10-x64\publish\%KeySpaceName%.dll .\Types2Swagger.cmd %EndColor%
echo .
%currentFolder%\tools\GenerateTypes2SwaggerCall.exe %KeySpaceName% bin\x64\Release\netcoreapp2.0\win10-x64\publish\App.dll .\Types2Swagger.cmd
if not errorlevel==0 goto :oops
rem pause
call .\Types2Swagger.cmd
echo .
echo %BlkBkgYelFgd% %currentFolder%\tools\GenerateSwaggerStandardOperations.exe %KeySpaceName% %initialSwaggerFile% %OutputDirectory%\typeDescriptions.json %swaggerWithOpsFile% %OAuthUrl% %EndColor%
echo .
%currentFolder%\tools\GenerateSwaggerStandardOperations.exe %KeySpaceName% %initialSwaggerFile% %OutputDirectory%\typeDescriptions.json %swaggerWithOpsFile% %OAuthUrl%
if not errorlevel==0 goto :oops
rem pause
rem call nswag swagger2cscontroller /ControllerBaseClass:Controller /AspNetNamespace:Microsoft.AspNetCore.Mvc /Input:%KeySpaceName%Swagger.json /Output:controller\%KeySpaceName%Controller.cs /ClassName:%KeySpaceName%Controller /Namespace:%UpperKeySpaceName%.Controllers
echo .
echo %BlkBkgYelFgd% %currentFolder%\tools\CreateControllerFromSwaggerWithStandardOperations.exe %swaggerWithOpsFile% %connectionStringOrLocalSettingsJsonFile% 1 24 %csproj% %OutputDirectory%\typeDescriptions.json %EndColor%
echo .
%currentFolder%\tools\CreateControllerFromSwaggerWithStandardOperations.exe %swaggerWithOpsFile% %connectionStringOrLocalSettingsJsonFile% 1 24 %csproj% %OutputDirectory%\typeDescriptions.json
if not errorlevel==0 goto :oops
rem pause
goto :ScriptEnd
:expl
@echo off
echo %BluBkgWhtFgd% CreateAspNetFromCassandraDB.cmd CassandraConnectionString KeySpaceName OutputDirectory OAuthURL %EndColor%
echo %BluBkgWhtFgd% Example: %EndColor%
echo %BluBkgWhtFgd% CreateAspNetFromCassandraDB.cmd "Contact Points = localhost; Port = 9042" PetStore c:\temp\PetStore https://somesite.com/oauth/authorize %EndColor%
echo %EndColor%
goto :ScriptEnd
:CheckIfExists
echo %BlkBkgYelFgd% Checking whether %1 is installed... %EndColor%
where /Q %1 > null
rem Echo with Red background and Yellow foreground.
if not [%errorlevel%]==[0] echo %RedBkgYelFgd% %2 %EndColor%
goto :EOF
:UpCase
rem FOR %%i IN ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I" "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R" "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") DO CALL SET "%1=%%%1:%%~i%%"
GOTO:EOF
:EchoPause
echo %1
pause
GOTO:EOF
:oops
echo %BlkBkgRedFgd% .
echo .
echo Aborting...
echo .
echo . %EndColor%
:ScriptEnd