Enable dual-device login and mobile APK update checks

This commit is contained in:
yoyuzh
2026-04-03 16:28:09 +08:00
parent 56f2a9fe0d
commit 52b5bbfe8e
50 changed files with 1659 additions and 164 deletions

View File

@@ -23,6 +23,8 @@ const repoRoot = process.cwd();
const frontDir = path.join(repoRoot, 'front');
const distDir = path.join(frontDir, 'dist');
const envFilePath = path.join(repoRoot, '.env.oss.local');
const apkSourcePath = path.join(frontDir, 'android', 'app', 'build', 'outputs', 'apk', 'debug', 'app-debug.apk');
const apkObjectPath = 'downloads/yoyuzh-portal.apk';
function parseArgs(argv) {
return {
@@ -153,6 +155,48 @@ async function uploadSpaAliases({
}
}
async function uploadApkIfPresent({
bucket,
endpoint,
region,
accessKeyId,
secretAccessKey,
sessionToken,
remotePrefix,
dryRun,
}) {
try {
await fs.access(apkSourcePath);
} catch (error) {
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
console.warn(`skip apk upload: not found at ${apkSourcePath}`);
return;
}
throw error;
}
const objectKey = buildObjectKey(remotePrefix, apkObjectPath);
if (dryRun) {
console.log(`[dry-run] upload ${apkObjectPath} -> ${objectKey}`);
return;
}
await uploadFile({
bucket,
endpoint,
region,
objectKey,
filePath: apkSourcePath,
contentTypeOverride: 'application/vnd.android.package-archive',
accessKeyId,
secretAccessKey,
sessionToken,
});
console.log(`uploaded ${objectKey}`);
}
async function main() {
const {dryRun, skipBuild} = parseArgs(process.argv.slice(2));
@@ -221,6 +265,17 @@ async function main() {
remotePrefix,
dryRun,
});
await uploadApkIfPresent({
bucket,
endpoint,
region,
accessKeyId,
secretAccessKey,
sessionToken,
remotePrefix,
dryRun,
});
}
main().catch((error) => {