Skip to content

Commit

Permalink
Actually fix reisxd#450 (also run fmt)
Browse files Browse the repository at this point in the history
  • Loading branch information
reis committed Sep 27, 2022
1 parent 56be930 commit c70c1ab
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 26 deletions.
10 changes: 6 additions & 4 deletions public/apps/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ <h1>Select the app you want to patch</h1>
/><label for="app-1">YouTube</label>
</li>
<li>
<input type="radio" name="app" id="app-2" value="youtube.music" /><label
for="app-2"
>YouTube Music</label
>
<input
type="radio"
name="app"
id="app-2"
value="youtube.music"
/><label for="app-2">YouTube Music</label>
</li>
<li>
<input
Expand Down
4 changes: 3 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<h1>
Welcome to <span class="accent-fun">ReVanced </span>Builder!
</h1>
<p style="font-family: 'Roboto', sans-serif;">A simple tool to patch ReVanced supported applications</p>
<p style="font-family: 'Roboto', sans-serif">
A simple tool to patch ReVanced supported applications
</p>
<button
class="highlighted"
id="continue"
Expand Down
14 changes: 7 additions & 7 deletions utils/FileDownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ let ws;
*/
async function overWriteJarNames(fileName) {
const filePath = joinPath(global.revancedDir, fileName);
if (fileName.includes('revanced-cli'))
global.jarNames.cli = filePath;
if (fileName.includes('revanced-cli')) global.jarNames.cli = filePath;

if (fileName.includes('revanced-patches') && fileName.endsWith('.jar'))
global.jarNames.patchesJar = filePath;

if (fileName.endsWith('.apk') && !fileName.startsWith('VancedMicroG'))
global.jarNames.integrations = filePath;

if (fileName.startsWith('VancedMicroG'))
global.jarNames.microG = filePath;
if (fileName.startsWith('VancedMicroG')) global.jarNames.microG = filePath;

if (fileName.endsWith('.json'))
global.jarNames.patchesList = filePath;
if (fileName.endsWith('.json')) global.jarNames.patchesList = filePath;
}

