Home / Function/ processArtifact() — react Function Reference

processArtifact() — react Function Reference

Architecture documentation for the processArtifact() function in download-build-artifacts.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4291e1a8_d44d_9d02_52de_aac73fe34e49["processArtifact()"]
  b7e2774f_9b65_2f26_1d36_abceee1db3ae["download-build-artifacts.js"]
  4291e1a8_d44d_9d02_52de_aac73fe34e49 -->|defined in| b7e2774f_9b65_2f26_1d36_abceee1db3ae
  a9106a40_7dcd_d923_0663_c543c16b405d["downloadArtifactsFromGitHub()"]
  a9106a40_7dcd_d923_0663_c543c16b405d -->|calls| 4291e1a8_d44d_9d02_52de_aac73fe34e49
  ce370be0_eacd_6d81_bccf_c0c98c073221["executableIsAvailable()"]
  4291e1a8_d44d_9d02_52de_aac73fe34e49 -->|calls| ce370be0_eacd_6d81_bccf_c0c98c073221
  style 4291e1a8_d44d_9d02_52de_aac73fe34e49 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/release/shared-commands/download-build-artifacts.js lines 88–159

async function processArtifact(artifact, opts) {
  // Download and extract artifact
  const cwd = join(__dirname, '..', '..', '..');
  const tmpDir = mkdtempSync(join(os.tmpdir(), 'react_'));
  await exec(`rm -rf ./build`, {cwd});
  await exec(
    `curl -L ${GITHUB_HEADERS} ${artifact.archive_download_url} > artifacts_combined.zip`,
    {
      cwd: tmpDir,
    }
  );

  if (opts.noVerify === true) {
    console.log(theme`{caution Skipping verification of build artifact.}`);
  } else {
    // Use https://cli.github.com/manual/gh_attestation_verify to verify artifact
    if (executableIsAvailable('gh')) {
      await exec(
        `gh attestation verify artifacts_combined.zip --repo=${OWNER}/${REPO}`,
        {
          cwd: tmpDir,
        }
      );
    }
  }

  await exec(
    `unzip ${tmpDir}/artifacts_combined.zip -d . && rm build2.tgz && tar -xvzf build.tgz && rm build.tgz`,
    {
      cwd,
    }
  );

  // Copy to staging directory
  // TODO: Consider staging the release in a different directory from the CI
  // build artifacts: `./build/node_modules` -> `./staged-releases`
  if (!existsSync(join(cwd, 'build'))) {
    await exec(`mkdir ./build`, {cwd});
  } else {
    await exec(`rm -rf ./build/node_modules`, {cwd});
  }
  let sourceDir;
  // TODO: Rename release channel to `next`
  if (opts.releaseChannel === 'stable') {
    sourceDir = 'oss-stable';
  } else if (opts.releaseChannel === 'experimental') {
    sourceDir = 'oss-experimental';
  } else if (opts.releaseChannel === 'rc') {
    sourceDir = 'oss-stable-rc';
  } else if (opts.releaseChannel === 'latest') {
    sourceDir = 'oss-stable-semver';
  } else {
    console.error(
      'Internal error: Invalid release channel: ' + opts.releaseChannel
    );
    process.exit(opts.releaseChannel);
  }
  await exec(`cp -r ./build/${sourceDir} ./build/node_modules`, {
    cwd,
  });

  // Validate artifact
  const buildSha = readFileSync('./build/COMMIT_SHA', 'utf8').replace(
    /[\u0000-\u001F\u007F-\u009F]/g,
    ''
  );
  if (buildSha !== opts.commit) {
    throw new Error(
      `Requested commit sha does not match downloaded artifact. Expected: ${opts.commit}, got: ${buildSha}`
    );
  }
}

Domain

Subdomains

Frequently Asked Questions

What does processArtifact() do?
processArtifact() is a function in the react codebase, defined in scripts/release/shared-commands/download-build-artifacts.js.
Where is processArtifact() defined?
processArtifact() is defined in scripts/release/shared-commands/download-build-artifacts.js at line 88.
What does processArtifact() call?
processArtifact() calls 1 function(s): executableIsAvailable.
What calls processArtifact()?
processArtifact() is called by 1 function(s): downloadArtifactsFromGitHub.

Analyze Your Own Codebase

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

Try Supermodel Free