Commit Graph

58 Commits

Author SHA1 Message Date
anirudh.bharti 7cdb87eb19 chore: replace mkdirp with mkdir fs (#46388)
Summary:
This pull request replaces the use of mkdirp with Node.js's built-in fs.mkdirSync({ recursive: true }) function, which is available in Node.js version 10.12.0 and above. This change reduces the number of external dependencies and simplifies the codebase by using the native capabilities of Node.js.

The motivation behind this change is to remove the unnecessary mkdirp dependency, as Node.js natively supports recursive directory creation since version 10.12.0. This streamlines the code and reduces the reliance on external libraries.

## Changelog:

[INTERNAL] [REMOVED] - Replaced mkdirp with fs.mkdirSync({ recursive: true }) in build scripts and codegen. Requires Node.js 10.12.0 and above.

Pull Request resolved: https://github.com/facebook/react-native/pull/46388

Test Plan: I ran the build and codegen scripts locally with Node.js version 10.12.0 and above after replacing mkdirp, ensuring the scripts work as expected. No issues were encountered, and all processes, including directory creation and file handling, function correctly.

Reviewed By: cortinico

Differential Revision: D62852488

Pulled By: huntie

fbshipit-source-id: 76f44102a80b499521c156308d276a17d279ce38
2024-09-17 07:03:44 -07:00
Alex Hunt 4a6b889e93 Move all package.json updates into set-version script (#45180)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45180

- Simplifies the responsibilities of `scripts/releases/set-rn-version.js`.
    - This no longer modifies `packages/react-native/package.json`, delegating this to `set-version`.
- Simplifies logic in `set-version`, **fixing behaviour** against deps in `packages/react-native/package.json`.
- This also acts as cleanup since D58469912 (template removal) — removing the unreferenced `update-template-package.js` util.

NOTE: This diff will be followed up by a merge of the `set-rn-version` script into `set-version`. (I had considered a rename to `version-rn-artifacts`, intentionally keeping this script separate and distinct from a future [`lerna version` + this script] setup — however the current UX and confusion with this naming would be too confusing. It can move into a util 👍🏻.)

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D59055522

fbshipit-source-id: 79b937f9e0ac790512b180ab4147aefef7f5202c
2024-06-26 07:59:49 -07:00
Riccardo Cipolleschi 710b0e64ab Port fixes to release scripts to use GITHUB_REF and GITHUB_REF_NAME variables (#45066)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45066

This changes ports in main the fixes we had to make to the release scripts to run properly in release mode.

This includes the commits:

* https://github.com/facebook/react-native/commit/375c88478c985976e1b59dfa7353042a18b4d132
* https://github.com/facebook/react-native/commit/609c7c05b13214f2a834b251de095243f8dcbf68
* https://github.com/facebook/react-native/pull/45062

## Changelog:
[Internal] - Fix release scripts to run properly in release mode

Reviewed By: cortinico

Differential Revision: D58782925

fbshipit-source-id: b096909d5f8281809ee3c2a01eefda1d19f32936
2024-06-20 03:24:29 -07:00
Riccardo Cipolleschi 993f500fcf Add support for patch rc versions
Summary:
We might want to publish some new versions of React Native with experimental feature to allow some partners to test whether those versions fixes some reported issues, before creating a proper stable version for the whole ecosystem.

The infra is mostly [setup for this](https://www.internalfb.com/code/fbsource/[496a64d180faab501b8598aa0ec26d47454fb961]/xplat/js/react-native-github/scripts/releases/utils/version-utils.js?lines=149), already. The only detail we need to take care of is not to move the `next` tag.

## Changelog:
[Internal]

Reviewed By: cortinico, huntie

Differential Revision: D56578456

fbshipit-source-id: 8dcc674aab5f85077c1b3e6580c5aeb99226eff8
2024-04-25 15:17:34 -07:00
Alex Hunt 5a80935cf2 Remove bump-all-updated-packages script (#43534)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43534

This is no longer used after switching to the new release workflow, which uses the newer and less error-prone `set-version` script.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D55027122

fbshipit-source-id: faa8cfd2af9b54fab611b108df162793c5768695
2024-03-19 07:05:03 -07:00
Alex Hunt 76598de621 Reorganise and document release script entry points (#42774)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42774

Reorganise release scripts so that command entry points are grouped based on execution context, which also reflects dependencies between scripts.

Also:

- Document the current behaviours of these scripts.
- Relocate utils out of the root contents.
- Replace `exec` call to `set-rn-version` script with function import.

NOTE: `yarn trigger-react-native-release` (documented command in release process) is unchanged, since this is aliased from `package.json`.

```
├── releases
│   ├── templates/
│   ├── utils/
│   ├── remove-new-arch-flags.js
│   ├── set-rn-version.js
│   └── update-template-package.js
├── releases-ci
│   ├── prepare-package-for-release.js
│   └── publish-npm.js
└── releases-local
    └── trigger-react-native-release.js
```

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53274341

fbshipit-source-id: eec2befc43e7a47fd821b2e2bcc818ddffbb6cf7
2024-02-01 06:02:17 -08:00
Alex Hunt b7b55854fe Enable Flow on misc release scripts (#42736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42736

- Minimally enable Flow in these scripts. This would have caught outdated imports in D53001971 and D53228096.
- Update `publish-npm` script with async `main()` function.
- Also delete leftover `ReactNativeVersion.js.template` file.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53225162

fbshipit-source-id: 9521291b7c84728e3e05af510ebf3244a9a189e5
2024-01-31 03:36:02 -08:00
Alex Hunt 2f818b464f Fix import in publish-npm script (#42740)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42740

Follow-up to a CircleCI breakage introduced by D53001971.

This was missed by both the typechecker (no Flow in file) and CI (no PR-time jobs covering this script).

Changelog: [Internal]

Reviewed By: cortinico, GijsWeterings, cipolleschi

Differential Revision: D53228096

fbshipit-source-id: fbbe1538ee52b8452399d86489239434d3a068be
2024-01-30 10:59:02 -08:00
Alex Hunt e97ba475aa Relocate and refactor set-rn-version script (#42730)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42730

Reviewing and modernising this script as part of simplifying our release publish workflow.

- Drop unused `--dependency-versions` arg from CLI entry point
- Simplify templating approach
- Type as Flow
- Drop dependencies on `shelljs` and `yargs`
- Relocate under `scripts/releases/`
- Rewrite tests as snapshot tests

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D53001971

fbshipit-source-id: e55a71a0bb37e3e18ba1e582a5c46ddd58823d81
2024-01-30 06:46:50 -08:00
Luna Wei 0851f04353 Flow type some util files (#42372)
Summary:
Changelog: [Internal] Flow comment type some util scripts

Pull Request resolved: https://github.com/facebook/react-native/pull/42372

Reviewed By: NickGerleman

Differential Revision: D52893759

Pulled By: lunaleaps

fbshipit-source-id: 6a3632f2c0b9faa97a451d82ef5a888bb5be81fa
2024-01-22 10:29:54 -08:00
Luna Wei fe0306d637 Support specifying dist-tags for monorepo package bumps (#42146)
Summary:
Currently our CI will auto-tag any `npm publish` as `latest` for the monorepo packages. This is because [we do not specify a tag](https://github.com/facebook/react-native/blob/main/scripts/monorepo/find-and-publish-all-bumped-packages.js#L104), so npm will [default to `latest`](https://docs.npmjs.com/cli/v10/commands/npm-dist-tag#description). We encountered a similar issue for `react-native` awhile ago and fixed that with [always specifying a tag](https://github.com/facebook/react-native/blob/main/scripts/npm-utils.js#L84), with the explicit opt-in for `latest`.

yarn and npm will resolve `*` dependencies using `latest`. This will be a problem for any React Native version that uses `*` deps. We have actively tried to remove these `*` versions but older patches may still contain them.

When we do a monorepo package bump, it may be for 0.71 and for a user who is initializing a 0.72 version project (that still has * deps), they will receive monorepo packages of version `0.71.x`, which is not compatible. (React Native monorepo packages do not faithfully follow semver)

This change allows us to specify what tags to use and suggest tags based on what branch you are on and asks for confirmation

```
> branch 0.73-stable
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "0.73-stable"
 ◉ "latest"
? Confirm these tags for *ALL* packages being bumped: "0.73-stable","latest" (Y/n)

> branch 0.72-stable
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "0.72-stable"
 ◯ "latest"
? Confirm these tags for *ALL* packages being bumped: "0.72-stable" (Y/n)

> branch main
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "nightly"
? Confirm these tags for *ALL* packages being bumped: "nightly" (Y/n)
```

## Changelog:

[INTERNAL] [CHANGED] - Support dist-tags in publishing monorepo packages to avoid default "latest" tag.

Pull Request resolved: https://github.com/facebook/react-native/pull/42146

Test Plan: `yarn test scripts/`

Reviewed By: NickGerleman

Differential Revision: D52551769

Pulled By: lunaleaps

fbshipit-source-id: 52f923464387cffdc6ca22c6f0a45425965a3680
2024-01-08 08:38:53 -08:00
Luna Wei 05ec058ac5 Add print-packages as a command (#41959)
Summary:
Working on releases, I'm often looking for the name of our monorepo packages (as sometimes the name doesn't align with the directory) and also getting a list of the versions of everything, as well as if its private/public -- which I've interpreted to mean that we publish it or we don't. I thought this might be convenient to add.

## Changelog:
[Internal] - Add `print-packages` as a command to print our monorepo packages (including react-native)

Pull Request resolved: https://github.com/facebook/react-native/pull/41959

Test Plan:
```
❯ yarn print-packages
yarn run v1.22.19
$ node ./scripts/monorepo/print
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤
│    0    │  ''   │     'react-native/assets-registry'     │    '0.74.0'    │
│    1    │  ''   │  'react-native/babel-plugin-codegen'   │    '0.74.0'    │
│    2    │  ''   │  'react-native/community-cli-plugin'   │    '0.74.0'    │
│    3    │  ''   │    'react-native/debugger-frontend'    │    '0.74.0'    │
│    4    │  ''   │     'react-native/dev-middleware'      │    '0.74.0'    │
│    5    │  ''   │      'react-native/eslint-config'      │    '0.74.0'    │
│    6    │  ''   │      'react-native/eslint-plugin'      │    '0.74.0'    │
│    7    │  ''   │   'react-native/eslint-plugin-specs'   │    '0.74.0'    │
│    8    │  ''   │ 'react-native/hermes-inspector-msggen' │    '0.72.0'    │
│    9    │  ''   │      'react-native/metro-config'       │    '0.74.0'    │
│   10    │  ''   │    'react-native/normalize-colors'     │    '0.74.1'    │
│   11    │  ''   │      'react-native/js-polyfills'       │    '0.74.0'    │
│   12    │  ''   │             'react-native'              │   '1000.0.0'   │
│   13    │  ''   │      'react-native/babel-preset'       │    '0.74.0'    │
│   14    │  ''   │ 'react-native/metro-babel-transformer' │    '0.74.0'    │
│   15    │  ''   │          'react-native/bots'           │    '0.0.0'     │
│   16    │  ''   │         'react-native/codegen'         │    '0.74.0'    │
│   17    │  ''   │ 'react-native/codegen-typescript-test' │    '0.0.1'     │
│   18    │  ''   │      'react-native/gradle-plugin'      │    '0.74.0'    │
│   19    │  ''   │         'react-native/tester'          │    '0.0.1'     │
│   20    │  ''   │       'react-native/tester-e2e'        │    '0.0.1'     │
│   21    │  ''   │    'react-native/typescript-config'    │    '0.74.0'    │
│   22    │  ''   │    'react-native/virtualized-lists'    │    '0.74.0'    │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┘
  Done in 0.55s.
```

Also added filter flag for private/public
```
❯ yarn print-packages --type private
yarn run v1.22.19
$ node ./scripts/monorepo/print --type private
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤
│    0    │  ''   │ 'react-native/hermes-inspector-msggen' │    '0.72.0'    │
│    1    │  ''   │          'react-native/bots'           │    '0.0.0'     │
│    2    │  ''   │ 'react-native/codegen-typescript-test' │    '0.0.1'     │
│    3    │  ''   │         'react-native/tester'          │    '0.0.1'     │
│    4    │  ''   │       'react-native/tester-e2e'        │    '0.0.1'     │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┘
  Done in 0.16s.
```

Also added a npm query where you can see the latest published version of a minor
```
❯ yarn print-packages --type public --minor 72
yarn run v1.22.19
$ node ./scripts/monorepo/print --type public --minor 72
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┬──────────────────────────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │             Version (72)             │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┼──────────────────────────────────────┤
│    0    │  ''   │     'react-native/assets-registry'     │    '0.74.0'    │               '0.72.0'               │
│    1    │  ''   │  'react-native/babel-plugin-codegen'   │    '0.74.0'    │               '0.72.3'               │
│    2    │  ''   │  'react-native/community-cli-plugin'   │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    3    │  ''   │    'react-native/debugger-frontend'    │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    4    │  ''   │     'react-native/dev-middleware'      │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    5    │  ''   │      'react-native/eslint-config'      │    '0.74.0'    │               '0.72.2'               │
│    6    │  ''   │      'react-native/eslint-plugin'      │    '0.74.0'    │               '0.72.0'               │
│    7    │  ''   │   'react-native/eslint-plugin-specs'   │    '0.74.0'    │               '0.72.4'               │
│    8    │  ''   │      'react-native/metro-config'       │    '0.74.0'    │              '0.72.11'               │
│    9    │  ''   │    'react-native/normalize-colors'     │    '0.74.1'    │               '0.72.0'               │
│   10    │  ''   │      'react-native/js-polyfills'       │    '0.74.0'    │               '0.72.1'               │
│   11    │  ''   │             'react-native'              │   '1000.0.0'   │               '0.72.8'               │
│   12    │  ''   │      'react-native/babel-preset'       │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   13    │  ''   │ 'react-native/metro-babel-transformer' │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   14    │  ''   │         'react-native/codegen'         │    '0.74.0'    │               '0.72.8'               │
│   15    │  ''   │      'react-native/gradle-plugin'      │    '0.74.0'    │              '0.72.11'               │
│   16    │  ''   │    'react-native/typescript-config'    │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   17    │  ''   │    'react-native/virtualized-lists'    │    '0.74.0'    │               '0.72.8'               │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┴──────────────────────────────────────┘
```

Reviewed By: cortinico

Differential Revision: D52347140

Pulled By: lunaleaps

fbshipit-source-id: 75811730e1afd5aae2d9fba4e437cd0d3d424a90
2024-01-02 11:46:03 -08:00
Moti Zilberman d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
Riccardo Cipolleschi 45285a513d Connect the flag removal script (#40782)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40782

## Changelog:
[Internal] - Connect the flag removal script

Reviewed By: cortinico

Differential Revision: D50083082

fbshipit-source-id: d7cc1e81debed7a8fa934c8010e5884ad29bd657
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi 89c9ca0f68 Generalize get-and-update-nightlies (#40786)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40786

## Changelog:
[Internal] -  Generalize get-and-update-nightlies

Reviewed By: cortinico

Differential Revision: D49956685

fbshipit-source-id: 506b812b93353526a941f3deb136f6bdc74cce35
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi 2d067568d7 Add double publishing support to set-rn-version (#40784)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40784

## Changelog
[Internal] Add double publishing support to set-rn-version

Reviewed By: cortinico

Differential Revision: D49955312

fbshipit-source-id: b154fe0c4cc53dbe3cc6319bbf43663307816ee4
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi 657aea0946 Update version-utils to accept new versions (#40783)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40783

ignore-github-export-checks
## Changelog:
[Internal] - Update version-utils to accept more versions for double publishing

Reviewed By: cortinico

Differential Revision: D49917128

fbshipit-source-id: 4556e5161986d8b041de464aa6939dfb2dd45e61
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi d16793dbe0 Update publishing to Sonatype for double publishing (#40781)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40781

## Changelog:
[Internal] - Allow Sonatype to double publish SNAPSHOTS

Reviewed By: cortinico

Differential Revision: D49914824

fbshipit-source-id: 830e20eb51ffdf5b7c4452972c436ca0cb4da5a9
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi 7ebfe7046d Compute the right version (#40780)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40780

## Changelog:
[Internal] - Compute the right version when publishing

Reviewed By: cortinico

Differential Revision: D49914416

fbshipit-source-id: 9ab5a3323851eec943f759b8be11c3d7d48df83f
2023-10-11 10:09:57 -07:00
Riccardo Cipolleschi 780567c727 Refactor publish-npm args to be more safe (#39532)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39532

This change refactors how we handle the parameters of publish-npm so we can only accept the build types we actually support.

## Changelog:
[Internal] - Make publish-npm args stricter

Reviewed By: cortinico

Differential Revision: D49374263

fbshipit-source-id: a17ddecc0ddcb30858dd0baaab8990ae765d304f
2023-09-21 04:35:41 -07:00
Rob Hogan 86968c1104 Use modern timers in monorepo Jest tests (#38955)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38955

Jest introduced "modern" timers based on `sinon/fake-timers` in Jest 26 ([release announcement](https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers)), and they became the default in Jest 27, in May 2021.

Modern timers have more capabilities - they were introduced with support for `queueMicrotask`, mocking `Date`, etc., and they've continued to receive more attention from the Jest team since - they're now much more comprehensive and more configurable than legacy timers.

Importantly, because they're not based on Jest mocks, they're not affected in surprising ways by eg `jest.resetAllMocks()` (a particularly confusing side-effect when fake timers are enabled globally, as in our setup).

This migrates RN's own tests and config to modern fake timers, or real timers where that's more appropriate.

NOTE: In cases where non-trivial changes to the tests are required, four test files are individually opted-in to `legacyFakeTimers` with a `TODO(legacy-fake-timers)`. I'll open these up for community contributions to fix.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48189907

fbshipit-source-id: 2e7ce74cc60e80679d81d7c16d599ad1bbe2c921
2023-08-11 11:01:06 -07:00
Luna Wei be348528e6 Delete validation in set-rn-version (#37814)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37814

Changelog: [Internal] - deleting file validation, do we need this?

Reviewed By: NickGerleman

Differential Revision: D46584771

fbshipit-source-id: 69a8853872b2b1582318a2e65d9919e2b50b2475
2023-06-14 07:44:51 -07:00
Luna Wei 31eb235a6a Fix set-rn-version (#37854)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37854

Changelog: [Internal] - Fix `saveFiles` in set-rn-version, incorrect function invoke

Reviewed By: NickGerleman

Differential Revision: D46582168

fbshipit-source-id: 944e182a88a1aa79bbf47d36ef8395c21dfefb24
2023-06-14 07:44:51 -07:00
Facebook Community Bot 2eba6ab5ac Re-sync with internal repository (#37831)
Co-authored-by: Facebook Community Bot <6422482+facebook-github-bot@users.noreply.github.com>
2023-06-12 17:34:52 -04:00
Luna Wei 7bcff07f13 Refactor nightly monorepo publish script (#37707)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37707

Changelog: [Internal] - Refactor nightly monorepo publish script to also return a map of packages and their current nightly version and rename to reflect. This may refer to a nightly version that was just published (if we detect changes) or the nightly tag on npm if no changes.

In subsequent diffs, will update the react-native nightly script to use this map to set the versions for nightly react-native versions.

Reviewed By: hoxyq

Differential Revision: D46450703

fbshipit-source-id: c4e425924aa6cfdcf10e932e1b151ba05d9b7237
2023-06-09 09:20:08 -07:00
Luna Wei fd9e295bef Publish nightly monorepo packages (#37556)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37556

Changelog: [Internal]

Before making this change, we need to publish `nightly` versions of all existing monorepo dependencies.

Reviewed By: hoxyq

Differential Revision: D46117197

fbshipit-source-id: bcf6364e068579e63ca19e8161dcd32de4353e56
2023-06-02 17:40:52 -07:00
Luna Wei 7819fef988 Refactor to npm-utils (#37555)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37555

Changelog: [Internal] Refactor some npm commands and centralize in npm-utils.

For now, centralize `getPackageVersionStrByTag` and `publishPackage` and update:
1. `publish-npm` to use utilities. This is how we publish `react-native` for commitlies, releases, and nightlies
2. Update `find-and-publish-all-bumped-packages.js` where we publish our monorepo dependencies

Reviewed By: cortinico, hoxyq

Differential Revision: D46131120

fbshipit-source-id: e6020058eb94b4f8d95068b8cd87cc765711be5b
2023-05-24 14:42:54 -07:00
Luna Wei b23cf101f7 Refactor set-rn-version and add tests (#37291)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37291

Changelog: [Internal] Add tests for `rn-set-version` script and refactor for clarity

Reviewed By: NickGerleman

Differential Revision: D45248915

fbshipit-source-id: f6b8566d553d0954647ba81c55767fab6a2caf1c
2023-05-16 16:44:34 -07:00
Luna Wei d24f568c6f Update nightly versioning of react-native (#37028)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37028

Changelog: [Internal] - Update nightly versions of react-native

Reviewed By: hoxyq

Differential Revision: D45192008

fbshipit-source-id: d3626c676906f996bc38f8cb156261b7ae202c2a
2023-05-05 14:48:29 -07:00
Luna Wei 03a4de9a46 Refactor publish-npm (#37030)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37030

Changelog: [Internal] - Refactor publish-npm logic so its easier to follow

Reviewed By: hoxyq

Differential Revision: D45172195

fbshipit-source-id: 23aa109db17d42f43c348e122a3c2a1974aa61e4
2023-04-25 10:13:34 -07:00
Luna Wei 7b62bcbf9d Tests for publish-npm (#37029)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37029

Changelog: [Internal] - Add tests to publish-npm

Reviewed By: hoxyq

Differential Revision: D45171640

fbshipit-source-id: b70bb478ae6b08891f1e82088bb0e07d5d68b4e5
2023-04-25 10:13:34 -07:00
Lorenzo Sciandra 7adf6b1e63 fix(script): handle patch versions after the .0 for set version (#36020)
Summary:
A small backport to main of a local fix done in 0.71 to account for the logic for releases 0.Y.1,2,3-prerelease (meaning, not just strictly 0).

I could have done like the other logics and just remove the check for patch, but decided to at least make sure it's a digit 😅

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[INTERNAL] [FIXED] - handle patch versions after the .0 for set version

Pull Request resolved: https://github.com/facebook/react-native/pull/36020

Test Plan: Tested in 0.71-stable, without it we can't test RNTestProject.

Reviewed By: jacdebug, cortinico

Differential Revision: D42924375

Pulled By: cipolleschi

fbshipit-source-id: b003d884cc45a2602adbc14fa8b66d3f1e0c94a6
2023-02-07 03:45:17 -08:00
Ruslan Lesiutin 4d8ba7b9fd refactor(scripts/monorepo/tests): moved related tests to scripts/monorepo/__tests__
Summary:
Changelog: [Internal]
just a small cleanup, moved all tests related to monorepo scripts under `/scripts/monorepo`

Reviewed By: cortinico

Differential Revision: D42308455

fbshipit-source-id: 7743a2af1381ff748556c15b89cf980f8f907674
2023-01-10 13:23:06 -08:00
Ruslan Lesiutin ec28c5bbaa feat(react-native-github): a script to automate patch version bumping of packages (#35767)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35767

Changelog: [Internal]

Introducing a script, which can be used to identify all packages inside `/packages`, which contain any changes after the last time its version was changed

How it works step by step:

```
check that no git changes are present

for each package:
    if package is private -> skip

    grep id of the last commit that changed package
    grep id of the last commit that changed version of the package

    if these ids are different:
        bump package patch version

commit changes if required
```

Can be executed only in git environment and by running: `node ./scripts/bump-all-updated-packages`

 ---

Also adding a separate script `align-package-versions.js`, which can be used to update versions of packages inside consumer packages

```
check that no git changes are present

for each package x:
   for each package y:
       if y has x as dependency:
           validate that y uses the latest version of x

if some changes were made:
   run yarn
```

 ---

Q: Why `run_yarn` step was removed from CircleCI flow?
A: For *-stable branches, there are no yarn workspaces and all packages are specified as direct dependencies, so if we update `react-native/assets-registry` to the next version, we won't be able to run `yarn` for react-native root package, because updated version is not yet published to npm

To avoid this, we first need publish new versions and then update them in consumer packages

 ---
The final flow:
1. Developer uses `node ./scripts/bump-all-updated-packages` to bump versions of all updated packages.
2. Commit created from step 1 being merged or directly pushed to `main` or `*-stable` branches
3. A workflow from CircleCI publishes all updated versions to npm
4. Developer can use `align-package-versions.js` script to create required changes to align all packages versions

Reviewed By: cortinico

Differential Revision: D42295344

fbshipit-source-id: 54b667adb3ee5f28d19ee9c7991570451549aac2
2023-01-10 13:23:06 -08:00
Ruslan Lesiutin 83afdafae4 feat(react-native-github): automate publishing bumped packages via circleci (#35621)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35621

Changelog: [Internal]

1. Added `for-each-package.js` script. This can be used to iterate through all of the packages inside `/packages` with the access to package manifest. This soon can be used as a replacement for `yarn workspaces --info`
2. Added `find-and-publish-all-bumped-packages.js` script. This script iterates through all the packages and detects if the version was changed via `git log -p` (same as `git diff`). If so, it tries to publish it to npm.
3. Added corresponding job and workflow to CircleCI config, which will use this script

Reviewed By: cortinico

Differential Revision: D41972733

fbshipit-source-id: c5d0ed5b852b744a699ecb88861ea3e82200e1f3
2022-12-14 02:17:16 -08:00
Riccardo Cipolleschi a67286913c Fix version validation for nightlies
Summary:
The nightly version is bumped after the check is performed, therefore it fails.

With this diff, we become slightly more accepting with nightlies, allowing both `0.0.0` and `0.0.0-xxxx` as valid version for nightlies.

## Changelog
[JS][Fixed] - Accept 0.0.0 with and without prelrelease for nightlies' versions

Reviewed By: cortinico

Differential Revision: D41534995

fbshipit-source-id: 2d0417441ca7d3d3f7660c9317133ac3c6de2eb9
2022-11-25 13:46:45 -08:00
Riccardo Cipolleschi f12b12c999 Improve version checks to avoid mistakes in the versioning (#35296)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35296

This change adds some version checks and enforces that every version matches some specific format based on the build type we are trying to run.

## Changelog
[General][Changed] - Improve version checks

Reviewed By: cortinico

Differential Revision: D41161756

fbshipit-source-id: 4172195c5e031c1eaf7b33bb74f381c04e9adaf5
2022-11-21 10:52:17 -08:00
Héctor Ramos 358b7a4458 hermes-utils.js: Add test coverage
Summary:
Improving test coverage in anticipation of some changes being made to `hermes-utils.js`.

Moved test scripts to `hermes/__tests__` and grouped related tests.

We have been delegating some of the work to local binaries via `execSync`, which can be hard to mock or test.  We now use a proxy `delegateSync` method that uses `spawnSync` internally to break down the invocation into `command`, `arguments`, `options`. Instead of simply mocking based on the command being executed, we can now conditionally mock based on the arguments being passed.

Added a `createTarballFromDirectory` method. This can be used later when creating different tarballs.

Added `populateMockFilesystemWithHermesBuildArtifacts()` to mock the filesystem state after Hermes has been built.

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D40871802

fbshipit-source-id: 4348d3c38926ec7eb13d794040a9040010879f58
2022-11-01 18:27:39 -07:00
Héctor Ramos 8f124be40e Hermes scripts: rename tarball methods to distinguish between source code and prebuilt artifacts (#35156)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35156

There are two tarballs: the source code for Hermes that is downloaded from GitHub, and the hermes-runtime-darwin-{}-v{}.tar.gz tarball with prebuilt artifacts that is built in CI.
Renamed some methods to make it clearer which tarball they work with.

Changelog: [internal]

Reviewed By: cipolleschi, dmytrorykun

Differential Revision: D40812290

fbshipit-source-id: a2c865e1d1461829fe8d468f52deeb55f3565cb0
2022-10-31 15:30:02 -07:00
Riccardo Cipolleschi 1546666a6d Consume Tarball from Maven (#35034)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35034

Currently, when creating an app using the command:
`npx react-native init MyApp --version nightly`
iOS fails to install the dependencies because it does not find a proper tarball to run Hermes.

This diff solve the problem by fetching the Hermes tarball that is created by the CI while building the nightly.

## Changelog:
[iOS][Fixed] - Make the nightly work with the  proper Hermes tarball

Reviewed By: cortinico

Differential Revision: D40512418

fbshipit-source-id: f510f84be9f19807236091687df5e13961103318
2022-10-20 10:43:31 -07:00
Héctor Ramos e4b5d3eec9 Circle CI: Upload both tarballs to releases, dry-run the release workflow on every commit (#35015)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35015

React Native releases are cut every few months. Without testing, the workflow is prone to breakage.

Dry-run the release workflow on every commit in order to surface any issues as they are introduced instead of at release time.

Fixed issues that surfaced during testing of this workflow:
- Upload both Hermes tarballs

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D40483764

fbshipit-source-id: 5ca6bd4dcdfd64c24882ffb202edbfd701efd462
2022-10-19 17:54:22 -07:00
Héctor Ramos 31bedd9815 Add hermes/create-tarball.js script (#34875)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34875

Create common script for generating a Hermes tarball after Hermes is built from source.

Use after building Hermes from source to create a tarball of the resulting build artifacts. The path to the tarball can be passed to CocoaPods via a `HERMES_ENGINE_TARBALL_PATH` envvar in order to use these pre-built Hermes artifacts when installing the `hermes-engine` pod with `pod install`.

Use in Circle CI when creating a Hermes tarball for caching and for use in stable React Native releases.

Usage:

```
pod install

# When Hermes is built from source via CocoaPods, the build artifacts will be located in the Pods directory for hermes-engine

node ./scripts/hermes/create-tarball.js \
  --inputDir ./sdks/hermes \
  --buildType Debug \
  --releaseVersion 1000.0.0 \
  --outputDir .
```

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D40124378

fbshipit-source-id: f9712e87526ccc737afac4599b0ab0a7bb3f3956
2022-10-07 10:21:25 -07:00
Vincenzo Vitale 10e47b891a Do not depend on an ENV variable when publishing and setting the RN version (#34746)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34746

The changes made in
https://github.com/facebook/react-native/pull/34694
introduced the need to have the env variable TMP_PUBLISH_DIR for the publishing and set-rn-version scripts to work.
This break any usage of set-rn-version when the env variable is not set upfront.

With this change, we are creating a temp folder in the scope that requires it (e.g. set-rn-version.js) and then passing the path to the save/revert functions.

## Changelog
[Internal] [Added] - Do not depend on an ENV variable when publishing and setting the RN version.

Reviewed By: cipolleschi

Differential Revision: D39683565

fbshipit-source-id: 21d85d1c16c4cb7324636ceb5eba626ff8cbb775
2022-09-22 07:34:50 -07:00
Vincenzo Vitale 0a3ca80af4 Build the React Native NPM package when git is not available (#34694)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34694

TL;DR Relax the assumption of having git to build the RN NPM package.

We do have two CI Systems: CircleCI for OpenSource and Sandcastle for Internal. It's crucial that the two CIs are aligned.

We currently don't have a way to test the new app template on Sandcastle for Android & iOS.
This results in scenarios where internal Diffs gets landed and break the public CI externally.

This is preparation work to then be able to build the RN NPM package in Sandcastle (which will be done in a follow-up diff).

With this we also introduce the restoring of all the changed files after the publishing script is done.

## Changelog

[Internal] [Added] - Made it possible to create publishing NPM packages in Sandcastle.

Reviewed By: cortinico, cipolleschi

Differential Revision: D39467471

fbshipit-source-id: b0de88a768b8a2fb798dd684fa8f97f4d0acb751
2022-09-16 02:58:36 -07:00
Héctor Ramos cd8dbd15ff Circle CI: Create GiHub Release draft when bumping version
Summary:
Automatically create a GitHub Release draft when a new React Native release is created.

The GitHub Release will be created by the same Circle CI job that publishes the package to npm.

This job will also upload the built Hermes binaries to the GitHub release.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D36646696

fbshipit-source-id: 0a863dc4e3215fc95f7852f8dc43858cdd852aaa
2022-07-14 13:42:08 -07:00
Héctor Ramos 54c346a03a Hermes: Add hermesc unit tests (#33914)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33914

Add test coverage for the new hermesc functions in hermes-utils.js

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D36361612

fbshipit-source-id: 270f30917245c8d81baf136d9f58da4d77f7ad55
2022-05-30 02:59:35 -07:00
Héctor Ramos 38b70653b2 Hermes: Use pre-built artifacts in hermes-engine
Summary:
Update `hermes-engine.podspec` to use pre-built Hermes artifacts from the corresponding React Native GitHub Release when targeting a specific React Native release.
Otherwise, fallback to building Hermes from source.

Changelog: [Internal]

Reviewed By: cortinico, cipolleschi

Differential Revision: D36609257

fbshipit-source-id: 6179c9e255558c7eaf1417ff46a2e7db120295f0
2022-05-25 03:30:57 -07:00
Héctor Ramos 004b8609d9 Hermes: Add scripts to package, remove shelljs
Summary:
The new Hermes scripts need to be included in the `react-native` npm.

The `shelljs` dependency that was used by the Hermes scripts is a dev dependency, so instead of adding to the `react-native` npm size, we refactored its use out of hermes-utils.js.

Changelog:
[General][Added] - Add Hermes scripts to package

Reviewed By: cortinico

Differential Revision: D36387135

fbshipit-source-id: 12d0bc29d365c4cb18d33a0d390e6e7d34864b7a
2022-05-24 14:08:48 -07:00
Nicola Corti 5bb0caf858 Fix test_windows by passing the correct platform to the Metro Virtual FS (#33870)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33870

I'm fixing a broken CI on master for `test_windows` as `metro-memory-fs` doesn't
automatically recognize the platform but needs to have it passed in input.
It was currently failing to parse a `C:\...` path. This fixes it.

Changelog:
[Internal] [Changed] - Fix `test_windows` by passing the correct platform to the Metro Virtual FS

Reviewed By: cipolleschi

Differential Revision: D36507564

fbshipit-source-id: 39dfd7e9ce492d126fbb513a70ec5a60965c61fd
2022-05-19 03:29:56 -07:00
Héctor Ramos 5dae5936fc Hermes: Add tests for hermes-utils.js
Summary:
Add test coverage for the new `scripts/hermes/hermes-utils.js` consolidated Hermes scripts.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D36334652

fbshipit-source-id: e9570d1232c21e36da4e6be8c67d80f4ec224326
2022-05-13 11:29:08 -07:00