Home / File/ enable-feature-flag.js — react Source File

enable-feature-flag.js — react Source File

Architecture documentation for enable-feature-flag.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

#!/usr/bin/env node
/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

'use strict';

const fs = require('fs');
const path = require('path');
const {execSync} = require('child_process');
const yargs = require('yargs/yargs');
const {hideBin} = require('yargs/helpers');

// Constants
const COMPILER_ROOT = path.resolve(__dirname, '..');
const ENVIRONMENT_TS_PATH = path.join(
  COMPILER_ROOT,
  'packages/babel-plugin-react-compiler/src/HIR/Environment.ts'
);
const FIXTURES_PATH = path.join(
  COMPILER_ROOT,
  'packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler'
);
const FIXTURE_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];

/**
 * Parse command line arguments
 */
function parseArgs() {
  const argv = yargs(hideBin(process.argv))
    .usage('Usage: $0 <flag-name>')
    .command('$0 <flag-name>', 'Enable a feature flag by default', yargs => {
      yargs.positional('flag-name', {
        describe: 'Name of the feature flag to enable',
        type: 'string',
      });
    })
    .example(
      '$0 validateExhaustiveMemoizationDependencies',
      'Enable the validateExhaustiveMemoizationDependencies flag'
    )
    .help('h')
    .alias('h', 'help')
    .strict()
    .parseSync();

  return argv['flag-name'];
}

/**
 * Enable a feature flag in Environment.ts by changing default(false) to default(true)
 */
function enableFlagInEnvironment(flagName) {
  console.log(`\nEnabling flag "${flagName}" in Environment.ts...`);

  const content = fs.readFileSync(ENVIRONMENT_TS_PATH, 'utf8');

// ... (288 more lines)

Domain

Subdomains

Frequently Asked Questions

What does enable-feature-flag.js do?
enable-feature-flag.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in enable-feature-flag.js?
enable-feature-flag.js defines 10 function(s): addPragmaToFixture, enableFlagInEnvironment, escapeRegex, findFixtureFile, main, parseArgs, parseFailingTests, runTests, updateSnapshots, verifyAllTestsPass.
Where is enable-feature-flag.js in the architecture?
enable-feature-flag.js is located at compiler/scripts/enable-feature-flag.js (domain: BabelCompiler, subdomain: Entrypoint, directory: compiler/scripts).

Analyze Your Own Codebase

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

Try Supermodel Free