diff --git a/package.json b/package.json index 3602665..f47da0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zen-browser/surfer", - "version": "1.7.0", + "version": "1.8.2", "description": "Simplifying building firefox forks!", "main": "index.js", "bin": { diff --git a/src/commands/download/firefox.ts b/src/commands/download/firefox.ts index fdc4de6..eabdbe6 100644 --- a/src/commands/download/firefox.ts +++ b/src/commands/download/firefox.ts @@ -20,7 +20,7 @@ import { resolveAddonDownloadUrl, unpackAddon, } from './addon' -import { configPath } from '../../utils' +import { configPath, shouldUseCandidate } from '../../utils' import fs from 'fs-extra' export function shouldSetupFirefoxSource() { @@ -30,8 +30,8 @@ export function shouldSetupFirefoxSource() { ) } -export async function setupFirefoxSource(version: string) { - const firefoxSourceTar = await downloadFirefoxSource(version) +export async function setupFirefoxSource(version: string, isCandidate = false) { + const firefoxSourceTar = await downloadFirefoxSource(version, isCandidate) await unpackFirefoxSource(firefoxSourceTar) @@ -108,8 +108,12 @@ async function unpackFirefoxSource(name: string): Promise { log.info(`Unpacked Firefox source to ${ENGINE_DIR}`) } -async function downloadFirefoxSource(version: string) { - const base = `https://archive.mozilla.org/pub/firefox/releases/${version}/source/` +async function downloadFirefoxSource(version: string, isCandidate = false) { + let base = `https://archive.mozilla.org/pub/firefox/releases/${version}/source/`; + if (isCandidate) { + console.log('Using candidate build') + base = `https://archive.mozilla.org/pub/firefox/candidates/${version}-candidates/build1/source/`; + } const filename = `firefox-${version}.source.tar.xz` const url = base + filename @@ -141,9 +145,11 @@ async function downloadFirefoxSource(version: string) { export async function downloadInternals({ version, force, + isCandidate = shouldUseCandidate() }: { version: string - force?: boolean + force?: boolean, + isCandidate?: boolean }) { // Provide a legible error if there is no version specified if (!version) { @@ -153,6 +159,10 @@ export async function downloadInternals({ process.exit(1) } + if (isCandidate) { + version = config.version.candidate as string; + } + if (force && existsSync(ENGINE_DIR)) { log.info('Removing existing workspace') rmSync(ENGINE_DIR, { recursive: true }) @@ -168,7 +178,7 @@ export async function downloadInternals({ } if (!existsSync(ENGINE_DIR)) { - await setupFirefoxSource(version) + await setupFirefoxSource(version, isCandidate) } for (const addon of getAddons()) { diff --git a/src/commands/patches/branding-patch.ts b/src/commands/patches/branding-patch.ts index 4560728..55e699d 100644 --- a/src/commands/patches/branding-patch.ts +++ b/src/commands/patches/branding-patch.ts @@ -297,15 +297,15 @@ function configureBrandingNsis( !define HelpLink "https://github.com/zen-browser/desktop/issues" ; The OFFICIAL define is a workaround to support different urls for Release and -; Beta since they share the same branding when building with other branches that -; set the update channel to beta. +; Stable since they share the same branding when building with other branches that +; set the update channel to stable. !define OFFICIAL !define URLStubDownloadX86 "https://download.mozilla.org/?os=win&lang=\${AB_CD}&product=firefox-latest" !define URLStubDownloadAMD64 "https://download.mozilla.org/?os=win64&lang=\${AB_CD}&product=firefox-latest" !define URLStubDownloadAArch64 "https://download.mozilla.org/?os=win64-aarch64&lang=\${AB_CD}&product=firefox-latest" !define URLManualDownload "https://zen-browser.app/download" !define URLSystemRequirements "https://www.mozilla.org/firefox/system-requirements/" -!define Channel "release" +!define Channel "stable" # The installer's certificate name and issuer expected by the stub installer !define CertNameDownload "${brandingConfig.brandFullName}" diff --git a/src/utils/config.ts b/src/utils/config.ts index 3812b06..0b5eefe 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -131,6 +131,10 @@ export interface Config { * The version of the selected product you are forking */ version?: string + /* + * Release candidate version + */ + candidate?: string } buildOptions: { windowsUseSymbolicLinks: boolean diff --git a/src/utils/version.ts b/src/utils/version.ts index 076c9bd..33e09d8 100644 --- a/src/utils/version.ts +++ b/src/utils/version.ts @@ -4,6 +4,8 @@ import axios from 'axios' import { log } from '../log' import { SupportedProducts } from './config' +import { config } from '..' +import { dynamicConfig } from '.' const firefoxTargets = JSON.parse(`{ "${SupportedProducts.Firefox}": "LATEST_FIREFOX_VERSION", @@ -13,6 +15,11 @@ const firefoxTargets = JSON.parse(`{ "${SupportedProducts.FirefoxNightly}": "FIREFOX_NIGHTLY" }`) +export const shouldUseCandidate = (): boolean => { + const brandingKey = dynamicConfig.get('brand') + return brandingKey !== 'stable' && (config.version.version !== config.version.candidate); +} + export const getLatestFF = async ( product: SupportedProducts = SupportedProducts.Firefox ): Promise => {