-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
directly call community-cli-plugin in react-native-xcode.sh (#44721)
Summary: For iOS builds of `react-native`, the [react-native-xcode.sh](https://www.internalfb.com/code/fbsource/[7ad79aae3e8bf565d53f087ac7f7b7622b19acec]/xplat/js/react-native-github/packages/react-native/scripts/react-native-xcode.sh) script is executed as one of the build phases. This phase bundles the JS application (dev or production). I've updated this to use the new `bundle.js` script instead of calling the `react-native/cli.js`. This is identical except with how the config is captured: {F1669960016} This is similar to our approach with the Gradle plugin, giving Framework authors more control. **Other:** formatting changes for the Privacy Manifest that Xcode keeps updating. Changelog: [Internal] Differential Revision: D57915368
- Loading branch information
1 parent
6c2e1cf
commit a9f8a4d
Showing
6 changed files
with
163 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"platforms": { | ||
"ios": {}, | ||
"android": {} | ||
}, | ||
"project": { | ||
"ios": { | ||
"sourceDir": "HELLOWORLD_PATH/ios", | ||
"xcodeProject": { | ||
"name": "HelloWorld.xcworkspace", | ||
"isWorkspace": true | ||
} | ||
}, | ||
"android": { | ||
"sourceDir": "HELLOWORLD_PATH/android", | ||
"appName": "app", | ||
"packageName": "com.helloworld", | ||
"applicationId": "com.helloworld", | ||
"mainActivity": ".MainActivity" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
/*:: | ||
import type {Command} from 'commander'; | ||
import type {Config} from '@react-native-community/cli-types'; | ||
*/ | ||
|
||
const {bundleCommand: bc} = require('@react-native/community-cli-plugin'); | ||
const {execSync} = require('child_process'); | ||
// $FlowFixMe - Types aren't accurate for CommonJS module | ||
const program /*: Command */ = require('commander'); | ||
const {existsSync, readFileSync} = require('fs'); | ||
const path = require('path'); | ||
|
||
program.version( | ||
JSON.parse( | ||
readFileSync(path.resolve(__dirname, '..', 'package.json'), 'utf8'), | ||
).version, | ||
); | ||
|
||
/*:: | ||
type BundleCommandArgs = { | ||
configCmd?: string, | ||
loadConfig?: string, | ||
}; | ||
*/ | ||
|
||
program | ||
.name(bc.name) | ||
.description(bc.description ?? '') | ||
.option( | ||
'--config-cmd <string>', | ||
'Command to generate a JSON project config', | ||
'npx react-native config', | ||
) | ||
.option('--load-config <string>', 'JSON project config') | ||
.action(async function handleAction( | ||
options /*: BundleCommandArgs*/, | ||
...args /*: string[]*/ | ||
) { | ||
let config /*: Config*/; | ||
|
||
if (options.loadConfig != null) { | ||
const rawText /*: string*/ = existsSync(options.loadConfig) | ||
? readFileSync(options.loadConfig, 'utf8') | ||
: options.loadConfig; | ||
config = JSON.parse(rawText); | ||
} else if (options.configCmd != null) { | ||
config = JSON.parse( | ||
execSync(options.configCmd.trim(), {encoding: 'utf8'}), | ||
); | ||
} | ||
|
||
if (config == null) { | ||
throw new Error('No config provided'); | ||
} | ||
|
||
await bc.func(args, config, options); | ||
}); | ||
|
||
if (bc.options != null) { | ||
for (const o of bc.options) { | ||
program.option( | ||
o.name, | ||
o.description ?? '', | ||
o.parse ?? (value => value), | ||
o.default, | ||
); | ||
} | ||
} | ||
|
||
if (require.main === module) { | ||
program.parse(process.argv); | ||
} | ||
|
||
module.exports = program; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters