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() {
const defaultKeys = await getTemplateSubstitutionsFromSecrets();
try {
// Keys from secrets/template-files can be overwritten by private-keys.json file.
const privateKeys = await new JsonFile(path.join(EXPO_DIR, 'private-keys.json')).readAsync();
return { ...defaultKeys, ...privateKeys };
} catch (error) {
return defaultKeys;
}
}
async function _uploadLogsAsync(info: any): Promise {
let user = await UserManager.getCurrentUserAsync();
let username = user ? user.username : 'anonymous';
// write info to file
let expoHome = UserSettings.dotExpoHomeDirectory();
let infoJsonFile = new JsonFile(path.join(expoHome, 'debug-info.json'));
await infoJsonFile.writeAsync(info);
// copy files to tempDir
let tempDir = path.join(Env.home(), `${username}-diagnostics`);
let archivePath = path.join(expoHome, 'diagnostics.tar.gz');
await Utils.ncpAsync(expoHome, tempDir, {
filter: filename => {
if (
filename.includes('diagnostics') ||
filename.includes('starter-app-cache') ||
filename.includes('android-apk-cache') ||
filename.includes('ios-simulator-app-cache') ||
filename.includes('state.json~')
) {
return false;
} else {
export async function readAssetJsonAsync(
projectDir: string
): Promise<{ assetJson: JsonFile; assetInfo: AssetOptimizationState }> {
const dirPath = path.join(projectDir, '.expo-shared');
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath);
}
const assetJson = new JsonFile(path.join(dirPath, 'assets.json'));
if (!fs.existsSync(assetJson.file)) {
const message =
`Creating ${chalk.italic('.expo-shared/assets.json')} in the project's root directory.\n` +
`This file is autogenerated and should not be edited directly.\n` +
'You should commit this to git so that asset state is shared between collaborators.';
logger.global.info(message);
await assetJson.writeAsync({});
}
const assetInfo = await assetJson.readAsync();
return { assetJson, assetInfo };
}
async function _renderPodDependenciesAsync(dependenciesConfigPath, options) {
let dependencies = await new JsonFile(dependenciesConfigPath).readAsync();
const type = options.isPodfile ? 'pod' : 'ss.dependency';
const noWarningsFlag = options.isPodfile ? `, :inhibit_warnings => true` : '';
let depsStrings = dependencies.map(dependency => {
let builder = '';
if (dependency.comments) {
builder += dependency.comments.map(commentLine => ` # ${commentLine}`).join('\n');
builder += '\n';
}
const otherPodfileFlags = options.isPodfile && dependency.otherPodfileFlags;
builder += ` ${type} '${dependency.name}', '${
dependency.version
}'${noWarningsFlag}${otherPodfileFlags || ''}`;
return builder;
});
return depsStrings.join('\n');
}
function projectSettingsJsonFile(projectRoot: string): JsonFile {
return new JsonFile(
path.join(dotExpoProjectDirectory(projectRoot), projectSettingsFile)
);
}
function packagerInfoJsonFile(projectRoot: string): JsonFile {
return new JsonFile(
path.join(dotExpoProjectDirectory(projectRoot), packagerInfoFile)
);
}
function projectSettingsJsonFile(projectRoot: string, filename: string) {
return new JsonFile(path.join(dotExpoProjectDirectory(projectRoot), filename));
}
async function _publishTestSuiteNoCacheAsync(id: string, useUnversioned: boolean): Promise {
await _installTestSuiteDependenciesAsync();
Log.collapsed('Modifying slug...');
let appJsonFile = new JsonFile(path.join(TEST_SUITE_DIR, 'app.json'));
let appJson = ((await appJsonFile.readAsync()) as unknown) as AppConfig;
appJson.expo.slug = id;
await appJsonFile.writeAsync(appJson as any);
await XDL.publishProjectWithExpoCliAsync(TEST_SUITE_DIR, {
useUnversioned,
});
}
function userSettingsJsonFile() {
return new JsonFile(userSettingsFile(), {
jsonParseErrorDefault: {},
cantReadFileDefault: {},
});
}