Skip to content

Commit

Permalink
Generalize feature flags script (facebook#47208)
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.

Reviewed By: NickGerleman, mdvacca

Differential Revision: D64982509
  • Loading branch information
rubennorte authored and facebook-github-bot committed Oct 29, 2024
1 parent c1e964a commit 6cbb5c4
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<<575eeb1e291c1a372eba7aabcdd948e3>>
* @generated SignedSource<<08972b0d212c7cbd368ce7efa4f78f5c>>
*/

/**
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<<f93759a639dbbb95d3307003e4907c86>>
* @generated SignedSource<<c1b973fa83784d377b620d4040a05e76>>
*/

/**
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<<44d0fe9a36e5e51816e10b8799d451fe>>
* @generated SignedSource<<e6ea4838853d8f298dd9c996b3439f2d>>
*/

/**
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<<917a6effbfd0a476cc05d90abee3c80b>>
* @generated SignedSource<<ae533ef1019fd91d55aa3d7a16145f1e>>
*/

/**
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<<2ad36465b1a411cb55d85416bd8ba823>>
* @generated SignedSource<<9f5a8ccd98fa587f0a9c394dec95d75b>>
*/

/**
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<<9770a9f125b8bcb4b1daef9e3458433f>>
* @generated SignedSource<<923c34dde7fe9ade2d40e12c8013449f>>
*/

/**
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<<aaf6af36813ab1895bf2bf8a6c8bcf1c>>
* @generated SignedSource<<8b3007bb9eaa592dc2c4cfb55be0bb74>>
*/

/**
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<<d4194069e582c0aa5e90938b27067044>>
* @generated SignedSource<<d3aabad51a0825fae9f61c4d9d39e562>>
*/

/**
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<<abba7ef1f3108b195eef7bfc0a9a26db>>
* @generated SignedSource<<5147e0a78602b2baa8892da1ce06f3d7>>
*/

/**
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<<c6419e8e932f65c7be43425e01776dc9>>
* @generated SignedSource<<b422822a6079e0c30f43e3c724da70fb>>
*/

/**
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<<fe44d2dba1abe83205db630abe1c2e9a>>
* @generated SignedSource<<7f8b1eab1e3f67089ff942b87c5a5a21>>
*/

/**
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<<afdb4fb4d8419dca361ca8bf7dbc4fb3>>
* @generated SignedSource<<9fb4a252a55e5f40124e6b6234d81b6f>>
*/

/**
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<<631c825e33e07674e19a084a33637a50>>
* @generated SignedSource<<72b8beea25e57854a4bcbf9fc50ae9b6>>
*/

/**
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<<18597e1e2a88be3d80b8747f72576d5f>>
* @generated SignedSource<<e1ade9dbf408d3ab46e682d80791acec>>
*/

/**
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<<43e3b8b18dec356b5121b581ab8ffa02>>
* @generated SignedSource<<08a47ddea235cdd65a3c88d24a718992>>
*/

/**
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<<f6fb3afe84c464ac7ae60b34181c182b>>
* @generated SignedSource<<5aed185219893d7469f1b1b782cf2f92>>
*/

/**
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<<096ac17a630f7b29d3a029c704dbd8db>>
* @generated SignedSource<<813292c349a40864e3c954a12bc12a25>>
* @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 6cbb5c4

Please sign in to comment.