@@ -4,11 +4,12 @@ REM Creates a RNW lib using the new arch template
4
4
REM
5
5
REM Options:
6
6
REM
7
- REM name The name of the app to create (default: testlib)
7
+ REM name The name of the lib to create (default: testlib)
8
8
REM /r [version] Use react@version (default: latest)
9
9
REM /rn [version] Use react-native@version (default: latest)
10
10
REM /rnw [version] Use react-native-windows@version (default: latest)
11
- REM /lt [template] Use create-react-native-library template (default: turbo-module)
11
+ REM /t [template] Use template (default: cpp-lib)
12
+ REM /bt [template] Use base create-react-native-library template (default: turbo-module)
12
13
REM /linkrnw Use your local RNW repo at RNW_ROOT
13
14
REM /verdaccio Configure new project to use verdaccio (used in CI)
14
15
REM
@@ -17,6 +18,12 @@ REM - You've set the RNW_ROOT environment variable with the path to your clone
17
18
18
19
setlocal enableextensions enabledelayedexpansion
19
20
21
+ call git rev-parse --is-inside-work-tree > NUL 2 >& 1
22
+ if %ERRORLEVEL% equ 0 (
23
+ @ echo creaternwlib.cmd: Unable to create a new project in an existing git repo
24
+ exit /b -1
25
+ )
26
+
20
27
if " %RNW_ROOT% " == " " (
21
28
@ echo creaternwlib.cmd: RNW_ROOT environment variable set to %~dp0 ..\..
22
29
set RNW_ROOT = %~dp0 ..\..
@@ -51,7 +58,10 @@ if not "%part%"=="" (
51
58
) else if " %part% " == " /rnw" (
52
59
set RNW_VERSION = %param%
53
60
shift
54
- ) else if " %part% " == " /lt" (
61
+ ) else if " %part% " == " /t" (
62
+ set RNW_TEMPLATE_TYPE = %param%
63
+ shift
64
+ ) else if " %part% " == " /bt" (
55
65
set RN_TEMPLATE_TYPE = %param%
56
66
shift
57
67
) else if " %part:~0 ,1 % " == " /" (
@@ -106,8 +116,8 @@ for /f "delims=" %%a in ('npm show react@%R_VERSION% version') do @set R_VERSION
106
116
107
117
@ echo creaternwlib.cmd Creating RNW lib " %LIB_NAME% " with react@%R_VERSION% , react-native@%RN_VERSION% , and react-native-windows@%RNW_VERSION%
108
118
109
- @ echo creaternwlib.cmd Creating base RN library project with: npx --yes create-react-native-library@
latest --slug
%LIB_NAME% --description
%LIB_NAME% --author-name
" React-Native-Windows Bot" --author-email
[email protected] --author-url http://example.com --repo-url http://example.com --languages kotlin-objc --type
%RN_TEMPLATE_TYPE% --react-native-version
%RN_VERSION% --example vanilla
%LIB_NAME%
110
- call npx --yes create-react-native-library@ latest --slug %LIB_NAME% --description %LIB_NAME% --author-name " React-Native-Windows Bot" --author-email 53619745+rnbot@ users.noreply.github.com --author-url http://example.com --repo-url http://example.com --languages kotlin-objc --type %RN_TEMPLATE_TYPE% --react-native-version %RN_VERSION% --example vanilla %LIB_NAME%
119
+ @ echo creaternwlib.cmd Creating base RN library project with: npx --yes create-react-native-library@
0.48.9 --slug
%LIB_NAME% --description
%LIB_NAME% --author-name
" React-Native-Windows Bot" --author-email
[email protected] --author-url http://example.com --repo-url http://example.com --languages kotlin-objc
--local false --type
%RN_TEMPLATE_TYPE% --react-native-version
%RN_VERSION% --example vanilla
%LIB_NAME%
120
+ call npx --yes create-react-native-library@ 0.48.9 --slug %LIB_NAME% --description %LIB_NAME% --author-name " React-Native-Windows Bot" --author-email 53619745+rnbot@ users.noreply.github.com --author-url http://example.com --repo-url http://example.com --languages kotlin-objc --local false --type %RN_TEMPLATE_TYPE% --react-native-version %RN_VERSION% --example vanilla %LIB_NAME%
111
121
112
122
if %ERRORLEVEL% neq 0 (
113
123
@ echo creaternwlib.cmd: Unable to create base RN library project
@@ -118,15 +128,13 @@ pushd "%LIB_NAME%"
118
128
119
129
if not " x%RN_VERSION:nightly =% " == " x%RN_VERSION% " (
120
130
@ echo creaternwlib.cmd Fixing react-native nightly issue
121
- pwsh.exe -Command " (gc package.json) -replace '" " nightly" " ', '" " %RN_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
122
- pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli" " : " " .*" " ', '" " @react-native-community/cli" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
123
- pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli-platform-android" " : " " .*" " ', '" " @react-native-community/cli-platform-android" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
124
- pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli-platform-ios" " : " " .*" " ', '" " @react-native-community/cli-platform-ios" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
131
+ pwsh.exe -Command " (gc package.json) -replace '" " react-native" " : " " [^\*]*" " ', '" " react-native" " : " " %RN_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
132
+ pwsh.exe -Command " (gc package.json) -replace '" " @react-native/(.+-(config|preset))" " : " " .*" " ', '" " @react-native/$1" " : " " %RN_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
133
+ pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli((-platform-)?(ios|android))?" " : " " .*" " ', '" " @react-native-community/cli$1" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
125
134
pushd example
126
- pwsh.exe -Command " (gc package.json) -replace '" " nightly" " ', '" " %RN_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
127
- pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli" " : " " .*" " ', '" " @react-native-community/cli" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
128
- pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli-platform-android" " : " " .*" " ', '" " @react-native-community/cli-platform-android" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
129
- pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli-platform-ios" " : " " .*" " ', '" " @react-native-community/cli-platform-ios" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
135
+ pwsh.exe -Command " (gc package.json) -replace '" " react-native" " : " " [^\*]*" " ', '" " react-native" " : " " %RN_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
136
+ pwsh.exe -Command " (gc package.json) -replace '" " @react-native/(.+-(config|preset))" " : " " .*" " ', '" " @react-native/$1" " : " " %RN_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
137
+ pwsh.exe -Command " (gc package.json) -replace '" " @react-native-community/cli((-platform-)?(ios|android))?" " : " " .*" " ', '" " @react-native-community/cli$1" " : " " %RNCLI_VERSION% " " ' | Out-File -encoding utf8NoBOM package.json"
130
138
popd
131
139
)
132
140
0 commit comments