/**
Expand Down Expand Up @@ -93,7 +90,10 @@ async function downloadFile(assets) {

if (dir.includes(fileName)) continue;

await dloadFromURL(asset.browser_download_url, joinPath(global.revancedDir, fileName));
await dloadFromURL(
asset.browser_download_url,
joinPath(global.revancedDir, fileName)
);
}
}

Expand Down
4 changes: 3 additions & 1 deletion utils/PatchListRememberer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ function getPatchesList(pkgName) {
readFileSync('includedPatchesList.json', 'utf8')
);

const package = patchesList.packages.find((package) => package.name === pkgName);
const package = patchesList.packages.find(
(package) => package.name === pkgName
);

if (!package) {
rmSync('includedPatchesList.json');
Expand Down
30 changes: 25 additions & 5 deletions utils/checkJDKAndAapt2.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,40 @@ module.exports = async function checkJDKAndAapt2(ws) {
'revanced/aapt2.zip',
ws
);
await exec(`unzip ${joinPath(global.revancedDir, 'aapt2.zip')} -d ${global.revancedDir}`);
await exec(
`unzip ${joinPath(global.revancedDir, 'aapt2.zip')} -d ${
global.revancedDir
}`
);

switch (process.arch) {
case 'arm64':
await exec(`cp ${joinPath(global.revancedDir, 'arm64-v8a/aapt2')} ${joinPath(global.revancedDir, 'aapt2')}`);
await exec(
`cp ${joinPath(global.revancedDir, 'arm64-v8a/aapt2')} ${joinPath(
global.revancedDir,
'aapt2'
)}`
);
await exec(`chmod +x ${joinPath(global.revancedDir, 'aapt2')}`);
break;
case 'arm':
await exec(`cp ${joinPath(global.revancedDir, 'armeabi-v7a/aapt2')} ${joinPath(global.revancedDir, 'aapt2')}`);
await exec(`chmod +x ${joinPath(global.revancedDir, aapt2)}`);
await exec(
`cp ${joinPath(global.revancedDir, 'armeabi-v7a/aapt2')} ${joinPath(
global.revancedDir,
'aapt2'
)}`
);
await exec(`chmod +x ${joinPath(global.revancedDir, 'aapt2')}`);
}

await exec(
`rm -rf ${joinPath(global.revancedDir, 'arm64-v8a')} ${joinPath(global.revancedDir, 'armeabi-v7a')} ${joinPath(global.revancedDir, 'x86')} ${joinPath(global.revancedDir, 'aapt2.zip')}`
`rm -rf ${joinPath(global.revancedDir, 'arm64-v8a')} ${joinPath(
global.revancedDir,
'armeabi-v7a'
)} ${joinPath(global.revancedDir, 'x86')} ${joinPath(
global.revancedDir,
'aapt2.zip'
)}`
);
}
};
8 changes: 8 additions & 0 deletions utils/downloadApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ async function downloadApp(ws) {
.first()
.attr('href');

if (!dlLink) {
return ws.send(
JSON.stringify({
event: 'error',
error: `The version ${version} does not have an APK available, please use an older version.`
})
);
}
const downloadLinkPage = await fetch(
`https://www.apkmirror.com${dlLink}`
).then((res) => res.text());
Expand Down
5 changes: 4 additions & 1 deletion utils/mountReVanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ module.exports = async function mountReVanced(pkg, ws) {

// Copy ReVanced APK to the folder **directly**
await exec(
`su -c 'cp "${joinPath(global.revancedDir, global.outputName)}" "/data/adb/revanced/"'`
`su -c 'cp "${joinPath(
global.revancedDir,
global.outputName
)}" "/data/adb/revanced/"'`
);

// Unmount the already existing ReVanced APK, so it can be updated
Expand Down
5 changes: 4 additions & 1 deletion utils/mountReVancedInstaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ module.exports = async function mountReVancedInstaller(deviceId) {

// Copy ReVanced APK to temp.
await exec(
`adb -s ${deviceId} push revanced/${joinPath(global.revancedDir, global.outputName)} /data/local/tmp/revanced.delete`
`adb -s ${deviceId} push revanced/${joinPath(
global.revancedDir,
global.outputName
)} /data/local/tmp/revanced.delete`
);
// Create folder
await runCommand('su -c \'mkdir -p "/data/adb/revanced/"\'', deviceId);
Expand Down
4 changes: 3 additions & 1 deletion wsEvents/checkFileAlreadyExists.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const { existsSync } = require('node:fs');
module.exports = function checkFileAlreadyExists(ws) {
ws.send(
JSON.stringify({
event: existsSync(join(global.revancedDir, `${global.jarNames.selectedApp}.apk`))
event: existsSync(
join(global.revancedDir, `${global.jarNames.selectedApp}.apk`)
)
? 'fileExists'
: 'fileDoesntExist',
isRooted: global.jarNames.isRooted
Expand Down
7 changes: 6 additions & 1 deletion wsEvents/installReVanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ module.exports = async function installReVanced(ws) {
})
);
try {
await exec(`adb -s ${deviceId} install ${joinPath(global.revancedDir, global.outputName)}`);
await exec(
`adb -s ${deviceId} install ${joinPath(
global.revancedDir,
global.outputName
)}`
);

ws.send(
JSON.stringify({
Expand Down
9 changes: 7 additions & 2 deletions wsEvents/patchApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ async function afterBuild(ws) {

if (!global.jarNames.isRooted && process.platform === 'android') {
await exec(
`cp ${join(global.revancedDir, global.outputName)} /storage/emulated/0/${global.outputName}`
`cp ${join(global.revancedDir, global.outputName)} /storage/emulated/0/${
global.outputName
}`
);
await exec(`cp ${global.jarNames.microG} /storage/emulated/0/microg.apk`);

Expand Down Expand Up @@ -97,7 +99,10 @@ async function reinstallReVanced() {
`adb -s ${global.jarNames.deviceID} uninstall ${pkgNameToGetUninstalled}`
);
await exec(
`adb -s ${global.jarNames.deviceID} install ${join(global.revancedDir, global.outputName)}`
`adb -s ${global.jarNames.deviceID} install ${join(
global.revancedDir,
global.outputName
)}`
);
}

Expand Down
3 changes: 2 additions & 1 deletion wsEvents/selectAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = async function selectAppVersion(message, ws) {
let arch = message.arch;

if (
(global.jarNames.selectedApp === 'youtube.music' && global.jarNames.devices[0]) ||
(global.jarNames.selectedApp === 'youtube.music' &&
global.jarNames.devices[0]) ||
process.platform === 'android'
) {
arch = await getDeviceArch(ws);
Expand Down
2 changes: 1 addition & 1 deletion wsEvents/updateFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { downloadFiles } = require('../utils/FileDownloader.js');
const checkJDKAndAapt2 = require('../utils/checkJDKAndAapt2.js');
const checkJDkAndADB = require('../utils/checkJDKAndADB.js');

global.revancedDir = joinPath(process.cwd(), "revanced");
global.revancedDir = joinPath(process.cwd(), 'revanced');
global.jarNames = {
cli: '',
patchesJar: global.revancedDir,
Expand Down

0 comments on commit c70c1ab

Please sign in to comment.