-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,69 @@ | ||
#!/bin/bash | ||
set -e -o pipefail | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
function cleanup { | ||
rm -rf build | ||
} | ||
REM Function for cleanup | ||
:cleanup | ||
rmdir /s /q build | ||
|
||
brew install gnu-sed | ||
REM Install gnu-sed using Homebrew for Windows | ||
choco install gnu-sed | ||
|
||
REM Install pkg globally using npm | ||
npm install -g pkg | ||
|
||
REM Install project dependencies using yarn | ||
yarn install | ||
|
||
REM Build project using yarn | ||
yarn build | ||
|
||
# Remove type from package.json files | ||
REM Remove "type" from package.json files | ||
gsed -i '/"type": "module",/{s///;h};${x;/./{x;q0};x;q1}' ./package.json | ||
|
||
# Create array of package.json files | ||
array=($(ls -d ./packages/*/package.json)) | ||
REM Create array of package.json files | ||
set "array=" | ||
for /f %%a in ('dir /b /s /ad ./packages/*/package.json') do ( | ||
set "array=!array! %%a" | ||
) | ||
|
||
# Delete package.json filepath where type module is not defined | ||
delete=(./packages/dom/package.json ./packages/sdk-utils/package.json) | ||
for del in ${delete[@]} | ||
do | ||
array=("${array[@]/$del}") | ||
done | ||
REM Delete package.json filepath where type module is not defined | ||
set "delete=./packages/dom/package.json ./packages/sdk-utils/package.json" | ||
for %%d in (%delete%) do ( | ||
set "array=!array:%%d=!" | ||
) | ||
|
||
# Remove type module from package.json where present | ||
for package in "${array[@]}" | ||
do | ||
if [ ! -z "$package" ] | ||
then | ||
gsed -i '/"type": "module",/{s///;h};${x;/./{x;q0};x;q1}' $package | ||
fi | ||
done | ||
REM Remove type module from package.json where present | ||
for %%p in (%array%) do ( | ||
if not "%%p" == "" ( | ||
gsed -i '/"type": "module",/{s///;h};${x;/./{x;q0};x;q1}' %%p | ||
) | ||
) | ||
|
||
echo "import { cli } from '@percy/cli';\ | ||
$(cat ./packages/cli/dist/percy.js)" > ./packages/cli/dist/percy.js | ||
REM Concatenate percy.js content with import statement | ||
echo import { cli } from '@percy/cli'; >> ./packages/cli/dist/percy.js | ||
type ./packages/cli/dist/percy.js >> ./packages/cli/dist/percy.js.tmp | ||
move /y ./packages/cli/dist/percy.js.tmp ./packages/cli/dist/percy.js | ||
|
||
REM Update NODE_ENV for executable in run.cjs | ||
gsed -i '/Update NODE_ENV for executable/{s//\nprocess.env.NODE_ENV = "executable";/;h};${x;/./{x;q0};x;q1}' ./packages/cli/bin/run.cjs | ||
|
||
# Convert ES6 code to cjs | ||
REM Convert ES6 code to cjs | ||
npm run build_cjs | ||
cp -R ./build/* packages/ | ||
xcopy /s /y /q build\* packages\ | ||
|
||
# Create executables | ||
REM Create executables using pkg | ||
pkg ./packages/cli/bin/run.js -d | ||
|
||
# Rename executables | ||
mv run-win.exe percy.exe && chmod +x percy.exe | ||
REM Rename executables | ||
ren run-win.exe percy.exe | ||
icacls percy.exe /grant:r Everyone:F | ||
|
||
REM Sign win exe | ||
echo %WINDOWS_CERT% | base64 -d > CodeSigning.p12 | ||
signtool.exe sign /fd SHA256 /f CodeSigning.p12 /p "%WINDOWS_CERT_KEY%" percy.exe | ||
|
||
REM Create zip file for uploading as assets | ||
powershell Compress-Archive -Path percy.exe -DestinationPath percy-win.zip | ||
|
||
cleanup | ||
REM Call cleanup function | ||
call :cleanup |