mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-10 02:05:31 +02:00
🔥 Remove branch checker
This commit is contained in:
parent
6867bc1db5
commit
24a9806588
8 changed files with 0 additions and 98 deletions
|
@ -12,10 +12,8 @@ import {
|
|||
melonPackage,
|
||||
reset,
|
||||
run,
|
||||
setBranch,
|
||||
setupProject,
|
||||
status,
|
||||
test,
|
||||
} from './commands'
|
||||
import { getFFVersion } from './commands/ff-version'
|
||||
import { applyPatches } from './commands/patches'
|
||||
|
@ -132,11 +130,6 @@ export const commands: Cmd[] = [
|
|||
description: 'Run the browser.',
|
||||
controller: run,
|
||||
},
|
||||
{
|
||||
cmd: 'set-branch <branch>',
|
||||
description: 'Change the default branch.',
|
||||
controller: setBranch,
|
||||
},
|
||||
{
|
||||
cmd: 'setup-project',
|
||||
description: 'Sets up a melon project for the first time',
|
||||
|
|
|
@ -20,7 +20,6 @@ import {
|
|||
ensureDir,
|
||||
getConfig,
|
||||
walkDirectoryTree,
|
||||
writeMetadata,
|
||||
} from '../utils'
|
||||
import { downloadFileToLocation } from '../utils/download'
|
||||
import { downloadArtifacts } from './download-artifacts'
|
||||
|
@ -106,10 +105,6 @@ export const download = async (): Promise<void> => {
|
|||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Write metadata',
|
||||
task: () => writeMetadata(),
|
||||
},
|
||||
{
|
||||
title: 'Cleanup',
|
||||
task: (ctx) => {
|
||||
|
|
|
@ -11,6 +11,5 @@ export * from './license-check'
|
|||
export * from './package'
|
||||
export * from './reset'
|
||||
export * from './run'
|
||||
export * from './set-branch'
|
||||
export * from './status'
|
||||
export * from './setupProject'
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
import execa from 'execa'
|
||||
import { existsSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { log } from '..'
|
||||
|
||||
export const setBranch = async (branch: string): Promise<void> => {
|
||||
if (!existsSync(resolve(process.cwd(), '.dotbuild', 'metadata'))) {
|
||||
return log.error('Cannot find metadata, aborting...')
|
||||
}
|
||||
|
||||
const metadata = JSON.parse(
|
||||
readFileSync(resolve(process.cwd(), '.dotbuild', 'metadata'), 'utf-8')
|
||||
)
|
||||
|
||||
try {
|
||||
await execa('git', ['rev-parse', '--verify', branch])
|
||||
|
||||
metadata.branch = branch
|
||||
|
||||
writeFileSync(
|
||||
resolve(process.cwd(), '.dotbuild', 'metadata'),
|
||||
JSON.stringify(metadata)
|
||||
)
|
||||
|
||||
log.success(`Default branch is at \`${branch}\`.`)
|
||||
} catch (e) {
|
||||
return log.error(`Branch with name \`${branch}\` does not exist.`)
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ import { resolve } from 'path'
|
|||
import { errorHandler, config as configInited } from './utils'
|
||||
import { commands } from './cmds'
|
||||
import { ENGINE_DIR } from './constants'
|
||||
import { shaCheck } from './middleware/sha-check'
|
||||
import { updateCheck } from './middleware/update-check'
|
||||
import { registerCommand } from './middleware/registerCommand'
|
||||
|
||||
|
@ -87,7 +86,6 @@ commands.forEach((command) => {
|
|||
|
||||
registerCommand(command.cmd)
|
||||
|
||||
await shaCheck(command.cmd)
|
||||
await updateCheck()
|
||||
|
||||
command.controller(...args)
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
import execa from 'execa'
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { bin_name, log } from '..'
|
||||
|
||||
const blacklistedCommands = ['reset', 'init', 'set-branch']
|
||||
|
||||
export const shaCheck = async (command: string): Promise<void> => {
|
||||
if (
|
||||
blacklistedCommands.filter((c) => command.startsWith(c)).length !== 0 ||
|
||||
!existsSync(resolve(process.cwd(), '.dotbuild', 'metadata'))
|
||||
)
|
||||
return
|
||||
|
||||
const metadata = JSON.parse(
|
||||
readFileSync(resolve(process.cwd(), '.dotbuild', 'metadata'), 'utf-8')
|
||||
)
|
||||
|
||||
const { stdout: currentBranch } = await execa('git', [
|
||||
'branch',
|
||||
'--show-current',
|
||||
])
|
||||
|
||||
if (metadata && metadata.branch) {
|
||||
if (metadata.branch !== currentBranch) {
|
||||
log.warning(`The current branch \`${currentBranch}\` differs from the original branch \`${metadata.branch}\`.
|
||||
|
||||
\t If you are changing the Firefox version, you will need to reset the tree
|
||||
\t with |${bin_name} reset --hard| and then |${bin_name} download|.
|
||||
|
||||
\t Or you can change the default branch by typing |${bin_name} set-branch <branch>|.`)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ export * from './delay'
|
|||
export * from './dispatch'
|
||||
export * from './error-handler'
|
||||
export * from './version'
|
||||
export * from './write-metadata'
|
||||
export * from './config'
|
||||
export * from './stringTemplate'
|
||||
export * from './fs'
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import execa from 'execa'
|
||||
import { writeFileSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { config } from '..'
|
||||
|
||||
export const writeMetadata = async (): Promise<void> => {
|
||||
const { stdout: sha } = await execa('git', ['rev-parse', 'HEAD'])
|
||||
const { stdout: branch } = await execa('git', ['branch', '--show-current'])
|
||||
|
||||
writeFileSync(
|
||||
resolve(process.cwd(), '.dotbuild', 'metadata'),
|
||||
JSON.stringify({
|
||||
sha,
|
||||
branch,
|
||||
birth: Date.now(),
|
||||
versions: config.version,
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue