Home / Function/ main() — react Function Reference

main() — react Function Reference

Architecture documentation for the main() function in publish-using-ci-workflow.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  7f9da990_f5b0_b840_dce2_63cf0c639a81["main()"]
  37d61257_7834_7ff9_7756_2c4472479997["publish-using-ci-workflow.js"]
  7f9da990_f5b0_b840_dce2_63cf0c639a81 -->|defined in| 37d61257_7834_7ff9_7756_2c4472479997
  7c5d17c6_9bfc_99f7_f961_0798168fa07a["getPublishWorkflowID()"]
  7f9da990_f5b0_b840_dce2_63cf0c639a81 -->|calls| 7c5d17c6_9bfc_99f7_f961_0798168fa07a
  8882da9a_b55e_e92b_03a4_ab9b56e99e14["pollUntilWorkflowFinishes()"]
  7f9da990_f5b0_b840_dce2_63cf0c639a81 -->|calls| 8882da9a_b55e_e92b_03a4_ab9b56e99e14
  style 7f9da990_f5b0_b840_dce2_63cf0c639a81 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/release/publish-using-ci-workflow.js lines 82–142

async function main() {
  const headCommitResponse = await fetch(
    'https://api.github.com/repos/facebook/react/commits/main'
  );
  const headCommitJSON = await headCommitResponse.json();
  const headCommitSha = headCommitJSON.sha;

  const pipelineResponse = await fetch(
    'https://circleci.com/api/v2/project/github/facebook/react/pipeline',
    {
      method: 'post',
      body: JSON.stringify({
        parameters: {
          prerelease_commit_sha: headCommitSha,
        },
      }),
      headers: {
        'Circle-Token': CIRCLE_TOKEN,
        'Content-Type': 'application/json',
      },
    }
  );

  if (!pipelineResponse.ok) {
    console.error(
      theme.error(
        `Failed to access CircleCI. Responded with status: ${pipelineResponse.status}`
      )
    );
    process.exit(1);
  }

  const pipelineJSON = await pipelineResponse.json();
  const pipelineID = pipelineJSON.id;

  const workflowID = await logPromise(
    getPublishWorkflowID(pipelineID),
    theme`{header Creating CI workflow}`,
    2 * 1000 // Estimated time: 2 seconds,
  );

  if (workflowID === null) {
    console.warn(
      theme.yellow(
        'Created a CI pipeline to publish the packages, but the script timed ' +
          "out when requesting the associated workflow ID. It's still " +
          'possible the workflow was created.\n\n' +
          'Visit ' +
          'https://app.circleci.com/pipelines/github/facebook/react?branch=main ' +
          'for a list of the latest workflows.'
      )
    );
    process.exit(1);
  }

  await logPromise(
    pollUntilWorkflowFinishes(workflowID),
    theme`{header Publishing in CI workflow}: https://app.circleci.com/pipelines/workflows/${workflowID}`,
    2 * 60 * 1000 // Estimated time: 2 minutes,
  );
}

Domain

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the react codebase, defined in scripts/release/publish-using-ci-workflow.js.
Where is main() defined?
main() is defined in scripts/release/publish-using-ci-workflow.js at line 82.
What does main() call?
main() calls 2 function(s): getPublishWorkflowID, pollUntilWorkflowFinishes.

Analyze Your Own Codebase

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

Try Supermodel Free