mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Windows installer v2.0
This commit is contained in:
parent
17c1bb7344
commit
fabaa416ce
34 changed files with 143 additions and 1106 deletions
|
@ -1,8 +1,9 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<variables>
|
||||
<version>1.2</version>
|
||||
<version>2.0</version>
|
||||
<author>GlenDC</author>
|
||||
<copyright>CodeCombat.com © 2013-2014</copyright>
|
||||
<github_url>https://github.com/codecombat/codecombat.git</github_url>
|
||||
<github_ssh>git@github.com:codecombat/codecombat.git</github_ssh>
|
||||
<database_backup>http://23.21.59.137/dump.tar.gz</database_backup>
|
||||
</variables>
|
|
@ -11,7 +11,6 @@
|
|||
<nodejs>http://nodejs.org/dist/v0.10.25/x64/node-v0.10.25-x64.msi</nodejs>
|
||||
<ruby>http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353-x64.exe?direct</ruby>
|
||||
<python>http://s3.amazonaws.com/CodeCombatLargeFiles/python-64.msi</python>
|
||||
<winsdk>http://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/winsdk_web.exe</winsdk>
|
||||
<vs12redist>http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe</vs12redist>
|
||||
</b64>
|
||||
<general>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<mongodb>Setting up a MongoDB database for you...</mongodb>
|
||||
<database>Downloading the last version of the CodeCombat database...</database>
|
||||
<script>Preparing the automatic startup script for you...</script>
|
||||
<close>Don't close!</close>
|
||||
</npm>
|
||||
<error>
|
||||
<path>Dieser Pfad existiert bereits. Willst du ihn wirklich überschreiben?</path>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<mongodb>Setting up a MongoDB database for you...</mongodb>
|
||||
<db>Downloading the last version of the CodeCombat database...</db>
|
||||
<script>Preparing the automatic startup script for you...</script>
|
||||
<close>Don't close!</close>
|
||||
</npm>
|
||||
<error>
|
||||
<path>That path already exists, are you sure you want to overwrite it?</path>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<mongodb>Setting up a MongoDB database for you...</mongodb>
|
||||
<db>Downloading the last version of the CodeCombat database...</db>
|
||||
<script>Preparing the automatic startup script for you...</script>
|
||||
<close>Don't close!</close>
|
||||
</npm>
|
||||
<error>
|
||||
<path>That path already exists, are you sure you want to overwrite it?</path>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<mongodb>Setting up a MongoDB database for you...</mongodb>
|
||||
<database>Downloading the last version of the CodeCombat database...</database>
|
||||
<script>Preparing the automatic startup script for you...</script>
|
||||
<close>Niet sluiten!</close>
|
||||
</npm>
|
||||
<error>
|
||||
<path>Dat pad bestaat al, ben je zeker dat je het wil overschrijven?</path>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<mongodb>正在为你设置 MongoDB 数据库...</mongodb>
|
||||
<db>正在下载 CodeCombat 数据库的最新版本...</db>
|
||||
<script>Preparing the automatic startup script for you...</script>
|
||||
<close>Don't close!</close>
|
||||
</npm>
|
||||
<error>
|
||||
<path>这个路径已经存在, 你想要覆盖它吗?</path>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<mongodb>Setting up a MongoDB database for you...</mongodb>
|
||||
<db>Downloading the last version of the CodeCombat database...</db>
|
||||
<script>Preparing the automatic startup script for you...</script>
|
||||
<close>Don't close!</close>
|
||||
</npm>
|
||||
<error>
|
||||
<path>That path already exists, are you sure you want to overwrite it?</path>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<mongodb>Setting up a MongoDB database for you...</mongodb>
|
||||
<db>Downloading the last version of the CodeCombat database...</db>
|
||||
<script>Preparing the automatic startup script for you...</script>
|
||||
<close>Don't close!</close>
|
||||
</npm>
|
||||
<error>
|
||||
<path>That path already exists, are you sure you want to overwrite it?</path>
|
||||
|
|
4
scripts/windows/coco-dev-setup/batch/scripts/configuration_cmd.bat
Executable file
4
scripts/windows/coco-dev-setup/batch/scripts/configuration_cmd.bat
Executable file
|
@ -0,0 +1,4 @@
|
|||
Color 0A
|
||||
mode con: cols=79 lines=55
|
||||
|
||||
TITLE CodeCombat.com - Development Environment Installation
|
|
@ -1 +1 @@
|
|||
call get_text !language_id! %1 %2 %3 %4 %5
|
||||
call get_text %language_id% %1 %2 %3 %4 %5
|
|
@ -99,13 +99,13 @@ goto:eof
|
|||
|
||||
:git_checkout
|
||||
md "%repository_path%"
|
||||
set "repository_path=%repository_path%\coco"
|
||||
set "repository_path=%repository_path%"
|
||||
|
||||
call print_dashed_seperator
|
||||
set "git_app_path=%git_bash_path%\bin\git.exe"
|
||||
|
||||
call get_config github_url
|
||||
"%git_app_path%" clone "!github_url!" "%repository_path%"
|
||||
"%git_app_path%" clone "!github_url!" "%repository_path%\coco"
|
||||
|
||||
goto:exit_git_setup
|
||||
goto:eof
|
||||
|
|
7
scripts/windows/coco-dev-setup/batch/scripts/nab_automatic_script.bat
Executable file
7
scripts/windows/coco-dev-setup/batch/scripts/nab_automatic_script.bat
Executable file
|
@ -0,0 +1,7 @@
|
|||
call print_dashed_seperator
|
||||
call get_local_text npm_script npm script
|
||||
echo %npm_script%
|
||||
|
||||
echo start cmd.exe cmd /c "TITLE CodeCombat.com - nodemon server & call nodemon -w server -w server_config.js">%~1\SCOCODE.bat
|
||||
echo start cmd.exe cmd /c "TITLE CodeCombat.com - brunch - live compiler & call brunch w">>%~1\SCOCODE.bat
|
||||
echo TITLE CodeCombat.com - mongodb database & mongod --setParameter textSearchEnabled=true --dbpath %~2>>%~1\SCOCODE.bat
|
7
scripts/windows/coco-dev-setup/batch/scripts/nab_install_bower.bat
Executable file
7
scripts/windows/coco-dev-setup/batch/scripts/nab_install_bower.bat
Executable file
|
@ -0,0 +1,7 @@
|
|||
call print_dashed_seperator
|
||||
call get_local_text npm_binstall npm binstall
|
||||
echo %npm_binstall%
|
||||
|
||||
cd /D %~1
|
||||
start /wait cmd /c "echo %npm_binstall% & bower cache clean & bower install"
|
||||
cd /D %work_directory%
|
35
scripts/windows/coco-dev-setup/batch/scripts/nab_install_mongodb.bat
Executable file
35
scripts/windows/coco-dev-setup/batch/scripts/nab_install_mongodb.bat
Executable file
|
@ -0,0 +1,35 @@
|
|||
call print_dashed_seperator
|
||||
call get_local_text npm_mongodb npm mongodb
|
||||
echo %npm_mongodb%
|
||||
|
||||
if exist %~1 (
|
||||
rmdir /s /q %~1
|
||||
)
|
||||
|
||||
md %~1
|
||||
|
||||
call print_dashed_seperator
|
||||
call get_local_text npm_db npm db
|
||||
echo %npm_db%
|
||||
|
||||
call get_config database_backup
|
||||
|
||||
call get_local_text npm_close npm close
|
||||
|
||||
cd /D %~1
|
||||
|
||||
start cmd /c "TITLE MongoDB - %npm_close% & mongod --setParameter textSearchEnabled=true --dbpath %~1"
|
||||
|
||||
%work_directory%\%curl_app% -k %database_backup% -o dump.tar.gz
|
||||
|
||||
start /wait cmd /c "%work_directory%\%zu_app% e dump.tar.gz && del dump.tar.gz && %work_directory%\%zu_app% x dump.tar && del dump.tar"
|
||||
|
||||
start /wait cmd /c "mongorestore dump"
|
||||
|
||||
rmdir /s /q dump
|
||||
|
||||
call %work_directory%\print_dashed_seperator
|
||||
|
||||
taskkill /F /fi "IMAGENAME eq mongod.exe"
|
||||
|
||||
cd /D %work_directory%
|
6
scripts/windows/coco-dev-setup/batch/scripts/nab_install_npm.bat
Executable file
6
scripts/windows/coco-dev-setup/batch/scripts/nab_install_npm.bat
Executable file
|
@ -0,0 +1,6 @@
|
|||
call get_local_text npm_install npm install
|
||||
echo %npm_install%
|
||||
|
||||
cd /D %~1
|
||||
start /wait cmd /c "echo %npm_install% & npm install -g bower brunch nodemon sendwithus"
|
||||
cd /D %work_directory%
|
7
scripts/windows/coco-dev-setup/batch/scripts/nab_install_npm_all.bat
Executable file
7
scripts/windows/coco-dev-setup/batch/scripts/nab_install_npm_all.bat
Executable file
|
@ -0,0 +1,7 @@
|
|||
call print_dashed_seperator
|
||||
call get_local_text npm_npm npm npm
|
||||
echo %npm_npm%
|
||||
|
||||
cd /D %~1
|
||||
start /wait cmd /c "echo %npm_npm% & npm install"
|
||||
cd /D %work_directory%
|
7
scripts/windows/coco-dev-setup/batch/scripts/nab_install_sass.bat
Executable file
7
scripts/windows/coco-dev-setup/batch/scripts/nab_install_sass.bat
Executable file
|
@ -0,0 +1,7 @@
|
|||
call print_dashed_seperator
|
||||
call get_local_text npm_sass npm sass
|
||||
echo %npm_sass%
|
||||
|
||||
cd /D %~1
|
||||
start /wait cmd /c "echo %npm_sass% & gem install sass"
|
||||
cd /D %work_directory%
|
|
@ -5,85 +5,20 @@ set work_directory=%CD%
|
|||
|
||||
set "curl_app=..\utilities\curl.exe"
|
||||
set "zu_app=..\utilities\7za.exe"
|
||||
set "keystuff=..\utilities\keystuff.exe"
|
||||
|
||||
set "coco_root=!repository_path!\coco"
|
||||
set coco_root=%repository_path%\coco
|
||||
set coco_db=%repository_path%\cocodb
|
||||
|
||||
goto:automatic_script
|
||||
call nab_install_npm %coco_root%
|
||||
|
||||
call get_local_text npm-install
|
||||
echo !npm_install!
|
||||
call nab_install_bower %coco_root%
|
||||
|
||||
cd !coco_root!
|
||||
start /wait cmd /c "echo !npm_install! & npm install -g bower brunch nodemon sendwithus"
|
||||
cd !work_directory!
|
||||
call nab_install_sass %coco_root%
|
||||
|
||||
call print_dashed_seperator
|
||||
call get_local_text npm-binstall
|
||||
echo !npm_binstall!
|
||||
call nab_install_npm_all %coco_root%
|
||||
|
||||
cd "!coco_root!"
|
||||
start /wait cmd /c "echo !npm_binstall! & bower install"
|
||||
cd "!work_directory!"
|
||||
call nab_install_mongodb %coco_db%
|
||||
|
||||
call print_dashed_seperator
|
||||
call get_local_text npm-sass
|
||||
echo !npm_sass!
|
||||
call nab_automatic_script.bat %coco_root% %coco_db%
|
||||
|
||||
cd "!coco_root!"
|
||||
start /wait cmd /c "echo !npm_sass! & gem install sass"
|
||||
cd "!work_directory!"
|
||||
|
||||
call print_dashed_seperator
|
||||
call get_local_text npm-npm
|
||||
echo !npm_npm!
|
||||
|
||||
cd "!coco_root!"
|
||||
start /wait cmd /c "echo !npm_npm! & npm install"
|
||||
cd "!work_directory!"
|
||||
|
||||
:: --- MONGODB
|
||||
|
||||
:mongodb
|
||||
call print_dashed_seperator
|
||||
call get_local_text npm-mongodb
|
||||
echo !npm_mongodb!
|
||||
|
||||
set "mdb_directory=!repository_path!\cocodb"
|
||||
|
||||
if exist mdb_directory (
|
||||
rmdir /s /q "!mdb_directory!"
|
||||
)
|
||||
|
||||
md !mdb_directory!
|
||||
|
||||
call print_dashed_seperator
|
||||
call get_local_text npm-db
|
||||
echo !npm_db!
|
||||
|
||||
call get_config database_backup
|
||||
|
||||
cd !mdb_directory!
|
||||
|
||||
start cmd /c "%work_directory%\%keystuff% Alt-Tab && mongod --setParameter textSearchEnabled=true --dbpath !mdb_directory!"
|
||||
|
||||
%curl_app% -k !database_backup! -o dump.tar.gz
|
||||
|
||||
start /wait cmd /c "%work_directory%\%keystuff% Alt-Tab && %zu_app% e dump.tar.gz && del dump.tar.gz && %zu_app% x dump.tar && del dump.tar"
|
||||
|
||||
start /wait cmd /c "mongorestore dump"
|
||||
|
||||
rmdir /s /q db
|
||||
|
||||
:: --- AUTOMATIC SCRIPT
|
||||
|
||||
::automatic_script
|
||||
call print_dashed_seperator
|
||||
call get_local_text npm-script
|
||||
echo !npm_script!
|
||||
|
||||
:: --- END
|
||||
|
||||
call print_dashed_seperator
|
||||
|
||||
pause
|
||||
call print_dashed_seperator
|
|
@ -1,8 +1,7 @@
|
|||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
Color 0A
|
||||
mode con: cols=79 lines=55
|
||||
call configuration_cmd
|
||||
|
||||
call print_header
|
||||
call print_dashed_seperator
|
||||
|
@ -24,44 +23,6 @@ call get_language
|
|||
|
||||
call download_and_install_applications
|
||||
|
||||
call github_setup
|
||||
|
||||
:: This will be available in v2.0
|
||||
::call npm_and_brunch_setup
|
||||
|
||||
call print_finished_header
|
||||
call print_dashed_seperator
|
||||
|
||||
call get_local_text end_succesfull end succesfull
|
||||
call get_local_text end_thankyou end thankyou
|
||||
echo %end_succesfull%
|
||||
echo %end_thankyou%
|
||||
|
||||
call print_dashed_seperator
|
||||
|
||||
call get_local_text start_s1 start s1
|
||||
call get_local_text start_s2 start s2
|
||||
call get_local_text start_s3 start s3
|
||||
call get_local_text start_s4 start s4
|
||||
call get_local_text start_s5 start s5
|
||||
call get_local_text start_s6 start s6
|
||||
|
||||
echo !start_s1!
|
||||
echo !start_s2!
|
||||
echo.
|
||||
echo !start_s3! '!repository_path!\coco\SCOCODE.bat'
|
||||
echo !start_s4!
|
||||
echo !start_s5!
|
||||
echo.
|
||||
echo !start_s6!
|
||||
|
||||
call print_dashed_seperator
|
||||
|
||||
call get_local_text end_readme end readme
|
||||
call ask_question "!end_readme!"
|
||||
|
||||
if "%result%"=="true" (
|
||||
call open_readme
|
||||
)
|
||||
start cmd /c "setup_p2.bat"
|
||||
|
||||
endlocal
|
47
scripts/windows/coco-dev-setup/batch/scripts/setup_p2.bat
Executable file
47
scripts/windows/coco-dev-setup/batch/scripts/setup_p2.bat
Executable file
|
@ -0,0 +1,47 @@
|
|||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
call configuration_cmd
|
||||
|
||||
call github_setup
|
||||
|
||||
call npm_and_brunch_setup
|
||||
|
||||
call print_finished_header
|
||||
call print_dashed_seperator
|
||||
|
||||
call get_local_text end_succesfull end succesfull
|
||||
call get_local_text end_thankyou end thankyou
|
||||
echo %end_succesfull%
|
||||
echo %end_thankyou%
|
||||
|
||||
call print_dashed_seperator
|
||||
|
||||
call get_local_text start_s1 start s1
|
||||
call get_local_text start_s2 start s2
|
||||
call get_local_text start_s3 start s3
|
||||
call get_local_text start_s4 start s4
|
||||
call get_local_text start_s5 start s5
|
||||
call get_local_text start_s6 start s6
|
||||
|
||||
echo !start_s1!
|
||||
echo !start_s2!
|
||||
echo.
|
||||
echo !start_s3! '!repository_path!\coco\SCOCODE.bat'
|
||||
echo !start_s4!
|
||||
echo !start_s5!
|
||||
echo.
|
||||
echo !start_s6!
|
||||
|
||||
call print_dashed_seperator
|
||||
|
||||
call get_local_text end_readme end readme
|
||||
call ask_question "!end_readme!"
|
||||
|
||||
if "%result%"=="true" (
|
||||
call open_readme
|
||||
)
|
||||
|
||||
exit
|
||||
|
||||
endlocal
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<variables>
|
||||
<version>1.0</version>
|
||||
<author>GlenDC</author>
|
||||
<copyright>CodeCombat.com © 2013-2014</copyright>
|
||||
</variables>
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<variables>
|
||||
<general>
|
||||
<b32>
|
||||
<nodejs>http://nodejs.org/dist/v0.10.25/node-v0.10.25-x86.msi</nodejs>
|
||||
<ruby>http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353.exe?direct</ruby>
|
||||
<python>http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi</python>
|
||||
</b32>
|
||||
<b64>
|
||||
<nodejs>http://nodejs.org/dist/v0.10.25/x64/node-v0.10.25-x64.msi</nodejs>
|
||||
<ruby>http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353-x64.exe?direct</ruby>
|
||||
<python>http://www.python.org/ftp/python/2.7.6/python-2.7.6.amd64.msi</python>
|
||||
</b64>
|
||||
<gitbash>https://msysgit.googlecode.com/files/Git-1.8.5.2-preview20131230.exe</gitbash>
|
||||
</general>
|
||||
<win7>
|
||||
<b32>mongodb=http://fastdl.mongodb.org/win32/mongodb-win32-i386-2.5.4.zip</b32>
|
||||
<b64>mongodb=http://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.5.4.zip</b64>
|
||||
</win7>
|
||||
<vista>
|
||||
<b32>mongodb=http://fastdl.mongodb.org/win32/mongodb-win32-i386-2.5.4.zip</b32>
|
||||
<b64>mongodb=http://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2.5.4.zip</b64>
|
||||
</vista>
|
||||
</variables>
|
|
@ -1,53 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<variables>
|
||||
<global>
|
||||
<native>English</native>
|
||||
<bye>Bye Bye!</bye>
|
||||
</global>
|
||||
<install>
|
||||
<begin>Installation has begun, this can take a while... Please stay tuned...</begin>
|
||||
<close>Don't close any windows please, unless specified explicitly.</close>
|
||||
</install>
|
||||
<dai>
|
||||
<title>[DOWNLOADING AND INSTALLING 3RD PARTY SOFTWARE]</title>
|
||||
<downloading>downloading:</downloading>
|
||||
<installing>installing:</installing>
|
||||
<cancel>Download and Installation cancelled...</cancel>
|
||||
<software>Software has been installed...</software>
|
||||
<devenv>Installation of the Developers Environment is complete!</devenv>
|
||||
<stop>Installation has been stopped...</stop>
|
||||
<unpacking>unpacking and moving:</unpacking>
|
||||
<bower>Installing bower, brunch, nodemon and sendwithus...</bower>
|
||||
</dai>
|
||||
<git>
|
||||
<stored>CodeCombat is safely stored on a git repository.</stored>
|
||||
<clapp>Therefore you need a git command-line application (Git-bash).</clapp>
|
||||
<examples>Examples: git-bash, CygWin, ...</examples>
|
||||
<question>Do you already have git-bash?</question>
|
||||
<path>Enter the path to where you installed Git-bash</path>
|
||||
<checkout>Checking out the Git Repository...</checkout>
|
||||
<username>Please enter your github username:</username>
|
||||
</git>
|
||||
<nodejs>
|
||||
<question>Do you already have the latest version of node-js installed?</question>
|
||||
<path>Please enter the full path of the location you installed nodejs to:</path>
|
||||
</nodejs>
|
||||
<ruby>
|
||||
<question>Do you already have the latest version of ruby installed?</question>
|
||||
</ruby>
|
||||
<mongodb>
|
||||
<question>Do you already have the latest version of mongo-db installed?</question>
|
||||
<path>Enter the path where you would like to install MongoDB:</path>
|
||||
</mongodb>
|
||||
<python>
|
||||
<question>Do you already have the latest version of python installed?</question>
|
||||
</python>
|
||||
<error>
|
||||
<xp>Sadly we can't support Windows XP... Please upgrade your OS!</xp>
|
||||
<os>Machine OS cannot be determined...</os>
|
||||
<osreport>Report your OS to the developers @ CodeCombat.com...</osreport>
|
||||
<nocleaning>... Cleaning up has been disabled... Terminating Script!</nocleaning>
|
||||
<git_app_path>The path to your git application is incorrect, please try again...</git_app_path>
|
||||
<invalid_path>The path you entered is invalid, please try again...</invalid_path>
|
||||
</error>
|
||||
</variables>
|
|
@ -1,3 +0,0 @@
|
|||
powershell .\get_var.ps1 config.coco %1 > var.tmp
|
||||
set /p %1= < var.tmp
|
||||
del /q var.tmp
|
|
@ -1,4 +0,0 @@
|
|||
@ECHO off
|
||||
powershell .\get_var.ps1 downloads.coco %2 %3 %4 %5 %6 > var.tmp
|
||||
set /p %1= < var.tmp
|
||||
del /q var.tmp
|
|
@ -1,4 +0,0 @@
|
|||
@ECHO off
|
||||
powershell .\get_var.ps1 %1.coco %3 %4 %5 %6 %7 > var.tmp
|
||||
set /p %2= < var.tmp
|
||||
del /q var.tmp
|
|
@ -1,17 +0,0 @@
|
|||
$xml_file = [xml](get-content $args[0])
|
||||
if($args.count -eq 2)
|
||||
{
|
||||
$xml_file.variables.($args[1])
|
||||
}
|
||||
elseif($args.count -eq 3)
|
||||
{
|
||||
$xml_file.variables.($args[1]).($args[2])
|
||||
}
|
||||
elseif($args.count -eq 4)
|
||||
{
|
||||
$xml_file.variables.($args[1]).($args[2]).($args[3])
|
||||
}
|
||||
elseif($args.count -eq 5)
|
||||
{
|
||||
$xml_file.variables.($args[1]).($args[2]).($args[3]).($args[4])
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
@echo off
|
||||
powershell "& "%*"
|
|
@ -1,533 +0,0 @@
|
|||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
Color 0A
|
||||
|
||||
mode con: cols=78 lines=60
|
||||
|
||||
:: Global Variables
|
||||
set "temp-dir=C:\Coco-Temp"
|
||||
set install-log=%temp-dir%\coco-dev-install-log.txt
|
||||
|
||||
:: set correct curl app
|
||||
IF EXIST "%PROGRAMFILES(X86)%" (
|
||||
(set "curl-app=utilities\curl\64bit\curl.exe")
|
||||
) ELSE (
|
||||
set "curl-app=utilities\curl\32bit\curl.exe"
|
||||
)
|
||||
|
||||
set "ZU-app=utilities\7za.exe"
|
||||
|
||||
:: BUGS:
|
||||
:: + DEBUG ALL STEPS UNTILL NOW DONE
|
||||
|
||||
|
||||
:: TODO:
|
||||
:: + Write code to install vs if it's not yet installed on users pc
|
||||
|
||||
:: + Configuraton and installation checklist:
|
||||
:: 1) cd codecombat
|
||||
:: 2) npm install -g bower brunch nodemon sendwithus
|
||||
:: 3) bower install
|
||||
:: 4) gem install sass
|
||||
:: 5) npm install
|
||||
:: 6) brunch -w
|
||||
:: Extra... @ Fail run npm install
|
||||
|
||||
:: + Copy the automated dev batch file to root folder
|
||||
:: => Let user define mongo-db directory
|
||||
:: + Start the dev environment
|
||||
|
||||
:: Create The Temporary Directory
|
||||
IF EXIST %temp-dir% rmdir %temp-dir% /s /q
|
||||
mkdir %temp-dir%
|
||||
|
||||
:: Create Log File
|
||||
copy /y nul %install-log% > nul
|
||||
|
||||
call:parse_aa_and_draw "config\header"
|
||||
call:draw_dss
|
||||
|
||||
call:parse_file_new "config\config" cnfg n
|
||||
|
||||
call:log "Welcome to the automated Installation of the CodeCombat Dev. Environment!"
|
||||
call:log_sse "v%%cnfg[1]%% authored by %%cnfg[2]%% and published by %%cnfg[3]%%."
|
||||
|
||||
:: Language Agreement Stuff
|
||||
|
||||
call:log "In order to continue the installation of the developers environment"
|
||||
call:log "you will have to read and agree with the following license:
|
||||
call:draw_dss
|
||||
echo.
|
||||
call:parse_aa_and_draw "license.txt"
|
||||
echo.
|
||||
call:draw_dss
|
||||
call:strict_user_yn_question "Have you read the license and do you agree with it?"
|
||||
|
||||
if "%res%"=="false" (
|
||||
call:log "Sorry to hear that, have a good day..."
|
||||
call:log_sse "Installation and Setup of the CodeCombat environment is cancelled."
|
||||
GOTO:END
|
||||
)
|
||||
|
||||
:: Tips
|
||||
call:log "Before we start the installation, here are some tips:"
|
||||
echo.
|
||||
|
||||
call:parse_aa_and_draw "config\tips"
|
||||
|
||||
call:draw_ss
|
||||
|
||||
:: Read Language Index
|
||||
call:parse_file_new "localisation\languages" lang lang_c
|
||||
|
||||
:: Read Download URLs
|
||||
call:parse_file_new "config\downloads" downloads n
|
||||
call:parse_file_new "config\downloads_32" downloads_32 n
|
||||
call:parse_file_new "config\downloads_64" downloads_64 n
|
||||
call:parse_file_new "config\downloads_vista_32" downloads_vista_32 n
|
||||
call:parse_file_new "config\downloads_vista_64" downloads_vista_64 n
|
||||
call:parse_file_new "config\downloads_7_32" downloads_7_32 n
|
||||
call:parse_file_new "config\downloads_7_64" downloads_7_64 n
|
||||
|
||||
:: Parse all Localisation Files
|
||||
for /L %%i in (1,1,%lang_c%) do (
|
||||
call:parse_file "localisation\%%lang[%%i]%%" languages languages_c
|
||||
)
|
||||
|
||||
set /A "wc = %languages_c% / %lang_c%"
|
||||
|
||||
:: Start install with language question (Localisation)
|
||||
call:log "Which language do you prefer?"
|
||||
|
||||
set /A c=0
|
||||
for /L %%i in (1,%wc%,%languages_c%) do (
|
||||
set /A "n = %%i - 1"
|
||||
call:log " [%%c%%] %%languages[%%i]%%"
|
||||
set /A c+=1
|
||||
)
|
||||
|
||||
set "lang_id=-1"
|
||||
call:user_enter_language_id
|
||||
goto:user_pick_language
|
||||
|
||||
:user_enter_language_id
|
||||
set /p lang_id= "Enter the language ID and press <ENTER>: "
|
||||
goto:eof
|
||||
|
||||
:user_pick_language
|
||||
set res=false
|
||||
if %lang_id% LSS 0 set res=true
|
||||
if %lang_id% GEQ %lang_c% set res=true
|
||||
if "%res%"=="true" (
|
||||
call:log "Invalid id! Please enter a correct id from the numbers listed above..."
|
||||
call:draw_dss
|
||||
call:user_enter_language_id
|
||||
goto:user_pick_language
|
||||
)
|
||||
|
||||
call:get_lw word 0
|
||||
call:log_ds "You choose '%word%', from now on all feedback will be logged in it."
|
||||
|
||||
call:log_lw 1
|
||||
call:log_lw_sse 2
|
||||
|
||||
:: downloads for all version...
|
||||
|
||||
:: [TODO] The choice between Cygwin && Git ?! Is => HAVE EXTERNAL GIT APPLICATION LIST!!!
|
||||
|
||||
call:log_lw_sse 3
|
||||
|
||||
call:log_lw 6
|
||||
call:log_lw 7
|
||||
call:log_lw 8
|
||||
call:install_software_o "git" "%%downloads[1]%%" exe 9
|
||||
call:draw_dss
|
||||
call:get_lw word 11
|
||||
|
||||
:: [TODO] Add downloads for windows visual studio ?!
|
||||
|
||||
call:user_set_git_path
|
||||
|
||||
:user_set_git_path_fail
|
||||
if not exist "%git_exe_path%" (
|
||||
call:log_lw 27
|
||||
call:draw_dss
|
||||
call:user_set_git_path
|
||||
)
|
||||
:: architecture specific downloads...
|
||||
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
|
||||
goto:eof
|
||||
|
||||
:user_set_git_path
|
||||
set /p git_exe_path="%word%: "
|
||||
call:user_set_git_path_fail
|
||||
goto:eof
|
||||
|
||||
:go_to_platform
|
||||
call:log_ds "Windows %~1 detected..."
|
||||
GOTO %~2
|
||||
goto:eof
|
||||
|
||||
:64BIT
|
||||
call:log_ds "64-bit computer detected..."
|
||||
|
||||
call:install_software_o "node-js" "%%downloads_64[1]%%" msi 12
|
||||
call:draw_dss
|
||||
|
||||
call:get_path_from_user 41 42
|
||||
set "node_js_path=%user_tmp_path%"
|
||||
Call:draw_dss
|
||||
|
||||
call:install_software_o "ruby" "%%downloads_64[2]%%" exe 13
|
||||
call:draw_dss
|
||||
call:install_software_o "python" "%%downloads_64[3]%%" msi 26
|
||||
|
||||
:: Some installations require specific windows versions
|
||||
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
|
||||
if "%version%" == "5.2" ( call:go_to_platform "XP" ver_XP_64 )
|
||||
if "%version%" == "6.0" ( call:go_to_platform "Vista" ver_Vista_64 )
|
||||
if "%version%" == "6.1" ( call:go_to_platform "7" ver_Win7_8_64 )
|
||||
if "%version%" == "6.2" ( call:go_to_platform "8.0" ver_Win7_8_64 )
|
||||
if "%version%" == "6.3" ( call:go_to_platform "8.1" ver_Win7_8_64 )
|
||||
GOTO warn_and_exit
|
||||
GOTO END
|
||||
|
||||
:32BIT
|
||||
call:log_ds "32-bit computer detected..."
|
||||
|
||||
call:install_software_o "node-js" "%%downloads_32[1]%%" msi 12
|
||||
call:draw_dss
|
||||
|
||||
call:get_path_from_user 41 42
|
||||
set "node_js_path=%user_tmp_path%"
|
||||
Call:draw_dss
|
||||
|
||||
call:install_software_o "ruby" "%%downloads_32[2]%%" exe 13
|
||||
call:draw_dss
|
||||
call:install_software_o "python" "%%downloads_32[3]%%" msi 26
|
||||
|
||||
:: Some installations require specific windows versions
|
||||
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
|
||||
if "%version%" == "5.2" ( call:go_to_platform "XP" ver_XP_32 )
|
||||
if "%version%" == "6.0" ( call:go_to_platform "Vista" ver_Vista_32 )
|
||||
if "%version%" == "6.1" ( call:go_to_platform "7" ver_Win7_8_32 )
|
||||
if "%version%" == "6.2" ( call:go_to_platform "8.0" ver_Win7_8_32 )
|
||||
if "%version%" == "6.3" ( call:go_to_platform "8.1" ver_Win7_8_32 )
|
||||
GOTO warn_and_exit
|
||||
GOTO END
|
||||
|
||||
:ver_Win7_8_32
|
||||
call:install_packed_software_o "mongo-db" "%%downloads_7_32[1]%%" 25 14
|
||||
set "mong-db-path = %packed_software_path%"
|
||||
goto git_rep_checkout
|
||||
|
||||
:ver_Vista_32
|
||||
call:install_packed_software_o "mongo-db" "%%downloads_vista_32[1]%%" 25 14
|
||||
set "mong-db-path = %packed_software_path%"
|
||||
goto git_rep_checkout
|
||||
|
||||
:ver_XP_32
|
||||
call:log_lw_ds 15
|
||||
goto END
|
||||
|
||||
:ver_Win7_8_64
|
||||
call:install_packed_software_o "mongo-db" "%%downloads_7_64[1]%%" 25 14
|
||||
set "mong-db-path = %packed_software_path%"
|
||||
goto git_rep_checkout
|
||||
|
||||
:ver_Vista_64
|
||||
call:install_packed_software_o "mongo-db" "%%downloads_vista_64[1]%%" 25 14
|
||||
set "mong-db-path = %packed_software_path%"
|
||||
goto git_rep_checkout
|
||||
|
||||
:ver_XP_64
|
||||
call:log_lw_ds 15
|
||||
goto END
|
||||
|
||||
:git_rep_checkout
|
||||
call:log_lw_ss 16
|
||||
call:log_lw_sse 17
|
||||
|
||||
set "PATH=%PATH%;%git_exe_path%\bin;%git_exe_path%\cmd" /M
|
||||
|
||||
call:log_lw 36
|
||||
call:log_lw 37
|
||||
call:log_lw 38
|
||||
|
||||
call:draw_dss
|
||||
|
||||
call:get_lw word 39
|
||||
set /p git_username="%word% "
|
||||
|
||||
call:draw_dss
|
||||
|
||||
call:get_empty_path_from_user 32
|
||||
set "git_repository_path=%user_tmp_path%"
|
||||
|
||||
goto:git_rep_checkout_auto
|
||||
|
||||
:git_rep_checkout_auto
|
||||
git clone https://github.com/%git_username%/codecombat.git "%git_repository_path%"
|
||||
goto:git_repo_configuration
|
||||
|
||||
:git_repo_configuration
|
||||
call:log_lw_ss 35
|
||||
call:log_lw_sse 36
|
||||
|
||||
SET "PATH=%PATH%;%node_js_path%" /M
|
||||
setx -m git "%git_exe_path%\bin"
|
||||
|
||||
call:log_lw 40
|
||||
start cmd /k "npm install -g bower brunch nodemon sendwithus & exit"
|
||||
|
||||
goto report_ok
|
||||
|
||||
:report_ok
|
||||
call:log_lw 18
|
||||
call:log_lw_sse 19
|
||||
|
||||
:: Open README file
|
||||
call:open_readme
|
||||
|
||||
goto clean_up
|
||||
|
||||
:open_readme
|
||||
call:open_txt_file "config/info"
|
||||
goto:eof
|
||||
|
||||
:warn_and_exit
|
||||
call:log_lw_ss 20
|
||||
call:log_lw_sse 21
|
||||
goto error_report
|
||||
|
||||
:error_report
|
||||
call:log_lw_ds 22
|
||||
goto END
|
||||
|
||||
:clean_up
|
||||
call:log_lw_sse 23
|
||||
rmdir %temp-dir% /s /q
|
||||
goto END
|
||||
|
||||
:: ============================ INSTALL SOFTWARE FUNCTIONS ======================
|
||||
|
||||
:download_software
|
||||
call:get_lw word 4
|
||||
call:log "%word% %~1..."
|
||||
%curl-app% -sS -k %~2 -o %temp-dir%\%~1-setup.%~3
|
||||
goto:eof
|
||||
|
||||
:install_software
|
||||
call:download_software %~1 %~2 %~3
|
||||
call:get_lw word 5
|
||||
call:log "%word% %~1..."
|
||||
START /WAIT %temp-dir%\%~1-setup.%~3
|
||||
goto:eof
|
||||
|
||||
:install_software_o
|
||||
call:get_lw word %~4
|
||||
call:user_yn_question "%word%"
|
||||
if "%res%"=="true" (
|
||||
call:install_software %~1 %~2 %~3
|
||||
) else (
|
||||
call:log_lw 10
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:install_packed_software
|
||||
call:download_software %~1 %~2 zip
|
||||
|
||||
call:draw_dss
|
||||
|
||||
call:get_lw word %~3
|
||||
|
||||
set /p packed_software_path="%word% "
|
||||
|
||||
:: remove chosen directory of user if it already exists (to prevent a window from popping up)
|
||||
IF EXIST %packed_software_path% rmdir %packed_software_path% /s /q
|
||||
|
||||
%ZU-app% x %temp-dir%\%~1-setup.zip -o%packed_software_path%
|
||||
|
||||
call:draw_dss
|
||||
|
||||
for /f "delims=" %%a in ('dir "%packed_software_path%\" /on /ad /b') do @set temp_dir=%%a
|
||||
for /f "delims=" %%a in ('dir "%packed_software_path%\%temp_dir%\" /on /ad /b') do (
|
||||
xcopy %packed_software_path%\%temp_dir% %packed_software_path%\ /S /E
|
||||
)
|
||||
|
||||
call:draw_dss
|
||||
rmdir %packed_software_path%\%temp_dir%\ /s /q
|
||||
goto:eof
|
||||
|
||||
:user_yn_question
|
||||
set /p result="%~1 [Y/N]: "
|
||||
call:draw_dss
|
||||
set "res=false"
|
||||
if "%result%"=="N" (set "res=true")
|
||||
if "%result%"=="n" (set "res=true")
|
||||
goto:eof
|
||||
|
||||
:strict_user_yn_question
|
||||
set /p result="%~1 [Y/N]: "
|
||||
call:draw_dss
|
||||
set "res=unset"
|
||||
if "%result%"=="N" (set "res=false")
|
||||
if "%result%"=="n" (set "res=false")
|
||||
if "%result%"=="Y" (set "res=true")
|
||||
if "%result%"=="y" (set "res=true")
|
||||
|
||||
if "%res%"=="unset" (
|
||||
call:log "Please answer the question with either Y or N..."
|
||||
call:draw_dss
|
||||
call:strict_user_yn_question "%~1"
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:install_packed_software_o
|
||||
call:get_lw word %~4
|
||||
call:user_yn_question "%word%"
|
||||
if "%res%"=="true" (
|
||||
call:install_packed_software %~1 %~2 %~3
|
||||
) else (
|
||||
call:log_lw 10
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:: ===================== USER - INTERACTION - FUNCTIONS ========================
|
||||
|
||||
:get_path_from_user
|
||||
call:get_lw word %~1
|
||||
set /p user_tmp_path="%word% "
|
||||
if not exist "%user_tmp_path%" (
|
||||
call:log_lw 43
|
||||
call:draw_dss
|
||||
call:get_path_from_user %~1 %~2
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:get_empty_path_from_user
|
||||
call:get_lw word %~1
|
||||
set /p user_tmp_path="%word% "
|
||||
if exist "%user_tmp_path%" (
|
||||
call:log_lw 33
|
||||
call:draw_dss
|
||||
call:get_path_from_user %~1
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:: ============================== FUNCTIONS ====================================
|
||||
|
||||
:log
|
||||
echo %~1
|
||||
echo %~1 >> %install-log%
|
||||
goto:eof
|
||||
|
||||
:draw_ss
|
||||
echo.
|
||||
call:log "-----------------------------------------------------------------------------"
|
||||
echo.
|
||||
goto:eof
|
||||
|
||||
:draw_dss
|
||||
echo.
|
||||
call:log "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
||||
echo.
|
||||
goto:eof
|
||||
|
||||
:draw_seperator
|
||||
echo.
|
||||
echo + + + + + + + +
|
||||
echo.
|
||||
goto:eof
|
||||
|
||||
:log_ss
|
||||
call:draw_ss
|
||||
call:log "%~1"
|
||||
goto:eof
|
||||
|
||||
:log_sse
|
||||
call:log "%~1"
|
||||
call:draw_ss
|
||||
goto:eof
|
||||
|
||||
:log_ds
|
||||
call:log_ss "%~1"
|
||||
call:draw_ss
|
||||
goto:eof
|
||||
|
||||
:: ============================== IO FUNCTIONS ====================================
|
||||
|
||||
:open_txt_file
|
||||
start "" notepad.exe %~1
|
||||
goto:eof
|
||||
|
||||
:parse_aa_and_draw
|
||||
set "file=%~1"
|
||||
for /f "usebackq tokens=* delims=;" %%a in ("%file%") do (
|
||||
echo.%%a
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:parse_file
|
||||
set "file=%~1"
|
||||
for /F "usebackq delims=" %%a in ("%file%") do (
|
||||
set /A %~3+=1
|
||||
call set %~2[%%%~3%%]=%%a
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:parse_file_new
|
||||
set /A %~3=0
|
||||
call:parse_file %~1 %~2 %~3
|
||||
goto:eof
|
||||
|
||||
:: ============================== LOCALISATION FUNCTIONS ================
|
||||
|
||||
:get_lw
|
||||
call:get_lw_id %~1 %lang_id% %~2
|
||||
goto:eof
|
||||
|
||||
:get_lw_id
|
||||
set /A count = %~2 * %wc% + %~3 + 1
|
||||
set "%~1=!languages[%count%]!"
|
||||
goto:eof
|
||||
|
||||
:log_lw
|
||||
call:get_lw str %~1
|
||||
call:log "%str%"
|
||||
goto:eof
|
||||
|
||||
:log_lw_prfx
|
||||
call:get_lw str %~1
|
||||
call:log "%~2%str%"
|
||||
goto:eof
|
||||
|
||||
:log_lw_ss
|
||||
call:get_lw str %~1
|
||||
call:log_ss "%str%"
|
||||
goto:eof
|
||||
|
||||
:log_lw_ds
|
||||
call:get_lw str %~1
|
||||
call:log_ds "%str%"
|
||||
goto:eof
|
||||
|
||||
:log_lw_sse
|
||||
call:get_lw str %~1
|
||||
call:log_sse "%str%"
|
||||
goto:eof
|
||||
|
||||
:: ============================== WINDOWS FUNCTIONS ======================
|
||||
|
||||
:set_env_var
|
||||
setx -m %~1 %~2
|
||||
goto:eof
|
||||
|
||||
:: ============================== EOF ====================================
|
||||
|
||||
:END
|
||||
exit
|
||||
goto:eof
|
||||
|
||||
endlocal
|
|
@ -1,50 +0,0 @@
|
|||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
:: + Configuraton and installation checklist:
|
||||
:: 1) cd codecombat
|
||||
:: 2) npm install -g bower brunch nodemon sendwithus
|
||||
:: 3) bower install
|
||||
:: 4) gem install sass
|
||||
:: 5) npm install
|
||||
:: 6) brunch -w
|
||||
:: Extra... @ Fail run npm install
|
||||
|
||||
echo "Moving to your git repository..."
|
||||
C:
|
||||
cd C:\CodeCombat
|
||||
|
||||
PAUSE
|
||||
|
||||
SET "PATH=%PATH%;C:\Program Files\Nodejs" /M
|
||||
setx -m git "C:\Program Files (x86)\Git\bin"
|
||||
SET "PATH=%PATH%;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd" /M
|
||||
|
||||
PAUSE
|
||||
|
||||
echo "Installing bower, brunch, nodemon and sendwithus..."
|
||||
start cmd /k "npm install -g bower brunch nodemon sendwithus & exit"
|
||||
|
||||
PAUSE
|
||||
|
||||
echo "running npm install..."
|
||||
start cmd /k "npm install & exit"
|
||||
|
||||
PAUSE
|
||||
|
||||
echo "Activating bower install..."
|
||||
start cmd /k "bower install & PAUSE & exit"
|
||||
|
||||
PAUSE
|
||||
|
||||
echo "Installing sass via gem..."
|
||||
start cmd /k "install sass & PAUSE & exit"
|
||||
|
||||
PAUSE
|
||||
|
||||
echo "comping repository via brunch..."
|
||||
start cmd /k "brunch -w & exit"
|
||||
|
||||
PAUSE
|
||||
|
||||
endlocal
|
|
@ -1,146 +0,0 @@
|
|||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#define tstring std::wstring
|
||||
#define tcout std::wcout
|
||||
|
||||
static const tstring DEF_URL = L"http://www.google.com";
|
||||
|
||||
int ErrorReport(const tstring & str, int value = 0)
|
||||
{
|
||||
tcout << str.c_str();
|
||||
return value;
|
||||
}
|
||||
|
||||
void GetHashInfo(tstring id, std::vector<std::wstring> & info) {
|
||||
while(id.size() > 0)
|
||||
{
|
||||
size_t pos = id.find(L'-');
|
||||
|
||||
tstring substr =
|
||||
id.substr(0, pos == tstring::npos ? id.length() : pos);
|
||||
info.push_back(substr);
|
||||
|
||||
if(pos == tstring::npos) id = L"";
|
||||
else
|
||||
{
|
||||
++pos;
|
||||
id = id.substr(pos, id.length() - pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetArrayVariable(
|
||||
const tstring & name,
|
||||
int id,
|
||||
const tstring & line
|
||||
)
|
||||
{
|
||||
tcout << L"set \"";
|
||||
tcout << name;
|
||||
tcout << L"[" << id << "]";
|
||||
tcout << L"=" << line;
|
||||
tcout << L"\"" << std::endl;
|
||||
}
|
||||
|
||||
void FillArray(
|
||||
const std::vector<tstring> & info,
|
||||
const tstring & name,
|
||||
const tstring & id_array_name,
|
||||
const tstring & file,
|
||||
int & id
|
||||
)
|
||||
{
|
||||
if(info.size() == 0) return;
|
||||
|
||||
auto it = info.begin();
|
||||
size_t indention = 0;
|
||||
unsigned int nlc = 0;
|
||||
|
||||
std::wifstream infile(file.c_str(), std::ifstream::in);
|
||||
|
||||
if(!infile)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
tcout << file.c_str() << std::endl;
|
||||
tcout << strerror(errno) << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
tstring line;
|
||||
int counter = 1;
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
size_t cpos = line.find('[');
|
||||
if(cpos == tstring::npos)
|
||||
{
|
||||
cpos = line.find_first_not_of(L" \t\r\n");
|
||||
}
|
||||
if(nlc++ == 0 || cpos == indention)
|
||||
{
|
||||
indention = cpos;
|
||||
if(it == info.end())
|
||||
{
|
||||
size_t pos = line.find(L'=') + 1;
|
||||
SetArrayVariable(
|
||||
name, id,
|
||||
line.substr(pos, line.size() - pos)
|
||||
);
|
||||
SetArrayVariable(
|
||||
id_array_name, id++,
|
||||
line.substr(cpos, pos - 3)
|
||||
);
|
||||
++counter;
|
||||
}
|
||||
else if(line.find(*it) != tstring::npos)
|
||||
{
|
||||
++it;
|
||||
nlc = 0;
|
||||
}
|
||||
}
|
||||
else if(counter > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
infile.close();
|
||||
return;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if(argc == 1)
|
||||
return ErrorReport(L"Please specify a localisation file.");
|
||||
else if(argc == 2)
|
||||
return ErrorReport(L"Please specify the name of the array.");
|
||||
else if(argc == 3)
|
||||
return ErrorReport(L"Please specify the name of the name-array.");
|
||||
else if(argc == 4)
|
||||
return ErrorReport(L"Please specify the counter parameter.");
|
||||
else if(argc == 5)
|
||||
return ErrorReport(L"Please specify one or more categories you are looking for.");
|
||||
|
||||
tstring file, name, counter_name, id_array_name;
|
||||
file = argv[1];
|
||||
name = argv[2];
|
||||
id_array_name = argv[3];
|
||||
counter_name = argv[4];
|
||||
int id = 1;
|
||||
|
||||
for(int i = 5 ; i < argc ; ++i)
|
||||
{
|
||||
std::vector<tstring> information;
|
||||
GetHashInfo(argv[i], information);
|
||||
FillArray(information, name, id_array_name, file, id);
|
||||
}
|
||||
|
||||
tcout << L"set \"" << counter_name << L"=" << (id - 1) << L"\"";
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#define tstring std::wstring
|
||||
#define tcout std::wcout
|
||||
|
||||
int ErrorReport(const tstring & str, int value = 0)
|
||||
{
|
||||
tcout << str.c_str();
|
||||
return value;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if(argc == 1)
|
||||
return ErrorReport(L"Please specify a download URL.");
|
||||
if(argc == 2)
|
||||
return ErrorReport(L"Please specify a name for your variable.");
|
||||
|
||||
tstring url, name, extension;
|
||||
url = argv[1];
|
||||
name = argv[2];
|
||||
|
||||
if(url.find(L"exe") != tstring::npos) extension = L"exe";
|
||||
else if(url.find(L"msi") != tstring::npos) extension = L"msi";
|
||||
else if(url.find(L"zip") != tstring::npos) extension = L"zip";
|
||||
|
||||
tcout << L"set \"" << name << L"=";
|
||||
tcout << extension << L"\"";
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#define tstring std::wstring
|
||||
#define tcout std::wcout
|
||||
|
||||
static const tstring DEF_URL = L"http://www.google.com";
|
||||
|
||||
int ErrorReport(const tstring & str, int value = 0)
|
||||
{
|
||||
tcout << str.c_str();
|
||||
return value;
|
||||
}
|
||||
|
||||
void GetHashInfo(tstring id, std::vector<std::wstring> & info) {
|
||||
while(id.size() > 0)
|
||||
{
|
||||
size_t pos = id.find(L'-');
|
||||
|
||||
tstring substr =
|
||||
id.substr(0, pos == tstring::npos ? id.length() : pos);
|
||||
info.push_back(substr);
|
||||
|
||||
if(pos == tstring::npos) id = L"";
|
||||
else
|
||||
{
|
||||
++pos;
|
||||
id = id.substr(pos, id.length() - pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring GetText(const std::vector<tstring> & info, const tstring & file)
|
||||
{
|
||||
if(info.size() == 0) return L"Info Size is 0.";
|
||||
|
||||
auto it = info.begin();
|
||||
auto last = info.end() - 1;
|
||||
size_t indention = 0;
|
||||
unsigned int nlc = 0;
|
||||
|
||||
std::wifstream infile(file.c_str(), std::ifstream::in);
|
||||
|
||||
if(!infile)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
tcout << file.c_str() << std::endl;
|
||||
tcout << strerror(errno) << std::endl;
|
||||
#endif
|
||||
return L"File couldn't be opened.";
|
||||
}
|
||||
|
||||
tstring line;
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
size_t cpos = line.find('[');
|
||||
if(nlc++ == 0 || cpos == indention)
|
||||
{
|
||||
indention = cpos;
|
||||
if(line.find(*it) != tstring::npos)
|
||||
{
|
||||
if(it == last)
|
||||
{
|
||||
size_t pos = line.find(L'=') + 1;
|
||||
infile.close();
|
||||
return line.substr(pos, line.size() - pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
nlc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
infile.close();
|
||||
return L"Var couldn't be found.";
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if(argc == 1)
|
||||
return ErrorReport(L"Please specify a localisation file.");
|
||||
else if(argc == 2)
|
||||
return ErrorReport(L"Please specify the ID you are looking for.");
|
||||
|
||||
tstring file, hash;
|
||||
file = argv[1];
|
||||
hash = argv[2];
|
||||
|
||||
std::vector<tstring> information;
|
||||
GetHashInfo(hash, information);
|
||||
|
||||
size_t size = information.size();
|
||||
for(unsigned int i = 0 ; i < size ; ++i)
|
||||
{
|
||||
tcout << information[i];
|
||||
if(i != size - 1) tcout << L"_";
|
||||
}
|
||||
tcout << L"=" << GetText(information, file);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue