@react-native/core-cli-utils 0.76.0-nightly-20240715-2eb7bcb8d → 0.76.0-nightly-20240720-3a5eb1973
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +22 -0
- package/dist/index.js +66 -0
- package/dist/index.js.flow +26 -0
- package/dist/private/android.d.ts +29 -0
- package/dist/private/android.js +74 -0
- package/dist/private/android.js.flow +42 -0
- package/dist/private/app.d.ts +37 -0
- package/dist/private/app.js +176 -0
- package/dist/private/app.js.flow +72 -0
- package/dist/private/apple.d.ts +54 -0
- package/dist/private/apple.js +148 -0
- package/dist/private/apple.js.flow +71 -0
- package/dist/private/clean.d.ts +59 -0
- package/dist/private/clean.js +141 -0
- package/dist/private/clean.js.flow +77 -0
- package/dist/private/types.d.ts +16 -0
- package/dist/private/types.js +1 -0
- package/dist/private/utils.d.ts +28 -0
- package/dist/private/utils.js +53 -0
- package/dist/private/utils.js.flow +38 -0
- package/dist/public/version.d.ts +27 -0
- package/dist/public/version.js +31 -0
- package/{src/public/version.flow.js → dist/public/version.js.flow} +12 -19
- package/package.json +2 -2
- package/src/index.flow.js +0 -26
- package/src/index.js +0 -20
- package/src/private/android.js +0 -121
- package/src/private/app.js +0 -250
- package/src/private/apple.js +0 -196
- package/src/private/clean.js +0 -203
- package/src/private/utils.js +0 -66
- package/src/public/version.js +0 -20
- /package/{src/private/types.js → dist/private/types.js.flow} +0 -0
|
@@ -27,27 +27,20 @@
|
|
|
27
27
|
//
|
|
28
28
|
// For react-native@0.75.0 you have to have a version of XCode >= 12
|
|
29
29
|
|
|
30
|
-
export const android
|
|
31
|
-
ANDROID_NDK:
|
|
32
|
-
ANDROID_SDK:
|
|
30
|
+
declare export const android: {
|
|
31
|
+
ANDROID_NDK: ">= 23.x",
|
|
32
|
+
ANDROID_SDK: ">= 33.x",
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export const apple
|
|
36
|
-
COCOAPODS: '>= 1.10.0',
|
|
37
|
-
XCODE: '>= 12.x',
|
|
38
|
-
};
|
|
35
|
+
declare export const apple: { COCOAPODS: ">= 1.10.0", XCODE: ">= 12.x" };
|
|
39
36
|
|
|
40
|
-
export const common
|
|
41
|
-
BUN:
|
|
42
|
-
JAVA:
|
|
43
|
-
NODE_JS:
|
|
44
|
-
NPM:
|
|
45
|
-
RUBY:
|
|
46
|
-
YARN:
|
|
37
|
+
declare export const common: {
|
|
38
|
+
BUN: ">= 1.0.0",
|
|
39
|
+
JAVA: ">= 17 <= 20",
|
|
40
|
+
NODE_JS: ">= 18",
|
|
41
|
+
NPM: ">= 4.x",
|
|
42
|
+
RUBY: ">= 2.6.10",
|
|
43
|
+
YARN: ">= 1.10.x",
|
|
47
44
|
};
|
|
48
45
|
|
|
49
|
-
export const all
|
|
50
|
-
...apple,
|
|
51
|
-
...android,
|
|
52
|
-
...common,
|
|
53
|
-
};
|
|
46
|
+
declare export const all: { ...apple, ...android, ...common };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/core-cli-utils",
|
|
3
|
-
"version": "0.76.0-nightly-
|
|
3
|
+
"version": "0.76.0-nightly-20240720-3a5eb1973",
|
|
4
4
|
"description": "React Native CLI library for Frameworks to build on",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.flow.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": ">=18"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
-
"
|
|
27
|
+
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {},
|
|
30
30
|
"devDependencies": {}
|
package/src/index.flow.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// @babel/register doesn't like export {foo} from './bar'; statements,
|
|
13
|
-
// so we have to jump through hoops here.
|
|
14
|
-
import {tasks as _android} from './private/android.js';
|
|
15
|
-
import {tasks as _app} from './private/app.js';
|
|
16
|
-
import {tasks as _apple} from './private/apple.js';
|
|
17
|
-
import {tasks as _clean} from './private/clean.js';
|
|
18
|
-
import * as _version from './public/version.js';
|
|
19
|
-
|
|
20
|
-
export const android = _android;
|
|
21
|
-
export const app = _app;
|
|
22
|
-
export const apple = _apple;
|
|
23
|
-
export const clean = _clean;
|
|
24
|
-
export const version = _version;
|
|
25
|
-
|
|
26
|
-
export type {Task} from './private/types';
|
package/src/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/*::
|
|
13
|
-
export type * from './index.flow';
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
if (process.env.BUILD_EXCLUDE_BABEL_REGISTER == null) {
|
|
17
|
-
require('../../../scripts/build/babel-register').registerForMonorepo();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = require('./index.flow');
|
package/src/private/android.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type {Task} from './types';
|
|
13
|
-
import type {ExecaPromise} from 'execa';
|
|
14
|
-
|
|
15
|
-
import {isWindows, task} from './utils';
|
|
16
|
-
import execa from 'execa';
|
|
17
|
-
|
|
18
|
-
type AndroidBuildMode = 'Debug' | 'Release';
|
|
19
|
-
|
|
20
|
-
type Path = string;
|
|
21
|
-
type Args = $ReadOnlyArray<string>;
|
|
22
|
-
|
|
23
|
-
type Config = {
|
|
24
|
-
cwd: Path,
|
|
25
|
-
hermes?: boolean,
|
|
26
|
-
mode: AndroidBuildMode,
|
|
27
|
-
name: string,
|
|
28
|
-
newArchitecture?: boolean,
|
|
29
|
-
sdk?: Path,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function gradle(
|
|
33
|
-
taskName: string,
|
|
34
|
-
args: Args,
|
|
35
|
-
options: {cwd: string, env?: {[k: string]: string | void}},
|
|
36
|
-
): ExecaPromise {
|
|
37
|
-
const gradlew = isWindows ? 'gradlew.bat' : './gradlew';
|
|
38
|
-
return execa(gradlew, [taskName, ...args], {
|
|
39
|
-
cwd: options.cwd,
|
|
40
|
-
env: options.env,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function androidSdkPath(sdk?: string): string {
|
|
45
|
-
return sdk ?? process.env.ANDROID_HOME ?? process.env.ANDROID_SDK ?? '';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function boolToStr(value: boolean): string {
|
|
49
|
-
return value ? 'true' : 'false';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const FIRST = 1;
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
// Android Tasks
|
|
56
|
-
//
|
|
57
|
-
export const tasks = (
|
|
58
|
-
config: Config,
|
|
59
|
-
): ({
|
|
60
|
-
assemble: (...gradleArgs: Args) => {
|
|
61
|
-
run: Task<ExecaPromise>,
|
|
62
|
-
},
|
|
63
|
-
build: (...gradleArgs: Args) => {
|
|
64
|
-
run: Task<ExecaPromise>,
|
|
65
|
-
},
|
|
66
|
-
install: (...gradleArgs: Args) => {
|
|
67
|
-
run: Task<ExecaPromise>,
|
|
68
|
-
},
|
|
69
|
-
}) => ({
|
|
70
|
-
assemble: (...gradleArgs: Args) => ({
|
|
71
|
-
run: task(FIRST, 'Assemble Android App', () => {
|
|
72
|
-
const args = [];
|
|
73
|
-
if (config.hermes != null) {
|
|
74
|
-
args.push(`-PhermesEnabled=${boolToStr(config.hermes)}`);
|
|
75
|
-
}
|
|
76
|
-
if (config.newArchitecture != null) {
|
|
77
|
-
args.push(`-PnewArchEnabled=${boolToStr(config.newArchitecture)}`);
|
|
78
|
-
}
|
|
79
|
-
args.push(...gradleArgs);
|
|
80
|
-
return gradle(`${config.name}:assemble${config.mode}`, gradleArgs, {
|
|
81
|
-
cwd: config.cwd,
|
|
82
|
-
env: {ANDROID_HOME: androidSdkPath(config.sdk)},
|
|
83
|
-
});
|
|
84
|
-
}),
|
|
85
|
-
}),
|
|
86
|
-
build: (...gradleArgs: Args) => ({
|
|
87
|
-
run: task(FIRST, 'Assembles and tests Android App', () => {
|
|
88
|
-
const args = [];
|
|
89
|
-
if (config.hermes != null) {
|
|
90
|
-
args.push(`-PhermesEnabled=${boolToStr(config.hermes)}`);
|
|
91
|
-
}
|
|
92
|
-
if (config.newArchitecture != null) {
|
|
93
|
-
args.push(`-PnewArchEnabled=${boolToStr(config.newArchitecture)}`);
|
|
94
|
-
}
|
|
95
|
-
args.push(...gradleArgs);
|
|
96
|
-
return gradle(`${config.name}:bundle${config.mode}`, args, {
|
|
97
|
-
cwd: config.cwd,
|
|
98
|
-
env: {ANDROID_HOME: androidSdkPath(config.sdk)},
|
|
99
|
-
});
|
|
100
|
-
}),
|
|
101
|
-
}),
|
|
102
|
-
/**
|
|
103
|
-
* Useful extra gradle arguments:
|
|
104
|
-
*
|
|
105
|
-
* -PreactNativeDevServerPort=8081 sets the port for the installed app to point towards a Metro
|
|
106
|
-
* server on (for example) 8081.
|
|
107
|
-
*/
|
|
108
|
-
install: (...gradleArgs: Args) => ({
|
|
109
|
-
run: task(FIRST, 'Installs the assembled Android App', () =>
|
|
110
|
-
gradle(`${config.name}:install${config.mode}`, gradleArgs, {
|
|
111
|
-
cwd: config.cwd,
|
|
112
|
-
env: {ANDROID_HOME: androidSdkPath(config.sdk)},
|
|
113
|
-
}),
|
|
114
|
-
),
|
|
115
|
-
}),
|
|
116
|
-
|
|
117
|
-
// We are not supporting launching the app and setting up the tunnel for metro <-> app, this is
|
|
118
|
-
// a framework concern. For an example of how one could do this, please look at the community
|
|
119
|
-
// CLI's code:
|
|
120
|
-
// https://github.com/react-native-community/cli/blob/54d48a4e08a1aef334ae6168788e0157a666b4f5/packages/cli-platform-android/src/commands/runAndroid/index.ts#L272C1-L290C2
|
|
121
|
-
});
|
package/src/private/app.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type {Task} from './types';
|
|
13
|
-
import type {ExecaPromise} from 'execa';
|
|
14
|
-
|
|
15
|
-
import {task} from './utils';
|
|
16
|
-
import debug from 'debug';
|
|
17
|
-
import execa from 'execa';
|
|
18
|
-
import fs from 'fs';
|
|
19
|
-
import path from 'path';
|
|
20
|
-
|
|
21
|
-
const log = debug('core-cli-utils');
|
|
22
|
-
|
|
23
|
-
type BundlerOptions = {
|
|
24
|
-
// Metro's config: https://metrobundler.dev/docs/configuration/
|
|
25
|
-
config?: string,
|
|
26
|
-
// Typically index.{ios,android}.js
|
|
27
|
-
entryFile: string,
|
|
28
|
-
+platform: 'ios' | 'android' | string,
|
|
29
|
-
dev: boolean,
|
|
30
|
-
// Metro built main bundle
|
|
31
|
-
outputJsBundle: string,
|
|
32
|
-
minify: boolean,
|
|
33
|
-
optimize: boolean,
|
|
34
|
-
// Generate a source map file
|
|
35
|
-
outputSourceMap: string,
|
|
36
|
-
// Where to pass the final bundle. Typically this is the App's resource
|
|
37
|
-
// folder, however this is app specific. React Native will need to know where
|
|
38
|
-
// this is to bootstrap your application. See:
|
|
39
|
-
// - Android: https://reactnative.dev/docs/integration-with-existing-apps?language=kotlin#creating-a-release-build-in-android-studio
|
|
40
|
-
// - iOS: https://reactnative.dev/docs/integration-with-existing-apps?language=swift#2-event-handler
|
|
41
|
-
outputBundle: string,
|
|
42
|
-
cwd: string,
|
|
43
|
-
|
|
44
|
-
jsvm: 'hermes' | 'jsc',
|
|
45
|
-
hermes?: HermesConfig,
|
|
46
|
-
|
|
47
|
-
...Bundler,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type HermesConfig = {
|
|
51
|
-
// Path where hermes is is installed
|
|
52
|
-
// iOS: Pods/hermes-engine
|
|
53
|
-
path: string,
|
|
54
|
-
// iOS: <hermes.path>/destroot/bin/hermesc
|
|
55
|
-
hermesc: string,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type BundlerWatch = {
|
|
59
|
-
+mode: 'watch',
|
|
60
|
-
callback?: (metro: ExecaPromise) => void,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
type BundlerBuild = {
|
|
64
|
-
+mode: 'bundle',
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
type Bundler = BundlerWatch | BundlerBuild;
|
|
68
|
-
|
|
69
|
-
const FIRST = 1,
|
|
70
|
-
SECOND = 2,
|
|
71
|
-
THIRD = 3,
|
|
72
|
-
FOURTH = 4;
|
|
73
|
-
|
|
74
|
-
function getNodePackagePath(packageName: string): string {
|
|
75
|
-
// $FlowIgnore[prop-missing] type definition is incomplete
|
|
76
|
-
return require.resolve(packageName, {cwd: [process.cwd(), ...module.paths]});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function metro(...args: $ReadOnlyArray<string>): ExecaPromise {
|
|
80
|
-
const metroPath = getNodePackagePath(path.join('metro', 'src', 'cli.js'));
|
|
81
|
-
log(`🚇 ${metroPath} ${args.join(' ')} `);
|
|
82
|
-
return execa('node', [metroPath, ...args]);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const tasks = {
|
|
86
|
-
bundle: (
|
|
87
|
-
options: BundlerOptions,
|
|
88
|
-
...args: $ReadOnlyArray<string>
|
|
89
|
-
): Bundle => {
|
|
90
|
-
const steps: Bundle = {
|
|
91
|
-
/* eslint-disable sort-keys */
|
|
92
|
-
validate: task(FIRST, 'Check if Metro is available', () => {
|
|
93
|
-
try {
|
|
94
|
-
require('metro');
|
|
95
|
-
} catch {
|
|
96
|
-
throw new Error('Metro is not available');
|
|
97
|
-
}
|
|
98
|
-
}),
|
|
99
|
-
javascript: task(SECOND, 'Metro watching for changes', () =>
|
|
100
|
-
metro('serve', ...args),
|
|
101
|
-
),
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
return options.mode === 'bundle'
|
|
105
|
-
? Object.assign(steps, bundleApp(options, ...args))
|
|
106
|
-
: steps;
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
type Bundle = {
|
|
111
|
-
validate?: Task<void>,
|
|
112
|
-
javascript: Task<ExecaPromise>,
|
|
113
|
-
sourcemap?: Task<void>,
|
|
114
|
-
validateHermesc?: Task<ExecaPromise>,
|
|
115
|
-
convert?: Task<ExecaPromise>,
|
|
116
|
-
compose?: Task<ExecaPromise>,
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const bundleApp = (
|
|
120
|
-
options: BundlerOptions,
|
|
121
|
-
...metroArgs: $ReadOnlyArray<string>
|
|
122
|
-
) => {
|
|
123
|
-
if (options.outputJsBundle === options.outputBundle) {
|
|
124
|
-
throw new Error('outputJsBundle and outputBundle cannot be the same.');
|
|
125
|
-
}
|
|
126
|
-
// When using Hermes, Metro should generate the JS bundle to an intermediate file
|
|
127
|
-
// to then be converted to bytecode in the outputBundle. Otherwise just write to
|
|
128
|
-
// the outputBundle directly.
|
|
129
|
-
let output =
|
|
130
|
-
options.jsvm === 'hermes' ? options.outputJsBundle : options.outputBundle;
|
|
131
|
-
|
|
132
|
-
// TODO: Fix this by not using Metro CLI, which appends a .js extension
|
|
133
|
-
if (output === options.outputJsBundle && !output.endsWith('.js')) {
|
|
134
|
-
log(
|
|
135
|
-
`Appending .js to outputBundle (because metro cli does it if it's missing): ${output}`,
|
|
136
|
-
);
|
|
137
|
-
output += '.js';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const isSourceMaps = options.outputSourceMap != null;
|
|
141
|
-
const bundle: Bundle = {
|
|
142
|
-
javascript: task(SECOND, 'Metro generating an .jsbundle', () => {
|
|
143
|
-
const args = [
|
|
144
|
-
'--platform',
|
|
145
|
-
options.platform,
|
|
146
|
-
'--dev',
|
|
147
|
-
options.dev ? 'true' : 'false',
|
|
148
|
-
'--reset-cache',
|
|
149
|
-
'--out',
|
|
150
|
-
output,
|
|
151
|
-
];
|
|
152
|
-
if (options.jsvm === 'hermes' && !options.dev) {
|
|
153
|
-
// Hermes doesn't require JS minification
|
|
154
|
-
args.push('--minify', 'false');
|
|
155
|
-
} else {
|
|
156
|
-
args.push('--minify', options.minify ? 'true' : 'false');
|
|
157
|
-
}
|
|
158
|
-
if (isSourceMaps) {
|
|
159
|
-
args.push('--source-map');
|
|
160
|
-
}
|
|
161
|
-
return metro('build', options.entryFile, ...args, ...metroArgs);
|
|
162
|
-
}),
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
if (options.jsvm === 'jsc') {
|
|
166
|
-
return bundle;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (options.hermes?.path == null || options.hermes?.hermesc == null) {
|
|
170
|
-
throw new Error('If jsvm == "hermes", hermes config must be provided.');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const hermes: HermesConfig = options.hermes;
|
|
174
|
-
|
|
175
|
-
const isHermesInstalled: boolean = fs.existsSync(hermes.path);
|
|
176
|
-
if (!isHermesInstalled) {
|
|
177
|
-
throw new Error(
|
|
178
|
-
'Hermes Pod must be installed before bundling.\n' +
|
|
179
|
-
'Did you forget to bootstrap?',
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const hermesc: string = path.join(hermes.path, hermes.hermesc);
|
|
184
|
-
|
|
185
|
-
/*
|
|
186
|
-
* Hermes only tasks:
|
|
187
|
-
*/
|
|
188
|
-
let composeSourceMaps;
|
|
189
|
-
if (isSourceMaps) {
|
|
190
|
-
bundle.sourcemap = task(
|
|
191
|
-
FIRST,
|
|
192
|
-
'Check if SourceMap script available',
|
|
193
|
-
() => {
|
|
194
|
-
composeSourceMaps = getNodePackagePath(
|
|
195
|
-
'react-native/scripts/compose-source-maps.js',
|
|
196
|
-
);
|
|
197
|
-
},
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
bundle.validateHermesc = task(FIRST, 'Check if Hermesc is available', () =>
|
|
202
|
-
execa(hermesc, ['--version']),
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
bundle.convert = task(
|
|
206
|
-
THIRD,
|
|
207
|
-
'Hermesc converting .jsbundle → bytecode',
|
|
208
|
-
() => {
|
|
209
|
-
const args = [
|
|
210
|
-
'-emit-binary',
|
|
211
|
-
'-max-diagnostic-width=80',
|
|
212
|
-
options.dev === true ? '-Og' : '-O',
|
|
213
|
-
];
|
|
214
|
-
if (isSourceMaps) {
|
|
215
|
-
args.push('-output-source-map');
|
|
216
|
-
}
|
|
217
|
-
args.push(`-out=${options.outputBundle}`, output);
|
|
218
|
-
return execa(hermesc, args, {cwd: options.cwd});
|
|
219
|
-
},
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
bundle.compose = task(FOURTH, 'Compose Hermes and Metro source maps', () => {
|
|
223
|
-
if (composeSourceMaps == null) {
|
|
224
|
-
throw new Error(
|
|
225
|
-
'Unable to find the compose-source-map.js script in react-native',
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
const metroSourceMap = output.replace(/(\.js)?$/, '.map');
|
|
229
|
-
const hermesSourceMap = options.outputBundle + '.map';
|
|
230
|
-
const compose = execa(
|
|
231
|
-
'node',
|
|
232
|
-
[
|
|
233
|
-
composeSourceMaps,
|
|
234
|
-
metroSourceMap,
|
|
235
|
-
hermesSourceMap,
|
|
236
|
-
`-o ${options.outputSourceMap}`,
|
|
237
|
-
],
|
|
238
|
-
{
|
|
239
|
-
cwd: options.cwd,
|
|
240
|
-
},
|
|
241
|
-
);
|
|
242
|
-
compose.finally(() => {
|
|
243
|
-
fs.rmSync(metroSourceMap, {force: true});
|
|
244
|
-
fs.rmSync(hermesSourceMap, {force: true});
|
|
245
|
-
});
|
|
246
|
-
return compose;
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
return bundle;
|
|
250
|
-
};
|
package/src/private/apple.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type {Task} from './types';
|
|
13
|
-
import type {ExecaPromise} from 'execa';
|
|
14
|
-
|
|
15
|
-
import {assertDependencies, isOnPath, task} from './utils';
|
|
16
|
-
import execa from 'execa';
|
|
17
|
-
import fs from 'fs';
|
|
18
|
-
import path from 'path';
|
|
19
|
-
|
|
20
|
-
type AppleBuildMode = 'Debug' | 'Release';
|
|
21
|
-
|
|
22
|
-
type AppleBuildOptions = {
|
|
23
|
-
isWorkspace: boolean,
|
|
24
|
-
name: string,
|
|
25
|
-
mode: AppleBuildMode,
|
|
26
|
-
scheme?: string,
|
|
27
|
-
destination: 'device' | 'simulator' | string,
|
|
28
|
-
...AppleOptions,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type AppleBootstrapOption = {
|
|
32
|
-
// Enabled by default
|
|
33
|
-
hermes: boolean,
|
|
34
|
-
newArchitecture: boolean,
|
|
35
|
-
frameworks?: 'static' | 'dynamic',
|
|
36
|
-
...AppleOptions,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type AppleInstallApp = {
|
|
40
|
-
// Install the app on a simulator or device, typically this is the description from
|
|
41
|
-
// `xcrun simctl list devices`
|
|
42
|
-
device: string,
|
|
43
|
-
appPath: string,
|
|
44
|
-
bundleId: string,
|
|
45
|
-
...AppleOptions,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type AppleOptions = {
|
|
49
|
-
// The directory where the Xcode project is located
|
|
50
|
-
cwd: string,
|
|
51
|
-
// The environment variables to pass to the build command
|
|
52
|
-
env?: {[key: string]: string | void, ...},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
function checkPodfileInSyncWithManifest(
|
|
56
|
-
lockfilePath: string,
|
|
57
|
-
manifestLockfilePath: string,
|
|
58
|
-
) {
|
|
59
|
-
try {
|
|
60
|
-
const expected = fs.readFileSync(lockfilePath, 'utf8');
|
|
61
|
-
const found = fs.readFileSync(manifestLockfilePath, 'utf8');
|
|
62
|
-
if (expected !== found) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
'Please run: yarn bootstrap ios, Podfile.lock and Pods/Manifest.lock are out of sync',
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
} catch (e) {
|
|
68
|
-
throw new Error('Please run: yarn run boostrap ios: ' + e.message);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const FIRST = 1,
|
|
73
|
-
SECOND = 2,
|
|
74
|
-
THIRD = 3;
|
|
75
|
-
|
|
76
|
-
/* eslint sort-keys: "off" */
|
|
77
|
-
export const tasks = {
|
|
78
|
-
// 1. Setup your environment for building the iOS apps
|
|
79
|
-
bootstrap: (
|
|
80
|
-
options: AppleBootstrapOption,
|
|
81
|
-
): {
|
|
82
|
-
validate: Task<void>,
|
|
83
|
-
installRubyGems: Task<ExecaPromise>,
|
|
84
|
-
installDependencies: Task<ExecaPromise>,
|
|
85
|
-
} => ({
|
|
86
|
-
validate: task(FIRST, 'Check Cocoapods and bundle are available', () => {
|
|
87
|
-
assertDependencies(
|
|
88
|
-
isOnPath('pod', 'CocoaPods'),
|
|
89
|
-
isOnPath('bundle', "Bundler to manage Ruby's gems"),
|
|
90
|
-
);
|
|
91
|
-
}),
|
|
92
|
-
installRubyGems: task(SECOND, 'Install Ruby Gems', () =>
|
|
93
|
-
execa('bundle', ['install'], {
|
|
94
|
-
cwd: options.cwd,
|
|
95
|
-
}),
|
|
96
|
-
),
|
|
97
|
-
installDependencies: task(THIRD, 'Install CocoaPods dependencies', () => {
|
|
98
|
-
const env = {
|
|
99
|
-
RCT_NEW_ARCH_ENABLED: options.newArchitecture ? '1' : '0',
|
|
100
|
-
USE_FRAMEWORKS: options.frameworks,
|
|
101
|
-
USE_HERMES: options.hermes ? '1' : '0',
|
|
102
|
-
};
|
|
103
|
-
if (options.frameworks == null) {
|
|
104
|
-
delete env.USE_FRAMEWORKS;
|
|
105
|
-
}
|
|
106
|
-
return execa('bundle', ['exec', 'pod', 'install'], {
|
|
107
|
-
cwd: options.cwd,
|
|
108
|
-
env,
|
|
109
|
-
});
|
|
110
|
-
}),
|
|
111
|
-
}),
|
|
112
|
-
|
|
113
|
-
// 2. Build the iOS app using a setup environment
|
|
114
|
-
build: (
|
|
115
|
-
options: AppleBuildOptions,
|
|
116
|
-
...args: $ReadOnlyArray<string>
|
|
117
|
-
): {
|
|
118
|
-
validate: Task<void>,
|
|
119
|
-
hasPodsInstalled: Task<void>,
|
|
120
|
-
build: Task<ExecaPromise>,
|
|
121
|
-
} => ({
|
|
122
|
-
validate: task(
|
|
123
|
-
FIRST,
|
|
124
|
-
"Check you've run xcode-select --install for xcodebuild",
|
|
125
|
-
() => {
|
|
126
|
-
assertDependencies(isOnPath('xcodebuild', 'Xcode Commandline Tools'));
|
|
127
|
-
},
|
|
128
|
-
),
|
|
129
|
-
hasPodsInstalled: task(FIRST, 'Check Pods are installed', () => {
|
|
130
|
-
for (const file of ['Podfile.lock', 'Pods']) {
|
|
131
|
-
try {
|
|
132
|
-
fs.accessSync(
|
|
133
|
-
path.join(options.cwd, file),
|
|
134
|
-
/* eslint-disable-next-line no-bitwise */
|
|
135
|
-
fs.constants.F_OK | fs.constants.R_OK,
|
|
136
|
-
);
|
|
137
|
-
} catch (e) {
|
|
138
|
-
throw new Error('Please run: yarn run boostrap ios: ' + e.message);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
checkPodfileInSyncWithManifest(
|
|
142
|
-
path.join(options.cwd, 'Podfile.lock'),
|
|
143
|
-
path.join(options.cwd, 'Pods/Manifest.lock'),
|
|
144
|
-
);
|
|
145
|
-
}),
|
|
146
|
-
build: task(SECOND, 'build an app artifact', () => {
|
|
147
|
-
const _args = [
|
|
148
|
-
options.isWorkspace ? '-workspace' : '-project',
|
|
149
|
-
options.name,
|
|
150
|
-
'-configuration',
|
|
151
|
-
options.mode,
|
|
152
|
-
];
|
|
153
|
-
if (options.scheme != null) {
|
|
154
|
-
_args.push('-scheme', options.scheme);
|
|
155
|
-
}
|
|
156
|
-
if (options.destination != null) {
|
|
157
|
-
// The user doesn't want a generic target, they know better.
|
|
158
|
-
switch (options.destination) {
|
|
159
|
-
case 'simulator':
|
|
160
|
-
_args.push('-sdk', 'iphonesimulator');
|
|
161
|
-
break;
|
|
162
|
-
case 'device':
|
|
163
|
-
default:
|
|
164
|
-
_args.push('-destination', options.destination);
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
_args.push(...args);
|
|
170
|
-
return execa('xcodebuild', _args, {cwd: options.cwd, env: options.env});
|
|
171
|
-
}),
|
|
172
|
-
}),
|
|
173
|
-
|
|
174
|
-
// 3. Install the built app on a simulator or device
|
|
175
|
-
ios: {
|
|
176
|
-
install: (
|
|
177
|
-
options: AppleInstallApp,
|
|
178
|
-
): {validate: Task<void>, install: Task<ExecaPromise>} => ({
|
|
179
|
-
validate: task(
|
|
180
|
-
FIRST,
|
|
181
|
-
"Check you've run xcode-select --install for xcrun",
|
|
182
|
-
() => {
|
|
183
|
-
assertDependencies(
|
|
184
|
-
isOnPath('xcrun', 'An Xcode Commandline tool: xcrun'),
|
|
185
|
-
);
|
|
186
|
-
},
|
|
187
|
-
),
|
|
188
|
-
install: task(SECOND, 'Install the app on a simulator', () =>
|
|
189
|
-
execa('xcrun', ['simctl', 'install', options.device, options.appPath], {
|
|
190
|
-
cwd: options.cwd,
|
|
191
|
-
env: options.env,
|
|
192
|
-
}),
|
|
193
|
-
),
|
|
194
|
-
}),
|
|
195
|
-
},
|
|
196
|
-
};
|