This repository has been archived by the owner on Feb 15, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import { | ||
bootstrap, | ||
build, | ||
discard, | ||
download, | ||
downloadArtifacts, | ||
execute, | ||
exportFile, | ||
exportPatches, | ||
fixLineEndings, | ||
importPatches, | ||
init, | ||
licenseCheck, | ||
melonPackage, | ||
reset, | ||
run, | ||
setBranch, | ||
status, | ||
test | ||
} from "./commands"; | ||
import { Cmd } from "./types"; | ||
|
||
export const commands: Cmd[] = [ | ||
{ | ||
cmd: "bootstrap", | ||
description: "Bootstrap Dot Browser.", | ||
controller: bootstrap | ||
}, | ||
{ | ||
cmd: "build [os]", | ||
aliases: ["b"], | ||
description: | ||
"Build Dot Browser. Specify the OS param for cross-platform builds.", | ||
options: [ | ||
{ | ||
arg: "--a, --arch <architecture>", | ||
description: | ||
"Specify architecture for build" | ||
} | ||
], | ||
controller: build | ||
}, | ||
{ | ||
cmd: "discard <file>", | ||
description: "Discard a files changes.", | ||
options: [ | ||
{ | ||
arg: "--keep, --keep-patch", | ||
description: | ||
"Keep the patch file instead of removing it" | ||
} | ||
], | ||
controller: discard | ||
}, | ||
{ | ||
cmd: "download [ffVersion]", | ||
description: "Download Firefox.", | ||
controller: download | ||
}, | ||
{ | ||
cmd: "download-artifacts", | ||
description: | ||
"Download Windows artifacts from GitHub.", | ||
flags: { | ||
platforms: ["win32"] | ||
}, | ||
controller: downloadArtifacts | ||
}, | ||
{ | ||
cmd: "execute", | ||
description: | ||
"Execute a command inside the engine directory.", | ||
controller: execute | ||
}, | ||
{ | ||
cmd: "export-file <file>", | ||
description: "Export a changed file as a patch.", | ||
controller: exportFile | ||
}, | ||
{ | ||
cmd: "export", | ||
aliases: ["export-patches"], | ||
description: | ||
"Export the changed files as patches.", | ||
controller: exportPatches | ||
}, | ||
{ | ||
cmd: "lfify", | ||
aliases: ["fix-le"], | ||
description: | ||
"Convert CRLF line endings to Unix LF line endings.", | ||
controller: fixLineEndings | ||
}, | ||
{ | ||
cmd: "import [type]", | ||
aliases: ["import-patches", "i"], | ||
description: "Import patches into the browser.", | ||
options: [ | ||
{ | ||
arg: "-m, --minimal", | ||
description: | ||
"Import patches in minimal mode" | ||
}, | ||
{ | ||
arg: "--noignore", | ||
description: | ||
"Bypass .gitignore. You shouldn't really use this." | ||
} | ||
], | ||
controller: importPatches | ||
}, | ||
{ | ||
cmd: "init <source>", | ||
aliases: ["initialise", "initialize"], | ||
description: "Initialise the Firefox directory.", | ||
controller: init | ||
}, | ||
{ | ||
cmd: "license-check", | ||
aliases: ["lc"], | ||
description: | ||
"Check the src directory for the absence of MPL-2.0 header.", | ||
controller: licenseCheck | ||
}, | ||
{ | ||
cmd: "package", | ||
aliases: ["pack"], | ||
description: | ||
"Package the browser for distribution.", | ||
controller: melonPackage | ||
}, | ||
{ | ||
cmd: "reset", | ||
description: | ||
"Reset the source directory to stock Firefox.", | ||
controller: reset | ||
}, | ||
{ | ||
cmd: "run [chrome]", | ||
aliases: ["r", "open"], | ||
description: "Run the browser.", | ||
controller: run | ||
}, | ||
{ | ||
cmd: "set-branch <branch>", | ||
description: "Change the default branch.", | ||
controller: setBranch | ||
}, | ||
{ | ||
cmd: "status", | ||
description: | ||
"Status and files changed for src directory.", | ||
controller: status | ||
}, | ||
{ | ||
cmd: "test", | ||
description: | ||
"Run the test suite for Dot Browser.", | ||
controller: test | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/// <reference path="./linus.d.ts"/> | ||
|
||
import distro from "linus"; | ||
import { bin_name } from ".."; | ||
import { log } from "../"; | ||
import { ENGINE_DIR } from "../constants"; | ||
import { dispatch } from "../utils"; | ||
import { pacmanInstall } from "./bootstrap/arch"; | ||
|
||
export const bootstrap = async () => { | ||
if (process.platform == "win32") | ||
log.error( | ||
`You do not need to bootstrap on Windows. As long as you ran |${bin_name} download-artifacts| everything should work fine.` | ||
); | ||
|
||
log.info(`Bootstrapping Dot Browser for Desktop...`); | ||
|
||
const args = ["--application-choice", "browser"]; | ||
|
||
if (process.platform === "linux") { | ||
linuxBootstrap(); | ||
} else { | ||
console.info( | ||
`Custom bootstrapping doesn't work on ${process.platform}. Consider contributing to improve support` | ||
); | ||
|
||
console.info( | ||
`Passing through to |mach bootstrap|` | ||
); | ||
|
||
await dispatch( | ||
`./mach`, | ||
["bootstrap", ...args], | ||
ENGINE_DIR | ||
); | ||
} | ||
}; | ||
|
||
function getDistro(): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
distro.name((err: Error, name: string) => { | ||
if (name) resolve(name); | ||
else { | ||
reject( | ||
err || "Failed to get linux distro" | ||
); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async function linuxBootstrap() { | ||
const distro = await getDistro(); | ||
|
||
switch (distro) { | ||
// Both arch and manjaro use the same package repo and the same package manager | ||
case "ManjaroLinux": | ||
case "ArchLinux": | ||
console.log( | ||
await pacmanInstall( | ||
// Shared packages | ||
"base-devel", | ||
"nodejs", | ||
"unzip", | ||
"zip", | ||
|
||
// Needed for desktop apps | ||
"alsa-lib", | ||
"dbus-glib", | ||
"gtk3", | ||
"libevent", | ||
"libvpx", | ||
"libxt", | ||
"mime-types", | ||
"nasm", | ||
"startup-notification", | ||
"gst-plugins-base-libs", | ||
"libpulse", | ||
"xorg-server-xvfb", | ||
"gst-libav", | ||
"gst-plugins-good" | ||
) | ||
); | ||
break; | ||
|
||
default: | ||
log.error(`Unimplemented distro '${distro}'`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import execa from "execa"; | ||
|
||
export async function pacmanInstall( | ||
...packages: string[] | ||
): Promise<string> { | ||
return ( | ||
await execa("sudo", [ | ||
"pacman", | ||
"--noconfirm", | ||
"-S", | ||
...packages | ||
]) | ||
).stdout; | ||
} |
Oops, something went wrong.