1const { getConfig } = require('@expo/config');
2const fs = require('fs');
3const path = require('path');
4
5const possibleProjectRoot = process.argv[2];
6const destinationDir = process.argv[3];
7
8// Remove projectRoot validation when we no longer support React Native <= 62
9let projectRoot;
10if (fs.existsSync(path.join(possibleProjectRoot, 'package.json'))) {
11  projectRoot = possibleProjectRoot;
12} else if (fs.existsSync(path.join(possibleProjectRoot, '..', 'package.json'))) {
13  projectRoot = path.resolve(possibleProjectRoot, '..');
14}
15
16const { exp } = getConfig(projectRoot, {
17  isPublicConfig: true,
18  skipSDKVersionRequirement: true,
19});
20fs.writeFileSync(path.join(destinationDir, 'app.config'), JSON.stringify(exp));
21