How to use the @expo/json-file function in @expo/json-file

To help you get started, we’ve selected a few @expo/json-file examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / tools / expotools / src / dynamic-macros / generateDynamicMacros.ts View on Github external
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;
  }
}
github expo / expo-cli / dev / xdl / src / Diagnostics.js View on Github external
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 {
github expo / expo-cli / packages / xdl / src / AssetUtils.ts View on Github external
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 };
}
github expo / expo-cli / packages / xdl / src / detach / IosPodsTools.js View on Github external
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');
}
github expo / expo-cli / packages / xdl / src / ProjectSettings.ts View on Github external
function projectSettingsJsonFile(projectRoot: string): JsonFile {
  return new JsonFile(
    path.join(dotExpoProjectDirectory(projectRoot), projectSettingsFile)
  );
}
github expo / expo-cli / packages / xdl / src / ProjectSettings.ts View on Github external
function packagerInfoJsonFile(projectRoot: string): JsonFile {
  return new JsonFile(
    path.join(dotExpoProjectDirectory(projectRoot), packagerInfoFile)
  );
}
github expo / xdl / src / ProjectSettings.js View on Github external
function projectSettingsJsonFile(projectRoot: string, filename: string) {
  return new JsonFile(path.join(dotExpoProjectDirectory(projectRoot), filename));
}
github expo / expo / tools / expotools / src / TestSuite.ts View on Github external
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,
  });
}
github expo / xdl / src / UserSettings.js View on Github external
function userSettingsJsonFile() {
  return new JsonFile(userSettingsFile(), {
    jsonParseErrorDefault: {},
    cantReadFileDefault: {},
  });
}

@expo/json-file

A module for reading, writing, and manipulating JSON files

MIT
Latest version published 2 months ago

Package Health Score

92 / 100
Full package analysis