mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-10 02:05:31 +02:00
♻️ Make the build more readable
This commit is contained in:
parent
56d5f02bfd
commit
22eb1c0a39
3 changed files with 21 additions and 28 deletions
|
@ -27,7 +27,7 @@ export const commands: Cmd[] = [
|
||||||
controller: bootstrap,
|
controller: bootstrap,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cmd: 'build [os]',
|
cmd: 'build',
|
||||||
aliases: ['b'],
|
aliases: ['b'],
|
||||||
description:
|
description:
|
||||||
'Build the melon app. Specify the OS param for cross-platform builds.',
|
'Build the melon app. Specify the OS param for cross-platform builds.',
|
||||||
|
|
|
@ -15,6 +15,9 @@ const platform: any = {
|
||||||
const applyConfig = async (os: string, arch: string) => {
|
const applyConfig = async (os: string, arch: string) => {
|
||||||
log.info('Applying mozconfig...')
|
log.info('Applying mozconfig...')
|
||||||
|
|
||||||
|
// Retrieve changeset
|
||||||
|
const { stdout: changeset } = await execa('git', ['rev-parse', 'HEAD'])
|
||||||
|
|
||||||
const templateOptions = {
|
const templateOptions = {
|
||||||
name: config.name,
|
name: config.name,
|
||||||
vendor: config.name,
|
vendor: config.name,
|
||||||
|
@ -23,36 +26,26 @@ const applyConfig = async (os: string, arch: string) => {
|
||||||
? 'branding/melon'
|
? 'branding/melon'
|
||||||
: 'branding/unofficial',
|
: 'branding/unofficial',
|
||||||
binName: config.binaryName,
|
binName: config.binaryName,
|
||||||
|
changeset,
|
||||||
}
|
}
|
||||||
|
|
||||||
let commonConfig = readFileSync(
|
const commonConfig = stringTemplate(
|
||||||
resolve(CONFIGS_DIR, 'common', 'mozconfig'),
|
readFileSync(resolve(CONFIGS_DIR, 'common', 'mozconfig'), 'utf-8'),
|
||||||
'utf-8'
|
templateOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
commonConfig = stringTemplate(commonConfig, templateOptions)
|
const osConfig = stringTemplate(
|
||||||
|
readFileSync(
|
||||||
const changesetPrefix = commonConfig
|
resolve(
|
||||||
.split('\n')
|
CONFIGS_DIR,
|
||||||
.find((ln) => ln.startsWith('export MOZ_SOURCE_CHANGESET='))
|
os,
|
||||||
|
arch === 'i686' ? 'mozconfig-i686' : 'mozconfig'
|
||||||
const changeset = changesetPrefix?.replace(/export MOZ_SOURCE_CHANGESET=/, '')
|
),
|
||||||
|
'utf-8'
|
||||||
const { stdout: gitSha } = await execa('git', ['rev-parse', 'HEAD'])
|
),
|
||||||
|
templateOptions
|
||||||
console.log(changeset, gitSha)
|
|
||||||
|
|
||||||
if (changeset) commonConfig = commonConfig.replace(changeset, gitSha)
|
|
||||||
|
|
||||||
writeFileSync(resolve(CONFIGS_DIR, 'common', 'mozconfig'), commonConfig)
|
|
||||||
|
|
||||||
let osConfig = readFileSync(
|
|
||||||
resolve(CONFIGS_DIR, os, arch === 'i686' ? 'mozconfig-i686' : 'mozconfig'),
|
|
||||||
'utf-8'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
osConfig = stringTemplate(osConfig, templateOptions)
|
|
||||||
|
|
||||||
// Allow a custom config to be placed in /mozconfig. This will not be committed
|
// Allow a custom config to be placed in /mozconfig. This will not be committed
|
||||||
// to origin
|
// to origin
|
||||||
let customConfig = existsSync(join(process.cwd(), 'mozconfig'))
|
let customConfig = existsSync(join(process.cwd(), 'mozconfig'))
|
||||||
|
@ -61,7 +54,7 @@ const applyConfig = async (os: string, arch: string) => {
|
||||||
|
|
||||||
customConfig = stringTemplate(customConfig, templateOptions)
|
customConfig = stringTemplate(customConfig, templateOptions)
|
||||||
|
|
||||||
const internalConfig = `# Internally defined by melon\n`
|
const internalConfig = `# Internally defined by melon`
|
||||||
|
|
||||||
const mergedConfig =
|
const mergedConfig =
|
||||||
`# This file is automatically generated. You should only modify this if you know what you are doing!\n\n` +
|
`# This file is automatically generated. You should only modify this if you know what you are doing!\n\n` +
|
||||||
|
@ -127,7 +120,7 @@ interface Options {
|
||||||
ui: boolean
|
ui: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const build = async (tier: string, options: Options): Promise<void> => {
|
export const build = async (options: Options): Promise<void> => {
|
||||||
const d = Date.now()
|
const d = Date.now()
|
||||||
|
|
||||||
// Host build
|
// Host build
|
||||||
|
|
|
@ -21,4 +21,4 @@ export MOZ_DISTRIBUTION_ID=${appId}
|
||||||
export MOZ_STUB_INSTALLER=1
|
export MOZ_STUB_INSTALLER=1
|
||||||
export MOZ_INCLUDE_SOURCE_INFO=1
|
export MOZ_INCLUDE_SOURCE_INFO=1
|
||||||
export MOZ_SOURCE_REPO=https://github.com/dothq/browser-desktop
|
export MOZ_SOURCE_REPO=https://github.com/dothq/browser-desktop
|
||||||
export MOZ_SOURCE_CHANGESET=5893b1f8552ad0956b28ffd8105bf706bc9ee6fa
|
export MOZ_SOURCE_CHANGESET=${changeset}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue