Skip to content

Conversation

@jonthysell
Copy link
Contributor

@jonthysell jonthysell commented Nov 9, 2023

Description

Adds the functionality for apps created with the new cpp-app template to run yarn windows, as an alias for react-native run-windows, similar to the old template.

To do this, I've created a new templateUtils module for shared template config code, with a new updateProjectPackageJson() method to make it easy for templates to inject items into a project's package.json file (in this case, a new scripts entry).

Type of Change

  • New feature (non-breaking change which adds functionality)

Why

Adds a useful feature of the old templates to the new template

What

See above.

Screenshots

N/A

Testing

Verified creating a new project works.

Changelog

Should this change be included in the release notes: yes

The new Fabric app template now supports yarn windows as an alias to react-native run-windows

Microsoft Reviewers: Open in CodeFlow

Adds the functionality for apps created with the new cpp-app template to run `yarn windows`, as an alias for `react-native run-windows`, similar to the old template.

To do this, I've created a new `templateUtils` module for shared template config code, with a new `updateProjectPackageJson()` method to make it easy for templates to inject items into a project's package.json file (in this case, a new `scripts` entry).
@jonthysell jonthysell requested review from a team as code owners November 9, 2023 21:58
@jonthysell jonthysell added the Area: Fabric Support Facebook Fabric label Nov 9, 2023
jonthysell added a commit to jonthysell/react-native-windows that referenced this pull request Nov 10, 2023
The upstream RN app template includes a jest test suite (run with `yarn test`) with a default test to render your app JS using the `react-test-renderer`. However, this only tests the iOS version of your app (it forces platform === 'ios') and therefore won't catch if there are issues in your `windows` platform files.

Using `@rnx-kit/jest-preset`, you can run jest tests against any platform via a custom jest config.

This PR adds `@rnx-kit/jest-preset` as a dev dependency to the new `cpp-app` template, as well as a `jest.config.windows.js` to use it. Furthermore it adds a script so users can run these tests for windows via `yarn test:windows`.

To support this, I've extended the templateUtils added in microsoft#12374 to include functionality to run `npm i` / `yarn` to install any new dependencies added.

Closes microsoft#11939
@jonthysell jonthysell merged commit 60b7883 into microsoft:main Nov 13, 2023
@jonthysell jonthysell deleted the cpp-app-scripts branch November 13, 2023 19:52
jonthysell added a commit to jonthysell/react-native-windows that referenced this pull request Nov 13, 2023
The upstream RN app template includes a jest test suite (run with `yarn test`) with a default test to render your app JS using the `react-test-renderer`. However, this only tests the iOS version of your app (it forces platform === 'ios') and therefore won't catch if there are issues in your `windows` platform files.

Using `@rnx-kit/jest-preset`, you can run jest tests against any platform via a custom jest config.

This PR adds `@rnx-kit/jest-preset` as a dev dependency to the new `cpp-app` template, as well as a `jest.config.windows.js` to use it. Furthermore it adds a script so users can run these tests for windows via `yarn test:windows`.

To support this, I've extended the templateUtils added in microsoft#12374 to include functionality to run `npm i` / `yarn` to install any new dependencies added.

Closes microsoft#11939
@jonthysell jonthysell added the New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Fabric Support Facebook Fabric New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants