MCPcopy Index your code
hub / github.com/TGX-Android/Publisher / getBuildFiles

Function getBuildFiles

main.js:750–827  ·  view source on GitHub ↗
(build, sdkVariant, abiVariant, callback)

Source from the content-addressed store, hash-verified

748}
749
750function getBuildFiles (build, sdkVariant, abiVariant, callback) {
751 const folder = sdkVariant + ucfirst(abiVariant) ; // latestUniversalRelease
752 const architecture = getDisplayVariant(abiVariant);
753
754 const outputsDir = settings.TGX_SOURCE_PATH + '/app/build/outputs';
755
756 const mappingDir = outputsDir + '/mapping/' + folder + 'Release';
757 const apkDir = outputsDir + '/apk/' + folder + '/release';
758
759 const nativeDebugSymbolsFile = outputsDir + '/native-debug-symbols/' + folder + 'Release' + '/native-debug-symbols.zip';
760
761 const result = { };
762
763 const check = () => {
764 if (result.nativeDebugSymbolsFile !== undefined && result.apkFile !== undefined && (result.apkFile === null || (result.apkFile.checksum && result.apkFile.checksum.md5 !== undefined && result.apkFile.checksum.sha1 !== undefined && result.apkFile.checksum.sha256 !== undefined)) && result.mappingFile !== undefined && result.metadata !== undefined) {
765 if (result.nativeDebugSymbolsFile && result.apkFile && (result.apkFile.checksum && result.apkFile.checksum.sha256 && result.apkFile.checksum.sha1 && result.apkFile.checksum.md5) && (result.mappingFile || build.outputApplication.dontObfuscate) && result.metadata) {
766 callback(result);
767 } else {
768 console.error('Cannot find build files for #' + build.version.name, JSON.stringify(result));
769 callback(null);
770 }
771 }
772 };
773
774 const prefix = '^' + escapeRegExp(build.outputApplication.name || 'Telegram X')
775 .replace(/ /g, '-')
776 .replace(/#/g, '') + '-' +
777 build.version.name.replace(/\./gi, '\\.') + '(?:\\+[0-9,]+)?' +
778 (sdkVariant !== 'latest' ? '(?:-' + sdkVariant + ')?' : '') +
779 (architecture ? '(?:-' + architecture + ')?' : '') +
780 (build.outputApplication.extension ? '(?:-' + build.outputApplication.extension + ')?' : '');
781 fs.exists(nativeDebugSymbolsFile, (exists) => {
782 result.nativeDebugSymbolsFile = exists ? {path: nativeDebugSymbolsFile} : null;
783 check();
784 });
785 findFile(apkDir, RegExp(prefix + '\\.apk$'), (apkFile) => {
786 if (apkFile) {
787 result.apkFile = {path: apkDir + '/' + apkFile};
788 ['sha256', 'sha1', 'md5'].forEach((algorithm) => {
789 checksum(result.apkFile.path, (err, checksum) => {
790 if (!result.apkFile.checksum) {
791 result.apkFile.checksum = {};
792 }
793 result.apkFile.checksum[algorithm] = checksum ? checksum : null;
794 check();
795 }, algorithm);
796 });
797 } else {
798 result.apkFile = null;
799 check();
800 }
801 });
802 findFile(apkDir, RegExp('^output-metadata\\.json$'), (metadataFile) => {
803 if (metadataFile) {
804 fs.readFile(apkDir + '/' + metadataFile, 'utf-8', (err, data) => {
805 const metadata = err ? null : JSON.parse(data);
806 if (err || !(metadata &&
807 metadata.elements &&

Callers 1

processPrivateCommandFunction · 0.85

Calls 6

ucfirstFunction · 0.85
getDisplayVariantFunction · 0.85
escapeRegExpFunction · 0.85
checkFunction · 0.85
findFileFunction · 0.85
checksumFunction · 0.85

Tested by

no test coverage detected