@@ -25,19 +25,13 @@ const os = require('os');
2525const {
2626 launchAndroidEmulator,
2727 isPackagerRunning,
28- launchPackagesInSeparateWindow ,
28+ launchPackagerInSeparateWindow ,
2929} = require ( './testing-utils' ) ;
3030
31- const { generateAndroidArtifacts} = require ( './release-utils' ) ;
32-
33- // setting this just 'cause this https://github.com/facebook/react-native/commit/0a3ca80af401654896cbc73e235711eef0f9b3c5
34- // breaks a bunch of stuff. This should be enough.
35- // TODO: follow up with Nicola in understanding the impact of the commit, and if we can remove this
36- // also, remove the folder
37- process . env . TMP_PUBLISH_DIR = fs . mkdtempSync (
38- path . join ( os . tmpdir ( ) , 'rn-publish-' ) ,
39- ) ;
40- console . info ( `The temp folder is ${ process . env . TMP_PUBLISH_DIR } ` ) ;
31+ const {
32+ generateAndroidArtifacts,
33+ saveFilesToRestore,
34+ } = require ( './release-utils' ) ;
4135
4236const argv = yargs
4337 . option ( 't' , {
@@ -72,12 +66,16 @@ if (isPackagerRunning() === 'running') {
7266}
7367
7468if ( argv . target === 'RNTester' ) {
75- //FIXME: make sure that the commands retains colors
69+ // FIXME: make sure that the commands retains colors
7670 // (--ansi) doesn't always work
7771 // see also https://github.com/shelljs/shelljs/issues/86
7872
7973 if ( argv . platform === 'iOS' ) {
80- console . info ( "We're going to test the Hermes version of RNTester iOS" ) ;
74+ console . info (
75+ `We're going to test the ${
76+ argv . hermes ? 'Hermes' : 'JSC'
77+ } version of RNTester iOS`,
78+ ) ;
8179 exec (
8280 `cd packages/rn-tester && USE_HERMES=${
8381 argv . hermes ? 1 : 0
@@ -86,7 +84,7 @@ if (argv.target === 'RNTester') {
8684
8785 // if everything succeeded so far, we can launch Metro and the app
8886 // start the Metro server in a separate window
89- launchPackagesInSeparateWindow ( ) ;
87+ launchPackagerInSeparateWindow ( ) ;
9088
9189 // launch the app on iOS simulator
9290 pushd ( 'packages/rn-tester' ) ;
@@ -97,21 +95,24 @@ if (argv.target === 'RNTester') {
9795
9896 launchAndroidEmulator ( ) ;
9997
100- if ( argv . hermes ) {
101- console . info (
102- "We're going to test the Hermes version of RNTester Android" ,
103- ) ;
104- exec (
105- './gradlew :packages:rn-tester:android:app:installHermesDebug --quiet' ,
106- ) ;
107- } else {
108- console . info ( "We're going to test the JSC version of RNTester Android" ) ;
109- exec ( './gradlew :packages:rn-tester:android:app:installJscDebug --quiet' ) ;
110- }
98+ console . info (
99+ `We're going to test the ${
100+ argv . hermes ? 'Hermes' : 'JSC'
101+ } version of RNTester Android`,
102+ ) ;
103+ exec (
104+ `./gradlew :packages:rn-tester:android:app:${
105+ argv . hermes ? 'installHermesDebug' : 'installJscDebug'
106+ } --quiet`,
107+ ) ;
108+
109+ // launch the app on Android simulator
110+ // TODO: we should find a way to make it work like for iOS, via npx react-native run-android
111+ // currently, that fails with an error.
111112
112113 // if everything succeeded so far, we can launch Metro and the app
113114 // start the Metro server in a separate window
114- launchPackagesInSeparateWindow ( ) ;
115+ launchPackagerInSeparateWindow ( ) ;
115116 // just to make sure that the Android up won't have troubles finding the Metro server
116117 exec ( 'adb reverse tcp:8081 tcp:8081' ) ;
117118 // launch the app
@@ -124,6 +125,14 @@ if (argv.target === 'RNTester') {
124125
125126 // create the local npm package to feed the CLI
126127
128+ // base setup required (specular to publish-npm.js)
129+ const tmpPublishingFolder = fs . mkdtempSync (
130+ path . join ( os . tmpdir ( ) , 'rn-publish-' ) ,
131+ ) ;
132+ console . info ( `The temp publishing folder is ${ tmpPublishingFolder } ` ) ;
133+
134+ saveFilesToRestore ( tmpPublishingFolder ) ;
135+
127136 // we need to add the unique timestamp to avoid npm/yarn to use some local caches
128137 const baseVersion = require ( '../package.json' ) . version ;
129138
@@ -135,67 +144,62 @@ if (argv.target === 'RNTester') {
135144
136145 const releaseVersion = `${ baseVersion } -${ dateIdentifier } ` ;
137146
138- // need to put it into into a try finally to ensure that we clean up the state
139- try {
140- // this is needed to generate the Android artifacts correctly
141- exec ( `node scripts/set-rn-version.js --to-version ${ releaseVersion } ` ) . code ;
147+ // this is needed to generate the Android artifacts correctly
148+ exec ( `node scripts/set-rn-version.js --to-version ${ releaseVersion } ` ) . code ;
142149
143- // Generate native files (Android only for now)
144- generateAndroidArtifacts ( releaseVersion ) ;
150+ // Generate native files (Android only for now)
151+ generateAndroidArtifacts ( releaseVersion , tmpPublishingFolder ) ;
145152
146- // create locally the node module
147- exec ( 'npm pack' ) ;
153+ // create locally the node module
154+ exec ( 'npm pack' ) ;
148155
149- const localNodeTGZPath = `${ pwd ( ) } /react-native-${ releaseVersion } .tgz` ;
150- exec ( `node scripts/set-rn-template-version.js "file:${ localNodeTGZPath } "` ) ;
156+ const localNodeTGZPath = `${ pwd ( ) } /react-native-${ releaseVersion } .tgz` ;
157+ exec ( `node scripts/set-rn-template-version.js "file:${ localNodeTGZPath } "` ) ;
151158
152- const repoRoot = pwd ( ) ;
159+ const repoRoot = pwd ( ) ;
153160
154- pushd ( '/tmp/' ) ;
155- // need to avoid the pod install step because it will fail! (see above)
156- exec (
157- `node ${ repoRoot } /cli.js init RNTestProject --template ${ repoRoot } --skip-install` ,
158- ) ;
161+ pushd ( '/tmp/' ) ;
162+ // need to avoid the pod install step because it will fail! (see above)
163+ exec (
164+ `node ${ repoRoot } /cli.js init RNTestProject --template ${ repoRoot } --skip-install` ,
165+ ) ;
166+
167+ cd ( 'RNTestProject' ) ;
168+ exec ( 'yarn install' ) ;
169+
170+ if ( argv . platform === 'iOS' ) {
171+ // if we want iOS, we need to do pod install - but with a trick
172+ cd ( 'ios' ) ;
173+ exec ( 'bundle install' ) ;
159174
160- cd ( 'RNTestProject' ) ;
161- exec ( 'yarn install' ) ;
162-
163- if ( argv . platform === 'iOS' ) {
164- // if we want iOS, we need to do pod install - but with a trick
165- cd ( 'ios' ) ;
166- exec ( 'bundle install' ) ;
167-
168- // TODO: we should be able to also use HERMES_ENGINE_TARBALL_PATH
169- // if we can make RNTester step generate it already so that it gets reused
170-
171- // need to discern if it's main branch or release branch
172- if ( baseVersion === '1000.0.0' ) {
173- // main branch
174- exec (
175- `USE_HERMES=${ argv . hermes ? 1 : 0 } bundle exec pod install --ansi` ,
176- ) ;
177- } else {
178- // a release branch
179- // copy over the .hermesversion file from react-native core into the RNTestProject
180- exec ( `cp -f ${ repoRoot } /sdks/.hermesversion .` ) ;
181- exec (
182- `CI=true USE_HERMES=${
183- argv . hermes ? 1 : 0
184- } bundle exec pod install --ansi`,
185- ) ;
186- }
187- cd ( '..' ) ;
188- exec ( 'yarn ios' ) ;
175+ // TODO: we should be able to also use HERMES_ENGINE_TARBALL_PATH
176+ // if we can make RNTester step generate it already so that it gets reused
177+
178+ // need to discern if it's main branch or release branch
179+ if ( baseVersion === '1000.0.0' ) {
180+ // main branch
181+ exec ( `USE_HERMES=${ argv . hermes ? 1 : 0 } bundle exec pod install --ansi` ) ;
189182 } else {
190- // android
191- exec ( 'yarn android' ) ;
183+ // TODO: to test this, I need to apply changes on top of a release branch
184+ // a release branch
185+ // copy over the .hermesversion file from react-native core into the RNTestProject
186+ exec ( `cp -f ${ repoRoot } /sdks/.hermesversion .` ) ;
187+ exec (
188+ `CI=true USE_HERMES=${
189+ argv . hermes ? 1 : 0
190+ } bundle exec pod install --ansi`,
191+ ) ;
192192 }
193- popd ( ) ;
194- } finally {
195- // at the end here I most likely want to set back the rn version to baseVersion!
196- // for git "cleanness" reasons
197- exec ( `node scripts/set-rn-template-version.js ${ baseVersion } ` ) ;
193+ cd ( '..' ) ;
194+ exec ( 'yarn ios' ) ;
195+ } else {
196+ // android
197+ exec ( 'yarn android' ) ;
198198 }
199+ popd ( ) ;
200+
201+ // just cleaning up the temp folder, the rest is done by the test clean script
202+ exec ( `rm -rf ${ tmpPublishingFolder } ` ) ;
199203}
200204
201205exit ( 0 ) ;
0 commit comments