mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-08 01:10:03 +02:00
🚨 Fix eslint warnings
This commit is contained in:
parent
6f6ce08a89
commit
b0eda8e28e
29 changed files with 175 additions and 167 deletions
|
@ -6,7 +6,6 @@
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"airbnb",
|
|
||||||
"eslint-config-prettier"
|
"eslint-config-prettier"
|
||||||
],
|
],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
|
|
92
docs/static/js.js
vendored
92
docs/static/js.js
vendored
|
@ -1,14 +1,14 @@
|
||||||
// search script, borrowed from book theme
|
// search script, borrowed from book theme
|
||||||
|
|
||||||
function debounce(func, wait) {
|
function debounce(func, wait) {
|
||||||
var timeout;
|
let timeout;
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
var context = this;
|
const context = this;
|
||||||
var args = arguments;
|
const args = arguments;
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
|
||||||
timeout = setTimeout(function () {
|
timeout = setTimeout(() => {
|
||||||
timeout = null;
|
timeout = null;
|
||||||
func.apply(context, args);
|
func.apply(context, args);
|
||||||
}, wait);
|
}, wait);
|
||||||
|
@ -26,30 +26,28 @@ function debounce(func, wait) {
|
||||||
// maximum sum. If there are multiple maximas, then get the last one.
|
// maximum sum. If there are multiple maximas, then get the last one.
|
||||||
// Enclose the terms in <b>.
|
// Enclose the terms in <b>.
|
||||||
function makeTeaser(body, terms) {
|
function makeTeaser(body, terms) {
|
||||||
var TERM_WEIGHT = 40;
|
const TERM_WEIGHT = 40;
|
||||||
var NORMAL_WORD_WEIGHT = 2;
|
const NORMAL_WORD_WEIGHT = 2;
|
||||||
var FIRST_WORD_WEIGHT = 8;
|
const FIRST_WORD_WEIGHT = 8;
|
||||||
var TEASER_MAX_WORDS = 30;
|
const TEASER_MAX_WORDS = 30;
|
||||||
|
|
||||||
var stemmedTerms = terms.map(function (w) {
|
const stemmedTerms = terms.map((w) => elasticlunr.stemmer(w.toLowerCase()));
|
||||||
return elasticlunr.stemmer(w.toLowerCase());
|
let termFound = false;
|
||||||
});
|
let index = 0;
|
||||||
var termFound = false;
|
const weighted = []; // contains elements of ["word", weight, index_in_document]
|
||||||
var index = 0;
|
|
||||||
var weighted = []; // contains elements of ["word", weight, index_in_document]
|
|
||||||
|
|
||||||
// split in sentences, then words
|
// split in sentences, then words
|
||||||
var sentences = body.toLowerCase().split(". ");
|
const sentences = body.toLowerCase().split(". ");
|
||||||
|
|
||||||
for (var i in sentences) {
|
for (var i in sentences) {
|
||||||
var words = sentences[i].split(" ");
|
const words = sentences[i].split(" ");
|
||||||
var value = FIRST_WORD_WEIGHT;
|
let value = FIRST_WORD_WEIGHT;
|
||||||
|
|
||||||
for (var j in words) {
|
for (const j in words) {
|
||||||
var word = words[j];
|
var word = words[j];
|
||||||
|
|
||||||
if (word.length > 0) {
|
if (word.length > 0) {
|
||||||
for (var k in stemmedTerms) {
|
for (const k in stemmedTerms) {
|
||||||
if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {
|
if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {
|
||||||
value = TERM_WEIGHT;
|
value = TERM_WEIGHT;
|
||||||
termFound = true;
|
termFound = true;
|
||||||
|
@ -70,10 +68,10 @@ function debounce(func, wait) {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
var windowWeights = [];
|
const windowWeights = [];
|
||||||
var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);
|
const windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);
|
||||||
// We add a window with all the weights first
|
// We add a window with all the weights first
|
||||||
var curSum = 0;
|
let curSum = 0;
|
||||||
for (var i = 0; i < windowSize; i++) {
|
for (var i = 0; i < windowSize; i++) {
|
||||||
curSum += weighted[i][1];
|
curSum += weighted[i][1];
|
||||||
}
|
}
|
||||||
|
@ -86,9 +84,9 @@ function debounce(func, wait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we didn't find the term, just pick the first window
|
// If we didn't find the term, just pick the first window
|
||||||
var maxSumIndex = 0;
|
let maxSumIndex = 0;
|
||||||
if (termFound) {
|
if (termFound) {
|
||||||
var maxFound = 0;
|
let maxFound = 0;
|
||||||
// backwards
|
// backwards
|
||||||
for (var i = windowWeights.length - 1; i >= 0; i--) {
|
for (var i = windowWeights.length - 1; i >= 0; i--) {
|
||||||
if (windowWeights[i] > maxFound) {
|
if (windowWeights[i] > maxFound) {
|
||||||
|
@ -98,8 +96,8 @@ function debounce(func, wait) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var teaser = [];
|
const teaser = [];
|
||||||
var startIndex = weighted[maxSumIndex][2];
|
let startIndex = weighted[maxSumIndex][2];
|
||||||
for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {
|
for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {
|
||||||
var word = weighted[i];
|
var word = weighted[i];
|
||||||
if (startIndex < word[2]) {
|
if (startIndex < word[2]) {
|
||||||
|
@ -124,7 +122,7 @@ function debounce(func, wait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatSearchResultItem(item, terms) {
|
function formatSearchResultItem(item, terms) {
|
||||||
var li = document.createElement("li");
|
const li = document.createElement("li");
|
||||||
li.classList.add("search-results__item");
|
li.classList.add("search-results__item");
|
||||||
li.innerHTML = `<a href="${item.ref}">${item.doc.title}</a>`;
|
li.innerHTML = `<a href="${item.ref}">${item.doc.title}</a>`;
|
||||||
li.innerHTML += `<div class="search-results__teaser">${makeTeaser(item.doc.body, terms)}</div>`;
|
li.innerHTML += `<div class="search-results__teaser">${makeTeaser(item.doc.body, terms)}</div>`;
|
||||||
|
@ -133,9 +131,9 @@ function debounce(func, wait) {
|
||||||
|
|
||||||
// Go from the book view to the search view
|
// Go from the book view to the search view
|
||||||
function toggleSearchMode() {
|
function toggleSearchMode() {
|
||||||
var $wrapContent = document.querySelector("#wrap");
|
const $wrapContent = document.querySelector("#wrap");
|
||||||
var $searchIcon = document.querySelector("#search-ico");
|
const $searchIcon = document.querySelector("#search-ico");
|
||||||
var $searchContainer = document.querySelector(".search-container");
|
const $searchContainer = document.querySelector(".search-container");
|
||||||
if ($searchContainer.classList.contains("search-container--is-visible")) {
|
if ($searchContainer.classList.contains("search-container--is-visible")) {
|
||||||
$searchContainer.classList.remove("search-container--is-visible");
|
$searchContainer.classList.remove("search-container--is-visible");
|
||||||
$wrapContent.style.display = "";
|
$wrapContent.style.display = "";
|
||||||
|
@ -149,30 +147,30 @@ function debounce(func, wait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSearch() {
|
function initSearch() {
|
||||||
var $searchInput = document.getElementById("search");
|
const $searchInput = document.getElementById("search");
|
||||||
if (!$searchInput) {
|
if (!$searchInput) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var $searchIcon = document.querySelector("#search-ico");
|
const $searchIcon = document.querySelector("#search-ico");
|
||||||
$searchIcon.addEventListener("click", toggleSearchMode);
|
$searchIcon.addEventListener("click", toggleSearchMode);
|
||||||
|
|
||||||
var $searchResults = document.querySelector(".search-results");
|
const $searchResults = document.querySelector(".search-results");
|
||||||
var $searchResultsHeader = document.querySelector(".search-results__header");
|
const $searchResultsHeader = document.querySelector(".search-results__header");
|
||||||
var $searchResultsItems = document.querySelector(".search-results__items");
|
const $searchResultsItems = document.querySelector(".search-results__items");
|
||||||
var MAX_ITEMS = 100;
|
const MAX_ITEMS = 100;
|
||||||
|
|
||||||
var options = {
|
const options = {
|
||||||
bool: "AND",
|
bool: "AND",
|
||||||
fields: {
|
fields: {
|
||||||
title: {boost: 2},
|
title: {boost: 2},
|
||||||
body: {boost: 1},
|
body: {boost: 1},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var currentTerm = "";
|
let currentTerm = "";
|
||||||
var index = elasticlunr.Index.load(window.searchIndex);
|
const index = elasticlunr.Index.load(window.searchIndex);
|
||||||
|
|
||||||
$searchInput.addEventListener("keyup", debounce(function() {
|
$searchInput.addEventListener("keyup", debounce(() => {
|
||||||
var term = $searchInput.value.trim();
|
const term = $searchInput.value.trim();
|
||||||
if (term === currentTerm || !index) {
|
if (term === currentTerm || !index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -182,9 +180,7 @@ function debounce(func, wait) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = index.search(term, options).filter(function (r) {
|
const results = index.search(term, options).filter((r) => r.doc.body !== "");
|
||||||
return r.doc.body !== "";
|
|
||||||
});
|
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
$searchResultsHeader.innerText = `Nothing like «${term}»`;
|
$searchResultsHeader.innerText = `Nothing like «${term}»`;
|
||||||
return;
|
return;
|
||||||
|
@ -192,7 +188,7 @@ function debounce(func, wait) {
|
||||||
|
|
||||||
currentTerm = term;
|
currentTerm = term;
|
||||||
$searchResultsHeader.innerText = `${results.length} found for «${term}»:`;
|
$searchResultsHeader.innerText = `${results.length} found for «${term}»:`;
|
||||||
for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {
|
for (let i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {
|
||||||
if (!results[i].doc.body) {
|
if (!results[i].doc.body) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -215,8 +211,8 @@ function debounce(func, wait) {
|
||||||
// mobile
|
// mobile
|
||||||
|
|
||||||
function burger() {
|
function burger() {
|
||||||
let x = document.querySelector("#trees");
|
const x = document.querySelector("#trees");
|
||||||
let y = document.querySelector("#mobile");
|
const y = document.querySelector("#mobile");
|
||||||
|
|
||||||
if (x.style.display === "block") {
|
if (x.style.display === "block") {
|
||||||
x.style.display = "none";
|
x.style.display = "none";
|
||||||
|
@ -277,7 +273,7 @@ function copyCodeBlockExecCommand(codeToCopy, highlightDiv) {
|
||||||
function codeWasCopied(button) {
|
function codeWasCopied(button) {
|
||||||
button.blur();
|
button.blur();
|
||||||
button.innerHTML = "";
|
button.innerHTML = "";
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
button.innerHTML = "";
|
button.innerHTML = "";
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/// <reference path="./linus.d.ts"/>
|
/// <reference path="./linus.d.ts"/>
|
||||||
|
|
||||||
import distro from 'linus'
|
import distro from 'linus'
|
||||||
import { bin_name } from '..'
|
import { bin_name , log } from '..'
|
||||||
import { log } from '../'
|
|
||||||
import { ENGINE_DIR } from '../constants'
|
import { ENGINE_DIR } from '../constants'
|
||||||
import { dispatch } from '../utils'
|
import { dispatch } from '../utils'
|
||||||
import { pacmanInstall } from './bootstrap/arch'
|
import { pacmanInstall } from './bootstrap/arch'
|
||||||
|
|
|
@ -99,14 +99,14 @@ const genericBuild = async (os: string, tier: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseDate = (d: number) => {
|
const parseDate = (d: number) => {
|
||||||
d = d / 1000
|
d /= 1000
|
||||||
var h = Math.floor(d / 3600)
|
const h = Math.floor(d / 3600)
|
||||||
var m = Math.floor((d % 3600) / 60)
|
const m = Math.floor((d % 3600) / 60)
|
||||||
var s = Math.floor((d % 3600) % 60)
|
const s = Math.floor((d % 3600) % 60)
|
||||||
|
|
||||||
var hDisplay = h > 0 ? h + (h == 1 ? ' hour, ' : ' hours, ') : ''
|
const hDisplay = h > 0 ? h + (h == 1 ? ' hour, ' : ' hours, ') : ''
|
||||||
var mDisplay = m > 0 ? m + (m == 1 ? ' minute, ' : ' minutes, ') : ''
|
const mDisplay = m > 0 ? m + (m == 1 ? ' minute, ' : ' minutes, ') : ''
|
||||||
var sDisplay = s > 0 ? s + (s == 1 ? ' second' : ' seconds') : ''
|
const sDisplay = s > 0 ? s + (s == 1 ? ' second' : ' seconds') : ''
|
||||||
return hDisplay + mDisplay + sDisplay
|
return hDisplay + mDisplay + sDisplay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ interface Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const build = async (tier: string, options: Options) => {
|
export const build = async (tier: string, options: Options) => {
|
||||||
let d = Date.now()
|
const d = Date.now()
|
||||||
|
|
||||||
// Host build
|
// Host build
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ export const build = async (tier: string, options: Options) => {
|
||||||
ARCHITECTURE
|
ARCHITECTURE
|
||||||
)}.`
|
)}.`
|
||||||
)
|
)
|
||||||
else arch = options.arch
|
arch = options.arch
|
||||||
}
|
}
|
||||||
|
|
||||||
await patchCheck()
|
await patchCheck()
|
||||||
|
|
|
@ -39,7 +39,7 @@ export const discard = async (file: string, options: Options) => {
|
||||||
|
|
||||||
const patchFile = resolve(
|
const patchFile = resolve(
|
||||||
PATCHES_DIR,
|
PATCHES_DIR,
|
||||||
file.replace(/\//g, '-').replace(/\./g, '-') + '.patch'
|
`${file.replace(/\//g, '-').replace(/\./g, '-') }.patch`
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!existsSync(patchFile))
|
if (!existsSync(patchFile))
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const downloadArtifacts = async () => {
|
||||||
let home = homedir().split(sep).join(posix.sep)
|
let home = homedir().split(sep).join(posix.sep)
|
||||||
|
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
home = '/' + home.replace(/\:/, '').replace(/\\/g, '/').toLowerCase()
|
home = `/${ home.replace(/\:/, '').replace(/\\/g, '/').toLowerCase()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(`Downloading Windows artifacts...`)
|
log.info(`Downloading Windows artifacts...`)
|
||||||
|
@ -38,10 +38,10 @@ export const downloadArtifacts = async () => {
|
||||||
data.on('data', (chunk: any) => {
|
data.on('data', (chunk: any) => {
|
||||||
receivedBytes += chunk.length
|
receivedBytes += chunk.length
|
||||||
|
|
||||||
let rand = Math.floor(Math.random() * 1000 + 1)
|
const rand = Math.floor(Math.random() * 1000 + 1)
|
||||||
|
|
||||||
if (rand > 999.5) {
|
if (rand > 999.5) {
|
||||||
let percentCompleted = parseInt(
|
const percentCompleted = parseInt(
|
||||||
Math.round((receivedBytes * 100) / length).toFixed(0)
|
Math.round((receivedBytes * 100) / length).toFixed(0)
|
||||||
)
|
)
|
||||||
if (percentCompleted % 2 == 0 || percentCompleted >= 100) return
|
if (percentCompleted % 2 == 0 || percentCompleted >= 100) return
|
||||||
|
|
|
@ -28,7 +28,7 @@ const onData = (data: any) => {
|
||||||
|
|
||||||
d.split('\n').forEach((line: any) => {
|
d.split('\n').forEach((line: any) => {
|
||||||
if (line.trim().length !== 0) {
|
if (line.trim().length !== 0) {
|
||||||
let t = line.split(' ')
|
const t = line.split(' ')
|
||||||
t.shift()
|
t.shift()
|
||||||
initProgressText = t.join(' ')
|
initProgressText = t.join(' ')
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ const unpack = async (name: string, version: string) => {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
ensureDirSync(ENGINE_DIR)
|
ensureDirSync(ENGINE_DIR)
|
||||||
|
|
||||||
let tarProc = execa('tar', [
|
const tarProc = execa('tar', [
|
||||||
'--transform',
|
'--transform',
|
||||||
`s,firefox-${gFFVersion},engine,`,
|
`s,firefox-${gFFVersion},engine,`,
|
||||||
`--show-transformed`,
|
`--show-transformed`,
|
||||||
|
@ -161,7 +161,7 @@ export const download = async (firefoxVersion?: string) => {
|
||||||
)
|
)
|
||||||
) ||
|
) ||
|
||||||
fs.existsSync(
|
fs.existsSync(
|
||||||
resolve(process.cwd(), 'firefox', 'firefox-' + version.split('b')[0])
|
resolve(process.cwd(), 'firefox', `firefox-${ version.split('b')[0]}`)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
log.error(
|
log.error(
|
||||||
|
@ -187,10 +187,10 @@ export const download = async (firefoxVersion?: string) => {
|
||||||
data.on('data', (chunk: any) => {
|
data.on('data', (chunk: any) => {
|
||||||
receivedBytes += chunk.length
|
receivedBytes += chunk.length
|
||||||
|
|
||||||
let rand = Math.floor(Math.random() * 1000 + 1)
|
const rand = Math.floor(Math.random() * 1000 + 1)
|
||||||
|
|
||||||
if (rand > 999.5) {
|
if (rand > 999.5) {
|
||||||
let percentCompleted = parseInt(
|
const percentCompleted = parseInt(
|
||||||
Math.round((receivedBytes * 100) / length).toFixed(0)
|
Math.round((receivedBytes * 100) / length).toFixed(0)
|
||||||
)
|
)
|
||||||
if (percentCompleted % 2 == 0 || percentCompleted >= 100) return
|
if (percentCompleted % 2 == 0 || percentCompleted >= 100) return
|
||||||
|
|
|
@ -29,10 +29,10 @@ export const exportFile = async (file: string) => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const name =
|
const name =
|
||||||
file
|
`${file
|
||||||
.split('/')
|
.split('/')
|
||||||
[file.replace(/\./g, '-').split('/').length - 1].replace(/\./g, '-') +
|
[file.replace(/\./g, '-').split('/').length - 1].replace(/\./g, '-')
|
||||||
'.patch'
|
}.patch`
|
||||||
|
|
||||||
const patchPath = file.replace(/\./g, '-').split('/').slice(0, -1)
|
const patchPath = file.replace(/\./g, '-').split('/').slice(0, -1)
|
||||||
|
|
||||||
|
|
|
@ -22,27 +22,25 @@ const flags: {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getFiles = async (flags: string, cwd: string) => {
|
const getFiles = async (flags: string, cwd: string) => {
|
||||||
let { stdout: ignored } = await execa(
|
const { stdout: ignored } = await execa(
|
||||||
'git',
|
'git',
|
||||||
['ls-files', `-${flags.toLowerCase()}`, '-i', '-o', '--exclude-standard'],
|
['ls-files', `-${flags.toLowerCase()}`, '-i', '-o', '--exclude-standard'],
|
||||||
{ cwd }
|
{ cwd }
|
||||||
)
|
)
|
||||||
|
|
||||||
let { stdout: fls } = await execa(
|
const { stdout: fls } = await execa(
|
||||||
'git',
|
'git',
|
||||||
['diff', `--diff-filter=${flags}`, '--name-only', '--ignore-space-at-eol'],
|
['diff', `--diff-filter=${flags}`, '--name-only', '--ignore-space-at-eol'],
|
||||||
{ cwd }
|
{ cwd }
|
||||||
)
|
)
|
||||||
|
|
||||||
const files = fls.split('\n').filter((i: any) => {
|
const files = fls.split('\n').filter((i: any) => !(ignored.split('\n').includes(i) || i == '.gitignore')) // this filters out the manual patches
|
||||||
return !(ignored.split('\n').includes(i) || i == '.gitignore')
|
|
||||||
}) // this filters out the manual patches
|
|
||||||
|
|
||||||
log.info(`Ignoring ${ignored.split('\n').length} files...`)
|
log.info(`Ignoring ${ignored.split('\n').length} files...`)
|
||||||
|
|
||||||
const fileNames: any = files.map((f: any) => {
|
const fileNames: any = files.map((f: any) => {
|
||||||
if (f.length !== 0) {
|
if (f.length !== 0) {
|
||||||
return f.replace(/\//g, '-').replace(/\./g, '-') + '.patch'
|
return `${f.replace(/\//g, '-').replace(/\./g, '-') }.patch`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -52,7 +50,7 @@ const getFiles = async (flags: string, cwd: string) => {
|
||||||
const exportModified = async (patchesDir: string, cwd: string) => {
|
const exportModified = async (patchesDir: string, cwd: string) => {
|
||||||
const { files, fileNames } = await getFiles('M', cwd)
|
const { files, fileNames } = await getFiles('M', cwd)
|
||||||
|
|
||||||
var filesWritten = 0
|
let filesWritten = 0
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
files.map(async (file: any, i: any) => {
|
files.map(async (file: any, i: any) => {
|
||||||
|
@ -81,7 +79,7 @@ const exportModified = async (patchesDir: string, cwd: string) => {
|
||||||
++filesWritten
|
++filesWritten
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(e)
|
log.error(e)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -101,11 +99,10 @@ const exportFlag = async (flag: string, cwd: string, actions: any[]) => {
|
||||||
return actions
|
return actions
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportManual = async (cwd: string) => {
|
const exportManual = async (cwd: string) => new Promise(async (resol) => {
|
||||||
return new Promise(async (resol) => {
|
|
||||||
manualPatches.forEach((patch) => {
|
manualPatches.forEach((patch) => {
|
||||||
if (patch.action == 'copy') {
|
if (patch.action == 'copy') {
|
||||||
if (typeof patch.src == 'string') {
|
if (typeof patch.src === 'string') {
|
||||||
const inSrc = resolve(cwd, patch.src)
|
const inSrc = resolve(cwd, patch.src)
|
||||||
const outsideSrc = resolve(COMMON_DIR, patch.src)
|
const outsideSrc = resolve(COMMON_DIR, patch.src)
|
||||||
|
|
||||||
|
@ -129,14 +126,13 @@ const exportManual = async (cwd: string) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
export const exportPatches = async () => {
|
export const exportPatches = async () => {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'export-patches has been deprecated in favour of export-file. This change has been made to limit the amount of active patches we have in the tree.'
|
'export-patches has been deprecated in favour of export-file. This change has been made to limit the amount of active patches we have in the tree.'
|
||||||
)
|
)
|
||||||
|
|
||||||
let actions: any[] = []
|
const actions: any[] = []
|
||||||
|
|
||||||
log.info(`Wiping patches directory...`)
|
log.info(`Wiping patches directory...`)
|
||||||
console.log()
|
console.log()
|
||||||
|
|
|
@ -19,11 +19,11 @@ const importManual = async (minimal?: boolean, noIgnore?: boolean) => {
|
||||||
if (!minimal) console.log()
|
if (!minimal) console.log()
|
||||||
|
|
||||||
return new Promise(async (res, rej) => {
|
return new Promise(async (res, rej) => {
|
||||||
var total = 0
|
const total = 0
|
||||||
|
|
||||||
var i = 0
|
let i = 0
|
||||||
|
|
||||||
for await (let { name, action, src } of manualPatches) {
|
for await (const { name, action, src } of manualPatches) {
|
||||||
++i
|
++i
|
||||||
|
|
||||||
const patch = new ManualPatch(
|
const patch = new ManualPatch(
|
||||||
|
@ -69,7 +69,7 @@ const importPatchFiles = async (minimal?: boolean, noIgnore?: boolean) => {
|
||||||
|
|
||||||
await delay(100)
|
await delay(100)
|
||||||
|
|
||||||
var i = 0
|
let i = 0
|
||||||
|
|
||||||
for await (const patchName of patches) {
|
for await (const patchName of patches) {
|
||||||
++i
|
++i
|
||||||
|
@ -108,7 +108,7 @@ const importMelonPatches = async (minimal?: boolean, noIgnore?: boolean) => {
|
||||||
|
|
||||||
await delay(100)
|
await delay(100)
|
||||||
|
|
||||||
var i = 0
|
let i = 0
|
||||||
|
|
||||||
for await (const patch of patches) {
|
for await (const patch of patches) {
|
||||||
++i
|
++i
|
||||||
|
|
|
@ -19,9 +19,9 @@ export const licenseCheck = async () => {
|
||||||
return data.split('diff --git a/')[1].split(' b/')[0]
|
return data.split('diff --git a/')[1].split(' b/')[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
let passed: string[] = []
|
const passed: string[] = []
|
||||||
let failed: string[] = []
|
const failed: string[] = []
|
||||||
let ignored: string[] = []
|
const ignored: string[] = []
|
||||||
|
|
||||||
originalPaths.forEach((p) => {
|
originalPaths.forEach((p) => {
|
||||||
const data = readFileSync(resolve(ENGINE_DIR, p), 'utf-8')
|
const data = readFileSync(resolve(ENGINE_DIR, p), 'utf-8')
|
||||||
|
@ -32,7 +32,7 @@ export const licenseCheck = async () => {
|
||||||
headerRegion.includes('This Source Code Form') &&
|
headerRegion.includes('This Source Code Form') &&
|
||||||
headerRegion.includes('copy of the MPL')
|
headerRegion.includes('copy of the MPL')
|
||||||
|
|
||||||
const isIgnored = ignoredExt.find((i) => p.endsWith(i)) ? true : false
|
const isIgnored = !!ignoredExt.find((i) => p.endsWith(i))
|
||||||
isIgnored && ignored.push(p)
|
isIgnored && ignored.push(p)
|
||||||
|
|
||||||
if (!isIgnored) {
|
if (!isIgnored) {
|
||||||
|
@ -41,7 +41,7 @@ export const licenseCheck = async () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let maxPassed = 5
|
const maxPassed = 5
|
||||||
let i = 0
|
let i = 0
|
||||||
|
|
||||||
for (const p of passed) {
|
for (const p of passed) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const reset = async () => {
|
||||||
const { src, action } = patch
|
const { src, action } = patch
|
||||||
|
|
||||||
if (action == 'copy') {
|
if (action == 'copy') {
|
||||||
if (typeof src == 'string') {
|
if (typeof src === 'string') {
|
||||||
const path = resolve(ENGINE_DIR, src)
|
const path = resolve(ENGINE_DIR, src)
|
||||||
|
|
||||||
if (path !== ENGINE_DIR) {
|
if (path !== ENGINE_DIR) {
|
||||||
|
@ -51,7 +51,7 @@ export const reset = async () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let leftovers = new Set()
|
const leftovers = new Set()
|
||||||
|
|
||||||
const { stdout: origFiles } = await execa(
|
const { stdout: origFiles } = await execa(
|
||||||
'git',
|
'git',
|
||||||
|
|
|
@ -6,9 +6,7 @@ import { dispatch } from '../utils'
|
||||||
|
|
||||||
export const run = async (chrome?: string) => {
|
export const run = async (chrome?: string) => {
|
||||||
const dirs = readdirSync(ENGINE_DIR)
|
const dirs = readdirSync(ENGINE_DIR)
|
||||||
const objDirname: any = dirs.find((dir) => {
|
const objDirname: any = dirs.find((dir) => dir.startsWith('obj-'))
|
||||||
return dir.startsWith('obj-')
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!objDirname) {
|
if (!objDirname) {
|
||||||
throw new Error('Dot Browser needs to be built before you can do this.')
|
throw new Error('Dot Browser needs to be built before you can do this.')
|
||||||
|
|
|
@ -61,7 +61,7 @@ export async function setupProject() {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
if (typeof product == 'undefined') return
|
if (typeof product === 'undefined') return
|
||||||
|
|
||||||
const productVersion = await getLatestFF(product)
|
const productVersion = await getLatestFF(product)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import execa from 'execa'
|
import execa from 'execa'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
|
import { log } from '..'
|
||||||
|
|
||||||
export const BUILD_TARGETS = ['linux', 'windows', 'macos']
|
export const BUILD_TARGETS = ['linux', 'windows', 'macos']
|
||||||
|
|
||||||
|
@ -17,15 +18,21 @@ export const PATCHES_DIR = resolve(process.cwd(), 'patches')
|
||||||
export const COMMON_DIR = resolve(process.cwd(), 'common')
|
export const COMMON_DIR = resolve(process.cwd(), 'common')
|
||||||
export const CONFIGS_DIR = resolve(process.cwd(), 'configs')
|
export const CONFIGS_DIR = resolve(process.cwd(), 'configs')
|
||||||
|
|
||||||
export let CONFIG_GUESS: any = null
|
export let CONFIG_GUESS: string
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CONFIG_GUESS = execa.commandSync('./build/autoconf/config.guess', {
|
CONFIG_GUESS = execa.commandSync('./build/autoconf/config.guess', {
|
||||||
cwd: ENGINE_DIR,
|
cwd: ENGINE_DIR,
|
||||||
}).stdout
|
}).stdout
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
log.warning('An error occurred running engine/build/autoconf/config.guess')
|
||||||
|
log.warning(e)
|
||||||
|
log.askForReport()
|
||||||
|
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
export const OBJ_DIR = resolve(ENGINE_DIR, `obj-${CONFIG_GUESS}`)
|
export const OBJ_DIR = resolve(ENGINE_DIR, `obj-${CONFIG_GUESS}`)
|
||||||
|
|
||||||
export const FTL_STRING_LINE_REGEX =
|
export const FTL_STRING_LINE_REGEX =
|
||||||
/(([a-zA-Z0-9\-]*|\.[a-z\-]*) =(.*|\.)|\[[a-zA-Z0-9]*\].*(\n\s?\s?})?|\*\[[a-zA-Z0-9]*\] .*(\n\s?\s?})?)/gm
|
/(([a-zA-Z0-9-]*|\.[a-z-]*) =(.*|\.)|\[[a-zA-Z0-9]*\].*(\n\s?\s?})?|\*\[[a-zA-Z0-9]*\] .*(\n\s?\s?})?)/gm
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { dirname, join, resolve } from 'path'
|
||||||
import readline from 'readline'
|
import readline from 'readline'
|
||||||
import sharp from 'sharp'
|
import sharp from 'sharp'
|
||||||
import { log } from '..'
|
import { log } from '..'
|
||||||
import { CONFIGS_DIR, ENGINE_DIR, PATCH_ARGS, SRC_DIR } from '../constants'
|
import { CONFIGS_DIR, ENGINE_DIR, PATCH_ARGS } from '../constants'
|
||||||
import { copyManual, walkDirectory } from '../utils'
|
import { copyManual, walkDirectory } from '../utils'
|
||||||
|
|
||||||
export interface IPatchApplier {
|
export interface IPatchApplier {
|
||||||
|
@ -24,13 +24,16 @@ export interface IPatchApplier {
|
||||||
|
|
||||||
export class PatchBase {
|
export class PatchBase {
|
||||||
protected name: string
|
protected name: string
|
||||||
|
|
||||||
protected status: number[]
|
protected status: number[]
|
||||||
|
|
||||||
protected options: {
|
protected options: {
|
||||||
minimal?: boolean
|
minimal?: boolean
|
||||||
noIgnore?: boolean
|
noIgnore?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
private _done = false
|
private _done = false
|
||||||
|
|
||||||
protected error: Error | unknown
|
protected error: Error | unknown
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -46,11 +49,11 @@ export class PatchBase {
|
||||||
this.options = options
|
this.options = options
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get done() {
|
protected get done(): boolean {
|
||||||
return this._done
|
return this._done
|
||||||
}
|
}
|
||||||
|
|
||||||
protected set done(_: any) {
|
protected set done(_: boolean) {
|
||||||
this._done = _
|
this._done = _
|
||||||
|
|
||||||
if (this.options.minimal) return
|
if (this.options.minimal) return
|
||||||
|
@ -74,7 +77,7 @@ export class PatchBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected start() {
|
protected start(): void {
|
||||||
if (this.options.minimal) return
|
if (this.options.minimal) return
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
|
@ -86,13 +89,14 @@ export class PatchBase {
|
||||||
|
|
||||||
public async applyWithStatus(status: [number, number]): Promise<void> {
|
public async applyWithStatus(status: [number, number]): Promise<void> {
|
||||||
this.status = status
|
this.status = status
|
||||||
if (!(this as any).apply) return
|
if (!(this as unknown as IPatchApplier).apply) return
|
||||||
await (this as any as IPatchApplier).apply()
|
await (this as unknown as IPatchApplier).apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ManualPatch extends PatchBase implements IPatchApplier {
|
export class ManualPatch extends PatchBase implements IPatchApplier {
|
||||||
private action: 'copy' | 'delete'
|
private action: 'copy' | 'delete'
|
||||||
|
|
||||||
private src: string | string[]
|
private src: string | string[]
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -199,7 +203,7 @@ export class PatchFile extends PatchBase implements IPatchApplier {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
await execa('git', ['apply', '-R', ...PATCH_ARGS, this.src as any], {
|
await execa('git', ['apply', '-R', ...PATCH_ARGS, this.src], {
|
||||||
cwd: ENGINE_DIR,
|
cwd: ENGINE_DIR,
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -208,7 +212,7 @@ export class PatchFile extends PatchBase implements IPatchApplier {
|
||||||
|
|
||||||
const { stdout, exitCode } = await execa(
|
const { stdout, exitCode } = await execa(
|
||||||
'git',
|
'git',
|
||||||
['apply', ...PATCH_ARGS, this.src as any],
|
['apply', ...PATCH_ARGS, this.src],
|
||||||
{ cwd: ENGINE_DIR }
|
{ cwd: ENGINE_DIR }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
17
src/index.ts
17
src/index.ts
|
@ -1,27 +1,26 @@
|
||||||
import Log from './log'
|
|
||||||
|
|
||||||
// The logger must be initialized before the config generator, otherwise reference
|
|
||||||
// errors occur
|
|
||||||
export let log = new Log()
|
|
||||||
|
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
import commander, { Command } from 'commander'
|
import commander, { Command } from 'commander'
|
||||||
import { existsSync, readFileSync } from 'fs'
|
import { existsSync, readFileSync } from 'fs'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
|
import Log from './log'
|
||||||
import { errorHandler, getConfig } from './utils'
|
import { errorHandler, getConfig } from './utils'
|
||||||
import { commands } from './cmds'
|
import { commands } from './cmds'
|
||||||
import { ENGINE_DIR } from './constants'
|
import { ENGINE_DIR } from './constants'
|
||||||
import { shaCheck } from './middleware/sha-check'
|
import { shaCheck } from './middleware/sha-check'
|
||||||
import { updateCheck } from './middleware/update-check'
|
import { updateCheck } from './middleware/update-check'
|
||||||
|
|
||||||
|
import { version as melon } from '../package.json'
|
||||||
|
|
||||||
|
// The logger must be initialized before the config generator, otherwise reference
|
||||||
|
// errors occur
|
||||||
|
export const log = new Log()
|
||||||
|
|
||||||
export const config = getConfig()
|
export const config = getConfig()
|
||||||
|
|
||||||
const program = new Command()
|
const program = new Command()
|
||||||
|
|
||||||
program.storeOptionsAsProperties(false).passCommandToAction(false)
|
program.storeOptionsAsProperties(false).passCommandToAction(false)
|
||||||
|
|
||||||
const { version: melon } = require('../package.json')
|
|
||||||
|
|
||||||
let reportedFFVersion
|
let reportedFFVersion
|
||||||
|
|
||||||
if (existsSync(resolve(ENGINE_DIR, 'browser', 'config', 'version.txt'))) {
|
if (existsSync(resolve(ENGINE_DIR, 'browser', 'config', 'version.txt'))) {
|
||||||
|
@ -74,7 +73,7 @@ commands.forEach((command) => {
|
||||||
_cmd.option(opt.arg, opt.description)
|
_cmd.option(opt.arg, opt.description)
|
||||||
})
|
})
|
||||||
|
|
||||||
_cmd.action(async (...args: any) => {
|
_cmd.action(async (...args: unknown[]) => {
|
||||||
await shaCheck(command.cmd)
|
await shaCheck(command.cmd)
|
||||||
await updateCheck()
|
await updateCheck()
|
||||||
|
|
||||||
|
|
32
src/log.ts
32
src/log.ts
|
@ -9,45 +9,49 @@ class Log {
|
||||||
this.startTime = d.getTime()
|
this.startTime = d.getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
getDiff() {
|
getDiff(): string {
|
||||||
const d = new Date()
|
const d = new Date()
|
||||||
|
|
||||||
const currentTime = d.getTime()
|
const currentTime = d.getTime()
|
||||||
|
|
||||||
const elapsedTime = currentTime - this.startTime
|
const elapsedTime = currentTime - this.startTime
|
||||||
|
|
||||||
var secs = Math.floor((elapsedTime / 1000) % 60)
|
const secs = Math.floor((elapsedTime / 1000) % 60)
|
||||||
var mins = Math.floor((elapsedTime / (60 * 1000)) % 60)
|
const mins = Math.floor((elapsedTime / (60 * 1000)) % 60)
|
||||||
var hours = Math.floor((elapsedTime / (60 * 60 * 1000)) % 24)
|
const hours = Math.floor((elapsedTime / (60 * 60 * 1000)) % 24)
|
||||||
|
|
||||||
const format = (r: number) => {
|
const format = (r: number) => (r.toString().length == 1 ? `0${r}` : r)
|
||||||
return r.toString().length == 1 ? '0' + r : r
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${format(hours)}:${format(mins)}:${format(secs)}`
|
return `${format(hours)}:${format(mins)}:${format(secs)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
info(...args: any[]) {
|
info(...args: unknown[]): void {
|
||||||
console.info(chalk.blueBright.bold(this.getDiff()), ...args)
|
console.info(chalk.blueBright.bold(this.getDiff()), ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
warning(...args: any[]) {
|
warning(...args: unknown[]): void {
|
||||||
console.info(chalk.yellowBright.bold(' WARNING'), ...args)
|
console.info(chalk.yellowBright.bold(' WARNING'), ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
hardWarning(...args: any[]) {
|
hardWarning(...args: unknown[]): void {
|
||||||
console.info('', chalk.bgRed.bold('WARNING'), ...args)
|
console.info('', chalk.bgRed.bold('WARNING'), ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
success(...args: any[]) {
|
success(...args: unknown[]): void {
|
||||||
console.log(`\n${chalk.greenBright.bold('SUCCESS')}`, ...args)
|
console.log(`\n${chalk.greenBright.bold('SUCCESS')}`, ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
error(...args: any[]) {
|
error(...args: unknown[]): void {
|
||||||
throw new Error(...args)
|
if (args[0] instanceof Error) {
|
||||||
|
throw args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(
|
||||||
|
...args.map((a) => (typeof a !== 'undefined' ? a.toString() : a))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
askForReport() {
|
askForReport(): void {
|
||||||
console.info(
|
console.info(
|
||||||
'The following error is a bug. Please open an issue on the melon issue structure with a link to your repository and the output from this command.'
|
'The following error is a bug. Please open an issue on the melon issue structure with a link to your repository and the output from this command.'
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { sync } from 'glob'
|
||||||
import { SRC_DIR } from './constants'
|
import { SRC_DIR } from './constants'
|
||||||
import { IPatch } from './interfaces/patch'
|
import { IPatch } from './interfaces/patch'
|
||||||
|
|
||||||
let files = sync('**/*', {
|
const files = sync('**/*', {
|
||||||
nodir: true,
|
nodir: true,
|
||||||
cwd: SRC_DIR,
|
cwd: SRC_DIR,
|
||||||
}).filter(
|
}).filter(
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { walkDirectory } from '../utils'
|
||||||
|
|
||||||
export const patchCountFile = resolve(process.cwd(), '.dotbuild', 'patchCount')
|
export const patchCountFile = resolve(process.cwd(), '.dotbuild', 'patchCount')
|
||||||
|
|
||||||
export const patchCheck = async () => {
|
export const patchCheck = async (): Promise<void> => {
|
||||||
const fileList = await walkDirectory(resolve(process.cwd(), 'src'))
|
const fileList = await walkDirectory(resolve(process.cwd(), 'src'))
|
||||||
const patchCount = fileList.length
|
const patchCount = fileList.length
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { bin_name, log } from '..'
|
||||||
|
|
||||||
const blacklistedCommands = ['reset', 'init', 'set-branch']
|
const blacklistedCommands = ['reset', 'init', 'set-branch']
|
||||||
|
|
||||||
export const shaCheck = async (command: string) => {
|
export const shaCheck = async (command: string): Promise<void> => {
|
||||||
if (
|
if (
|
||||||
blacklistedCommands.filter((c) => command.startsWith(c)).length !== 0 ||
|
blacklistedCommands.filter((c) => command.startsWith(c)).length !== 0 ||
|
||||||
!existsSync(resolve(process.cwd(), '.dotbuild', 'metadata'))
|
!existsSync(resolve(process.cwd(), '.dotbuild', 'metadata'))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { config, log } from '../'
|
import { config, log } from '..'
|
||||||
|
|
||||||
export const updateCheck = async () => {
|
export const updateCheck = async (): Promise<void> => {
|
||||||
const firefoxVersion = config.version.version
|
const firefoxVersion = config.version.version
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -11,12 +11,16 @@ export const updateCheck = async () => {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
let version = Object.keys(data)[Object.keys(data).length - 1]
|
const version = Object.keys(data)[Object.keys(data).length - 1]
|
||||||
|
|
||||||
if (firefoxVersion && version !== firefoxVersion)
|
if (firefoxVersion && version !== firefoxVersion)
|
||||||
log.warning(
|
log.warning(
|
||||||
`Latest version of Firefox (${version}) does not match frozen version (${firefoxVersion}).`
|
`Latest version of Firefox (${version}) does not match frozen version (${firefoxVersion}).`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
log.warning(`Failed to check for updates.`)
|
||||||
|
log.warning(e)
|
||||||
|
log.askForReport()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
export const delay = (delay: number) => {
|
export const delay = (delay: number): Promise<boolean> =>
|
||||||
return new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
setTimeout(() => resolve(true), delay)
|
setTimeout(() => resolve(true), delay)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import execa from 'execa'
|
import execa from 'execa'
|
||||||
import { log } from '..'
|
import { log } from '..'
|
||||||
|
|
||||||
const handle = (data: any, killOnError?: boolean) => {
|
const handle = (data: string | Error, killOnError?: boolean) => {
|
||||||
const d = data.toString()
|
const d = data.toString()
|
||||||
|
|
||||||
d.split('\n').forEach((line: any) => {
|
d.split('\n').forEach((line: string) => {
|
||||||
if (line.length !== 0) log.info(line.replace(/\s\d{1,5}:\d\d\.\d\d /g, ''))
|
if (line.length !== 0) log.info(line.replace(/\s\d{1,5}:\d\d\.\d\d /g, ''))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -16,16 +16,16 @@ const handle = (data: any, killOnError?: boolean) => {
|
||||||
|
|
||||||
export const dispatch = (
|
export const dispatch = (
|
||||||
cmd: string,
|
cmd: string,
|
||||||
args?: any[],
|
args?: string[],
|
||||||
cwd?: string,
|
cwd?: string,
|
||||||
noLog?: boolean,
|
noLog?: boolean,
|
||||||
killOnError?: boolean
|
killOnError?: boolean
|
||||||
) => {
|
): Promise<boolean> =>
|
||||||
return new Promise((resolve, reject) => {
|
new Promise((resolve) => {
|
||||||
process.env.MACH_USE_SYSTEM_PYTHON = 'true'
|
process.env.MACH_USE_SYSTEM_PYTHON = 'true'
|
||||||
|
|
||||||
const proc = execa(cmd, args, {
|
const proc = execa(cmd, args, {
|
||||||
cwd: cwd ? cwd : process.cwd(),
|
cwd: cwd || process.cwd(),
|
||||||
env: process.env,
|
env: process.env,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -39,4 +39,3 @@ export const dispatch = (
|
||||||
resolve(true)
|
resolve(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { readFileSync } from 'fs-extra'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { log } from '..'
|
import { log } from '..'
|
||||||
|
|
||||||
export const errorHandler = (err: Error, isUnhandledRej: boolean) => {
|
export const errorHandler = (err: Error, isUnhandledRej: boolean): void => {
|
||||||
let cc = readFileSync(resolve(process.cwd(), '.dotbuild', 'command'), 'utf-8')
|
let cc = readFileSync(resolve(process.cwd(), '.dotbuild', 'command'), 'utf-8')
|
||||||
cc = cc.replace(/(\r\n|\n|\r)/gm, '')
|
cc = cc.replace(/(\r\n|\n|\r)/gm, '')
|
||||||
|
|
||||||
|
@ -21,7 +21,10 @@ export const errorHandler = (err: Error, isUnhandledRej: boolean) => {
|
||||||
: err.message.replace(/\n/g, '\n\t ')
|
: err.message.replace(/\n/g, '\n\t ')
|
||||||
)
|
)
|
||||||
if (err.stack || isUnhandledRej) {
|
if (err.stack || isUnhandledRej) {
|
||||||
const stack: any = err.stack?.split('\n')
|
const stack: string[] | undefined = err.stack?.split('\n')
|
||||||
|
|
||||||
|
if (!stack) return
|
||||||
|
|
||||||
stack.shift()
|
stack.shift()
|
||||||
stack.shift()
|
stack.shift()
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -29,7 +32,7 @@ export const errorHandler = (err: Error, isUnhandledRej: boolean) => {
|
||||||
stack
|
stack
|
||||||
.join('\n')
|
.join('\n')
|
||||||
.replace(/(\r\n|\n|\r)/gm, '')
|
.replace(/(\r\n|\n|\r)/gm, '')
|
||||||
.replace(/ at /g, '\n\t • ')
|
.replace(/ {4}at /g, '\n\t • ')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,12 @@ import {
|
||||||
} from 'fs-extra'
|
} from 'fs-extra'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import rimraf from 'rimraf'
|
import rimraf from 'rimraf'
|
||||||
|
import { log } from '..'
|
||||||
import { ENGINE_DIR, SRC_DIR } from '../constants'
|
import { ENGINE_DIR, SRC_DIR } from '../constants'
|
||||||
|
|
||||||
const getChunked = (location: string) => {
|
const getChunked = (location: string) => location.replace(/\\/g, '/').split('/')
|
||||||
return location.replace(/\\/g, '/').split('/')
|
|
||||||
}
|
|
||||||
|
|
||||||
export const copyManual = (name: string, noIgnore?: boolean) => {
|
export const copyManual = (name: string, noIgnore?: boolean): void => {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
|
@ -20,7 +19,9 @@ export const copyManual = (name: string, noIgnore?: boolean) => {
|
||||||
) {
|
) {
|
||||||
rimraf.sync(resolve(ENGINE_DIR, ...getChunked(name)))
|
rimraf.sync(resolve(ENGINE_DIR, ...getChunked(name)))
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
log.error(e)
|
||||||
|
}
|
||||||
|
|
||||||
ensureSymlink(
|
ensureSymlink(
|
||||||
resolve(SRC_DIR, ...getChunked(name)),
|
resolve(SRC_DIR, ...getChunked(name)),
|
||||||
|
@ -41,6 +42,5 @@ export const copyManual = (name: string, noIgnore?: boolean) => {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
// return e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ const firefoxTargets = JSON.parse(`{
|
||||||
|
|
||||||
export const getLatestFF = async (
|
export const getLatestFF = async (
|
||||||
product: SupportedProducts = SupportedProducts.Firefox
|
product: SupportedProducts = SupportedProducts.Firefox
|
||||||
) => {
|
): Promise<string> => {
|
||||||
const { data } = await axios.get(
|
const { data } = await axios.get(
|
||||||
'https://product-details.mozilla.org/1.0/firefox_versions.json'
|
'https://product-details.mozilla.org/1.0/firefox_versions.json'
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import execa from 'execa'
|
import execa from 'execa'
|
||||||
import { writeFileSync } from 'fs-extra'
|
import { writeFileSync } from 'fs-extra'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
|
import { config } from '..'
|
||||||
|
|
||||||
const pjson = require('../../package.json')
|
export const writeMetadata = async (): Promise<void> => {
|
||||||
|
|
||||||
export const writeMetadata = async () => {
|
|
||||||
const { stdout: sha } = await execa('git', ['rev-parse', 'HEAD'])
|
const { stdout: sha } = await execa('git', ['rev-parse', 'HEAD'])
|
||||||
const { stdout: branch } = await execa('git', ['branch', '--show-current'])
|
const { stdout: branch } = await execa('git', ['branch', '--show-current'])
|
||||||
|
|
||||||
|
@ -14,7 +13,7 @@ export const writeMetadata = async () => {
|
||||||
sha,
|
sha,
|
||||||
branch,
|
branch,
|
||||||
birth: Date.now(),
|
birth: Date.now(),
|
||||||
versions: pjson.versions,
|
versions: config.version,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,9 @@
|
||||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||||
/* Advanced Options */
|
/* Advanced Options */
|
||||||
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
||||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||||
|
|
||||||
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules/**/*",
|
"node_modules/**/*",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue