How to use the @expo/xdl.Project.currentStatus 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 / commands / export.js View on Github external
throw new CommandError(
      'OUTPUT_DIR_EXISTS',
      `Output directory ${outputPath} already exists. Aborting export.`
    );
  }
  if (!options.publicUrl) {
    throw new CommandError('MISSING_PUBLIC_URL', 'Missing required option: --public-url');
  }
  // If we are not in dev mode, ensure that url is https
  if (!options.dev && !UrlUtils.isHttps(options.publicUrl)) {
    throw new CommandError('INVALID_PUBLIC_URL', '--public-url must be a valid HTTPS URL.');
  } else if (!validator.isURL(options.publicUrl, { protocols: ['http', 'https'] })) {
    console.warn(`Dev Mode: publicUrl ${options.publicUrl} does not conform to HTTP format.`);
  }

  const status = await Project.currentStatus(projectDir);

  let startedOurOwn = false;
  if (status !== 'running') {
    log('Unable to find an existing Expo CLI instance for this directory, starting a new one...');

    installExitHooks(projectDir);

    const startOpts = { reset: options.clear, nonPersistent: true };
    if (options.maxWorkers) {
      startOpts.maxWorkers = options.maxWorkers;
    }
    log('Exporting your app...');
    await Project.startAsync(projectDir, startOpts, !options.quiet);
    startedOurOwn = true;
  }
github expo / expo-cli / packages / expo-cli / src / commands / upgrade.ts View on Github external
// Can't upgrade if we don't have a SDK version (tapping on head meme)
  if (!exp.sdkVersion) {
    if (workflow === 'bare') {
      log.error(
        'This command only works for bare workflow projects that also have the expo package installed and sdkVersion configured in app.json.'
      );
      throw new CommandError('SDK_VERSION_REQUIRED_FOR_UPGRADE_COMMAND_IN_BARE');
    } else {
      log.error('No sdkVersion field is present in app.json, cannot upgrade project.');
      throw new CommandError('SDK_VERSION_REQUIRED_FOR_UPGRADE_COMMAND_IN_MANAGED');
    }
  }

  // Can't upgrade if Expo is running
  let status = await Project.currentStatus(projectRoot);
  if (status === 'running') {
    await Project.stopAsync(projectRoot);
    log(
      chalk.bold.underline(
        'We found an existing expo-cli instance running for this project and closed it to continue.'
      )
    );
    log.addNewLineIfNone();
  }

  let currentSdkVersionString = exp.sdkVersion;
  let sdkVersions = await Versions.releasedSdkVersionsAsync();
  let latestSdkVersion = await Versions.newestReleasedSdkVersionAsync();
  let latestSdkVersionString = latestSdkVersion.version;
  let targetSdkVersionString =
    maybeFormatSdkVersion(requestedSdkVersion) || latestSdkVersion.version;
github expo / expo-cli / packages / expo-cli / src / exp.ts View on Github external
if (chunk.tag === 'device') {
            logWithLevel(chunk);
          }
        },
      },
      type: 'raw',
    });

    // The existing CLI modules only pass one argument to this function, so skipProjectValidation
    // will be undefined in most cases. we can explicitly pass a truthy value here to avoid
    // validation (eg for init)
    //
    // If the packager/manifest server is running and healthy, there is no need
    // to rerun Doctor because the directory was already checked previously
    // This is relevant for command such as `send`
    if (!skipProjectValidation && (await Project.currentStatus(projectDir)) !== 'running') {
      let spinner = ora('Making sure project is set up correctly...').start();
      log.setSpinner(spinner);
      // validate that this is a good projectDir before we try anything else

      let status = await Doctor.validateWithoutNetworkAsync(projectDir);
      if (status === Doctor.FATAL) {
        throw new Error(`There is an error with your project. See above logs for information.`);
      }
      spinner.stop();
      log.setSpinner(null);
    }

    // the existing CLI modules only pass one argument to this function, so skipProjectValidation
    // will be undefined in most cases. we can explicitly pass a truthy value here to avoid validation (eg for init)

    return asyncFn(projectDir, ...args);
