Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Show beta versions, recommended versions and sort by version number instead of upload date #260

Merged
merged 4 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"open": "^8.4.0",
"path": "^0.12.7",
"portfinder": "^1.0.29",
"semver": "^7.3.7",
"ws": "^8.8.1"
},
"devDependencies": {
Expand Down
9 changes: 7 additions & 2 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function setAppVersion (arch, version) {
function getAppVersions (isRooted) {
document.getElementsByTagName('header')[0].innerHTML = `
<h1>Select the version you want to download</h1>
Versions marked as beta might have bugs or be unstable, unless marked as recommended
${
isRooted
? "<span><strong>You are building rooted ReVanced</strong>, you'll need to download the version matching with your YouTube version.<br>(You'll also need YouTube installed)<br>If you didn't intend on doing a rooted build, include all \"Root required to exclude\" patches<span>"
Expand Down Expand Up @@ -237,8 +238,12 @@ ws.onmessage = (msg) => {
for (const version of message.versionList) {
document.getElementById('versions').innerHTML += `
<li>
<input type="radio" name="version" id="app-${i}" value="${version.version}"/>
<label for="app-${i}">${version.version}</label></li>`;
<input type="radio" name="version" id="app-${i}" value="${
version.version
}"/>
<label for="app-${i}">${version.version} ${
version.beta ? ' (beta)' : ''
} ${version.recommended ? ' (recommended)' : ''}</label></li>`;
i++;
}

Expand Down
8 changes: 4 additions & 4 deletions utils/FileDownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ async function overWriteJarNames (fileName) {

// yes.

function insert (str, index, value) {
return str.substr(0, index) + value + str.substr(index);
}
// function insert (str, index, value) {
// return str.substr(0, index) + value + str.substr(index);
// }

async function getDownloadLink (json) {
const apiRequest = await fetchURL(
Expand Down Expand Up @@ -71,7 +71,7 @@ async function downloadFile (assets) {
const dir = fs.readdirSync('./revanced/');
let fileExt = asset.browser_download_url.split('/').pop().split('.');
fileExt = fileExt[fileExt.length - 1];
let fileName = assets.repo
let fileName = assets.repo;
fileName += `-${assets.version}.${fileExt}`;
overWriteJarNames(fileName);
if (dir.includes(fileName)) continue;
Expand Down
7 changes: 4 additions & 3 deletions utils/mountReVanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ module.exports = async function (pkg, ws) {
// await actualExec(`su -c 'monkey -p ${pkg} 1 && kill $(pidof -s ${pkg})'`);

// Mount APK with command so it doesn't require restart
await actualExec(`su -mm -c 'base_path="/data/adb/revanced/${pkg}.apk";stock_path=$( pm path ${pkg} | grep base | sed 's/package://g' );mount -o bind $base_path $stock_path'`)
// Kill app process
await actualExec(
`su -mm -c 'base_path="/data/adb/revanced/${pkg}.apk";stock_path=$( pm path ${pkg} | grep base | sed 's/package://g' );mount -o bind $base_path $stock_path'`
);
// Kill app process
await actualExec(`su -c 'am force-stop ${pkg}'`);


ws.send(
JSON.stringify({
event: 'patchLog',
Expand Down
17 changes: 14 additions & 3 deletions wsEvents/GetAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const getAppVersion = require('../utils/getAppVersion.js');
const downloadApp = require('../utils/downloadApp.js');
const { exec } = require('child_process');
const { promisify } = require('util');
const lt = require('semver/functions/lt');

const actualExec = promisify(exec);

Expand Down Expand Up @@ -126,18 +127,28 @@ module.exports = async function (message, ws) {
.replace('WarnWetter ', '')
.replace('TikTok ', '');

if (versionName.includes('beta')) continue;
else if (
if (
global.jarNames.selectedApp === 'android' &&
!versionName.includes('release')
) {
continue;
}
if (versionName.includes('(Wear OS)')) continue;
versionList.push({
version: versionName
version: versionName.split(' ')[0], // remove beta suffix if there is one
recommended: global.versions.includes(versionName.split(' ')[0]),
beta: !!versionName.split(' ')[1]
});
}
versionList.sort(
(a, b) =>
lt(
a.version.replace(/\.0(?<digit>\d)/gi, '.$1'), // because apparently x.0y.z (ex. 5.09.51) isn't a valid version
b.version.replace(/\.0(?<digit>\d)/gi, '.$1')
)
? 1
: -1 /* yes i need to add this to the end, the sort function is stupid */
);
return ws.send(
JSON.stringify({
event: 'appVersions',
Expand Down
1 change: 1 addition & 0 deletions wsEvents/GetPatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = async function (message, ws) {
const isCompatible = pkg === global.jarNames.selectedApp;

const versionsArr = versions.split(', ');
global.versions = versionsArr.map((i) => i.trim());
const maxVersion = versionsArr.sort()[versionsArr.length - 1];

if (isCompatible && (!isRooted || hasRoot)) {
Expand Down
4 changes: 3 additions & 1 deletion wsEvents/PatchApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ async function afterBuild (ws) {
await actualExec(
`cp revanced/${global.outputName} /storage/emulated/0/${global.outputName}`
);
await actualExec(`cp ${global.jarNames.microG} /storage/emulated/0/microg.apk`);
await actualExec(
`cp ${global.jarNames.microG} /storage/emulated/0/microg.apk`
);

ws.send(
JSON.stringify({
Expand Down