mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-04 13:44:00 +01:00
b55a28f755
Refactor the remaining logic from gulp. Part of the browser build script refactor effort. Webpack is now responsible for performing most of the operations previously done by gulp. This includes: - Setting browser specific class - Building the manifest file The `package.json` is modified to include browser specific commands for `build`, `build:prod`, `build:watch` and `dist`. # Manifests Manifests now uses the `copy-webpack-plugin` `transform` feature. The logic is located in `apps/browser/webpack/manifest.js`. It reads a template, which supports some basic operations primarily overriding with browser specific fields using `__browser__`. The `manifest.json` for both regular and mv3 builds are identical to our existing manifests except: - `applications` renamed to `browser_specific_settings`. - `permissions` sorted alphabetically. # Safari build Safari requires additional packaging commands. This is implemented as a powershell script due to the cross-platform nature, and since we generally require powershell in our distribution pipelines. An alternative would be to write it in bash, but bash is less powerful and would require some additional commands like `jq`. Another alternative is to write it using js, but that would require additional dependencies.
113 lines
3.6 KiB
PowerShell
Executable File
113 lines
3.6 KiB
PowerShell
Executable File
#!/usr/bin/env pwsh
|
|
|
|
####
|
|
# Builds the safari appex.
|
|
####
|
|
|
|
$buildDir = Join-Path $PSScriptRoot "../build"
|
|
$distDir = Join-Path $PSScriptRoot "../dist"
|
|
|
|
Write-Output $PSScriptRoot
|
|
|
|
if (-not (Test-Path $buildDir)) {
|
|
Write-Output "No build directory found. Exiting..."
|
|
exit
|
|
}
|
|
|
|
# Create dist directory if it doesn't exist
|
|
if (-not (Test-Path $distDir)) {
|
|
New-Item -ItemType Directory -Path $distDir
|
|
}
|
|
|
|
$subBuildPaths = @("mas", "masdev", "dmg")
|
|
$safariSrc = Join-Path $PSScriptRoot "../src/safari"
|
|
$safariDistPath = Join-Path -Path $distDir -ChildPath "Safari"
|
|
|
|
if (-not (Test-Path $safariDistPath)) {
|
|
New-Item -ItemType Directory -Path $safariDistPath
|
|
}
|
|
|
|
# Delete old safari dists
|
|
Remove-Item -LiteralPath $safariDistPath -Force -Recurse
|
|
|
|
foreach ($subBuildPath in $subBuildPaths) {
|
|
$safariBuildPath = Join-Path -Path $safariDistPath -ChildPath $subBuildPath
|
|
$builtAppexPath = Join-Path -Path $safariBuildPath -ChildPath "build/Release/safari.appex"
|
|
$builtAppexFrameworkPath = Join-Path -Path $safariBuildPath -ChildPath "build/Release/safari.appex/Contents/Frameworks/"
|
|
$entitlementsPath = Join-Path -Path $safariSrc -ChildPath "safari/safari.entitlements"
|
|
|
|
switch ($subBuildPath) {
|
|
"mas" {
|
|
$codesignArgs = @(
|
|
"--verbose",
|
|
"--force",
|
|
"--sign",
|
|
'"3rd Party Mac Developer Application: Bitwarden Inc"',
|
|
"--entitlements",
|
|
$entitlementsPath
|
|
)
|
|
}
|
|
"masdev" {
|
|
$codesignArgs = @(
|
|
"--verbose",
|
|
"--force",
|
|
"--sign",
|
|
"E7C9978F6FBCE0553429185C405E61F5380BE8EB",
|
|
"--entitlements",
|
|
$entitlementsPath
|
|
)
|
|
}
|
|
"dmg" {
|
|
$codesignArgs = @(
|
|
"--verbose",
|
|
"--force",
|
|
"-o",
|
|
"runtime",
|
|
"--sign",
|
|
'"Developer ID Application: 8bit Solutions LLC"',
|
|
"--entitlements",
|
|
$entitlementsPath
|
|
)
|
|
}
|
|
}
|
|
|
|
# Copy safari src
|
|
Copy-Item -Path $safariSrc -Destination $safariBuildPath -Recurse
|
|
|
|
# Copy build
|
|
$target = Join-Path -Path $safariBuildPath -ChildPath "safari/app"
|
|
Copy-Item -Path $buildDir -Destination $target -Recurse
|
|
|
|
# Update versions
|
|
$jsonFilePath = Join-Path $buildDir "manifest.json"
|
|
$jsonContent = Get-Content -Path $jsonFilePath -Raw
|
|
$jsonObject = $jsonContent | ConvertFrom-Json
|
|
|
|
$infoFile = Join-Path -Path $safariBuildPath -ChildPath "safari/Info.plist"
|
|
(Get-Content $infoFile).Replace('0.0.1', $jsonObject.version).Replace('0.0.2', $jsonObject.version) | Set-Content $infoFile
|
|
|
|
$projectFile = Join-Path -Path $safariBuildPath -ChildPath "desktop.xcodeproj/project.pbxproj"
|
|
(Get-Content $projectFile).Replace('../../../build', "../safari/app") | Set-Content $projectFile
|
|
|
|
# Build using xcode
|
|
$xcodeBuildArgs = @(
|
|
"-project",
|
|
(Join-Path $safariBuildPath "desktop.xcodeproj"),
|
|
"-alltargets",
|
|
"-configuration",
|
|
"Release"
|
|
)
|
|
$proc = Start-Process "xcodebuild" -ArgumentList $xcodeBuildArgs -NoNewWindow -PassThru
|
|
$proc.WaitForExit()
|
|
|
|
# Codesign
|
|
$libs = Get-ChildItem -Path $builtAppexFrameworkPath -Filter "*.dylib"
|
|
foreach ($lib in $libs) {
|
|
$proc = Start-Process "codesign" -ArgumentList ($codesignArgs + $lib.FullName) -NoNewWindow -PassThru
|
|
$proc.WaitForExit()
|
|
}
|
|
|
|
$proc = Start-Process "codesign" -ArgumentList ($codesignArgs + $builtAppexPath) -NoNewWindow -PassThru
|
|
$proc.WaitForExit()
|
|
}
|