1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  */
    
  7. 
    
  8. const {execSync} = require('child_process');
    
  9. const {readFileSync} = require('fs');
    
  10. const {resolve} = require('path');
    
  11. 
    
  12. const DARK_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.5)';
    
  13. const DARK_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.5)';
    
  14. const DARK_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.5)';
    
  15. const LIGHT_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.75)';
    
  16. const LIGHT_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.75)';
    
  17. const LIGHT_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.75)';
    
  18. 
    
  19. const GITHUB_URL = 'https://github.com/facebook/react';
    
  20. 
    
  21. function getGitCommit() {
    
  22.   try {
    
  23.     return execSync('git show -s --no-show-signature --format=%h')
    
  24.       .toString()
    
  25.       .trim();
    
  26.   } catch (error) {
    
  27.     // Mozilla runs this command from a git archive.
    
  28.     // In that context, there is no Git revision.
    
  29.     return null;
    
  30.   }
    
  31. }
    
  32. 
    
  33. function getVersionString(packageVersion = null) {
    
  34.   if (packageVersion == null) {
    
  35.     packageVersion = JSON.parse(
    
  36.       readFileSync(
    
  37.         resolve(__dirname, '..', 'react-devtools-core', './package.json'),
    
  38.       ),
    
  39.     ).version;
    
  40.   }
    
  41. 
    
  42.   const commit = getGitCommit();
    
  43. 
    
  44.   return `${packageVersion}-${commit}`;
    
  45. }
    
  46. 
    
  47. module.exports = {
    
  48.   DARK_MODE_DIMMED_WARNING_COLOR,
    
  49.   DARK_MODE_DIMMED_ERROR_COLOR,
    
  50.   DARK_MODE_DIMMED_LOG_COLOR,
    
  51.   LIGHT_MODE_DIMMED_WARNING_COLOR,
    
  52.   LIGHT_MODE_DIMMED_ERROR_COLOR,
    
  53.   LIGHT_MODE_DIMMED_LOG_COLOR,
    
  54.   GITHUB_URL,
    
  55.   getGitCommit,
    
  56.   getVersionString,
    
  57. };