Home / Function/ publishToNPM() — react Function Reference

publishToNPM() — react Function Reference

Architecture documentation for the publishToNPM() function in publish-release.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  edf7d9af_6c6f_2c2b_ce81_1a87700830bc["publishToNPM()"]
  2073ecda_ac22_e62c_fb04_236af8022ec8["publish-release.js"]
  edf7d9af_6c6f_2c2b_ce81_1a87700830bc -->|defined in| 2073ecda_ac22_e62c_fb04_236af8022ec8
  7432554c_b057_f600_c294_f31d31c1666a["main()"]
  7432554c_b057_f600_c294_f31d31c1666a -->|calls| edf7d9af_6c6f_2c2b_ce81_1a87700830bc
  style edf7d9af_6c6f_2c2b_ce81_1a87700830bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/devtools/publish-release.js lines 60–120

async function publishToNPM() {
  const {otp} = await inquirer.prompt([
    {
      type: 'input',
      name: 'otp',
      message: 'Please provide an NPM two-factor auth token:',
    },
  ]);

  console.log('');

  if (!otp) {
    console.error(chalk.red(`Invalid OTP provided: "${chalk.bold(otp)}"`));
    process.exit(0);
  }

  for (let index = 0; index < NPM_PACKAGES.length; index++) {
    const npmPackage = NPM_PACKAGES[index];
    const packagePath = join(ROOT_PATH, 'packages', npmPackage);
    const {version} = readJsonSync(join(packagePath, 'package.json'));

    // Check if this package version has already been published.
    // If so we might be resuming from a previous run.
    // We could infer this by comparing the build-info.json,
    // But for now the easiest way is just to ask if this is expected.
    const versionListJSON = await execRead(
      `npm view ${npmPackage} versions --json`
    );
    const versionList = JSON.parse(versionListJSON);
    const versionIsAlreadyPublished = versionList.includes(version);

    if (versionIsAlreadyPublished) {
      console.log('');
      console.log(
        `${npmPackage} version ${chalk.bold(
          version
        )} has already been published.`
      );

      await confirm(`Is this expected (will skip ${npmPackage}@${version})?`);
      continue;
    }

    if (DRY_RUN) {
      console.log(`Publishing package ${chalk.bold(npmPackage)}`);
      console.log(chalk.dim(`  npm publish --otp=${otp}`));
    } else {
      const publishPromise = exec(`npm publish --otp=${otp}`, {
        cwd: packagePath,
      });

      await logger(
        publishPromise,
        `Publishing package ${chalk.bold(npmPackage)}`,
        {
          estimate: 2500,
        }
      );
    }
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does publishToNPM() do?
publishToNPM() is a function in the react codebase, defined in scripts/devtools/publish-release.js.
Where is publishToNPM() defined?
publishToNPM() is defined in scripts/devtools/publish-release.js at line 60.
What calls publishToNPM()?
publishToNPM() is called by 1 function(s): main.

Analyze Your Own Codebase

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

Try Supermodel Free