How to use the @expo/xdl.UserManager.ensureLoggedInAsync function in @expo/xdl

To help you get started, we’ve selected a few @expo/xdl 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-cli / packages / expo-cli / src / credentials / context.ts View on Github external
async init(projectDir: string) {
    const status = await Doctor.validateWithoutNetworkAsync(projectDir);
    if (status !== Doctor.FATAL) {
      /* This manager does not need to work in project context */
      const { exp } = await readConfigJsonAsync(projectDir);
      this._manifest = exp;
      this._hasProjectContext = true;
    }

    this._user = await UserManager.ensureLoggedInAsync();
    this._apiClient = ApiV2.clientForUser(this.user);
    this._iosApiClient = new IosApi(this._user);
  }
}
github expo / expo-cli / packages / expo-cli / src / commands / publish-info.js View on Github external
.asyncActionProjectDir(async (projectDir, options) => {
      if (options.count && (isNaN(options.count) || options.count < 1 || options.count > 100)) {
        throw new Error('-n must be a number between 1 and 100 inclusive');
      }

      // TODO(ville): handle the API result for not authenticated user instead of checking upfront
      const user = await UserManager.ensureLoggedInAsync();
      const { exp } = await readConfigJsonAsync(projectDir);

      let result: any;
      if (process.env.EXPO_NEXT_API) {
        const api = ApiV2.clientForUser(user);
        result = await api.postAsync('publish/history', {
          owner: exp.owner,
          slug: await Project.getSlugAsync(projectDir, options),
          version: VERSION,
          releaseChannel: options.releaseChannel,
          count: options.count,
          platform: options.platform,
        });
      } else {
        // TODO(ville): move request from multipart/form-data to JSON once supported by the endpoint.
        let formData = new FormData();
github expo / expo-cli / packages / expo-cli / src / commands / build-native / index.ts View on Github external
async function buildAction(projectDir: string, options: Options) {
  if (!options.platform || !Object.values(Platform).includes(options.platform)) {
    throw new Error('Pass valid platform: [android|ios]');
  }
  if (!options.type) {
    options.type = BuildType.Generic;
  }
  // it will accept all types of builds but will fail later on unsupported types.
  if (!Object.values(BuildType).includes(options.type)) {
    throw new Error(`--type option must be 'generic' or 'managed'`);
  }
  const user: User = await UserManager.ensureLoggedInAsync();
  const builder = new Builder(user);
  const buildArtifactUrl = await builder.buildProject(projectDir, options);
  log(`Artifact url: ${buildArtifactUrl}`);
}
github expo / expo-cli / packages / expo-cli / src / commands / build / BaseBuilder.js View on Github external
async prepareProjectInfo(): Promise {
    // always use local json to unify behaviour between regular apps and self hosted ones
    const { exp } = await readConfigJsonAsync(this.projectDir);
    this.manifest = exp;
    this.user = await UserManager.ensureLoggedInAsync();

    await this.checkProjectConfig();
  }
github expo / expo-cli / packages / expo-cli / src / commands / publish-info.js View on Github external
.asyncActionProjectDir(async (projectDir, options) => {
      if (options.count && (isNaN(options.count) || options.count < 1 || options.count > 100)) {
        throw new Error('-n must be a number between 1 and 100 inclusive');
      }

      // TODO(ville): handle the API result for not authenticated user instead of checking upfront
      await UserManager.ensureLoggedInAsync();

      // TODO(ville): move request from multipart/form-data to JSON once supported by the endpoint.
      let formData = new FormData();
      formData.append('queryType', 'history');
      let { exp } = await readConfigJsonAsync(projectDir);
      if (exp.owner) {
        formData.append('owner', exp.owner);
      }
      formData.append('slug', await Project.getSlugAsync(projectDir, options));
      formData.append('version', VERSION);
      if (options.releaseChannel) {
        formData.append('releaseChannel', options.releaseChannel);
      }
      if (options.count) {
        formData.append('count', options.count);
      }
github expo / expo-cli / packages / expo-cli / src / commands / publish-modify.js View on Github external
.asyncActionProjectDir(async (projectDir, options) => {
      if (!options.releaseChannel) {
        throw new Error('You must specify a release channel.');
      }
      if (!options.publishId) {
        throw new Error('You must specify a publish id. You can find ids using publish:history.');
      }
      const user = await UserManager.ensureLoggedInAsync();
      const api = ApiV2.clientForUser(user);
      try {
        let result = await api.postAsync('publish/set', {
          releaseChannel: options.releaseChannel,
          publishId: options.publishId,
          slug: await Project.getSlugAsync(projectDir, options),
        });
        let tableString = table.printTableJson(
          result.queryResult,
          'Channel Set Status ',
          'SUCCESS'
        );
        console.log(tableString);
      } catch (e) {
        log.error(e);
      }
github expo / expo-cli / packages / expo-cli / src / commands / build-native / index.ts View on Github external
async function statusAction() {
  const user: User = await UserManager.ensureLoggedInAsync();
  const builder = new Builder(user);
  const result = await builder.getLatestBuilds();
  printBuildTable(result.builds);
}