@echo off

cd /d %~dp0

rem _build.bat 偐傜 call 偡傞応崌廳暋偡傞偺偱僐儊儞僩傾僂僩
rem call C:\opengionV8\uap\bin\init.bat

set CLASSPATH=./readFile.jar;./closure-compiler-v20210808.jar;%CLASSPATH%;

set SRCDIR=%~dp0src\script
set OUTDIR=%~dp0jsp

rem ==========================================================================
rem
rem Node.js 偺 tsc 合菽迋艁Ats抬操(TypeScript)傪丄狠蔬操偡傞丅
rem
rem 尰忬丄ts 仺 js 抬操偼丄SRCDIR忋偺 ts 抬操傪丄SRCDIR忋偵丄js 抬操傪偟偰嶌惉偟傑偡丅
rem 屻懕張棟偱丄js抬操傪埑弅偟傑偡丅
rem

for /F "tokens=1,2 delims= " %%i in ( 'java org.opengion.tools.ReadFile %SRCDIR% %OUTDIR% .ts .js' ) do (
	@echo %%i
	call tsc -t ES5 %%i 2>>log2.txt
)

rem ==========================================================================
rem https://github.com/google/closure-compiler
rem https://mvnrepository.com/artifact/com.google.javascript/closure-compiler

rem ReadFile 偱丄backup彍奜丄.js 偺傒丄擔晅偑怴偟偄応崌偺傒張棟傪峴偆
rem 弌椡愭偵抬操偑偁偭偰丄啦呀垒踢偑摨偠(弌椡愭偑怴偟偄)偐丄徊睫偑摨偠側傜張棟偟側偄丅
for /F "tokens=1,2 delims= " %%i in ( 'java org.opengion.tools.ReadFile %SRCDIR% %OUTDIR% .js' ) do (
	@echo %%i %%j
	java -jar closure-compiler-v20210808.jar --js %%i --js_output_file %%j 2>>log2.txt
)

rem ==========================================================================
rem https://github.com/clean-css/clean-css-cli
rem
rem Node.js 忋偱幚峴偝傟傞 CSS 埑弅
rem $ npm install clean-css-cli -g

rem /*! 偱巒傑傞僐儊儞僩偼偦偺傑傑徚偝傟偢偵巆傞 */
rem breaks:afterComment=on 偱丄忋婰僐儊儞僩偺屻傠偵夵峴傪擖傟傞丅

for /F "tokens=1,2 delims= " %%i in ( 'java org.opengion.tools.ReadFile %SRCDIR% %OUTDIR% .css' ) do (
	@echo %%i %%j
	call cleancss %%i -o %%j -f 'breaks:afterComment=on' 2>>log2.txt
)