github expo / expo-cli / packages / expo-cli / src / commands / publish.js View on Github external
);
    process.exit(1);
  }
  const hasOptimized = fs.existsSync(path.join(projectDir, '/.expo-shared/assets.json'));
  const nonInteractive = options.parent && options.parent.nonInteractive;
  if (!hasOptimized && !nonInteractive) {
    log.warn(
      'Warning: Your project may contain unoptimized image assets. Smaller image sizes can improve app performance.'
    );
    log.warn(
      `To compress the images in your project, abort publishing and run ${chalk.bold(
        'expo optimize'
      )}.`
    );
  }
  const status = await Project.currentStatus(projectDir);

  let startedOurOwn = false;
  if (status !== 'running') {
    log('Unable to find an existing Expo CLI instance for this directory, starting a new one...');
    installExitHooks(projectDir);

    const startOpts = { reset: options.clear, nonPersistent: true };
    if (options.maxWorkers) {
      startOpts.maxWorkers = options.maxWorkers;
    }

    await Project.startAsync(projectDir, startOpts, !options.quiet);
    startedOurOwn = true;
  }

  let recipient = await sendTo.getRecipient(options.sendTo);
github expo / expo-cli / packages / expo-cli / src / commands / publish.js View on Github external
);
    process.exit(1);
  }
  const hasOptimized = fs.existsSync(path.join(projectDir, '/.expo-shared/assets.json'));
  const nonInteractive = options.parent && options.parent.nonInteractive;
  if (!hasOptimized && !nonInteractive) {
    log.warn(
      'Warning: Your project may contain unoptimized image assets. Smaller image sizes can improve app performance.'
    );
    log.warn(
      `To compress the images in your project, abort publishing and run ${chalk.bold(
        'expo optimize'
      )}.`
    );
  }
  const status = await Project.currentStatus(projectDir);

  let startedOurOwn = false;
  if (status !== 'running') {
    log('Unable to find an existing Expo CLI instance for this directory, starting a new one...');
    installExitHooks(projectDir);

    const startOpts = { reset: options.clear, nonPersistent: true };
    if (options.maxWorkers) {
      startOpts.maxWorkers = options.maxWorkers;
    }

    await Project.startAsync(projectDir, startOpts, !options.quiet);
    startedOurOwn = true;
  }

  let recipient = await sendTo.getRecipient(options.sendTo);
github expo / expo / tools / expotools / src / dynamic-macros / macros.ts View on Github external
async TEST_APP_URI() {
    if (process.env.TEST_SUITE_URI) {
      return process.env.TEST_SUITE_URI;
    } else {
      try {
        let testSuitePath = path.join(__dirname, '..', 'apps', 'test-suite');
        let status = await Project.currentStatus(testSuitePath);
        if (status === 'running') {
          return await UrlUtils.constructManifestUrlAsync(testSuitePath);
        } else {
          return '';
        }
      } catch (e) {
        return '';
      }
    }
  },
github expo / expo / tools-public / generate-dynamic-macros.js View on Github external
async TEST_APP_URI() {
    if (process.env.TEST_SUITE_URI) {
      return process.env.TEST_SUITE_URI;
    } else {
      try {
        let testSuitePath = path.join(__dirname, '..', 'apps', 'test-suite');
        let status = await Project.currentStatus(testSuitePath);
        if (status === 'running') {
          return await UrlUtils.constructManifestUrlAsync(testSuitePath);
        } else {
          return '';
        }
      } catch (e) {
        return '';
      }
    }
  },
github expo / expo-cli / packages / expo-cli / src / commands / url.ts View on Github external
async function action(projectDir: string, options: ProjectUrlOptions) {
  await urlOpts.optsAsync(projectDir, options);

  if ((await Project.currentStatus(projectDir)) !== 'running') {
    throw new CommandError(
      'NOT_RUNNING',
      `Project is not running. Please start it with \`expo start\`.`
    );
  }
  const url = options.web
    ? await getWebAppUrlAsync(projectDir)
    : await UrlUtils.constructManifestUrlAsync(projectDir);

  log.newLine();
  urlOpts.printQRCode(url);

  log('Your URL is\n\n' + chalk.underline(url) + '\n');
  log.raw(url);

  if (!options.web) {
github expo / expo-cli / packages / dev-tools / server / graphql / GraphQLSchema.js View on Github external
async manifestUrl(project) {
      if ((await Project.currentStatus(project.projectDir)) === 'running') {
        return UrlUtils.constructManifestUrlAsync(project.projectDir);
      } else {
        return null;
      }
    },
    settings(project) {