Home / File/ download-build-artifacts.js — react Source File

download-build-artifacts.js — react Source File

Architecture documentation for download-build-artifacts.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

'use strict';

const {join} = require('path');
const theme = require('../theme');
const {exec} = require('child-process-promise');
const {existsSync, mkdtempSync, readFileSync} = require('fs');
const {logPromise} = require('../utils');
const os = require('os');

if (process.env.GH_TOKEN == null) {
  console.log(
    theme`{error Expected GH_TOKEN to be provided as an env variable}`
  );
  process.exit(1);
}

const OWNER = 'facebook';
const REPO = 'react';
const WORKFLOW_ID = 'runtime_build_and_test.yml';
const GITHUB_HEADERS = `
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer ${process.env.GH_TOKEN}" \
  -H "X-GitHub-Api-Version: 2022-11-28"`.trim();

async function executableIsAvailable(name) {
  try {
    await exec(`which ${name}`);
    return true;
  } catch (_error) {
    return false;
  }
}

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

function getWorkflowId() {
  if (
    existsSync(join(__dirname, `../../../.github/workflows/${WORKFLOW_ID}`))
  ) {
    return WORKFLOW_ID;
  } else {
    throw new Error(
      `Incorrect workflow ID: .github/workflows/${WORKFLOW_ID} does not exist. Please check the name of the workflow being downloaded from.`
    );
  }
}

async function getWorkflowRun(commit) {
  const res = await exec(
    `curl -L ${GITHUB_HEADERS} https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${getWorkflowId()}/runs?head_sha=${commit}`
  );

  const json = JSON.parse(res.stdout);
  const workflowRun = json.workflow_runs.find(run => run.head_sha === commit);

  if (workflowRun == null || workflowRun.id == null) {
    console.log(
      theme`{error The workflow run for the specified commit (${commit}) could not be found.}`
// ... (167 more lines)

Domain

Subdomains

Frequently Asked Questions

What does download-build-artifacts.js do?
download-build-artifacts.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in download-build-artifacts.js?
download-build-artifacts.js defines 8 function(s): downloadArtifactsFromGitHub, downloadBuildArtifacts, executableIsAvailable, getArtifact, getWorkflowId, getWorkflowRun, processArtifact, sleep.
Where is download-build-artifacts.js in the architecture?
download-build-artifacts.js is located at scripts/release/shared-commands/download-build-artifacts.js (domain: BabelCompiler, subdomain: Optimization, directory: scripts/release/shared-commands).

Analyze Your Own Codebase

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

Try Supermodel Free