Home / Function/ run() — react Function Reference

run() — react Function Reference

Architecture documentation for the run() function in publish.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  c46f29bb_fa16_87cd_4df0_73a0d9b81128["run()"]
  95e2e5e6_cd65_a68b_96bf_610a93c18a60["publish.js"]
  c46f29bb_fa16_87cd_4df0_73a0d9b81128 -->|defined in| 95e2e5e6_cd65_a68b_96bf_610a93c18a60
  style c46f29bb_fa16_87cd_4df0_73a0d9b81128 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/release/publish.js lines 22–113

const run = async () => {
  try {
    const params = parseParams();

    const version =
      params.publishVersion ??
      readJsonSync('./build/node_modules/react/package.json').version;
    const isExperimental = version.includes('experimental');

    params.cwd = join(__dirname, '..', '..');
    params.packages = await getPublicPackages(isExperimental);

    if (params.onlyPackages.length > 0 && params.skipPackages.length > 0) {
      console.error(
        '--onlyPackages and --skipPackages cannot be used together'
      );
      process.exit(1);
    }

    if (params.onlyPackages.length > 0) {
      params.packages = params.packages.filter(packageName => {
        return params.onlyPackages.includes(packageName);
      });
    }

    // Pre-filter any skipped packages to simplify the following commands.
    // As part of doing this we can also validate that none of the skipped packages were misspelled.
    params.skipPackages.forEach(packageName => {
      const index = params.packages.indexOf(packageName);
      if (index < 0) {
        console.log(
          theme`Invalid skip package {package ${packageName}} specified.`
        );
        process.exit(1);
      } else {
        params.packages.splice(index, 1);
      }
    });

    await validateTags(params);
    await confirmSkippedPackages(params);
    await confirmVersionAndTags(params);
    await validateSkipPackages(params);
    await checkNPMPermissions(params);

    const packageNames = params.packages;

    if (params.ci) {
      let failed = false;
      for (let i = 0; i < packageNames.length; i++) {
        try {
          const packageName = packageNames[i];
          await publishToNPM(params, packageName, null);
        } catch (error) {
          failed = true;
          console.error(error.message);
          console.log();
          console.log(
            theme.error`Publish failed. Will attempt to publish remaining packages.`
          );
        }
      }
      if (failed) {
        console.log(theme.error`One or more packages failed to publish.`);
        process.exit(1);
      }
    } else {
      clear();
      let otp = await promptForOTP(params);
      for (let i = 0; i < packageNames.length; ) {
        const packageName = packageNames[i];
        try {
          await publishToNPM(params, packageName, otp);
          i++;
        } catch (error) {
          console.error(error.message);
          console.log();
          console.log(
            theme.error`Publish failed. Enter a fresh otp code to retry.`
          );
          otp = await promptForOTP(params);

Domain

Subdomains

Frequently Asked Questions

What does run() do?
run() is a function in the react codebase, defined in scripts/release/publish.js.
Where is run() defined?
run() is defined in scripts/release/publish.js at line 22.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free