7
7
'use strict' ;
8
8
9
9
const forEachPackage = require ( './monorepo/for-each-package' ) ;
10
+ const newGithubReleaseUrl = require ( './new-github-release-url' ) ;
10
11
const { applyPackageVersions, publishPackage} = require ( './npm-utils' ) ;
12
+ const { failIfTagExists} = require ( './release-utils' ) ;
11
13
const updateTemplatePackage = require ( './update-template-package' ) ;
14
+ const { execSync} = require ( 'child_process' ) ;
12
15
const fs = require ( 'fs' ) ;
13
16
const path = require ( 'path' ) ;
14
17
const { cat, echo, exit} = require ( 'shelljs' ) ;
15
18
const yargs = require ( 'yargs' ) ;
16
19
20
+ const REPO_ROOT = path . resolve ( __dirname , '../' ) ;
21
+
17
22
/**
18
23
* This script updates core packages to the version of React Native that we are basing on,
19
24
* updates internal visionOS packages and releases them.
@@ -89,6 +94,7 @@ function releaseOOT(
89
94
oneTimePassword ,
90
95
tag = 'latest' ,
91
96
) {
97
+ const isNightly = tag === 'nightly' ;
92
98
const allPackages = getPackages ( ) ;
93
99
const corePackages = Object . keys ( allPackages ) . filter ( packageName =>
94
100
packageName . startsWith ( '@react-native/' ) ,
@@ -102,25 +108,55 @@ function releaseOOT(
102
108
{ } ,
103
109
) ;
104
110
111
+ const visionOSPackagesVersions = visionOSPackages . reduce (
112
+ ( acc , pkg ) => ( { ...acc , [ pkg ] : newVersion } ) ,
113
+ { } ,
114
+ ) ;
115
+
105
116
// Update `packges/react-native` package.json and all visionOS packages
106
- visionOSPackages . forEach ( pkg => {
107
- echo ( `Setting ${ pkg } version to ${ newVersion } ` ) ;
108
- setPackage ( allPackages [ pkg ] , newVersion , corePackagesVersions ) ;
109
- } ) ;
117
+ if ( isNightly ) {
118
+ visionOSPackages . forEach ( pkg => {
119
+ echo ( `Setting ${ pkg } version to ${ newVersion } ` ) ;
120
+ setPackage ( allPackages [ pkg ] , newVersion , corePackagesVersions ) ;
121
+ } ) ;
122
+ } else {
123
+ visionOSPackages . forEach ( pkg => {
124
+ echo ( `Setting ${ pkg } version to ${ newVersion } ` ) ;
125
+ setPackage ( allPackages [ pkg ] , newVersion , visionOSPackagesVersions ) ;
126
+ } ) ;
127
+ }
110
128
111
129
// Update template package.json
112
130
updateTemplatePackage ( {
113
131
'react-native' : reactNativeVersion ,
114
- ...corePackagesVersions ,
115
- ...visionOSPackages . reduce ( ( acc , pkg ) => ( { ...acc , [ pkg ] : newVersion } ) , { } ) ,
132
+ ...visionOSPackagesVersions ,
116
133
} ) ;
134
+
135
+ if ( isNightly ) {
136
+ updateTemplatePackage ( corePackagesVersions ) ;
137
+ }
138
+
117
139
echo ( `Updating template and it's dependencies to ${ reactNativeVersion } ` ) ;
118
140
141
+ echo ( 'Building packages...\n' ) ;
142
+ execSync ( 'node ./scripts/build/build.js' , {
143
+ cwd : REPO_ROOT ,
144
+ stdio : [ process . stdin , process . stdout , process . stderr ] ,
145
+ } ) ;
146
+
119
147
// Release visionOS packages only if OTP is passed
120
148
if ( ! oneTimePassword ) {
121
149
return ;
122
150
}
123
151
152
+ const gitTag = `v${ newVersion } -visionos` ;
153
+ failIfTagExists ( gitTag , 'release' ) ;
154
+ // Create git tag
155
+ execSync ( `git tag -a ${ gitTag } -m "Release ${ newVersion } "` , {
156
+ cwd : REPO_ROOT ,
157
+ stdio : [ process . stdin , process . stdout , process . stderr ] ,
158
+ } ) ;
159
+
124
160
const results = visionOSPackages
125
161
. map ( npmPackage => {
126
162
return path . join ( __dirname , '..' , allPackages [ npmPackage ] ) ;
@@ -144,6 +180,19 @@ function releaseOOT(
144
180
', ' ,
145
181
) } to npm with version: ${ newVersion } `,
146
182
) ;
183
+
184
+ const releaseURL = newGithubReleaseUrl ( {
185
+ tag : gitTag ,
186
+ title : `Release ${ newVersion } ` ,
187
+ repo : 'react-native-visionos' ,
188
+ user : 'callstack' ,
189
+ } ) ;
190
+
191
+ echo ( '\n\n' ) ;
192
+ echo ( '-------------------------------------------\n' ) ;
193
+ echo ( `Create a new release here: ${ releaseURL } \n` ) ;
194
+ echo ( '-------------------------------------------' ) ;
195
+
147
196
return exit ( 0 ) ;
148
197
}
149
198
}
0 commit comments