Skip to content

Commit

Permalink
Remove com.apple.quarantine flag, git, Xcode CLI tools requirement (#105
Browse files Browse the repository at this point in the history
)

* Reliably remove com.apple.quarantine in portable download

* Support spaces in PWD

* Fixed handling of ImageMagick for dir with spaces

* Remove git dependency from Purple, PATH and download

* Remove XCode CLI Tools requirement
  • Loading branch information
younglim authored Mar 15, 2023
1 parent b50cb74 commit 72267dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 41 deletions.
28 changes: 14 additions & 14 deletions scripts/hats_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ echo "hats Shell - Created By younglim - NO WARRANTY PROVIDED"
echo "================================================================"
echo ""

if [ ${PWD##*/} = "scripts" ]; then
CURR_FOLDERNAME=$(basename $PWD)
if [ $CURR_FOLDERNAME = "scripts" ]; then
cd ..
fi

if ! command -v python3 &> /dev/null
then
echo "Installing Xcode CLI Tools"
xcode-select --install
CURR_FOLDERNAME=$(basename $PWD)
fi

if [[ $(uname -m) == 'arm64' ]]; then
Expand All @@ -33,20 +29,24 @@ fi

if $(ls ImageMagick-*/bin/compare 1> /dev/null 2>&1) && [ -d purple-hats ]; then
echo "INFO: Set symbolic link to ImageMagick"
ln -sf "$(ls -d $PWD/ImageMagick-*)" "purple-hats/$(ls -d ImageMagick-*)"

if find ./purple-hats -name "ImageMagick*" -maxdepth 1 -type l -ls &> /dev/null; then
unlink ./purple-hats/ImageMagick* &>/dev/null
fi

export IMAGEMAGICK_FOLDERNAME=$(ls -d ImageMagick-*)
export PATH_TO_IMAGEMAGICK="$PWD/$IMAGEMAGICK_FOLDERNAME"
ln -sf "$PATH_TO_IMAGEMAGICK" "./purple-hats/$IMAGEMAGICK_FOLDERNAME"

echo "INFO: Set path to ImageMagick"
export PATH="$(ls -d $PWD/ImageMagick-*/bin):$PATH"
echo "INFO: Set path to ImageMagick binaries"
export PATH="$PATH_TO_IMAGEMAGICK/bin:$PATH"

fi

echo "INFO: Path to node: $PATH_TO_NODE"

echo "INFO: Removing com.apple.quarantine attributes for required binaries to run"
find ./**/ImageMagick*/bin -exec xattr -d com.apple.quarantine {} \;&>/dev/null
find ./**/ImageMagick*/lib/*.dylib -exec xattr -d com.apple.quarantine {} \;&>/dev/null
find ./**/ms-playwright/**/** -maxdepth 1 -name "*.app" -exec xattr -d com.apple.quarantine {} \;&>/dev/null
xattr -d com.apple.quarantine $PATH_TO_NODE/node &>/dev/null
xattr -rd com.apple.quarantine . &>/dev/null

export PUPPETEER_SKIP_DOWNLOAD='true'
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD='true'
Expand Down
3 changes: 0 additions & 3 deletions scripts/hats_shell_ps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ $env:Path = "$path_to_hats\node_modules\.bin;./node_modules/.bin;$env:Path";
echo "INFO: Set path to npm-global for this session"
$env:Path = "$path_to_hats\npm-global;$path_to_hats\npm-global\bin;$env:Path";

echo "INFO: Set path to git for this session"
$env:Path = "$path_to_hats\git\bin;$env:Path";

echo "INFO: Set path to Playwright cache for this session"
$env:PLAYWRIGHT_BROWSERS_PATH = "$path_to_hats\ms-playwright"

Expand Down
10 changes: 0 additions & 10 deletions scripts/install_purple_dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ if ((Split-Path -Path $pwd -Leaf) -eq "scripts") {
$ProgressPreferences = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'

# Install Git binaries
if (-Not (Test-Path git\git-cmd.exe)) {
Write-Output "Downloading Git"
Invoke-WebRequest -o ".\PortableGit.7z.exe" "https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/PortableGit-2.39.1-64-bit.7z.exe"

Write-Output "Unzip Git"
.\PortableGit.7z.exe -o ".\git" -y | Out-Null
Remove-Item -Force .\PortableGit.7z.exe
}

# Install NodeJS binaries
if (-Not (Test-Path nodejs-win\node.exe)) {
Write-Output "Downloading Node"
Expand Down
15 changes: 1 addition & 14 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,7 @@ export const getVersion = () => {
const loadJSON = path => JSON.parse(fs.readFileSync(new URL(path, import.meta.url)));
const versionNum = loadJSON('./package.json').version;

let branchName;

try {
branchName = execSync('git branch --show-current', { stdio: 'pipe' }).toString().trim();
} catch (error) {
silentLogger.warn(`Unable to fetch branch name: ${error.stderr.toString()}`);
}

let appVersion = versionNum;

if (branchName) {
appVersion += `-${branchName}`;
}
return appVersion;
return versionNum;
};

export const getHostnameFromRegex = url => {
Expand Down

0 comments on commit 72267dc

Please sign in to comment.