Home / Function/ main() — react Function Reference

main() — react Function Reference

Architecture documentation for the main() function in deploy.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  bfd63950_a7b7_3bf8_b5ef_b416137c3d1a["main()"]
  967080ba_358f_7b5f_218a_69b2c1b4977a["deploy.js"]
  bfd63950_a7b7_3bf8_b5ef_b416137c3d1a -->|defined in| 967080ba_358f_7b5f_218a_69b2c1b4977a
  style bfd63950_a7b7_3bf8_b5ef_b416137c3d1a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-extensions/deploy.js lines 9–49

const main = async buildId => {
  const root = join(__dirname, buildId);
  const buildPath = join(root, 'build');

  execSync(`node ${join(root, './build')}`, {
    cwd: __dirname,
    env: {
      ...process.env,
      NODE_ENV: 'production',
    },
    stdio: 'inherit',
  });
  shell.cp(join(root, 'now.json'), join(buildPath, 'now.json'));
  const file = readFileSync(join(root, 'now.json'));
  const json = JSON.parse(file);
  const alias = json.alias[0];

  const commit = execSync('git rev-parse HEAD').toString().trim().slice(0, 7);

  let date = new Date();
  date = `${date.toLocaleDateString()} – ${date.toLocaleTimeString()}`;

  const installationInstructions =
    buildId === 'chrome'
      ? readFileSync(join(__dirname, 'deploy.chrome.html'))
      : readFileSync(join(__dirname, 'deploy.firefox.html'));

  let html = readFileSync(join(__dirname, 'deploy.html')).toString();
  html = html.replace(/%commit%/g, commit);
  html = html.replace(/%date%/g, date);
  html = html.replace(/%installation%/, installationInstructions);

  writeFileSync(join(buildPath, 'index.html'), html);

  await exec(`now deploy && now alias ${alias}`, {
    cwd: buildPath,
    stdio: 'inherit',
  });

  console.log(`Deployed to https://${alias}.now.sh`);
};

Domain

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the react codebase, defined in packages/react-devtools-extensions/deploy.js.
Where is main() defined?
main() is defined in packages/react-devtools-extensions/deploy.js at line 9.

Analyze Your Own Codebase

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

Try Supermodel Free