@react-native/core-cli-utils 0.87.0-nightly-20260519-58cd1bf58 → 0.87.0-nightly-20260528-eaf770433

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.
@@ -1,29 +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
- *
8
- * @format
9
- */
10
-
11
- import type { Task } from "./types";
12
- import type { ExecaPromise } from "execa";
13
- type AndroidBuildMode = "Debug" | "Release";
14
- type Path = string;
15
- type Args = ReadonlyArray<string>;
16
- type Config = {
17
- cwd: Path;
18
- hermes?: boolean;
19
- mode: AndroidBuildMode;
20
- name: string;
21
- newArchitecture?: boolean;
22
- sdk?: Path;
23
- };
24
- export declare const tasks: (config: Config) => {
25
- assemble: (...gradleArgs: Args) => { run: Task<ExecaPromise> };
26
- build: (...gradleArgs: Args) => { run: Task<ExecaPromise> };
27
- install: (...gradleArgs: Args) => { run: Task<ExecaPromise> };
28
- };
29
- export declare type tasks = typeof tasks;
@@ -1,74 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true,
5
- });
6
- exports.tasks = void 0;
7
- var _utils = require("./utils");
8
- var _execa = _interopRequireDefault(require("execa"));
9
- function _interopRequireDefault(e) {
10
- return e && e.__esModule ? e : { default: e };
11
- }
12
- function gradle(taskName, args, options) {
13
- const gradlew = _utils.isWindows ? "gradlew.bat" : "./gradlew";
14
- return (0, _execa.default)(gradlew, [taskName, ...args], {
15
- cwd: options.cwd,
16
- env: options.env,
17
- });
18
- }
19
- function androidSdkPath(sdk) {
20
- return sdk ?? process.env.ANDROID_HOME ?? process.env.ANDROID_SDK ?? "";
21
- }
22
- function boolToStr(value) {
23
- return value ? "true" : "false";
24
- }
25
- const FIRST = 1;
26
- const tasks = (config) => ({
27
- assemble: (...gradleArgs) => ({
28
- run: (0, _utils.task)(FIRST, "Assemble Android App", () => {
29
- const args = [];
30
- if (config.hermes != null) {
31
- args.push(`-PhermesEnabled=${boolToStr(config.hermes)}`);
32
- }
33
- if (config.newArchitecture != null) {
34
- args.push(`-PnewArchEnabled=${boolToStr(config.newArchitecture)}`);
35
- }
36
- args.push(...gradleArgs);
37
- return gradle(`${config.name}:assemble${config.mode}`, gradleArgs, {
38
- cwd: config.cwd,
39
- env: {
40
- ANDROID_HOME: androidSdkPath(config.sdk),
41
- },
42
- });
43
- }),
44
- }),
45
- build: (...gradleArgs) => ({
46
- run: (0, _utils.task)(FIRST, "Assembles and tests Android App", () => {
47
- const args = [];
48
- if (config.hermes != null) {
49
- args.push(`-PhermesEnabled=${boolToStr(config.hermes)}`);
50
- }
51
- if (config.newArchitecture != null) {
52
- args.push(`-PnewArchEnabled=${boolToStr(config.newArchitecture)}`);
53
- }
54
- args.push(...gradleArgs);
55
- return gradle(`${config.name}:bundle${config.mode}`, args, {
56
- cwd: config.cwd,
57
- env: {
58
- ANDROID_HOME: androidSdkPath(config.sdk),
59
- },
60
- });
61
- }),
62
- }),
63
- install: (...gradleArgs) => ({
64
- run: (0, _utils.task)(FIRST, "Installs the assembled Android App", () =>
65
- gradle(`${config.name}:install${config.mode}`, gradleArgs, {
66
- cwd: config.cwd,
67
- env: {
68
- ANDROID_HOME: androidSdkPath(config.sdk),
69
- },
70
- }),
71
- ),
72
- }),
73
- });
74
- exports.tasks = tasks;
@@ -1,41 +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
- */
10
-
11
- import type { Task } from "./types";
12
- import type { ExecaPromise } from "execa";
13
-
14
- type AndroidBuildMode = "Debug" | "Release";
15
-
16
- type Path = string;
17
- type Args = ReadonlyArray<string>;
18
-
19
- type Config = {
20
- cwd: Path,
21
- hermes?: boolean,
22
- mode: AndroidBuildMode,
23
- name: string,
24
- newArchitecture?: boolean,
25
- sdk?: Path,
26
- };
27
-
28
- //
29
- // Android Tasks
30
- //
31
- declare export const tasks: (config: Config) => {
32
- assemble: (...gradleArgs: Args) => {
33
- run: Task<ExecaPromise>,
34
- },
35
- build: (...gradleArgs: Args) => {
36
- run: Task<ExecaPromise>,
37
- },
38
- install: (...gradleArgs: Args) => {
39
- run: Task<ExecaPromise>,
40
- },
41
- };
@@ -1,37 +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
- *
8
- * @format
9
- */
10
-
11
- import type { Task } from "./types";
12
- import type { ExecaPromise } from "execa";
13
- type BundlerOptions =
14
- /**
15
- * > 38 | ...Bundler,
16
- * | ^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
17
- **/
18
- any;
19
- type HermesConfig = { path: string; hermesc: string };
20
- type BundlerWatch = {
21
- readonly mode: "watch";
22
- callback?: (metro: ExecaPromise) => void;
23
- };
24
- type BundlerBuild = { readonly mode: "bundle" };
25
- type Bundler = BundlerWatch | BundlerBuild;
26
- export declare const tasks: {
27
- bundle: (options: BundlerOptions, ...args: ReadonlyArray<string>) => Bundle;
28
- };
29
- export declare type tasks = typeof tasks;
30
- type Bundle = {
31
- validate?: Task<void>;
32
- javascript: Task<ExecaPromise>;
33
- sourcemap?: Task<void>;
34
- validateHermesc?: Task<ExecaPromise>;
35
- convert?: Task<ExecaPromise>;
36
- compose?: Task<ExecaPromise>;
37
- };
@@ -1,172 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true,
5
- });
6
- exports.tasks = void 0;
7
- var _utils = require("./utils");
8
- var _debug = _interopRequireDefault(require("debug"));
9
- var _execa = _interopRequireDefault(require("execa"));
10
- var _fs = _interopRequireDefault(require("fs"));
11
- var _path = _interopRequireDefault(require("path"));
12
- function _interopRequireDefault(e) {
13
- return e && e.__esModule ? e : { default: e };
14
- }
15
- const log = (0, _debug.default)("core-cli-utils");
16
- const FIRST = 1,
17
- SECOND = 2,
18
- THIRD = 3,
19
- FOURTH = 4;
20
- function getNodePackagePath(packageName) {
21
- return require.resolve(packageName, {
22
- cwd: [process.cwd(), ...module.paths],
23
- });
24
- }
25
- function metro(...args) {
26
- log(`🚇 metro ${args.join(" ")} `);
27
- return (0, _execa.default)("npx", ["--offline", "metro", ...args]);
28
- }
29
- const tasks = (exports.tasks = {
30
- bundle: (options, ...args) => {
31
- const steps = {
32
- validate: (0, _utils.task)(FIRST, "Check if Metro is available", () => {
33
- try {
34
- require("metro");
35
- } catch {
36
- throw new Error("Metro is not available");
37
- }
38
- }),
39
- javascript: (0, _utils.task)(SECOND, "Metro watching for changes", () =>
40
- metro("serve", ...args),
41
- ),
42
- };
43
- return options.mode === "bundle"
44
- ? Object.assign(steps, bundleApp(options, ...args))
45
- : steps;
46
- },
47
- });
48
- const bundleApp = (options, ...metroArgs) => {
49
- if (options.outputJsBundle === options.outputBundle) {
50
- throw new Error("outputJsBundle and outputBundle cannot be the same.");
51
- }
52
- let output =
53
- options.jsvm === "hermes" ? options.outputJsBundle : options.outputBundle;
54
- if (output === options.outputJsBundle && !output.endsWith(".js")) {
55
- log(
56
- `Appending .js to outputBundle (because metro cli does it if it's missing): ${output}`,
57
- );
58
- output += ".js";
59
- }
60
- const isSourceMaps = options.outputSourceMap != null;
61
- const bundle = {
62
- javascript: (0, _utils.task)(
63
- SECOND,
64
- "Metro generating an .jsbundle",
65
- () => {
66
- const args = [
67
- "--platform",
68
- options.platform,
69
- "--dev",
70
- options.dev ? "true" : "false",
71
- "--reset-cache",
72
- "--out",
73
- output,
74
- ];
75
- if (options.jsvm === "hermes" && !options.dev) {
76
- args.push("--minify", "false");
77
- } else {
78
- args.push("--minify", options.minify ? "true" : "false");
79
- }
80
- if (isSourceMaps) {
81
- args.push("--source-map");
82
- }
83
- return metro("build", options.entryFile, ...args, ...metroArgs);
84
- },
85
- ),
86
- };
87
- if (options.jsvm === "jsc") {
88
- return bundle;
89
- }
90
- if (options.hermes?.path == null || options.hermes?.hermesc == null) {
91
- throw new Error('If jsvm == "hermes", hermes config must be provided.');
92
- }
93
- const hermes = options.hermes;
94
- const isHermesInstalled = _fs.default.existsSync(hermes.path);
95
- if (!isHermesInstalled) {
96
- throw new Error(
97
- "Hermes Pod must be installed before bundling.\n" +
98
- "Did you forget to bootstrap?",
99
- );
100
- }
101
- const hermesc = _path.default.join(hermes.path, hermes.hermesc);
102
- let composeSourceMaps;
103
- if (isSourceMaps) {
104
- bundle.sourcemap = (0, _utils.task)(
105
- FIRST,
106
- "Check if SourceMap script available",
107
- () => {
108
- composeSourceMaps = getNodePackagePath(
109
- "react-native/scripts/compose-source-maps.js",
110
- );
111
- },
112
- );
113
- }
114
- bundle.validateHermesc = (0, _utils.task)(
115
- FIRST,
116
- "Check if Hermesc is available",
117
- () => (0, _execa.default)(hermesc, ["--version"]),
118
- );
119
- bundle.convert = (0, _utils.task)(
120
- THIRD,
121
- "Hermesc converting .jsbundle → bytecode",
122
- () => {
123
- const args = [
124
- "-emit-binary",
125
- "-max-diagnostic-width=80",
126
- options.dev === true ? "-Og" : "-O",
127
- ];
128
- if (isSourceMaps) {
129
- args.push("-output-source-map");
130
- }
131
- args.push(`-out=${options.outputBundle}`, output);
132
- return (0, _execa.default)(hermesc, args, {
133
- cwd: options.cwd,
134
- });
135
- },
136
- );
137
- bundle.compose = (0, _utils.task)(
138
- FOURTH,
139
- "Compose Hermes and Metro source maps",
140
- () => {
141
- if (composeSourceMaps == null) {
142
- throw new Error(
143
- "Unable to find the compose-source-map.js script in react-native",
144
- );
145
- }
146
- const metroSourceMap = output.replace(/(\.js)?$/, ".map");
147
- const hermesSourceMap = options.outputBundle + ".map";
148
- const compose = (0, _execa.default)(
149
- "node",
150
- [
151
- composeSourceMaps,
152
- metroSourceMap,
153
- hermesSourceMap,
154
- `-o ${options.outputSourceMap}`,
155
- ],
156
- {
157
- cwd: options.cwd,
158
- },
159
- );
160
- compose.finally(() => {
161
- _fs.default.rmSync(metroSourceMap, {
162
- force: true,
163
- });
164
- _fs.default.rmSync(hermesSourceMap, {
165
- force: true,
166
- });
167
- });
168
- return compose;
169
- },
170
- );
171
- return bundle;
172
- };
@@ -1,71 +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
- */
10
-
11
- import type { Task } from "./types";
12
- import type { ExecaPromise } from "execa";
13
-
14
- type BundlerOptions = {
15
- // Metro's config: https://metrobundler.dev/docs/configuration/
16
- config?: string,
17
- // Typically index.{ios,android}.js
18
- entryFile: string,
19
- +platform: "ios" | "android" | string,
20
- dev: boolean,
21
- // Metro built main bundle
22
- outputJsBundle: string,
23
- minify: boolean,
24
- optimize: boolean,
25
- // Generate a source map file
26
- outputSourceMap: string,
27
- // Where to pass the final bundle. Typically this is the App's resource
28
- // folder, however this is app specific. React Native will need to know where
29
- // this is to bootstrap your application. See:
30
- // - Android: https://reactnative.dev/docs/integration-with-existing-apps?language=kotlin#creating-a-release-build-in-android-studio
31
- // - iOS: https://reactnative.dev/docs/integration-with-existing-apps?language=swift#2-event-handler
32
- outputBundle: string,
33
- cwd: string,
34
-
35
- jsvm: "hermes" | "jsc",
36
- hermes?: HermesConfig,
37
-
38
- ...Bundler,
39
- };
40
-
41
- type HermesConfig = {
42
- // Path where hermes is is installed
43
- // iOS: Pods/hermes-engine
44
- path: string,
45
- // iOS: <hermes.path>/destroot/bin/hermesc
46
- hermesc: string,
47
- };
48
-
49
- type BundlerWatch = {
50
- +mode: "watch",
51
- callback?: (metro: ExecaPromise) => void,
52
- };
53
-
54
- type BundlerBuild = {
55
- +mode: "bundle",
56
- };
57
-
58
- type Bundler = BundlerWatch | BundlerBuild;
59
-
60
- declare export const tasks: {
61
- bundle: (options: BundlerOptions, ...args: ReadonlyArray<string>) => Bundle,
62
- };
63
-
64
- type Bundle = {
65
- validate?: Task<void>,
66
- javascript: Task<ExecaPromise>,
67
- sourcemap?: Task<void>,
68
- validateHermesc?: Task<ExecaPromise>,
69
- convert?: Task<ExecaPromise>,
70
- compose?: Task<ExecaPromise>,
71
- };
@@ -1,56 +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
- *
8
- * @format
9
- */
10
-
11
- import type { Task } from "./types";
12
- import type { ExecaPromise } from "execa";
13
- type AppleBuildMode = "Debug" | "Release";
14
- type AppleBuildOptions =
15
- /**
16
- * > 22 | ...AppleOptions,
17
- * | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
18
- **/
19
- any;
20
- type AppleBootstrapOption =
21
- /**
22
- * > 30 | ...AppleOptions,
23
- * | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
24
- **/
25
- any;
26
- type AppleInstallApp =
27
- /**
28
- * > 39 | ...AppleOptions,
29
- * | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
30
- **/
31
- any;
32
- type AppleOptions = { cwd: string; env?: { [key: string]: string | void } };
33
- export declare const tasks: {
34
- bootstrap: (options: AppleBootstrapOption) => {
35
- cleanupBuildFolder: Task<void>;
36
- runCodegen: Task<void>;
37
- validate: Task<void>;
38
- installRubyGems: Task<ExecaPromise>;
39
- installDependencies: Task<ExecaPromise>;
40
- };
41
- build: (
42
- options: AppleBuildOptions,
43
- ...args: ReadonlyArray<string>
44
- ) => {
45
- validate: Task<void>;
46
- hasPodsInstalled: Task<void>;
47
- build: Task<ExecaPromise>;
48
- };
49
- ios: {
50
- install: (options: AppleInstallApp) => {
51
- validate: Task<void>;
52
- install: Task<ExecaPromise>;
53
- };
54
- };
55
- };
56
- export declare type tasks = typeof tasks;
@@ -1,179 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true,
5
- });
6
- exports.tasks = void 0;
7
- var _utils = require("./utils");
8
- var _execa = _interopRequireDefault(require("execa"));
9
- var _fs = _interopRequireDefault(require("fs"));
10
- var _path = _interopRequireDefault(require("path"));
11
- function _interopRequireDefault(e) {
12
- return e && e.__esModule ? e : { default: e };
13
- }
14
- function checkPodfileInSyncWithManifest(lockfilePath, manifestLockfilePath) {
15
- try {
16
- const expected = _fs.default.readFileSync(lockfilePath, "utf8");
17
- const found = _fs.default.readFileSync(manifestLockfilePath, "utf8");
18
- if (expected !== found) {
19
- throw new Error(
20
- "Please run: yarn bootstrap ios, Podfile.lock and Pods/Manifest.lock are out of sync",
21
- );
22
- }
23
- } catch (e) {
24
- throw new Error("Please run: yarn run bootstrap ios: " + e.message);
25
- }
26
- }
27
- const FIRST = 1,
28
- SECOND = 2,
29
- THIRD = 3,
30
- FOURTH = 4,
31
- FIFTH = 5;
32
- function getNodePackagePath(packageName) {
33
- return require.resolve(packageName, {
34
- cwd: [process.cwd(), ...module.paths],
35
- });
36
- }
37
- const tasks = (exports.tasks = {
38
- bootstrap: (options) => ({
39
- cleanupBuildFolder: (0, _utils.task)(FIRST, "Cleanup build folder", () => {
40
- _execa.default.sync("rm", ["-rf", "build"], {
41
- cwd: options.cwd,
42
- });
43
- }),
44
- runCodegen: (0, _utils.task)(SECOND, "Run codegen", () => {
45
- const reactNativePath = _path.default.dirname(
46
- getNodePackagePath("react-native"),
47
- );
48
- const codegenScript = _path.default.join(
49
- reactNativePath,
50
- "scripts",
51
- "generate-codegen-artifacts.js",
52
- );
53
- _execa.default.sync("node", [
54
- codegenScript,
55
- "-p",
56
- process.cwd(),
57
- "-o",
58
- options.cwd,
59
- "-t",
60
- "ios",
61
- ]);
62
- }),
63
- validate: (0, _utils.task)(
64
- THIRD,
65
- "Check Cocoapods and bundle are available",
66
- () => {
67
- (0, _utils.assertDependencies)(
68
- (0, _utils.isOnPath)("pod", "CocoaPods"),
69
- (0, _utils.isOnPath)("bundle", "Bundler to manage Ruby's gems"),
70
- );
71
- },
72
- ),
73
- installRubyGems: (0, _utils.task)(FOURTH, "Install Ruby Gems", () =>
74
- (0, _execa.default)("bundle", ["install"], {
75
- cwd: options.cwd,
76
- }),
77
- ),
78
- installDependencies: (0, _utils.task)(
79
- FIFTH,
80
- "Install CocoaPods dependencies",
81
- () => {
82
- const env = {
83
- RCT_NEW_ARCH_ENABLED: options.newArchitecture ? "1" : "0",
84
- USE_FRAMEWORKS: options.frameworks,
85
- USE_HERMES: options.hermes ? "1" : "0",
86
- RCT_IGNORE_PODS_DEPRECATION: "1",
87
- };
88
- if (options.frameworks == null) {
89
- delete env.USE_FRAMEWORKS;
90
- }
91
- return (0, _execa.default)("bundle", ["exec", "pod", "install"], {
92
- cwd: options.cwd,
93
- env,
94
- });
95
- },
96
- ),
97
- }),
98
- build: (options, ...args) => ({
99
- validate: (0, _utils.task)(
100
- FIRST,
101
- "Check you've run xcode-select --install for xcodebuild",
102
- () => {
103
- (0, _utils.assertDependencies)(
104
- (0, _utils.isOnPath)("xcodebuild", "Xcode Commandline Tools"),
105
- );
106
- },
107
- ),
108
- hasPodsInstalled: (0, _utils.task)(
109
- FIRST,
110
- "Check Pods are installed",
111
- () => {
112
- for (const file of ["Podfile.lock", "Pods"]) {
113
- try {
114
- _fs.default.accessSync(
115
- _path.default.join(options.cwd, file),
116
- _fs.default.constants.F_OK | _fs.default.constants.R_OK,
117
- );
118
- } catch (e) {
119
- throw new Error("Please run: yarn run bootstrap ios: " + e.message);
120
- }
121
- }
122
- checkPodfileInSyncWithManifest(
123
- _path.default.join(options.cwd, "Podfile.lock"),
124
- _path.default.join(options.cwd, "Pods/Manifest.lock"),
125
- );
126
- },
127
- ),
128
- build: (0, _utils.task)(SECOND, "build an app artifact", () => {
129
- const _args = [
130
- options.isWorkspace ? "-workspace" : "-project",
131
- options.name,
132
- "-configuration",
133
- options.mode,
134
- ];
135
- if (options.scheme != null) {
136
- _args.push("-scheme", options.scheme);
137
- }
138
- if (options.destination != null) {
139
- switch (options.destination) {
140
- case "simulator":
141
- _args.push("-sdk", "iphonesimulator");
142
- break;
143
- case "device":
144
- default:
145
- _args.push("-destination", options.destination);
146
- break;
147
- }
148
- }
149
- _args.push(...args);
150
- return (0, _execa.default)("xcodebuild", _args, {
151
- cwd: options.cwd,
152
- env: options.env,
153
- });
154
- }),
155
- }),
156
- ios: {
157
- install: (options) => ({
158
- validate: (0, _utils.task)(
159
- FIRST,
160
- "Check you've run xcode-select --install for xcrun",
161
- () => {
162
- (0, _utils.assertDependencies)(
163
- (0, _utils.isOnPath)("xcrun", "An Xcode Commandline tool: xcrun"),
164
- );
165
- },
166
- ),
167
- install: (0, _utils.task)(SECOND, "Install the app on a simulator", () =>
168
- (0, _execa.default)(
169
- "xcrun",
170
- ["simctl", "install", options.device, options.appPath],
171
- {
172
- cwd: options.cwd,
173
- env: options.env,
174
- },
175
- ),
176
- ),
177
- }),
178
- },
179
- });