Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getTemplateSubstitutions() {
try {
return await new JsonFile(path.join(EXPONENT_DIR, 'secrets', 'keys.json')).readAsync();
} catch (e) {
// Don't have access to decrypted secrets, use public keys
console.log('generate-dynamic-macros is falling back to `template-files/keys.json`');
return await new JsonFile(path.join(EXPONENT_DIR, 'template-files', 'keys.json')).readAsync();
}
}
async function getSavedDevHomeUrlAsync(platform) {
let devHomeConfig = await new JsonFile(
path.join(EXPONENT_DIR, 'dev-home-config.json')
).readAsync();
return devHomeConfig.url;
}
async function copyTemplateFilesAsync(platform, args, templateSubstitutions) {
let templateFilesPath = args.templateFilesPath || path.join(EXPONENT_DIR, 'template-files');
let templatePaths = await new JsonFile(
path.join(templateFilesPath, `${platform}-paths.json`)
).readAsync();
let promises = [];
_.forEach(templatePaths, (dest, source) => {
promises.push(
copyTemplateFileAsync(
path.join(templateFilesPath, platform, source),
path.join(EXPONENT_DIR, dest, source),
templateSubstitutions,
args.configuration
)
);
});
await Promise.all(promises);
function sdkVersionAsync(packageJsonFilePath) {
return new JsonFile(packageJsonFilePath).getAsync('exp').then(exp => {
if (!exp.hasOwnProperty('sdkVersion')) {
throw new Error(`SDK version is missing from the project's package.json file`);
}
return exp.sdkVersion;
});
}