Skip to content

Commit 961f45c

Browse files
SaadnajmishwantonShawn Dempsey
authored
Fix build errors with codegen discovery flag enabled (#1320) (#1376)
* Revert "Use execFileSync over execSync when messing with file paths in generate-artifacts.js" This reverts commit d68d209. * [RN][macos] Don't try and build Fabric example when USE_CODEGEN_DISCOVERY=1 * use `execFileSync` for secure argument passing * Fix tag comments * Don't use template literals as arguments Co-authored-by: Shawn Dempsey <[email protected]> Co-authored-by: Shawn Dempsey <[email protected]> Co-authored-by: Shawn Dempsey <[email protected]>
1 parent db2ba86 commit 961f45c

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

packages/rn-tester/Podfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ def pods(options = {})
4141

4242
prefix_path = "../.."
4343

44-
if ENV['USE_CODEGEN_DISCOVERY'] == '1'
45-
# Custom fabric component is only supported when using codegen discovery.
46-
pod 'MyNativeView', :path => "NativeComponentExample"
47-
end
44+
# [TODO(macOS GH#774) - don't enable Fabric on RNTester by default until it works on macOS
45+
# if ENV['USE_CODEGEN_DISCOVERY'] == '1'
46+
# # Custom fabric component is only supported when using codegen discovery.
47+
# pod 'MyNativeView', :path => "NativeComponentExample"
48+
# end
49+
# ]TODO(macOS GH#774)
4850

4951
use_react_native!(
5052
path: prefix_path,

scripts/generate-artifacts.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* in a CODEGEN_CONFIG_FILENAME file.
1717
*/
1818

19-
const {execSync, execFileSync} = require('child_process');
19+
const {execFileSync} = require('child_process');
2020
const fs = require('fs');
2121
const os = require('os');
2222
const path = require('path');
@@ -185,14 +185,16 @@ function main(appRootDir, outputPath) {
185185
console.log(
186186
'\n\n[Codegen] >>>>> Building react-native-codegen package',
187187
);
188-
execSync('yarn install', {
188+
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
189+
execFileSync('yarn', ['install'], {
189190
cwd: codegenCliPath,
190191
stdio: 'inherit',
191192
});
192-
execSync('yarn build', {
193+
execFileSync('yarn', ['build'], {
193194
cwd: codegenCliPath,
194195
stdio: 'inherit',
195196
});
197+
// ]TODO(macOS GH#774)
196198
}
197199
} else if (fs.existsSync(CODEGEN_NPM_PATH)) {
198200
codegenCliPath = CODEGEN_NPM_PATH;
@@ -235,8 +237,7 @@ function main(appRootDir, outputPath) {
235237
console.log(`\n\n[Codegen] >>>>> Processing ${library.config.name}`);
236238
// Generate one schema for the entire library...
237239
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
238-
execFileSync(
239-
'node',
240+
execFileSync('node', [
240241
path.join(
241242
codegenCliPath,
242243
'lib',
@@ -246,17 +247,17 @@ function main(appRootDir, outputPath) {
246247
),
247248
pathToSchema,
248249
pathToJavaScriptSources,
249-
); // ]TODO(macOS GH#774)
250+
]); // ]TODO(macOS GH#774)
250251
console.log(`[Codegen] Generated schema: ${pathToSchema}`);
251252

252253
// ...then generate native code artifacts.
254+
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
253255
const libraryTypeArg = library.config.type
254-
? `--libraryType ${library.config.type}`
255-
: '';
256+
? ['--libraryType', library.config.type]
257+
: null; // ]TODO(macOS GH#774)
256258
fs.mkdirSync(pathToTempOutputDir, {recursive: true});
257259
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
258-
execFileSync(
259-
'node',
260+
execFileSync('node', [
260261
path.join(RN_ROOT, 'scripts', 'generate-specs-cli.js'),
261262
'--platform',
262263
'ios',
@@ -266,13 +267,17 @@ function main(appRootDir, outputPath) {
266267
pathToTempOutputDir,
267268
'--libraryName',
268269
library.config.name,
269-
libraryTypeArg,
270-
); // ]TODO(macOS GH#774)
270+
...libraryTypeArg,
271+
]); // ]TODO(macOS GH#774)
271272

272273
// Finally, copy artifacts to the final output directory.
273274
fs.mkdirSync(pathToOutputDirIOS, {recursive: true});
274275
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
275-
execFileSync('cp', '-R', `${pathToTempOutputDir}/*`, pathToOutputDirIOS); // ]TODO(macOS GH#774)
276+
execFileSync('cp', [
277+
'-R',
278+
path.join(pathToTempOutputDir, '/'),
279+
pathToOutputDirIOS,
280+
]); // ]TODO(macOS GH#774)
276281
console.log(`[Codegen] Generated artifacts: ${pathToOutputDirIOS}`);
277282

278283
// Filter the react native core library out.
@@ -295,16 +300,15 @@ function main(appRootDir, outputPath) {
295300
// Generate FabricComponentProvider.
296301
// Only for iOS at this moment.
297302
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
298-
execFileSync(
299-
'node',
303+
execFileSync('node', [
300304
path.join(RN_ROOT, 'scripts', 'generate-provider-cli.js'),
301305
'--platform',
302306
'ios',
303-
'--schemaListPast',
307+
'--schemaListPath',
304308
schemaListTmpPath,
305309
'--outputDir',
306310
iosOutputDir,
307-
); // ]TODO(macOS GH#774)
311+
]); // ]TODO(macOS GH#774)
308312
console.log(`Generated provider in: ${iosOutputDir}`);
309313
}
310314
} catch (err) {

0 commit comments

Comments
 (0)