31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
import { readFileSync, writeFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import { renderAndroidPrivacy } from './app-legal-config.mjs';
|
|
|
|
const projectRoot = resolve(import.meta.dirname, '..');
|
|
const templatePath = resolve(projectRoot, 'androidPrivacy.json.example');
|
|
// uni-app CLI uses src/ as UNI_INPUT_DIR. The App-Plus compiler only copies
|
|
// androidPrivacy.json from that input directory into the native build resource.
|
|
const outputPath = resolve(projectRoot, 'src', 'androidPrivacy.json');
|
|
|
|
const argumentValue = (name) => {
|
|
const prefix = `--${name}=`;
|
|
return process.argv.find((argument) => argument.startsWith(prefix))?.slice(prefix.length);
|
|
};
|
|
|
|
const termsUrl = argumentValue('terms-url') || process.env.VITE_APP_TERMS_URL;
|
|
const privacyUrl = argumentValue('privacy-url') || process.env.VITE_APP_PRIVACY_URL;
|
|
|
|
try {
|
|
const rendered = renderAndroidPrivacy(
|
|
readFileSync(templatePath, 'utf8'),
|
|
termsUrl,
|
|
privacyUrl
|
|
);
|
|
writeFileSync(outputPath, rendered, 'utf8');
|
|
console.log('src/androidPrivacy.json configured with prompt=none; final public legal URLs validated for the login page.');
|
|
} catch (error) {
|
|
console.error(`Android privacy configuration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
process.exit(1);
|
|
}
|