chore: Update process.platform to use surferPlatform

This commit is contained in:
Mauro Balades 2024-07-10 18:44:55 +02:00
parent af40c2e3e3
commit 795991d1dc
12 changed files with 20 additions and 27 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "@zen-browser/surfer", "name": "@zen-browser/surfer",
"version": "1.0.5", "version": "1.0.6",
"description": "Simplifying building firefox forks!", "description": "Simplifying building firefox forks!",
"main": "index.js", "main": "index.js",
"bin": { "bin": {

View file

@ -163,7 +163,7 @@ export const build = async (options: Options): Promise<void> => {
// Host build // Host build
const prettyHost = platform[process.platform] const prettyHost = platform[process.surferPlatform]
if (BUILD_TARGETS.includes(prettyHost)) { if (BUILD_TARGETS.includes(prettyHost)) {
if (!options.skipPatchCheck) await patchCheck() if (!options.skipPatchCheck) await patchCheck()

View file

@ -53,7 +53,7 @@ async function unpackFirefoxSource(name: string): Promise<void> {
// //
// If BSD tar adds --transform support in the future, we can use that // If BSD tar adds --transform support in the future, we can use that
// instead // instead
if (process.platform == 'darwin') { if (process.surferPlatform == 'darwin') {
// GNU Tar doesn't come preinstalled on any MacOS machines, so we need to // GNU Tar doesn't come preinstalled on any MacOS machines, so we need to
// check for it and ask for the user to install it if necessary // check for it and ask for the user to install it if necessary
if (!commandExistsSync('gtar')) { if (!commandExistsSync('gtar')) {
@ -69,7 +69,7 @@ async function unpackFirefoxSource(name: string): Promise<void> {
tarExec, tarExec,
[ [
'--strip-components=1', '--strip-components=1',
process.platform == 'win32' ? '--force-local' : undefined, process.surferPlatform == 'win32' ? '--force-local' : undefined,
'-xf', '-xf',
windowsPathToUnix(resolve(MELON_TMP_DIR, name)), windowsPathToUnix(resolve(MELON_TMP_DIR, name)),
'-C', '-C',

View file

@ -69,7 +69,7 @@ export const surferPackage = async () => {
// Windows has some special dist files that are available within the dist // Windows has some special dist files that are available within the dist
// directory. // directory.
if (process.platform == 'win32') { if (process.surferPlatform == 'win32') {
const installerDistributionDirectory = join( const installerDistributionDirectory = join(
OBJ_DIR, OBJ_DIR,
'dist', 'dist',
@ -143,7 +143,7 @@ async function createMarFile(version: string, channel: string) {
join(OBJ_DIR, 'dist/host/bin', 'mar') join(OBJ_DIR, 'dist/host/bin', 'mar')
) )
if (process.platform == 'win32') { if (process.surferPlatform == 'win32') {
marBinary += '.exe' marBinary += '.exe'
} }
@ -151,7 +151,7 @@ async function createMarFile(version: string, channel: string) {
// <obj dir>/dist/${binaryName}/${brandFullName}.app and on everything else, // <obj dir>/dist/${binaryName}/${brandFullName}.app and on everything else,
// the contents of the folder <obj dir>/dist/${binaryName} // the contents of the folder <obj dir>/dist/${binaryName}
const binary = const binary =
process.platform == 'darwin' process.surferPlatform == 'darwin'
? join(OBJ_DIR, 'dist', config.binaryName, `${getCurrentBrandName()}.app`) ? join(OBJ_DIR, 'dist', config.binaryName, `${getCurrentBrandName()}.app`)
: join(OBJ_DIR, 'dist', config.binaryName) : join(OBJ_DIR, 'dist', config.binaryName)

View file

@ -109,7 +109,7 @@ async function setupImages(configPath: string, outputPath: string) {
) )
// TODO: Custom MacOS icon support // TODO: Custom MacOS icon support
if (process.platform == 'darwin') { if (process.surferPlatform == 'darwin') {
log.debug('Generating Mac Icons') log.debug('Generating Mac Icons')
const temporary = join(MELON_TMP_DIR, 'macos_icon_info.iconset') const temporary = join(MELON_TMP_DIR, 'macos_icon_info.iconset')

View file

@ -29,7 +29,7 @@ export const copyManual = async (name: string): Promise<void> => {
} }
if ( if (
process.platform == 'win32' && process.surferPlatform == 'win32' &&
!config.buildOptions.windowsUseSymbolicLinks !config.buildOptions.windowsUseSymbolicLinks
) { ) {
// Make the directory if it doesn't already exist. // Make the directory if it doesn't already exist.

View file

@ -52,7 +52,7 @@ function getReleaseMarName(releaseInfo: ReleaseInfo): string | undefined {
return return
} }
switch (process.platform) { switch (process.surferPlatform) {
case 'win32': { case 'win32': {
return releaseInfo.x86?.windowsMar return releaseInfo.x86?.windowsMar
} }
@ -113,11 +113,11 @@ async function writeUpdateFileToDisk(
} }
function getTargets(): string[] { function getTargets(): string[] {
if (process.platform == 'win32') { if (process.surferPlatform == 'win32') {
return ausPlatformsMap.win64 return ausPlatformsMap.win64
} }
if (process.platform == 'linux') { if (process.surferPlatform == 'linux') {
return ausPlatformsMap.linux64 return ausPlatformsMap.linux64
} }

View file

@ -78,7 +78,7 @@ export const FTL_STRING_LINE_REGEX =
export let BASH_PATH: string | undefined export let BASH_PATH: string | undefined
// All windows specific code should be located inside of this if statement // All windows specific code should be located inside of this if statement
if ((process as any).surferOriginalPlatform == 'win32') { if ((process as any).platform == 'win32') {
const gitPath = execa.sync('where.exe git.exe').stdout.toString() const gitPath = execa.sync('where.exe git.exe').stdout.toString()
if (gitPath.includes('git.exe')) { if (gitPath.includes('git.exe')) {

View file

@ -59,9 +59,9 @@ export MOZ_APPUPDATE_HOST=${
} }
function getPlatformOptimiseFlags(): string { function getPlatformOptimiseFlags(): string {
let optimiseFlags = `# Unknown platform ${process.platform}` let optimiseFlags = `# Unknown platform ${process.surferPlatform}`
switch (process.platform) { switch (process.surferPlatform) {
case 'linux': { case 'linux': {
optimiseFlags = `ac_add_options --enable-optimize="-O3 -march=haswell -mtune=haswell -w"` optimiseFlags = `ac_add_options --enable-optimize="-O3 -march=haswell -mtune=haswell -w"`
break break

View file

@ -1,20 +1,13 @@
#!/usr/bin/env node #!/usr/bin/env node
Object.defineProperty(process, 'surferOriginalPlatform', {
value: process.platform,
writable: false,
enumerable: true,
configurable: true,
});
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 as any).surferOriginalPlatform; return process.platform;
} }
Object.defineProperty(process, 'platform', { 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
@ -96,7 +89,7 @@ for (const command of commands) {
if ( if (
command.flags && command.flags &&
command.flags.platforms && command.flags.platforms &&
!command.flags.platforms.includes(process.platform) !command.flags.platforms.includes(process.surferPlatform)
) { ) {
continue continue
} }

View file

@ -25,7 +25,7 @@ import { execSync } from 'node:child_process'
import { accessSync, constants } from 'node:fs' import { accessSync, constants } from 'node:fs'
import path from 'node:path' import path from 'node:path'
const onWindows = (process as any).surferOriginalPlatform == 'win32' const onWindows = (process as any).platform == 'win32'
const fileNotExistsSync = (commandName: string): boolean => { const fileNotExistsSync = (commandName: string): boolean => {
try { try {

View file

@ -22,7 +22,7 @@ import { log } from '../log'
* @returns A unix path * @returns A unix path
*/ */
export const windowsPathToUnix = (path: string): string => export const windowsPathToUnix = (path: string): string =>
(process as any).surferOriginalPlatform == 'win32' ? path.replace(/\\/g, '/') : path (process as any).platform == 'win32' ? path.replace(/\\/g, '/') : path
export async function walkDirectory(directory: string): Promise<string[]> { export async function walkDirectory(directory: string): Promise<string[]> {
const output = [] const output = []