CARVIEW |
Select Language
HTTP/2 200
date: Sat, 26 Jul 2025 21:28:11 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/microsoft/react-native-windows.git
etag: W/"666adc9c19a724c26f7cb0e9cd282dec"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=sHsl%2BipySKBllEBGj%2FZujH2M1F9CC2sAHQDClX3L6%2FSW%2Bnz8ttoLKCtxJwOxZ%2FTj3GXZsvoGx28w0oCP2vAS12R8lCTNDmApiWjb73ShFRciP8Jr5JatSJUYePD54TfXwB1OEUtrKCArkun86ONWSuBmAtdjFYKu4fKXtudPvoVBIDEtTV7KEXAeCwQ%2B5tcf3x73HLHz2yIvJwArA1FALvYq4UgBfQvrAXMDfnJJpdo7axHfpLHTsmP4RcUykRq4YTjLv%2BQJYKjt0%2BLnSmEFKA%3D%3D--cIvyvJlv1Nv8ul%2F1--13AhHv6qrq7YKmbEpFVNSg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.895657151.1753565290; Path=/; Domain=github.com; Expires=Sun, 26 Jul 2026 21:28:10 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 26 Jul 2026 21:28:10 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 8F6E:1C79A4:90BD5B:BBF96B:6885486A
Improve new project name(space) validation and cleaning (#13566) · microsoft/react-native-windows@849d71f · GitHub
Copy file name to clipboard
Copy file name to clipboard
Copy file name to clipboardExpand all lines: packages/@react-native-windows/cli/src/commands/initWindows/initWindows.ts
Copy file name to clipboardExpand all lines: packages/@react-native-windows/cli/src/e2etest/initWindows.test.ts
Copy file name to clipboardExpand all lines: packages/@react-native-windows/cli/src/generator-windows/index.ts
Copy file name to clipboard
Copy file name to clipboardExpand all lines: packages/@react-native-windows/telemetry/src/utils/errorUtils.ts
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit 849d71f
authored
Improve new project name(space) validation and cleaning (#13566)
## Description
This PR moves all of the logic concerning validating and cleaning project names when creating new projects (via the `init-windows` CLI command or the soon to be deprecated `react-native-windows-init` command) into one shared location with unit tests. It also updates the cleaning logic to handle package scopes (i.e. `@org/package`) and better apply cleaning to packages with hyphens (i.e. `my-package`).
Going forward, when creating (new or old arch) projects with `init-windows`, the flow will still to adhere the following rules:
1. Verify that a string specified with `--name` or `--namespace` is valid, or else error out.
2. If an item isn't specified, do our best to determine the value from `package.json`, etc., and clean that value if necessary.
When using `react-native-windows-init`, (which still only lets you specify the `--namespace`, and always figures out name from `package.json`, etc.), the flow will be mostly the same as before, where both name and namespace will be cleaned automatically if invalid, rather than erroring out. (However the consolidated cleaning logic should mean an improvement when using tools other than the RN CLI for creating your initial RN project).
### Type of Change
- Bug fix (non-breaking change which fixes an issue)
### Why
The rules for what constitutes a "valid" name for a RN project has changed over the years with each of the different tools that are used to create RN projects. This PR is an attempt to both broaden the number of supported new project tools while also ensuring RNW still produces usable native code.
Closes #13558
Closes #13426
### What
Moved all name(space) logic into a new `nameHelpers` module, exposed them to existing callers, and created unit tests.
## Screenshots
N/A
## Testing
Add new tests for nameHelpers.
## Changelog
Should this change be included in the release notes: _yes_
Improve new project name(space) validation and cleaning1 parent cf493d4 commit 849d71fCopy full SHA for 849d71f
File tree
Expand file treeCollapse file tree
7 files changed
+155
-27
lines changedFilter options
- change
- packages/@react-native-windows
- cli/src
- commands/initWindows
- e2etest
- generator-windows
- utils
- telemetry/src/utils
Expand file treeCollapse file tree
7 files changed
+155
-27
lines changedchange/@react-native-windows-cli-db04fef2-0cc5-477b-ac9a-1aa9f4e4c2ee.json
Copy file name to clipboard+7Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + |
change/@react-native-windows-telemetry-ca4bf582-eec5-4ee4-8830-19a6d937a87b.json
Copy file name to clipboard+7Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + |
packages/@react-native-windows/cli/src/commands/initWindows/initWindows.ts
Copy file name to clipboardExpand all lines: packages/@react-native-windows/cli/src/commands/initWindows/initWindows.ts+38-17Lines changed: 38 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
32 | 33 |
| |
33 | 34 |
| |
34 | 35 |
| |
| |||
94 | 95 |
| |
95 | 96 |
| |
96 | 97 |
| |
97 |
| - | |
98 |
| - | |
99 |
| - | |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 | 98 |
| |
110 | 99 |
| |
111 | 100 |
| |
| |||
152 | 141 |
| |
153 | 142 |
| |
154 | 143 |
| |
155 |
| - | |
| 144 | + | |
| 145 | + | |
156 | 146 |
| |
157 | 147 |
| |
158 |
| - | |
| 148 | + | |
159 | 149 |
| |
160 | 150 |
| |
161 | 151 |
| |
| 152 | + | |
162 | 153 |
| |
163 | 154 |
| |
164 |
| - | |
| 155 | + | |
165 | 156 |
| |
166 |
| - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
167 | 166 |
| |
168 | 167 |
| |
169 |
| - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
170 | 191 |
| |
171 | 192 |
| |
172 | 193 |
| |
|
packages/@react-native-windows/cli/src/e2etest/initWindows.test.ts
Copy file name to clipboardExpand all lines: packages/@react-native-windows/cli/src/e2etest/initWindows.test.ts+56Lines changed: 56 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| 14 | + | |
| 15 | + | |
14 | 16 |
| |
15 | 17 |
| |
16 | 18 |
| |
| |||
57 | 59 |
| |
58 | 60 |
| |
59 | 61 |
| |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + |
packages/@react-native-windows/cli/src/generator-windows/index.ts
Copy file name to clipboardExpand all lines: packages/@react-native-windows/cli/src/generator-windows/index.ts+8-10Lines changed: 8 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
| |||
46 | 47 |
| |
47 | 48 |
| |
48 | 49 |
| |
49 |
| - | |
50 |
| - | |
51 |
| - | |
52 |
| - | |
53 |
| - | |
54 | 50 |
| |
55 | 51 |
| |
56 | 52 |
| |
| |||
91 | 87 |
| |
92 | 88 |
| |
93 | 89 |
| |
94 |
| - | |
95 |
| - | |
96 |
| - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
97 | 94 |
| |
98 | 95 |
| |
99 | 96 |
| |
100 |
| - | |
101 |
| - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
102 | 100 |
| |
103 | 101 |
| |
104 | 102 |
| |
|
packages/@react-native-windows/cli/src/utils/nameHelpers.ts
Copy file name to clipboard+38Lines changed: 38 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + |
packages/@react-native-windows/telemetry/src/utils/errorUtils.ts
Copy file name to clipboardExpand all lines: packages/@react-native-windows/telemetry/src/utils/errorUtils.ts+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
| 81 | + | |
81 | 82 |
| |
82 | 83 |
| |
83 | 84 |
| |
|
You can’t perform that action at this time.
0 commit comments