Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit 5777e35

Browse files
committed
πŸŽ‰ Copy all the melon code over
1 parent f32d867 commit 5777e35

38 files changed

Lines changed: 2727 additions & 0 deletions

β€Žsrc/cmds.tsβ€Ž

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
import {
2+
bootstrap,
3+
build,
4+
discard,
5+
download,
6+
downloadArtifacts,
7+
execute,
8+
exportFile,
9+
exportPatches,
10+
fixLineEndings,
11+
importPatches,
12+
init,
13+
licenseCheck,
14+
melonPackage,
15+
reset,
16+
run,
17+
setBranch,
18+
status,
19+
test
20+
} from "./commands";
21+
import { Cmd } from "./types";
22+
23+
export const commands: Cmd[] = [
24+
{
25+
cmd: "bootstrap",
26+
description: "Bootstrap Dot Browser.",
27+
controller: bootstrap
28+
},
29+
{
30+
cmd: "build [os]",
31+
aliases: ["b"],
32+
description:
33+
"Build Dot Browser. Specify the OS param for cross-platform builds.",
34+
options: [
35+
{
36+
arg: "--a, --arch <architecture>",
37+
description:
38+
"Specify architecture for build"
39+
}
40+
],
41+
controller: build
42+
},
43+
{
44+
cmd: "discard <file>",
45+
description: "Discard a files changes.",
46+
options: [
47+
{
48+
arg: "--keep, --keep-patch",
49+
description:
50+
"Keep the patch file instead of removing it"
51+
}
52+
],
53+
controller: discard
54+
},
55+
{
56+
cmd: "download [ffVersion]",
57+
description: "Download Firefox.",
58+
controller: download
59+
},
60+
{
61+
cmd: "download-artifacts",
62+
description:
63+
"Download Windows artifacts from GitHub.",
64+
flags: {
65+
platforms: ["win32"]
66+
},
67+
controller: downloadArtifacts
68+
},
69+
{
70+
cmd: "execute",
71+
description:
72+
"Execute a command inside the engine directory.",
73+
controller: execute
74+
},
75+
{
76+
cmd: "export-file <file>",
77+
description: "Export a changed file as a patch.",
78+
controller: exportFile
79+
},
80+
{
81+
cmd: "export",
82+
aliases: ["export-patches"],
83+
description:
84+
"Export the changed files as patches.",
85+
controller: exportPatches
86+
},
87+
{
88+
cmd: "lfify",
89+
aliases: ["fix-le"],
90+
description:
91+
"Convert CRLF line endings to Unix LF line endings.",
92+
controller: fixLineEndings
93+
},
94+
{
95+
cmd: "import [type]",
96+
aliases: ["import-patches", "i"],
97+
description: "Import patches into the browser.",
98+
options: [
99+
{
100+
arg: "-m, --minimal",
101+
description:
102+
"Import patches in minimal mode"
103+
},
104+
{
105+
arg: "--noignore",
106+
description:
107+
"Bypass .gitignore. You shouldn't really use this."
108+
}
109+
],
110+
controller: importPatches
111+
},
112+
{
113+
cmd: "init <source>",
114+
aliases: ["initialise", "initialize"],
115+
description: "Initialise the Firefox directory.",
116+
controller: init
117+
},
118+
{
119+
cmd: "license-check",
120+
aliases: ["lc"],
121+
description:
122+
"Check the src directory for the absence of MPL-2.0 header.",
123+
controller: licenseCheck
124+
},
125+
{
126+
cmd: "package",
127+
aliases: ["pack"],
128+
description:
129+
"Package the browser for distribution.",
130+
controller: melonPackage
131+
},
132+
{
133+
cmd: "reset",
134+
description:
135+
"Reset the source directory to stock Firefox.",
136+
controller: reset
137+
},
138+
{
139+
cmd: "run [chrome]",
140+
aliases: ["r", "open"],
141+
description: "Run the browser.",
142+
controller: run
143+
},
144+
{
145+
cmd: "set-branch <branch>",
146+
description: "Change the default branch.",
147+
controller: setBranch
148+
},
149+
{
150+
cmd: "status",
151+
description:
152+
"Status and files changed for src directory.",
153+
controller: status
154+
},
155+
{
156+
cmd: "test",
157+
description:
158+
"Run the test suite for Dot Browser.",
159+
controller: test
160+
}
161+
];

β€Žsrc/commands/bootstrap.tsβ€Ž

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/// <reference path="./linus.d.ts"/>
2+
3+
import distro from "linus";
4+
import { bin_name } from "..";
5+
import { log } from "../";
6+
import { ENGINE_DIR } from "../constants";
7+
import { dispatch } from "../utils";
8+
import { pacmanInstall } from "./bootstrap/arch";
9+
10+
export const bootstrap = async () => {
11+
if (process.platform == "win32")
12+
log.error(
13+
`You do not need to bootstrap on Windows. As long as you ran |${bin_name} download-artifacts| everything should work fine.`
14+
);
15+
16+
log.info(`Bootstrapping Dot Browser for Desktop...`);
17+
18+
const args = ["--application-choice", "browser"];
19+
20+
if (process.platform === "linux") {
21+
linuxBootstrap();
22+
} else {
23+
console.info(
24+
`Custom bootstrapping doesn't work on ${process.platform}. Consider contributing to improve support`
25+
);
26+
27+
console.info(
28+
`Passing through to |mach bootstrap|`
29+
);
30+
31+
await dispatch(
32+
`./mach`,
33+
["bootstrap", ...args],
34+
ENGINE_DIR
35+
);
36+
}
37+
};
38+
39+
function getDistro(): Promise<string> {
40+
return new Promise((resolve, reject) => {
41+
distro.name((err: Error, name: string) => {
42+
if (name) resolve(name);
43+
else {
44+
reject(
45+
err || "Failed to get linux distro"
46+
);
47+
}
48+
});
49+
});
50+
}
51+
52+
async function linuxBootstrap() {
53+
const distro = await getDistro();
54+
55+
switch (distro) {
56+
// Both arch and manjaro use the same package repo and the same package manager
57+
case "ManjaroLinux":
58+
case "ArchLinux":
59+
console.log(
60+
await pacmanInstall(
61+
// Shared packages
62+
"base-devel",
63+
"nodejs",
64+
"unzip",
65+
"zip",
66+
67+
// Needed for desktop apps
68+
"alsa-lib",
69+
"dbus-glib",
70+
"gtk3",
71+
"libevent",
72+
"libvpx",
73+
"libxt",
74+
"mime-types",
75+
"nasm",
76+
"startup-notification",
77+
"gst-plugins-base-libs",
78+
"libpulse",
79+
"xorg-server-xvfb",
80+
"gst-libav",
81+
"gst-plugins-good"
82+
)
83+
);
84+
break;
85+
86+
default:
87+
log.error(`Unimplemented distro '${distro}'`);
88+
}
89+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import execa from "execa";
2+
3+
export async function pacmanInstall(
4+
...packages: string[]
5+
): Promise<string> {
6+
return (
7+
await execa("sudo", [
8+
"pacman",
9+
"--noconfirm",
10+
"-S",
11+
...packages
12+
])
13+
).stdout;
14+
}

0 commit comments

Comments
Β (0)