1. #!/usr/bin/env node
    
  2. 
    
  3. 'use strict';
    
  4. 
    
  5. const clear = require('clear');
    
  6. const {existsSync} = require('fs');
    
  7. const {readJsonSync} = require('fs-extra');
    
  8. const {join} = require('path');
    
  9. const theme = require('../theme');
    
  10. const {execRead} = require('../utils');
    
  11. 
    
  12. const run = async ({cwd, packages, tags}) => {
    
  13.   // Tags are named after the react version.
    
  14.   const {version} = readJsonSync(
    
  15.     `${cwd}/build/node_modules/react/package.json`
    
  16.   );
    
  17. 
    
  18.   clear();
    
  19. 
    
  20.   if (tags.length === 1 && tags[0] === 'next') {
    
  21.     console.log(
    
  22.       theme`{header A "next" release} {version ${version}} {header has been published!}`
    
  23.     );
    
  24.   } else if (tags.length === 1 && tags[0] === 'experimental') {
    
  25.     console.log(
    
  26.       theme`{header An "experimental" release} {version ${version}} {header has been published!}`
    
  27.     );
    
  28.   } else {
    
  29.     const nodeModulesPath = join(cwd, 'build/node_modules');
    
  30. 
    
  31.     console.log(
    
  32.       theme.caution`The release has been published but you're not done yet!`
    
  33.     );
    
  34. 
    
  35.     if (tags.includes('latest')) {
    
  36.       // All packages are built from a single source revision,
    
  37.       // so it is safe to read build info from any one of them.
    
  38.       const arbitraryPackageName = packages[0];
    
  39.       // FIXME: New build script does not output build-info.json. It's only used
    
  40.       // by this post-publish print job, and only for "latest" releases, so I've
    
  41.       // disabled it as a workaround so the publish script doesn't crash for
    
  42.       // "next" and "experimental" pre-releases.
    
  43.       const {commit} = readJsonSync(
    
  44.         join(
    
  45.           cwd,
    
  46.           'build',
    
  47.           'node_modules',
    
  48.           arbitraryPackageName,
    
  49.           'build-info.json'
    
  50.         )
    
  51.       );
    
  52. 
    
  53.       console.log();
    
  54.       console.log(
    
  55.         theme.header`Please review and commit all local, staged changes.`
    
  56.       );
    
  57. 
    
  58.       console.log();
    
  59.       console.log('Version numbers have been updated in the following files:');
    
  60.       for (let i = 0; i < packages.length; i++) {
    
  61.         const packageName = packages[i];
    
  62.         console.log(theme.path`• packages/%s/package.json`, packageName);
    
  63.       }
    
  64.       const status = await execRead(
    
  65.         'git diff packages/shared/ReactVersion.js',
    
  66.         {cwd}
    
  67.       );
    
  68.       if (status) {
    
  69.         console.log(theme.path`• packages/shared/ReactVersion.js`);
    
  70.       }
    
  71. 
    
  72.       console.log();
    
  73.       console.log(
    
  74.         theme`{header Don't forget to also update and commit the }{path CHANGELOG}`
    
  75.       );
    
  76. 
    
  77.       // Prompt the release engineer to tag the commit and update the CHANGELOG.
    
  78.       // (The script could automatically do this, but this seems safer.)
    
  79.       console.log();
    
  80.       console.log(
    
  81.         theme.header`Tag the source for this release in Git with the following command:`
    
  82.       );
    
  83.       console.log(
    
  84.         theme`  {command git tag -a v}{version %s} {command -m "v%s"} {version %s}`,
    
  85.         version,
    
  86.         version,
    
  87.         commit
    
  88.       );
    
  89.       console.log(theme.command`  git push origin --tags`);
    
  90. 
    
  91.       console.log();
    
  92.       console.log(theme.header`Lastly, please fill in the release on GitHub.`);
    
  93.       console.log(
    
  94.         theme.link`https://github.com/facebook/react/releases/tag/v%s`,
    
  95.         version
    
  96.       );
    
  97.       console.log(
    
  98.         theme`\nThe GitHub release should also include links to the following artifacts:`
    
  99.       );
    
  100.       for (let i = 0; i < packages.length; i++) {
    
  101.         const packageName = packages[i];
    
  102.         if (existsSync(join(nodeModulesPath, packageName, 'umd'))) {
    
  103.           const {version: packageVersion} = readJsonSync(
    
  104.             join(nodeModulesPath, packageName, 'package.json')
    
  105.           );
    
  106.           console.log(
    
  107.             theme`{path • %s:} {link https://unpkg.com/%s@%s/umd/}`,
    
  108.             packageName,
    
  109.             packageName,
    
  110.             packageVersion
    
  111.           );
    
  112.         }
    
  113.       }
    
  114. 
    
  115.       // Update reactjs.org so the React version shown in the header is up to date.
    
  116.       console.log();
    
  117.       console.log(
    
  118.         theme.header`Once you've pushed changes, update the docs site.`
    
  119.       );
    
  120.       console.log(
    
  121.         'This will ensure that any newly-added error codes can be decoded.'
    
  122.       );
    
  123. 
    
  124.       console.log();
    
  125.     }
    
  126.   }
    
  127. };
    
  128. 
    
  129. module.exports = run;