main() — react Function Reference
Architecture documentation for the main() function in enable-feature-flag.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD ab68ec04_512e_f89e_9e49_ae73608023f0["main()"] fdb06a3a_b735_af93_2b10_31380c21c8b7["enable-feature-flag.js"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|defined in| fdb06a3a_b735_af93_2b10_31380c21c8b7 ae108147_61d1_61f8_7133_384ffd3e340b["parseArgs()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| ae108147_61d1_61f8_7133_384ffd3e340b 104a1d32_414e_ab5b_d52a_9e300bc4b025["enableFlagInEnvironment()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| 104a1d32_414e_ab5b_d52a_9e300bc4b025 77ee9936_13cc_cf59_df6b_00e1447cdfc5["runTests()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| 77ee9936_13cc_cf59_df6b_00e1447cdfc5 c83f450b_4a22_69d3_6045_9e51a0d7225e["parseFailingTests()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| c83f450b_4a22_69d3_6045_9e51a0d7225e e9a6c968_588d_a8e2_633c_0f8b3c63f7fa["findFixtureFile()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| e9a6c968_588d_a8e2_633c_0f8b3c63f7fa 58164e4d_3af0_d588_b322_d2416e5a91c6["addPragmaToFixture()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| 58164e4d_3af0_d588_b322_d2416e5a91c6 314ce396_c4c8_3833_6334_6393e6f81179["updateSnapshots()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| 314ce396_c4c8_3833_6334_6393e6f81179 8b10b33c_dacb_5e2f_27fa_87868d6869cc["verifyAllTestsPass()"] ab68ec04_512e_f89e_9e49_ae73608023f0 -->|calls| 8b10b33c_dacb_5e2f_27fa_87868d6869cc style ab68ec04_512e_f89e_9e49_ae73608023f0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/scripts/enable-feature-flag.js lines 267–344
async function main() {
const flagName = parseArgs();
console.log(`\nEnabling flag: '${flagName}'`);
try {
// Step 1: Enable flag in Environment.ts
enableFlagInEnvironment(flagName);
// Step 2: Run tests to find failures
const {output} = runTests();
const failingTests = parseFailingTests(output);
console.log(`\nFound ${failingTests.length} failing tests`);
if (failingTests.length === 0) {
console.log('No failing tests! Feature flag enabled successfully.');
process.exit(0);
}
// Step 3: Add pragma to each failing fixture
console.log(`\nAdding '@${flagName}:false' pragma to failing fixtures...`);
const notFound = [];
let notFoundCount = 0;
for (const testName of failingTests) {
const fixturePath = findFixtureFile(testName);
if (!fixturePath) {
console.warn(`Could not find fixture file for: ${testName}`);
notFound.push(fixturePath);
continue;
}
const updated = addPragmaToFixture(fixturePath, flagName);
if (updated) {
updatedCount++;
console.log(` Updated: ${testName}`);
}
}
console.log(
`\nSummary: Updated ${updatedCount} fixtures, ${notFoundCount} not found`
);
if (notFoundCount.length !== 0) {
console.error(
'\nFailed to update snapshots, could not find:\n' + notFound.join('\n')
);
process.exit(1);
}
// Step 4: Update snapshots
if (!updateSnapshots()) {
console.error('\nFailed to update snapshots');
process.exit(1);
}
// Step 5: Verify all tests pass
if (!verifyAllTestsPass()) {
console.error('\nVerification failed: Some tests are still failing');
process.exit(1);
}
console.log('\nSuccess! Feature flag enabled and all tests passing.');
console.log(`\nSummary:`);
console.log(` - Enabled "${flagName}" in Environment.ts`);
console.log(` - Updated ${updatedCount} fixture files with pragma`);
console.log(` - All tests passing`);
process.exit(0);
} catch (error) {
console.error('\nFatal error:', error.message);
console.error(error.stack);
process.exit(1);
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does main() do?
main() is a function in the react codebase, defined in compiler/scripts/enable-feature-flag.js.
Where is main() defined?
main() is defined in compiler/scripts/enable-feature-flag.js at line 267.
What does main() call?
main() calls 8 function(s): addPragmaToFixture, enableFlagInEnvironment, findFixtureFile, parseArgs, parseFailingTests, runTests, updateSnapshots, verifyAllTestsPass.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free