Skip to content

Commit

Permalink
Generalize feature flags script
Browse files Browse the repository at this point in the history
Summary:
Chagelog: [internal]

Small change to unify the yarn commands for feature flags into a single `featureflags` command with options.

Differential Revision: D64982509
  • Loading branch information
rubennorte authored and facebook-github-bot committed Oct 25, 2024
1 parent eddc0a1 commit 5062c39
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 47 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"flow": "flow",
"format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"",
"format": "npm run prettier && npm run clang-format",
"featureflags-check": "cd packages/react-native && yarn featureflags-check",
"featureflags-update": "cd packages/react-native && yarn featureflags-update",
"featureflags": "cd packages/react-native && yarn featureflags",
"lint-ci": "./scripts/circleci/analyze_code.sh && yarn shellcheck",
"lint-java": "node ./scripts/lint-java.js",
"lint": "eslint .",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f98a6ddd268fb59b5ee5edb4997b3a63>>
* @generated SignedSource<<6bc1c779d0b9c0992e4657eb1c6efc21>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

package com.facebook.react.internal.featureflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6b3d3512d88c836dd809204cad636211>>
* @generated SignedSource<<7ca0d65f41a40cd6be26c549f8fc85fc>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

package com.facebook.react.internal.featureflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0ef9a66ccabeb0357f4b15c3e897f8fb>>
* @generated SignedSource<<3dd8c79c6b680c4761fdcd495386e3fe>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

package com.facebook.react.internal.featureflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ee5400241a72652a2f8ff343a06e4e8c>>
* @generated SignedSource<<9bc911195401de29bab8958cd4157b19>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

package com.facebook.react.internal.featureflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<949f5cdf6d0a4015fbd680ba718dce6d>>
* @generated SignedSource<<81dd35b66024651fe4e4968f0704451d>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

package com.facebook.react.internal.featureflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<4e42e76c98b7434273e4f11212f0527b>>
* @generated SignedSource<<8694ff4508b663e6c527b719eeb4207f>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

package com.facebook.react.internal.featureflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<732d1ea726d8a08859bd153dc767ec7a>>
* @generated SignedSource<<565778c9f580fb4447930b080fa140ae>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#include "JReactNativeFeatureFlagsCxxInterop.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<88fc1d08894dc2f774ed8c64b20bdaeb>>
* @generated SignedSource<<6f0443c154bbc82a537c997dd6269326>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<e510ad161d5c9473e9f8d9b898c7d727>>
* @generated SignedSource<<d9eb4f6e593483a67fb3ef350cfb8707>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#include "ReactNativeFeatureFlags.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<29b98e3d5daf7ad09cdee366ef38753e>>
* @generated SignedSource<<dd1f920b4e1aeb5a647c4e0879f7ebb3>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<59763b4423e81fbb2f99f78d12c9cca7>>
* @generated SignedSource<<ffa7ecb6773c104331bb765fb0bf9f95>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#include <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bcb41adc68b6a45985943b99c088deb5>>
* @generated SignedSource<<8dcef6466f53c17c4969397a30a7a310>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<116547f17bc1b3d16a8de7c92c5a9d53>>
* @generated SignedSource<<f5ffc9601ff4f035c1d1d8f5a5cc8b1a>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<db5be5cf16d7e39a9b5d812ae6285571>>
* @generated SignedSource<<cc7d88ff24669e16983e1d5fdf702755>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<77a440bf8f6221e90d5ab7a1d7ad638e>>
* @generated SignedSource<<0ec2eba801e132a8dfaa946221248914>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#include "NativeReactNativeFeatureFlags.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0885affcf6782a59b0f4a3d1370ffc90>>
* @generated SignedSource<<913df5186d57463be5566d0c0cad7855>>
*/

/**
Expand All @@ -14,7 +14,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

#pragma once
Expand Down
3 changes: 1 addition & 2 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
],
"scripts": {
"prepack": "node ./scripts/prepack.js",
"featureflags-check": "node ./scripts/featureflags/index.js --verify-unchanged",
"featureflags-update": "node ./scripts/featureflags/index.js"
"featureflags": "node ./scripts/featureflags/index.js"
},
"peerDependencies": {
"@types/react": "^18.2.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/scripts/featureflags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ must be regenerated running this from the `react-native`
repository:

```shell
yarn featureflags-update
yarn featureflags --update
```

## Access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {FeatureFlagDefinitions} from './types';
*
* If you modify this file, you need to update all the generated files
* running the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

// These flags are only used in tests for the feature flags system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function generateFiles(

throw new Error(
`Detected changes in generated files for feature flags:\n${changedFilesStr}\n\n` +
'Please rerun `yarn featureflags-update` and commit the changes.',
'Please rerun `yarn featureflags --update` and commit the changes.',
);
}

Expand Down
24 changes: 22 additions & 2 deletions packages/react-native/scripts/featureflags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@

if (require.main === module) {
require('../../../../scripts/build/babel-register').registerForMonorepo();
const update = require('./update').default;
update(process.argv.includes('--verify-unchanged'));

let command;

if (process.argv.includes('--update')) {
command = 'update';
} else if (process.argv.includes('--verify-unchanged')) {
command = 'verify-unchanged';
}

switch (command) {
case 'update':
require('./update').default(false);
break;
case 'verify-unchanged':
require('./update').default(true);
break;
default:
console.error(
'Usage: node featureflags.js [--update|--verify-unchanged]',
);
process.exit(1);
}
}
2 changes: 1 addition & 1 deletion packages/react-native/scripts/featureflags/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ export const DO_NOT_MODIFY_COMMENT = `/**
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/`;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f78f43e37af86d21faf92f4fea89f351>>
* @generated SignedSource<<7b21b622cc3cfa0c42c549484307b7cd>>
* @flow strict
*/

Expand All @@ -15,7 +15,7 @@
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags-update
* yarn featureflags --update
*/

import {
Expand Down
Loading

0 comments on commit 5062c39

Please sign in to comment.