77 lines
3.1 KiB
PowerShell
77 lines
3.1 KiB
PowerShell
# Script di creazione e compilazione versione per test in macchina
|
|
|
|
# Prerequisito: da administrator --> installare 7zip cmdlet (rif https://www.sans.org/blog/powershell-7-zip-module-versus-compress-archive-with-encryption/)
|
|
# Install-Module -Name 7Zip4Powershell
|
|
|
|
|
|
# Check parameters
|
|
Param (
|
|
[Parameter(Mandatory=$True)]
|
|
[ValidateNotNull()]
|
|
$npmInstall,
|
|
[Parameter(Mandatory=$True)]
|
|
[ValidateNotNull()]
|
|
$npmBuild,
|
|
[Parameter(Mandatory=$True)]
|
|
[ValidateNotNull()]
|
|
$version
|
|
)
|
|
|
|
# recupera timestamp x logging
|
|
function Get-TimeStamp
|
|
{
|
|
return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
|
|
}
|
|
# registra log!
|
|
function DoLog($txt2log)
|
|
{
|
|
Write-Output "$(Get-TimeStamp) $txt2log" | Out-File c:\tmp\Script.log -Append
|
|
}
|
|
|
|
Write-Output "-------------------------------- START script --------------------------------" | Out-File c:\tmp\Script.log
|
|
$StopWatch = New-Object System.Diagnostics.Stopwatch
|
|
$StopWatch.Start()
|
|
|
|
# mi sposto in wwwroot
|
|
cd wwwroot
|
|
# NPM install/build step
|
|
if($npmInstall -eq "y")
|
|
{
|
|
DoLog("START npm install")
|
|
npm install | Out-File c:\tmp\Script.log -Append
|
|
DoLog("END npm install")
|
|
}
|
|
|
|
if($npmBuild -eq "y")
|
|
{
|
|
DoLog("START file replace")
|
|
# replace seriate server dev (seriate.steamware.net) --> produzione (locahost)
|
|
((Get-Content -path index.html -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path index.html -NoNewline
|
|
((Get-Content -path config.development.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.development.json -NoNewline
|
|
((Get-Content -path config.production.json -Raw) -replace 'seriate.steamware.net','localhost') | Set-Content -Path config.production.json -NoNewline
|
|
|
|
# build pacchetti npm
|
|
DoLog("START npm run build ")
|
|
npm run build | Out-File c:\tmp\Script.log -Append
|
|
DoLog("END npm run build ")
|
|
}
|
|
|
|
# torno in folder base
|
|
cd ..
|
|
|
|
# copio wwwroot --> view
|
|
DoLog("START copy step")
|
|
robocopy C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\view /MIR /Z /LOG:C:\tmp\ViewMirror.log /XF *.babelrc .bowerrc .editorconfig bower.json compilerconfig.json* package*.json tsconfig.json webpack.config.js /XD C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot\node_modules C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\wwwroot\src
|
|
robocopy C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\ C:\Users\samuele\Desktop\ThermoActive\ /MIR /Z /LOG:C:\tmp\ThermoMirror.log /XD C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\wwwroot C:\Users\samuele\Documents\VisualStudio\cms_thermo_active\Thermo.Active\bin\Client_Debug
|
|
DoLog("END copy step")
|
|
|
|
|
|
# Compression step
|
|
DoLog("START ZIP step")
|
|
Compress-7Zip -Path C:\Users\samuele\Desktop\ThermoActive -ArchiveFileName "C:\Users\samuele\Desktop\ThermoActive_$version.zip" -Format Zip
|
|
DoLog("END ZIP step")
|
|
|
|
$StopWatch.Stop()
|
|
$StopWatch.Elapsed | Out-File c:\tmp\Script.log -Append
|
|
DoLog("-------------------------------- END script --------------------------------")
|