mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-07 17:05:33 +02:00
Refactor code formatting and fix paths
This commit is contained in:
parent
7f6da82ec4
commit
97d630b78f
13 changed files with 233 additions and 124 deletions
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -24,4 +24,3 @@ jobs:
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@zen-browser/surfer",
|
"name": "@zen-browser/surfer",
|
||||||
"version": "1.4.21",
|
"version": "1.4.22",
|
||||||
"description": "Simplifying building firefox forks!",
|
"description": "Simplifying building firefox forks!",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
|
@ -173,7 +173,7 @@ export const build = async (options: Options): Promise<void> => {
|
||||||
|
|
||||||
log.info('Starting build...')
|
log.info('Starting build...')
|
||||||
|
|
||||||
let exit = await genericBuild(prettyHost, options.ui);
|
let exit = await genericBuild(prettyHost, options.ui)
|
||||||
process.exit(exit ? 0 : 1);
|
process.exit(exit ? 0 : 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {
|
||||||
resolveAddonDownloadUrl,
|
resolveAddonDownloadUrl,
|
||||||
unpackAddon,
|
unpackAddon,
|
||||||
} from './addon'
|
} from './addon'
|
||||||
import { configPath } from '../../utils';
|
import { configPath } from '../../utils'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
|
|
||||||
export function shouldSetupFirefoxSource() {
|
export function shouldSetupFirefoxSource() {
|
||||||
|
@ -68,16 +68,27 @@ async function unpackFirefoxSource(name: string): Promise<void> {
|
||||||
log.info(`Unpacking ${resolve(MELON_TMP_DIR, name)} to ${ENGINE_DIR}`)
|
log.info(`Unpacking ${resolve(MELON_TMP_DIR, name)} to ${ENGINE_DIR}`)
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
log.info('Unpacking Firefox source on Windows (7z)')
|
log.info('Unpacking Firefox source on Windows (7z)')
|
||||||
await execa('7z', ['x', resolve(MELON_TMP_DIR, name), '-o' + resolve(MELON_TMP_DIR, name.replace('.tar.xz', '.tar'))]);
|
await execa('7z', [
|
||||||
|
'x',
|
||||||
|
resolve(MELON_TMP_DIR, name),
|
||||||
|
'-o' + resolve(MELON_TMP_DIR, name.replace('.tar.xz', '.tar')),
|
||||||
|
])
|
||||||
log.info('Unpacking Firefox source again without the .xz extension')
|
log.info('Unpacking Firefox source again without the .xz extension')
|
||||||
await execa('7z', ['x', resolve(MELON_TMP_DIR, name.replace('.tar.xz', '.tar')), '-o' + MELON_TMP_DIR]);
|
await execa('7z', [
|
||||||
const archiveDir = resolve(MELON_TMP_DIR, 'firefox-' + config.version.version);
|
'x',
|
||||||
|
resolve(MELON_TMP_DIR, name.replace('.tar.xz', '.tar')),
|
||||||
|
'-o' + MELON_TMP_DIR,
|
||||||
|
])
|
||||||
|
const archiveDir = resolve(
|
||||||
|
MELON_TMP_DIR,
|
||||||
|
'firefox-' + config.version.version
|
||||||
|
)
|
||||||
if (existsSync(ENGINE_DIR)) {
|
if (existsSync(ENGINE_DIR)) {
|
||||||
// remove the existing engine directory
|
// remove the existing engine directory
|
||||||
fs.removeSync(ENGINE_DIR);
|
fs.removeSync(ENGINE_DIR)
|
||||||
}
|
}
|
||||||
log.info('Moving Firefox source to engine directory');
|
log.info('Moving Firefox source to engine directory')
|
||||||
fs.moveSync(archiveDir, ENGINE_DIR);
|
fs.moveSync(archiveDir, ENGINE_DIR)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +102,7 @@ async function unpackFirefoxSource(name: string): Promise<void> {
|
||||||
ENGINE_DIR,
|
ENGINE_DIR,
|
||||||
].filter(Boolean) as string[],
|
].filter(Boolean) as string[],
|
||||||
{
|
{
|
||||||
shell: BASH_PATH
|
shell: BASH_PATH,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
log.info(`Unpacked Firefox source to ${ENGINE_DIR}`)
|
log.info(`Unpacked Firefox source to ${ENGINE_DIR}`)
|
||||||
|
|
|
@ -22,9 +22,9 @@ const machPath = resolve(ENGINE_DIR, 'mach')
|
||||||
async function getLocales() {
|
async function getLocales() {
|
||||||
// l10n/supported-languages is a list of locales divided by newlines
|
// l10n/supported-languages is a list of locales divided by newlines
|
||||||
// open the file and split it by newlines
|
// open the file and split it by newlines
|
||||||
const localesText = await readFile("l10n/supported-languages", "utf-8");
|
const localesText = await readFile('l10n/supported-languages', 'utf-8')
|
||||||
log.info(`Found locales:\n${localesText}`);
|
log.info(`Found locales:\n${localesText}`)
|
||||||
return localesText.split("\n");
|
return localesText.split('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
export const surferPackage = async () => {
|
export const surferPackage = async () => {
|
||||||
|
@ -55,14 +55,14 @@ export const surferPackage = async () => {
|
||||||
)
|
)
|
||||||
|
|
||||||
const currentCWD = process.cwd()
|
const currentCWD = process.cwd()
|
||||||
const zenMacDestDir = join(currentCWD, 'zen-browser');
|
const zenMacDestDir = join(currentCWD, 'zen-browser')
|
||||||
|
|
||||||
if (!process.env.SURFER_SIGNING_MODE) {
|
if (!process.env.SURFER_SIGNING_MODE) {
|
||||||
await dispatch(machPath, arguments_, ENGINE_DIR, true)
|
await dispatch(machPath, arguments_, ENGINE_DIR, true)
|
||||||
|
|
||||||
// Merge language packs
|
// Merge language packs
|
||||||
for (const locale of await getLocales()) {
|
for (const locale of await getLocales()) {
|
||||||
const arguments_ = ["build", `merge-${locale}`]
|
const arguments_ = ['build', `merge-${locale}`]
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
`Packaging \`${config.binaryName}\` with args ${JSON.stringify(
|
`Packaging \`${config.binaryName}\` with args ${JSON.stringify(
|
||||||
|
@ -73,50 +73,94 @@ export const surferPackage = async () => {
|
||||||
await dispatch(machPath, arguments_, ENGINE_DIR, true)
|
await dispatch(machPath, arguments_, ENGINE_DIR, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Copying language packs")
|
log.info('Copying language packs')
|
||||||
|
|
||||||
await dispatch(machPath, ['package-multi-locale', '--locales', ...(await getLocales())], ENGINE_DIR, true)
|
await dispatch(
|
||||||
|
machPath,
|
||||||
|
['package-multi-locale', '--locales', ...(await getLocales())],
|
||||||
|
ENGINE_DIR,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
// If we are on macos, run "mach macos-sign" to sign the app and repack it
|
// If we are on macos, run "mach macos-sign" to sign the app and repack it
|
||||||
|
|
||||||
if ((process as any).surferPlatform == 'darwin') {
|
if ((process as any).surferPlatform == 'darwin') {
|
||||||
log.info('Signing the app')
|
log.info('Signing the app')
|
||||||
|
|
||||||
const dmgFile = (await readdir(join(OBJ_DIR, 'dist'))).find((file) => file.endsWith('.dmg'))
|
const dmgFile = (await readdir(join(OBJ_DIR, 'dist'))).find((file) =>
|
||||||
|
file.endsWith('.dmg')
|
||||||
|
)
|
||||||
if (!dmgFile) {
|
if (!dmgFile) {
|
||||||
log.error('Could not find the dmg file')
|
log.error('Could not find the dmg file')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug('Copying the dmg file to the current working directory')
|
log.debug('Copying the dmg file to the current working directory')
|
||||||
// extract the dmg file
|
// extract the dmg file
|
||||||
const dmgPath = join(OBJ_DIR, 'dist', dmgFile);
|
const dmgPath = join(OBJ_DIR, 'dist', dmgFile)
|
||||||
|
|
||||||
await dispatch(machPath, ['python', '-m', 'mozbuild.action.unpack_dmg', dmgPath, zenMacDestDir], ENGINE_DIR, true);
|
await dispatch(
|
||||||
|
machPath,
|
||||||
|
['python', '-m', 'mozbuild.action.unpack_dmg', dmgPath, zenMacDestDir],
|
||||||
|
ENGINE_DIR,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
log.info('Signing the app')
|
log.info('Signing the app')
|
||||||
if (process.env.MACOS_APPLE_DEVELOPER_ID) {
|
if (process.env.MACOS_APPLE_DEVELOPER_ID) {
|
||||||
log.info('Signing the app with the developer id')
|
log.info('Signing the app with the developer id')
|
||||||
await dispatch('chmod', ['+x', '../build/codesign/codesign.bash'], ENGINE_DIR, true);
|
await dispatch(
|
||||||
await dispatch('../build/codesign/codesign.bash', [
|
'chmod',
|
||||||
'-a', join(zenMacDestDir, 'Zen Browser.app'),
|
['+x', '../build/codesign/codesign.bash'],
|
||||||
'-i', process.env.MACOS_APPLE_DEVELOPER_ID,
|
ENGINE_DIR,
|
||||||
'-b', '../build/codesign/browser.developer.entitlements.xml',
|
true
|
||||||
'-p', '../build/codesign/plugin-container.developer.entitlements.xml'
|
)
|
||||||
], ENGINE_DIR, true);
|
await dispatch(
|
||||||
|
'../build/codesign/codesign.bash',
|
||||||
|
[
|
||||||
|
'-a',
|
||||||
|
join(zenMacDestDir, 'Zen Browser.app'),
|
||||||
|
'-i',
|
||||||
|
process.env.MACOS_APPLE_DEVELOPER_ID,
|
||||||
|
'-b',
|
||||||
|
'../build/codesign/browser.developer.entitlements.xml',
|
||||||
|
'-p',
|
||||||
|
'../build/codesign/plugin-container.developer.entitlements.xml',
|
||||||
|
],
|
||||||
|
ENGINE_DIR,
|
||||||
|
true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
log.info('Stapling the app');
|
log.info('Stapling the app')
|
||||||
await dispatch("xcrun", ['stapler', 'staple', join(zenMacDestDir, 'Zen Browser.app')], ENGINE_DIR, true);
|
await dispatch(
|
||||||
log.info('Repacking the app');
|
'xcrun',
|
||||||
const brandingPath = join(ENGINE_DIR, 'browser', 'branding', brandingKey);
|
['stapler', 'staple', join(zenMacDestDir, 'Zen Browser.app')],
|
||||||
|
ENGINE_DIR,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
log.info('Repacking the app')
|
||||||
|
const brandingPath = join(ENGINE_DIR, 'browser', 'branding', brandingKey)
|
||||||
await remove(dmgPath)
|
await remove(dmgPath)
|
||||||
await dispatch(machPath, ['python', '-m', 'mozbuild.action.make_dmg',
|
await dispatch(
|
||||||
'--volume-name', 'Zen Browser',
|
machPath,
|
||||||
'--icon', join(brandingPath, 'firefox.icns'),
|
[
|
||||||
'--background', join(brandingPath, 'background.png'),
|
'python',
|
||||||
'--dsstore', join(brandingPath, 'dsstore'),
|
'-m',
|
||||||
|
'mozbuild.action.make_dmg',
|
||||||
|
'--volume-name',
|
||||||
|
'Zen Browser',
|
||||||
|
'--icon',
|
||||||
|
join(brandingPath, 'firefox.icns'),
|
||||||
|
'--background',
|
||||||
|
join(brandingPath, 'background.png'),
|
||||||
|
'--dsstore',
|
||||||
|
join(brandingPath, 'dsstore'),
|
||||||
zenMacDestDir,
|
zenMacDestDir,
|
||||||
dmgPath], ENGINE_DIR, true);
|
dmgPath,
|
||||||
|
],
|
||||||
|
ENGINE_DIR,
|
||||||
|
true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +233,12 @@ export const surferPackage = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const marPath = await createMarFile(version, channel, brandingDetails.release.github, zenMacDestDir)
|
const marPath = await createMarFile(
|
||||||
|
version,
|
||||||
|
channel,
|
||||||
|
brandingDetails.release.github,
|
||||||
|
zenMacDestDir
|
||||||
|
)
|
||||||
dynamicConfig.set('marPath', marPath)
|
dynamicConfig.set('marPath', marPath)
|
||||||
|
|
||||||
await generateBrowserUpdateFiles()
|
await generateBrowserUpdateFiles()
|
||||||
|
@ -210,7 +259,12 @@ function getCurrentBrandName(): string {
|
||||||
return config.brands[brand].brandFullName
|
return config.brands[brand].brandFullName
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createMarFile(version: string, channel: string, github?: { repo: string }, zenMacDestDir?: string): Promise<string> {
|
async function createMarFile(
|
||||||
|
version: string,
|
||||||
|
channel: string,
|
||||||
|
github?: { repo: string },
|
||||||
|
zenMacDestDir?: string
|
||||||
|
): Promise<string> {
|
||||||
log.info(`Creating mar file...`)
|
log.info(`Creating mar file...`)
|
||||||
let marBinary: string = windowsPathToUnix(
|
let marBinary: string = windowsPathToUnix(
|
||||||
join(OBJ_DIR, 'dist/host/bin', 'mar')
|
join(OBJ_DIR, 'dist/host/bin', 'mar')
|
||||||
|
@ -228,8 +282,8 @@ async function createMarFile(version: string, channel: string, github?: { repo:
|
||||||
? join(zenMacDestDir, `${getCurrentBrandName()}.app`)
|
? join(zenMacDestDir, `${getCurrentBrandName()}.app`)
|
||||||
: join(OBJ_DIR, 'dist', config.binaryName)
|
: join(OBJ_DIR, 'dist', config.binaryName)
|
||||||
|
|
||||||
const marPath = resolve(DIST_DIR, 'output.mar');
|
const marPath = resolve(DIST_DIR, 'output.mar')
|
||||||
log.debug(`Writing MAR to ${DIST_DIR} from ${binary}`);
|
log.debug(`Writing MAR to ${DIST_DIR} from ${binary}`)
|
||||||
await configDispatch('./tools/update-packaging/make_full_update.sh', {
|
await configDispatch('./tools/update-packaging/make_full_update.sh', {
|
||||||
args: [
|
args: [
|
||||||
// The mar output location
|
// The mar output location
|
||||||
|
|
|
@ -41,8 +41,13 @@ export const BRANDING_DIR = join(CONFIGS_DIR, 'branding')
|
||||||
const BRANDING_STORE = join(ENGINE_DIR, 'browser', 'branding')
|
const BRANDING_STORE = join(ENGINE_DIR, 'browser', 'branding')
|
||||||
const BRANDING_FF = join(BRANDING_STORE, 'unofficial')
|
const BRANDING_FF = join(BRANDING_STORE, 'unofficial')
|
||||||
|
|
||||||
const REQUIRED_FILES = ['logo.png', 'logo-mac.png', 'firefox.ico', 'firefox64.ico']
|
const REQUIRED_FILES = [
|
||||||
const BRANDING_NSIS = 'branding.nsi';
|
'logo.png',
|
||||||
|
'logo-mac.png',
|
||||||
|
'firefox.ico',
|
||||||
|
'firefox64.ico',
|
||||||
|
]
|
||||||
|
const BRANDING_NSIS = 'branding.nsi'
|
||||||
|
|
||||||
const CSS_REPLACE_REGEX = new RegExp(
|
const CSS_REPLACE_REGEX = new RegExp(
|
||||||
'#130829|hsla\\(235, 43%, 10%, .5\\)',
|
'#130829|hsla\\(235, 43%, 10%, .5\\)',
|
||||||
|
@ -87,11 +92,11 @@ async function setupImages(configPath: string, outputPath: string) {
|
||||||
|
|
||||||
// Firefox doesn't use 512 by 512, but we need it to generate ico files later
|
// Firefox doesn't use 512 by 512, but we need it to generate ico files later
|
||||||
await every([16, 22, 24, 32, 48, 64, 128, 256, 512], async (size) => {
|
await every([16, 22, 24, 32, 48, 64, 128, 256, 512], async (size) => {
|
||||||
const logoPath = join(configPath, `logo${size}.png`);
|
const logoPath = join(configPath, `logo${size}.png`)
|
||||||
if (!filesExist([logoPath])) throw new Error(`Missing logo${size}.png`);
|
if (!filesExist([logoPath])) throw new Error(`Missing logo${size}.png`)
|
||||||
|
|
||||||
const outputPathLogo = join(outputPath, `default${size}.png`);
|
const outputPathLogo = join(outputPath, `default${size}.png`)
|
||||||
await copyFile(logoPath, outputPathLogo);
|
await copyFile(logoPath, outputPathLogo)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -178,9 +183,11 @@ async function copyMozFiles(
|
||||||
(file) => !existsSync(join(outputPath, file.replace(BRANDING_FF, '')))
|
(file) => !existsSync(join(outputPath, file.replace(BRANDING_FF, '')))
|
||||||
)
|
)
|
||||||
|
|
||||||
const css = files.filter((file) => extname(file).includes('css'));
|
const css = files.filter((file) => extname(file).includes('css'))
|
||||||
|
|
||||||
const everythingElse = files.filter((file) => !css.includes(file) && !file.includes(BRANDING_NSIS));
|
const everythingElse = files.filter(
|
||||||
|
(file) => !css.includes(file) && !file.includes(BRANDING_NSIS)
|
||||||
|
)
|
||||||
|
|
||||||
for (const [contents, path] of css
|
for (const [contents, path] of css
|
||||||
.map((filePath) => [
|
.map((filePath) => [
|
||||||
|
@ -196,12 +203,22 @@ async function copyMozFiles(
|
||||||
writeFileSync(path, contents)
|
writeFileSync(path, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
const brandingNsis = files.filter((file) => file.includes(BRANDING_NSIS));
|
const brandingNsis = files.filter((file) => file.includes(BRANDING_NSIS))
|
||||||
console.assert(brandingNsis.length == 1, 'There should only be one branding.nsi file');
|
console.assert(
|
||||||
const outputBrandingNsis = join(outputPath, brandingNsis[0].replace(BRANDING_FF, ''));
|
brandingNsis.length == 1,
|
||||||
const configureProfileBrandingPath = join(outputPath, 'pref', 'firefox-branding.js');
|
'There should only be one branding.nsi file'
|
||||||
log.debug('Configuring branding.nsi into ' + outputBrandingNsis);
|
)
|
||||||
configureBrandingNsis(outputBrandingNsis, brandingConfig);
|
const outputBrandingNsis = join(
|
||||||
|
outputPath,
|
||||||
|
brandingNsis[0].replace(BRANDING_FF, '')
|
||||||
|
)
|
||||||
|
const configureProfileBrandingPath = join(
|
||||||
|
outputPath,
|
||||||
|
'pref',
|
||||||
|
'firefox-branding.js'
|
||||||
|
)
|
||||||
|
log.debug('Configuring branding.nsi into ' + outputBrandingNsis)
|
||||||
|
configureBrandingNsis(outputBrandingNsis, brandingConfig)
|
||||||
|
|
||||||
// Copy everything else from the default firefox branding directory
|
// Copy everything else from the default firefox branding directory
|
||||||
for (const file of everythingElse) {
|
for (const file of everythingElse) {
|
||||||
|
@ -209,7 +226,7 @@ async function copyMozFiles(
|
||||||
copyFileSync(file, join(outputPath, file.replace(BRANDING_FF, '')))
|
copyFileSync(file, join(outputPath, file.replace(BRANDING_FF, '')))
|
||||||
}
|
}
|
||||||
|
|
||||||
configureProfileBranding(configureProfileBrandingPath, brandingConfig);
|
configureProfileBranding(configureProfileBrandingPath, brandingConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
@ -243,18 +260,23 @@ export async function apply(name: string): Promise<void> {
|
||||||
await copyMozFiles(outputPath, brandingConfig)
|
await copyMozFiles(outputPath, brandingConfig)
|
||||||
await addOptionalIcons(configPath, outputPath)
|
await addOptionalIcons(configPath, outputPath)
|
||||||
|
|
||||||
setUpdateURLs();
|
setUpdateURLs()
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureBrandingNsis(brandingNsis: string, brandingConfig: {
|
function configureBrandingNsis(
|
||||||
|
brandingNsis: string,
|
||||||
|
brandingConfig: {
|
||||||
backgroundColor: string
|
backgroundColor: string
|
||||||
brandShorterName: string
|
brandShorterName: string
|
||||||
brandShortName: string
|
brandShortName: string
|
||||||
brandFullName: string
|
brandFullName: string
|
||||||
brandingGenericName: string
|
brandingGenericName: string
|
||||||
brandingVendor: string
|
brandingVendor: string
|
||||||
}) {
|
}
|
||||||
writeFileSync(brandingNsis, `
|
) {
|
||||||
|
writeFileSync(
|
||||||
|
brandingNsis,
|
||||||
|
`
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
@ -331,35 +353,44 @@ function configureBrandingNsis(brandingNsis: string, brandingConfig: {
|
||||||
!define INSTALL_INSTALLING_TEXT_COLOR 0xFFFFFF
|
!define INSTALL_INSTALLING_TEXT_COLOR 0xFFFFFF
|
||||||
# This color is written as 0x00BBGGRR because it's actually a COLORREF value.
|
# This color is written as 0x00BBGGRR because it's actually a COLORREF value.
|
||||||
!define PROGRESS_BAR_BACKGROUND_COLOR 0xFFAA00
|
!define PROGRESS_BAR_BACKGROUND_COLOR 0xFFAA00
|
||||||
`);
|
`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addOptionalIcons(brandingPath: string, outputPath: string) {
|
function addOptionalIcons(brandingPath: string, outputPath: string) {
|
||||||
// move all icons in the top directory and inside "content/" into the branding directory
|
// move all icons in the top directory and inside "content/" into the branding directory
|
||||||
const icons = readdirSync(brandingPath);
|
const icons = readdirSync(brandingPath)
|
||||||
const iconsContent = readdirSync(join(brandingPath, 'content'));
|
const iconsContent = readdirSync(join(brandingPath, 'content'))
|
||||||
|
|
||||||
for (const icon of icons) {
|
for (const icon of icons) {
|
||||||
if (icon.includes('content')) continue;
|
if (icon.includes('content')) continue
|
||||||
log.info(`Copying ${icon} to ${outputPath}`);
|
log.info(`Copying ${icon} to ${outputPath}`)
|
||||||
copyFileSync(join(brandingPath, icon), join(outputPath, icon));
|
copyFileSync(join(brandingPath, icon), join(outputPath, icon))
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const icon of iconsContent) {
|
for (const icon of iconsContent) {
|
||||||
log.info(`Copying ${icon} to ${outputPath}`);
|
log.info(`Copying ${icon} to ${outputPath}`)
|
||||||
copyFileSync(join(brandingPath, 'content', icon), join(outputPath, 'content', icon));
|
copyFileSync(
|
||||||
|
join(brandingPath, 'content', icon),
|
||||||
|
join(outputPath, 'content', icon)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureProfileBranding(brandingPath: string, brandingConfig: {
|
function configureProfileBranding(
|
||||||
|
brandingPath: string,
|
||||||
|
brandingConfig: {
|
||||||
backgroundColor: string
|
backgroundColor: string
|
||||||
brandShorterName: string
|
brandShorterName: string
|
||||||
brandShortName: string
|
brandShortName: string
|
||||||
brandFullName: string
|
brandFullName: string
|
||||||
brandingGenericName: string
|
brandingGenericName: string
|
||||||
brandingVendor: string
|
brandingVendor: string
|
||||||
}) {
|
}
|
||||||
writeFileSync(brandingPath, `
|
) {
|
||||||
|
writeFileSync(
|
||||||
|
brandingPath,
|
||||||
|
`
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
@ -384,15 +415,16 @@ pref("app.releaseNotesURL.prompt", "https://zen-browser.app/release-notes/%VERSI
|
||||||
// Number of usages of the web console.
|
// Number of usages of the web console.
|
||||||
// If this is less than 5, then pasting code into the web console is disabled
|
// If this is less than 5, then pasting code into the web console is disabled
|
||||||
pref("devtools.selfxss.count", 5);
|
pref("devtools.selfxss.count", 5);
|
||||||
`);
|
`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpdateURLs() {
|
function setUpdateURLs() {
|
||||||
const sufix = (compatMode && (process as any).surferPlatform !== 'macos')
|
const sufix =
|
||||||
? '-generic' : '';
|
compatMode && (process as any).surferPlatform !== 'macos' ? '-generic' : ''
|
||||||
const baseURL = `URL=https://@MOZ_APPUPDATE_HOST@/updates/browser/%BUILD_TARGET%/%CHANNEL%${sufix}/update.xml`;
|
const baseURL = `URL=https://@MOZ_APPUPDATE_HOST@/updates/browser/%BUILD_TARGET%/%CHANNEL%${sufix}/update.xml`
|
||||||
const appIni = join(ENGINE_DIR, 'build', 'application.ini.in');
|
const appIni = join(ENGINE_DIR, 'build', 'application.ini.in')
|
||||||
const appIniContents = readFileSync(appIni).toString();
|
const appIniContents = readFileSync(appIni).toString()
|
||||||
const updatedAppIni = appIniContents.replace(/URL=.*update.xml/g, baseURL);
|
const updatedAppIni = appIniContents.replace(/URL=.*update.xml/g, baseURL)
|
||||||
writeFileSync(appIni, updatedAppIni);
|
writeFileSync(appIni, updatedAppIni)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ const ausPlatformsMap = {
|
||||||
'Darwin_x86_64-gcc3',
|
'Darwin_x86_64-gcc3',
|
||||||
],
|
],
|
||||||
macosArm: ['Darwin_aarch64-gcc3'],
|
macosArm: ['Darwin_aarch64-gcc3'],
|
||||||
win64: ['WINNT_x86_64-msvc', 'WINNT_x86_64-msvc-x64']
|
win64: ['WINNT_x86_64-msvc', 'WINNT_x86_64-msvc-x64'],
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlatformConfig() {
|
export async function getPlatformConfig() {
|
||||||
|
@ -52,13 +52,19 @@ function getReleaseMarName(releaseInfo: ReleaseInfo): string | undefined {
|
||||||
|
|
||||||
switch ((process as any).surferPlatform) {
|
switch ((process as any).surferPlatform) {
|
||||||
case 'win32': {
|
case 'win32': {
|
||||||
return compatMode ? releaseInfo.archives["windows-compat"] : releaseInfo.archives["windows"];
|
return compatMode
|
||||||
|
? releaseInfo.archives['windows-compat']
|
||||||
|
: releaseInfo.archives['windows']
|
||||||
}
|
}
|
||||||
case 'darwin': {
|
case 'darwin': {
|
||||||
return compatMode ? releaseInfo.archives["macos-x64"] : releaseInfo.archives["macos-aarch64"];
|
return compatMode
|
||||||
|
? releaseInfo.archives['macos-x64']
|
||||||
|
: releaseInfo.archives['macos-aarch64']
|
||||||
}
|
}
|
||||||
case 'linux': {
|
case 'linux': {
|
||||||
return compatMode ? releaseInfo.archives["linux-compat"] : releaseInfo.archives["linux"];
|
return compatMode
|
||||||
|
? releaseInfo.archives['linux-compat']
|
||||||
|
: releaseInfo.archives['linux']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +77,12 @@ function getReleaseMarURL(releaseInfo: ReleaseInfo) {
|
||||||
|
|
||||||
// The user is using github to distribute release binaries for this version.
|
// The user is using github to distribute release binaries for this version.
|
||||||
if (releaseInfo.github) {
|
if (releaseInfo.github) {
|
||||||
completeMarURL = `https://github.com/${releaseInfo.github.repo}/releases/download/${releaseInfo.displayVersion}/${releaseMarName}`
|
let releaseVersion = releaseInfo.displayVersion
|
||||||
|
const channel = dynamicConfig.get('brand') as string
|
||||||
|
if (channel === 'twilight') {
|
||||||
|
releaseVersion = 'twilight'
|
||||||
|
}
|
||||||
|
completeMarURL = `https://github.com/${releaseInfo.github.repo}/releases/download/${releaseVersion}/${releaseMarName}`
|
||||||
log.info(`Using '${completeMarURL}' as the distribution url`)
|
log.info(`Using '${completeMarURL}' as the distribution url`)
|
||||||
} else {
|
} else {
|
||||||
log.warning(
|
log.warning(
|
||||||
|
@ -96,7 +107,8 @@ async function writeUpdateFileToDisk(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const suffix = (compatMode && (process as any).surferPlatform !== 'macos') ? '-generic' : ''
|
const suffix =
|
||||||
|
compatMode && (process as any).surferPlatform !== 'macos' ? '-generic' : ''
|
||||||
const xmlPath = join(
|
const xmlPath = join(
|
||||||
DIST_DIR,
|
DIST_DIR,
|
||||||
'update',
|
'update',
|
||||||
|
|
|
@ -93,7 +93,9 @@ if (process.platform == 'win32') {
|
||||||
|
|
||||||
BASH_PATH = execa.sync('where.exe bash.exe').stdout.toString()
|
BASH_PATH = execa.sync('where.exe bash.exe').stdout.toString()
|
||||||
if (!BASH_PATH.includes('bash.exe')) {
|
if (!BASH_PATH.includes('bash.exe')) {
|
||||||
BASH_PATH = process.env.SURFER_SIGNING_MODE ? 'C:\\mozilla-build\\msys2\\usr\\bin\\bash.exe' : '';
|
BASH_PATH = process.env.SURFER_SIGNING_MODE
|
||||||
|
? 'C:\\mozilla-build\\msys2\\usr\\bin\\bash.exe'
|
||||||
|
: ''
|
||||||
if (BASH_PATH === '') {
|
if (BASH_PATH === '') {
|
||||||
log.error('Could not find bash, aborting')
|
log.error('Could not find bash, aborting')
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
function getPlatform() {
|
function getPlatform() {
|
||||||
if (process.env.SURFER_PLATFORM) {
|
if (process.env.SURFER_PLATFORM) {
|
||||||
return process.env.SURFER_PLATFORM;
|
return process.env.SURFER_PLATFORM
|
||||||
}
|
}
|
||||||
return process.platform;
|
return process.platform
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(process, 'surferPlatform', { value: getPlatform() });
|
Object.defineProperty(process, 'surferPlatform', { value: getPlatform() })
|
||||||
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -48,7 +48,7 @@ export const bin_name = BIN_NAME
|
||||||
|
|
||||||
const programVersions = []
|
const programVersions = []
|
||||||
|
|
||||||
export const compatMode = process.env.SURFER_COMPAT == 'true';
|
export const compatMode = process.env.SURFER_COMPAT == 'true'
|
||||||
|
|
||||||
for (const brand in config.brands) {
|
for (const brand in config.brands) {
|
||||||
const brandConfig = config.brands[brand]
|
const brandConfig = config.brands[brand]
|
||||||
|
|
2
src/types.d.ts
vendored
2
src/types.d.ts
vendored
|
@ -29,4 +29,4 @@ export interface CmdOption {
|
||||||
|
|
||||||
export type CmdFlagPlatform = NodeJS.Platform
|
export type CmdFlagPlatform = NodeJS.Platform
|
||||||
|
|
||||||
declare module 'mount-dmg';
|
declare module 'mount-dmg'
|
||||||
|
|
|
@ -62,13 +62,13 @@ export interface ReleaseInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
archives?: {
|
archives?: {
|
||||||
"windows"?: string,
|
windows?: string
|
||||||
"macos-aarch64"?: string,
|
'macos-aarch64'?: string
|
||||||
"macos-x64"?: string,
|
'macos-x64'?: string
|
||||||
"linux"?: string,
|
linux?: string
|
||||||
|
|
||||||
"windows-compat"?: string,
|
'windows-compat'?: string
|
||||||
"linux-compat"?: string,
|
'linux-compat'?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,8 @@ import { log } from '../log'
|
||||||
*/
|
*/
|
||||||
export const windowsPathToUnix = (path: string): string =>
|
export const windowsPathToUnix = (path: string): string =>
|
||||||
(process as any).platform == 'win32'
|
(process as any).platform == 'win32'
|
||||||
?
|
? (process.env.SURFER_SIGNING_MODE ? '/c' : '') +
|
||||||
(process.env.SURFER_SIGNING_MODE ? "/c" : "")
|
path.replace(/[\\]+/g, '/').replace(/^([a-zA-Z]+:|\.\/)/, '')
|
||||||
+ path.replace(/[\\]+/g, '/').replace(/^([a-zA-Z]+:|\.\/)/, '')
|
|
||||||
: path
|
: path
|
||||||
|
|
||||||
export async function walkDirectory(directory: string): Promise<string[]> {
|
export async function walkDirectory(directory: string): Promise<string[]> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue