@react-native/core-cli-utils 0.75.0-nightly-20240425-2876fae8d → 0.75.0-nightly-20240426-9c4ee6df0

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 CHANGED
@@ -9,11 +9,4 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- declare const $$EXPORT_DEFAULT_DECLARATION$$: {
13
- android: any;
14
- apple: any;
15
- clean: any;
16
- version: any;
17
- };
18
- export default $$EXPORT_DEFAULT_DECLARATION$$;
19
- export type { Task } from "./private/types";
12
+ export * from "./index.flow.js";
@@ -0,0 +1,20 @@
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
+ * @oncall react_native
10
+ */
11
+
12
+ import { tasks as _android } from "./private/android.js";
13
+ import { tasks as _apple } from "./private/apple.js";
14
+ import { tasks as _clean } from "./private/clean.js";
15
+ import * as _version from "./public/version.js";
16
+ export declare const android: typeof _android;
17
+ export declare const apple: typeof _apple;
18
+ export declare const clean: typeof _clean;
19
+ export declare const version: typeof _version;
20
+ export type { Task } from "./private/types";
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.version = exports.clean = exports.apple = exports.android = void 0;
7
+ var _android2 = require("./private/android.js");
8
+ var _apple2 = require("./private/apple.js");
9
+ var _clean2 = require("./private/clean.js");
10
+ var _version = _interopRequireWildcard(require("./public/version.js"));
11
+ function _getRequireWildcardCache(nodeInterop) {
12
+ if (typeof WeakMap !== "function") return null;
13
+ var cacheBabelInterop = new WeakMap();
14
+ var cacheNodeInterop = new WeakMap();
15
+ return (_getRequireWildcardCache = function (nodeInterop) {
16
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
17
+ })(nodeInterop);
18
+ }
19
+ function _interopRequireWildcard(obj, nodeInterop) {
20
+ if (!nodeInterop && obj && obj.__esModule) {
21
+ return obj;
22
+ }
23
+ if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
24
+ return { default: obj };
25
+ }
26
+ var cache = _getRequireWildcardCache(nodeInterop);
27
+ if (cache && cache.has(obj)) {
28
+ return cache.get(obj);
29
+ }
30
+ var newObj = {};
31
+ var hasPropertyDescriptor =
32
+ Object.defineProperty && Object.getOwnPropertyDescriptor;
33
+ for (var key in obj) {
34
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
35
+ var desc = hasPropertyDescriptor
36
+ ? Object.getOwnPropertyDescriptor(obj, key)
37
+ : null;
38
+ if (desc && (desc.get || desc.set)) {
39
+ Object.defineProperty(newObj, key, desc);
40
+ } else {
41
+ newObj[key] = obj[key];
42
+ }
43
+ }
44
+ }
45
+ newObj.default = obj;
46
+ if (cache) {
47
+ cache.set(obj, newObj);
48
+ }
49
+ return newObj;
50
+ }
51
+ /**
52
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
53
+ *
54
+ * This source code is licensed under the MIT license found in the
55
+ * LICENSE file in the root directory of this source tree.
56
+ *
57
+ *
58
+ * @format
59
+ * @oncall react_native
60
+ */
61
+
62
+ // @babel/register doesn't like export {foo} from './bar'; statements,
63
+ // so we have to jump through hoops here.
64
+
65
+ const android = _android2.tasks;
66
+ exports.android = android;
67
+ const apple = _apple2.tasks;
68
+ exports.apple = apple;
69
+ const clean = _clean2.tasks;
70
+ exports.clean = clean;
71
+ const version = _version;
72
+ exports.version = version;
@@ -0,0 +1,24 @@
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 _apple } from "./private/apple.js";
16
+ import { tasks as _clean } from "./private/clean.js";
17
+ import * as _version from "./public/version.js";
18
+
19
+ declare export const android: typeof _android;
20
+ declare export const apple: typeof _apple;
21
+ declare export const clean: typeof _clean;
22
+ declare export const version: typeof _version;
23
+
24
+ export type { Task } from "./private/types";
package/dist/index.js CHANGED
@@ -3,51 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true,
5
5
  });
6
- exports.default = void 0;
7
- var _android = require("./private/android.js");
8
- var _apple = require("./private/apple.js");
9
- var _clean = require("./private/clean.js");
10
- var version = _interopRequireWildcard(require("./public/version.js"));
11
- function _getRequireWildcardCache(nodeInterop) {
12
- if (typeof WeakMap !== "function") return null;
13
- var cacheBabelInterop = new WeakMap();
14
- var cacheNodeInterop = new WeakMap();
15
- return (_getRequireWildcardCache = function (nodeInterop) {
16
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
17
- })(nodeInterop);
18
- }
19
- function _interopRequireWildcard(obj, nodeInterop) {
20
- if (!nodeInterop && obj && obj.__esModule) {
21
- return obj;
22
- }
23
- if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
24
- return { default: obj };
25
- }
26
- var cache = _getRequireWildcardCache(nodeInterop);
27
- if (cache && cache.has(obj)) {
28
- return cache.get(obj);
29
- }
30
- var newObj = {};
31
- var hasPropertyDescriptor =
32
- Object.defineProperty && Object.getOwnPropertyDescriptor;
33
- for (var key in obj) {
34
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
35
- var desc = hasPropertyDescriptor
36
- ? Object.getOwnPropertyDescriptor(obj, key)
37
- : null;
38
- if (desc && (desc.get || desc.set)) {
39
- Object.defineProperty(newObj, key, desc);
40
- } else {
41
- newObj[key] = obj[key];
42
- }
43
- }
44
- }
45
- newObj.default = obj;
46
- if (cache) {
47
- cache.set(obj, newObj);
48
- }
49
- return newObj;
50
- }
6
+ var _indexFlow = require("./index.flow.js");
7
+ Object.keys(_indexFlow).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _indexFlow[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _indexFlow[key];
14
+ },
15
+ });
16
+ });
51
17
  /**
52
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
53
19
  *
@@ -58,13 +24,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
58
24
  * @format
59
25
  * @oncall react_native
60
26
  */
61
- /* eslint sort-keys : "error" */
62
- var _default = {
63
- // Platforms
64
- android: typeof _android.tasks,
65
- apple: typeof _apple.tasks,
66
- clean: typeof _clean.tasks,
67
- // Meta
68
- version: typeof version,
69
- };
70
- exports.default = _default;
27
+
28
+ const path = require("path");
29
+
30
+ /*::
31
+ export type * from './index.flow.js';
32
+ */
@@ -4,17 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict-local
7
+ * @flow
8
8
  * @format
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- /* eslint sort-keys : "error" */
13
- declare export default {
14
- android: $FlowFixMe,
15
- apple: $FlowFixMe,
16
- clean: $FlowFixMe,
17
- version: $FlowFixMe,
18
- };
19
-
20
- export type { Task } from "./private/types";
12
+ export * from "./index.flow.js";
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  import type { Task } from "./types";
13
- import execa from "execa";
13
+ import type { ExecaPromise } from "execa";
14
14
  type AndroidBuildMode = "debug" | "release";
15
15
  type AndroidBuild = {
16
16
  sourceDir: string;
@@ -18,7 +18,6 @@ type AndroidBuild = {
18
18
  mode: AndroidBuildMode;
19
19
  gradleArgs?: Array<string>;
20
20
  };
21
- type GradleReturn = ReturnType<typeof execa>;
22
21
  /**
23
22
  * Assembles an Android app using Gradle
24
23
  */
@@ -27,7 +26,7 @@ export declare const assemble: (
27
26
  appName: string,
28
27
  mode: AndroidBuildMode,
29
28
  ...args: ReadonlyArray<string>
30
- ) => GradleReturn;
29
+ ) => ExecaPromise;
31
30
  /**
32
31
  * Assembles and tests an Android app using Gradle
33
32
  */
@@ -36,7 +35,7 @@ export declare const build: (
36
35
  appName: string,
37
36
  mode: AndroidBuildMode,
38
37
  ...args: ReadonlyArray<string>
39
- ) => GradleReturn;
38
+ ) => ExecaPromise;
40
39
  /**
41
40
  * Installs an Android app using Gradle
42
41
  */
@@ -45,7 +44,7 @@ export declare const install: (
45
44
  appName: string,
46
45
  mode: AndroidBuildMode,
47
46
  ...args: ReadonlyArray<string>
48
- ) => GradleReturn;
47
+ ) => ExecaPromise;
49
48
  /**
50
49
  * Runs a custom Gradle task if your frameworks needs aren't handled by assemble, build or install.
51
50
  */
@@ -53,10 +52,19 @@ export declare const customTask: (
53
52
  cwd: string,
54
53
  customTaskName: string,
55
54
  ...args: ReadonlyArray<string>
56
- ) => GradleReturn;
55
+ ) => ExecaPromise;
57
56
  type AndroidTasks = {
58
- assemble: (options: AndroidBuild, ...args: ReadonlyArray<string>) => Task[];
59
- build: (options: AndroidBuild, ...args: ReadonlyArray<string>) => Task[];
60
- install: (options: AndroidBuild, ...args: ReadonlyArray<string>) => Task[];
57
+ assemble: (
58
+ options: AndroidBuild,
59
+ ...args: ReadonlyArray<string>
60
+ ) => { run: Task<ExecaPromise> };
61
+ build: (
62
+ options: AndroidBuild,
63
+ ...args: ReadonlyArray<string>
64
+ ) => { run: Task<ExecaPromise> };
65
+ install: (
66
+ options: AndroidBuild,
67
+ ...args: ReadonlyArray<string>
68
+ ) => { run: Task<ExecaPromise> };
61
69
  };
62
70
  export declare const tasks: AndroidTasks;
@@ -64,33 +64,35 @@ const install = (cwd, appName, mode, ...args) =>
64
64
  exports.install = install;
65
65
  const customTask = (cwd, customTaskName, ...args) =>
66
66
  gradle(cwd, customTaskName, ...args);
67
+ exports.customTask = customTask;
68
+ const FIRST = 1;
67
69
 
68
70
  //
69
71
  // Android Tasks
70
72
  //
71
- exports.customTask = customTask;
73
+
72
74
  const tasks = {
73
- assemble: (options, ...gradleArgs) => [
74
- (0, _utils.task)("Assemble Android App", () =>
75
+ assemble: (options, ...gradleArgs) => ({
76
+ run: (0, _utils.task)(FIRST, "Assemble Android App", () =>
75
77
  assemble(options.sourceDir, options.appName, options.mode, ...gradleArgs)
76
78
  ),
77
- ],
78
- build: (options, ...gradleArgs) => [
79
- (0, _utils.task)("Assembles and tests Android App", () =>
79
+ }),
80
+ build: (options, ...gradleArgs) => ({
81
+ run: (0, _utils.task)(FIRST, "Assembles and tests Android App", () =>
80
82
  build(options.sourceDir, options.appName, options.mode, ...gradleArgs)
81
83
  ),
82
- ],
84
+ }),
83
85
  /**
84
86
  * Useful extra gradle arguments:
85
87
  *
86
88
  * -PreactNativeDevServerPort=8081 sets the port for the installed app to point towards a Metro
87
89
  * server on (for example) 8081.
88
90
  */
89
- install: (options, ...gradleArgs) => [
90
- (0, _utils.task)("Installs the assembled Android App", () =>
91
+ install: (options, ...gradleArgs) => ({
92
+ run: (0, _utils.task)(FIRST, "Installs the assembled Android App", () =>
91
93
  install(options.sourceDir, options.appName, options.mode, ...gradleArgs)
92
94
  ),
93
- ],
95
+ }),
94
96
 
95
97
  // We are not supporting launching the app and setting up the tunnel for metro <-> app, this is
96
98
  // a framework concern. For an example of how one could do this, please look at the community
@@ -10,8 +10,7 @@
10
10
  */
11
11
 
12
12
  import type { Task } from "./types";
13
-
14
- import execa from "execa";
13
+ import type { ExecaPromise } from "execa";
15
14
 
16
15
  type AndroidBuildMode = "debug" | "release";
17
16
 
@@ -22,8 +21,6 @@ type AndroidBuild = {
22
21
  gradleArgs?: Array<string>,
23
22
  };
24
23
 
25
- type GradleReturn = ReturnType<typeof execa>;
26
-
27
24
  //
28
25
  // Gradle Task wrappers
29
26
  //
@@ -36,7 +33,7 @@ declare export const assemble: (
36
33
  appName: string,
37
34
  mode: AndroidBuildMode,
38
35
  ...args: $ReadOnlyArray<string>
39
- ) => GradleReturn;
36
+ ) => ExecaPromise;
40
37
 
41
38
  /**
42
39
  * Assembles and tests an Android app using Gradle
@@ -46,7 +43,7 @@ declare export const build: (
46
43
  appName: string,
47
44
  mode: AndroidBuildMode,
48
45
  ...args: $ReadOnlyArray<string>
49
- ) => GradleReturn;
46
+ ) => ExecaPromise;
50
47
 
51
48
  /**
52
49
  * Installs an Android app using Gradle
@@ -56,7 +53,7 @@ declare export const install: (
56
53
  appName: string,
57
54
  mode: AndroidBuildMode,
58
55
  ...args: $ReadOnlyArray<string>
59
- ) => GradleReturn;
56
+ ) => ExecaPromise;
60
57
 
61
58
  /**
62
59
  * Runs a custom Gradle task if your frameworks needs aren't handled by assemble, build or install.
@@ -65,16 +62,24 @@ declare export const customTask: (
65
62
  cwd: string,
66
63
  customTaskName: string,
67
64
  ...args: $ReadOnlyArray<string>
68
- ) => GradleReturn;
65
+ ) => ExecaPromise;
69
66
 
70
67
  //
71
68
  // Android Tasks
72
69
  //
73
-
74
70
  type AndroidTasks = {
75
- assemble: (options: AndroidBuild, ...args: $ReadOnlyArray<string>) => Task[],
76
- build: (options: AndroidBuild, ...args: $ReadOnlyArray<string>) => Task[],
77
- install: (options: AndroidBuild, ...args: $ReadOnlyArray<string>) => Task[],
71
+ assemble: (
72
+ options: AndroidBuild,
73
+ ...args: $ReadOnlyArray<string>
74
+ ) => { run: Task<ExecaPromise> },
75
+ build: (
76
+ options: AndroidBuild,
77
+ ...args: $ReadOnlyArray<string>
78
+ ) => { run: Task<ExecaPromise> },
79
+ install: (
80
+ options: AndroidBuild,
81
+ ...args: $ReadOnlyArray<string>
82
+ ) => { run: Task<ExecaPromise> },
78
83
  };
79
84
 
80
85
  declare export const tasks: AndroidTasks;
@@ -10,23 +10,45 @@
10
10
  */
11
11
 
12
12
  import type { Task } from "./types";
13
+ import type { ExecaPromise } from "execa";
13
14
  type AppleBuildMode = "Debug" | "Release";
14
- type AppleBuildOptions = {
15
- isWorkspace: boolean;
16
- name: string;
17
- mode: AppleBuildMode;
18
- scheme: string;
19
- destination?: string;
20
- } & AppleOptions;
21
- type AppleBootstrapOption = {
22
- bundleInstall: boolean;
23
- newArchitecture: boolean;
24
- } & AppleOptions;
25
- type AppleInstallApp = { device: string; appPath: string } & AppleOptions;
15
+ type AppleBuildOptions =
16
+ /**
17
+ * > 23 | ...AppleOptions,
18
+ * | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
19
+ **/
20
+ any;
21
+ type AppleBootstrapOption =
22
+ /**
23
+ * > 29 | ...AppleOptions,
24
+ * | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
25
+ **/
26
+ any;
27
+ type AppleInstallApp =
28
+ /**
29
+ * > 37 | ...AppleOptions,
30
+ * | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
31
+ **/
32
+ any;
26
33
  type AppleOptions = { cwd: string; env?: { [key: string]: string | void } };
27
- type AppleBuildTasks = {
28
- bootstrap: (options: AppleBootstrapOption) => Task[];
29
- build: (options: AppleBuildOptions, ...args: ReadonlyArray<string>) => Task[];
30
- ios: { install: (options: AppleInstallApp) => Task[] };
34
+ export declare const tasks: {
35
+ bootstrap: (options: AppleBootstrapOption) => {
36
+ validate: Task<void>;
37
+ installRubyGems: Task<ExecaPromise>;
38
+ installDependencies: Task<ExecaPromise>;
39
+ };
40
+ build: (
41
+ options: AppleBuildOptions,
42
+ ...args: ReadonlyArray<string>
43
+ ) => {
44
+ validate: Task<void>;
45
+ hasPodsInstalled: Task<void>;
46
+ build: Task<ExecaPromise>;
47
+ };
48
+ ios: {
49
+ install: (options: AppleInstallApp) => {
50
+ validate: Task<void>;
51
+ install: Task<ExecaPromise>;
52
+ };
53
+ };
31
54
  };
32
- export declare const tasks: AppleBuildTasks;
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.tasks = void 0;
7
7
  var _utils = require("./utils");
8
8
  var _execa = _interopRequireDefault(require("execa"));
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+ var _path = _interopRequireDefault(require("path"));
9
11
  function _interopRequireDefault(obj) {
10
12
  return obj && obj.__esModule ? obj : { default: obj };
11
13
  }
@@ -20,37 +22,79 @@ function _interopRequireDefault(obj) {
20
22
  * @oncall react_native
21
23
  */
22
24
 
25
+ const FIRST = 1,
26
+ SECOND = 2,
27
+ THIRD = 3;
28
+
29
+ /* eslint sort-keys: "off" */
23
30
  const tasks = {
24
- bootstrap: (options) => [
25
- (0, _utils.task)("Install CocoaPods dependencies", async () => {
26
- (0, _utils.assertDependencies)(
27
- (0, _utils.isOnPath)("pod", "CocoaPods"),
28
- (0, _utils.isOnPath)("bundle", "Bundler to manage Ruby's gems")
29
- );
30
- if (options.bundleInstall) {
31
- await (0, _execa.default)("bundle", ["exec", "install"], {
32
- cwd: options.cwd,
33
- });
31
+ // 1. Setup your environment for building the iOS apps
32
+ bootstrap: (options) => ({
33
+ validate: (0, _utils.task)(
34
+ FIRST,
35
+ "Check Cocoapods and bundle are available",
36
+ () => {
37
+ (0, _utils.assertDependencies)(
38
+ (0, _utils.isOnPath)("pod", "CocoaPods"),
39
+ (0, _utils.isOnPath)("bundle", "Bundler to manage Ruby's gems")
40
+ );
34
41
  }
35
- return await (0, _execa.default)("bundle", ["exec", "pod", "install"], {
42
+ ),
43
+ installRubyGems: (0, _utils.task)(SECOND, "Install Ruby Gems", () =>
44
+ (0, _execa.default)("bundle", ["install"], {
36
45
  cwd: options.cwd,
37
- env: {
38
- RCT_NEW_ARCH_ENABLED: options.newArchitecture ? "1" : "0",
39
- },
40
- });
41
- }),
42
- ],
43
- build: (options, ...args) => [
44
- (0, _utils.task)("build an app artifact", () => {
45
- (0, _utils.assertDependencies)(
46
- (0, _utils.isOnPath)("xcodebuild", "Xcode Commandline Tools")
47
- );
46
+ })
47
+ ),
48
+ installDependencies: (0, _utils.task)(
49
+ THIRD,
50
+ "Install CocoaPods dependencies",
51
+ () =>
52
+ (0, _execa.default)("bundle", ["exec", "pod", "install"], {
53
+ cwd: options.cwd,
54
+ env: {
55
+ RCT_NEW_ARCH_ENABLED: options.newArchitecture ? "1" : "0",
56
+ },
57
+ })
58
+ ),
59
+ }),
60
+ // 2. Build the iOS app using a setup environment
61
+ build: (options, ...args) => ({
62
+ validate: (0, _utils.task)(
63
+ FIRST,
64
+ "Check you've run xcode-select --install for xcodebuild",
65
+ () => {
66
+ (0, _utils.assertDependencies)(
67
+ (0, _utils.isOnPath)("xcodebuild", "Xcode Commandline Tools")
68
+ );
69
+ }
70
+ ),
71
+ hasPodsInstalled: (0, _utils.task)(
72
+ FIRST,
73
+ "Check Pods are installed",
74
+ () => {
75
+ for (const file of ["Podfile.lock", "Pods"]) {
76
+ try {
77
+ _fs.default.accessSync(
78
+ _path.default.join(
79
+ options.cwd,
80
+ file
81
+ ) /* eslint-disable-next-line no-bitwise */,
82
+ _fs.default.constants.F_OK | _fs.default.constants.R_OK
83
+ );
84
+ } catch {
85
+ throw new Error("Please run: yarn run boostrap ios");
86
+ }
87
+ }
88
+ }
89
+ ),
90
+ build: (0, _utils.task)(SECOND, "build an app artifact", () => {
48
91
  const _args = [
49
92
  options.isWorkspace ? "-workspace" : "-project",
50
93
  options.name,
51
- "-scheme",
52
- options.scheme,
53
94
  ];
95
+ if (options.scheme != null) {
96
+ _args.push("-scheme", options.scheme);
97
+ }
54
98
  if (options.destination != null) {
55
99
  _args.push("-destination", options.destination);
56
100
  }
@@ -60,23 +104,30 @@ const tasks = {
60
104
  env: options.env,
61
105
  });
62
106
  }),
63
- ],
107
+ }),
108
+ // 3. Install the built app on a simulator or device
64
109
  ios: {
65
- install: (options) => [
66
- (0, _utils.task)("Install the app on a simulator", () => {
67
- (0, _utils.assertDependencies)(
68
- (0, _utils.isOnPath)("xcrun", "An Xcode Commandline tool: xcrun")
69
- );
70
- return (0, _execa.default)(
110
+ install: (options) => ({
111
+ validate: (0, _utils.task)(
112
+ FIRST,
113
+ "Check you've run xcode-select --install for xcrun",
114
+ () => {
115
+ (0, _utils.assertDependencies)(
116
+ (0, _utils.isOnPath)("xcrun", "An Xcode Commandline tool: xcrun")
117
+ );
118
+ }
119
+ ),
120
+ install: (0, _utils.task)(SECOND, "Install the app on a simulator", () =>
121
+ (0, _execa.default)(
71
122
  "xcrun",
72
123
  ["simctl", "install", options.device, options.appPath],
73
124
  {
74
125
  cwd: options.cwd,
75
126
  env: options.env,
76
127
  }
77
- );
78
- }),
79
- ],
128
+ )
129
+ ),
130
+ }),
80
131
  },
81
132
  };
82
133
  exports.tasks = tasks;
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import type { Task } from "./types";
13
+ import type { ExecaPromise } from "execa";
13
14
 
14
15
  type AppleBuildMode = "Debug" | "Release";
15
16
 
@@ -17,35 +18,51 @@ type AppleBuildOptions = {
17
18
  isWorkspace: boolean,
18
19
  name: string,
19
20
  mode: AppleBuildMode,
20
- scheme: string,
21
+ scheme?: string,
21
22
  destination?: string, // Device or Simulator or UUID
22
- } & AppleOptions;
23
+ ...AppleOptions,
24
+ };
23
25
 
24
26
  type AppleBootstrapOption = {
25
- bundleInstall: boolean,
26
27
  // Enabled by default
27
28
  newArchitecture: boolean,
28
- } & AppleOptions;
29
+ ...AppleOptions,
30
+ };
29
31
 
30
32
  type AppleInstallApp = {
33
+ // Install the app on a simulator or device, typically this is the description from
34
+ // `xcrun simctl list devices`
31
35
  device: string,
32
36
  appPath: string,
33
- } & AppleOptions;
37
+ ...AppleOptions,
38
+ };
34
39
 
35
40
  type AppleOptions = {
41
+ // The directory where the Xcode project is located
36
42
  cwd: string,
43
+ // The environment variables to pass to the build command
37
44
  env?: { [key: string]: string | void, ... },
38
45
  };
39
46
 
40
- type AppleBuildTasks = {
41
- bootstrap: (options: AppleBootstrapOption) => Task[],
47
+ /* eslint sort-keys: "off" */
48
+ declare export const tasks: {
49
+ bootstrap: (options: AppleBootstrapOption) => {
50
+ validate: Task<void>,
51
+ installRubyGems: Task<ExecaPromise>,
52
+ installDependencies: Task<ExecaPromise>,
53
+ },
42
54
  build: (
43
55
  options: AppleBuildOptions,
44
56
  ...args: $ReadOnlyArray<string>
45
- ) => Task[],
57
+ ) => {
58
+ validate: Task<void>,
59
+ hasPodsInstalled: Task<void>,
60
+ build: Task<ExecaPromise>,
61
+ },
46
62
  ios: {
47
- install: (options: AppleInstallApp) => Task[],
63
+ install: (options: AppleInstallApp) => {
64
+ validate: Task<void>,
65
+ install: Task<ExecaPromise>,
66
+ },
48
67
  },
49
68
  };
50
-
51
- declare export const tasks: AppleBuildTasks;
@@ -10,14 +10,7 @@
10
10
  */
11
11
 
12
12
  import type { Task } from "./types";
13
- type CleanTasks = {
14
- android: (androidSrcDir: null | undefined | string) => Task[];
15
- cocoapods?: (projectRootDir: string) => Task[];
16
- metro: () => Task[];
17
- npm: (projectRootDir: string, verifyCache?: boolean) => Task[];
18
- watchman: (projectRootDir: string) => Task[];
19
- yarn: (projectRootDir: string) => Task[];
20
- };
13
+ import type { ExecaPromise, Options as ExecaOptions } from "execa";
21
14
  /**
22
15
  * Removes the contents of a directory matching a given pattern, but keeps the directory.
23
16
  * @private
@@ -25,17 +18,42 @@ type CleanTasks = {
25
18
  export declare function deleteDirectoryContents(
26
19
  directory: string,
27
20
  filePattern: RegExp
28
- ): Task["action"];
21
+ ): () => Promise<void>;
29
22
  /**
30
23
  * Removes a directory recursively.
31
24
  * @private
32
25
  */
33
- export declare function deleteDirectory(directory: string): Task["action"];
26
+ export declare function deleteDirectory(directory: string): () => Promise<void>;
34
27
  /**
35
28
  * Deletes the contents of the tmp directory matching a given pattern.
36
29
  * @private
37
30
  */
38
31
  export declare function deleteTmpDirectoryContents(
39
32
  filepattern: RegExp
40
- ): ReturnType<typeof deleteDirectoryContents>;
33
+ ): () => Promise<void>;
34
+ type CocoaPodsClean = { clean: Task<ExecaPromise> };
35
+ type AndroidClean = { validate: Task<void>; run: Task<ExecaPromise> };
36
+ type MetroClean = {
37
+ metro: Task<Promise<void>>;
38
+ haste: Task<Promise<void>>;
39
+ react_native: Task<Promise<void>>;
40
+ };
41
+ type NpmClean = {
42
+ node_modules: Task<Promise<void>>;
43
+ verify_cache: Task<ExecaPromise>;
44
+ };
45
+ type WatchmanClean = { stop: Task<ExecaPromise>; cache: Task<ExecaPromise> };
46
+ type YarnClean = { clean: Task<ExecaPromise> };
47
+ type CleanTasks = {
48
+ android: (
49
+ andoirdSrcDir: null | undefined | string,
50
+ opts?: ExecaOptions
51
+ ) => AndroidClean;
52
+ cocoapods: CocoaPodsClean;
53
+ metro: () => MetroClean;
54
+ npm: (projectRootDir: string) => NpmClean;
55
+ watchman: (projectRootDir: string) => WatchmanClean;
56
+ yarn: (projectRootDir: string) => YarnClean;
57
+ cocoapods?: (projectRootDir: string) => CocoaPodsClean;
58
+ };
41
59
  export declare const tasks: CleanTasks;
@@ -26,6 +26,8 @@ function _interopRequireDefault(obj) {
26
26
  * @oncall react_native
27
27
  */
28
28
 
29
+ const FIRST = 1,
30
+ SECOND = 2;
29
31
  const rmrf = (pathname) => {
30
32
  if (!(0, _fs.existsSync)(pathname)) {
31
33
  return;
@@ -70,74 +72,77 @@ function deleteDirectory(directory) {
70
72
  function deleteTmpDirectoryContents(filepattern) {
71
73
  return deleteDirectoryContents(_os.default.tmpdir(), filepattern);
72
74
  }
73
-
75
+ const platformGradlew = _utils.isWindows ? "gradlew.bat" : "gradlew";
74
76
  // The tasks that cleanup various build artefacts.
77
+ /* eslint sort-keys: "off" */
75
78
  const tasks = {
76
79
  /**
77
80
  * Cleans up the Android Gradle cache
78
81
  */
79
- android: (androidSrcDir) => [
80
- (0, _utils.task)("🧹 Clean Gradle cache", async function gradle(opts) {
82
+ android: (androidSrcDir, opts) => ({
83
+ validate: (0, _utils.task)(FIRST, "Check gradlew is available", () => {
84
+ (0, _utils.assertDependencies)(
85
+ (0, _utils.isOnPath)(platformGradlew, "Gradle wrapper")
86
+ );
87
+ }),
88
+ run: (0, _utils.task)(SECOND, "🧹 Clean Gradle cache", () => {
81
89
  const gradlew = _path.default.join(
82
90
  androidSrcDir ?? "android",
83
- _utils.isWindows ? "gradlew.bat" : "gradlew"
91
+ platformGradlew
84
92
  );
85
- if (!(0, _fs.existsSync)(gradlew)) {
86
- return;
87
- }
88
93
  const script = _path.default.basename(gradlew);
89
94
  const cwd = _path.default.dirname(gradlew);
90
- await (0,
91
- _execa.default)(_utils.isWindows ? script : `./${script}`, ["clean"], {
92
- cwd,
93
- ...opts,
94
- });
95
+ return (0, _execa.default)(
96
+ _utils.isWindows ? script : "./" + script,
97
+ ["clean"],
98
+ {
99
+ cwd,
100
+ ...opts,
101
+ }
102
+ );
95
103
  }),
96
- ],
104
+ }),
97
105
  /**
98
- * Agressively cleans up all Metro caches.
106
+ * Aggressively cleans up all Metro caches.
99
107
  */
100
- metro: () => [
101
- (0, _utils.task)(
108
+ metro: () => ({
109
+ metro: (0, _utils.task)(
110
+ FIRST,
102
111
  "🧹 Clean Metro cache",
103
112
  deleteTmpDirectoryContents(/^metro-.+/)
104
113
  ),
105
- (0, _utils.task)(
114
+ haste: (0, _utils.task)(
115
+ FIRST,
106
116
  "🧹 Clean Haste cache",
107
117
  deleteTmpDirectoryContents(/^haste-map-.+/)
108
118
  ),
109
- (0, _utils.task)(
119
+ react_native: (0, _utils.task)(
120
+ FIRST,
110
121
  "🧹 Clean React Native cache",
111
122
  deleteTmpDirectoryContents(/^react-.+/)
112
123
  ),
113
- ],
124
+ }),
114
125
  /**
115
126
  * Cleans up the `node_modules` folder and optionally garbage collects the npm cache.
116
127
  */
117
- npm: (projectRootDir, verifyCache = false) => {
118
- const _tasks = [
119
- (0, _utils.task)(
120
- "🧹 Clean node_modules",
121
- deleteDirectory(_path.default.join(projectRootDir, "node_modules"))
122
- ),
123
- ];
124
- if (verifyCache) {
125
- _tasks.push(
126
- (0, _utils.task)("🔬 Verify npm cache", (opts) =>
127
- (0, _execa.default)("npm", ["cache", "verify"], {
128
- cwd: projectRootDir,
129
- ...opts,
130
- })
131
- )
132
- );
133
- }
134
- return _tasks;
135
- },
128
+ npm: (projectRootDir) => ({
129
+ node_modules: (0, _utils.task)(
130
+ FIRST,
131
+ "🧹 Clean node_modules",
132
+ deleteDirectory(_path.default.join(projectRootDir, "node_modules"))
133
+ ),
134
+ verify_cache: (0, _utils.task)(SECOND, "🔬 Verify npm cache", (opts) =>
135
+ (0, _execa.default)("npm", ["cache", "verify"], {
136
+ cwd: projectRootDir,
137
+ ...opts,
138
+ })
139
+ ),
140
+ }),
136
141
  /**
137
142
  * Stops Watchman and clears its cache
138
143
  */
139
- watchman: (projectRootDir) => [
140
- (0, _utils.task)("✋ Stop Watchman", (opts) =>
144
+ watchman: (projectRootDir) => ({
145
+ stop: (0, _utils.task)(FIRST, "✋ Stop Watchman", (opts) =>
141
146
  (0, _execa.default)(
142
147
  _utils.isWindows ? "tskill" : "killall",
143
148
  ["watchman"],
@@ -147,44 +152,37 @@ const tasks = {
147
152
  }
148
153
  )
149
154
  ),
150
- (0, _utils.task)("🧹 Delete Watchman cache", (opts) =>
155
+ cache: (0, _utils.task)(SECOND, "🧹 Delete Watchman cache", (opts) =>
151
156
  (0, _execa.default)("watchman", ["watch-del-all"], {
152
157
  cwd: projectRootDir,
153
158
  ...opts,
154
159
  })
155
160
  ),
156
- ],
161
+ }),
157
162
  /**
158
163
  * Cleans up the Yarn cache
159
164
  */
160
- yarn: (projectRootDir) => [
161
- (0, _utils.task)("🧹 Clean Yarn cache", (opts) =>
165
+ yarn: (projectRootDir) => ({
166
+ clean: (0, _utils.task)(FIRST, "🧹 Clean Yarn cache", (opts) =>
162
167
  (0, _execa.default)("yarn", ["cache", "clean"], {
163
168
  cwd: projectRootDir,
164
169
  ...opts,
165
170
  })
166
171
  ),
167
- ],
172
+ }),
168
173
  };
169
174
  exports.tasks = tasks;
170
175
  if (_utils.isMacOS) {
171
176
  /**
172
177
  * Cleans up the local and global CocoaPods cache
173
178
  */
174
- tasks.cocoapods = (projectRootDir) => [
179
+ tasks.cocoapods = (projectRootDir) => ({
175
180
  // TODO: add project root
176
- (0, _utils.task)(
177
- "🧹 Clean CocoaPods pod cache",
178
- function removePodCache(opts) {
179
- return (0, _execa.default)("bundle", ["exec", "pod", "deintegrate"], {
180
- cwd: projectRootDir,
181
- ...opts,
182
- });
183
- }
181
+ clean: (0, _utils.task)(FIRST, "🧹 Clean CocoaPods pod cache", (opts) =>
182
+ (0, _execa.default)("bundle", ["exec", "pod", "deintegrate"], {
183
+ cwd: projectRootDir,
184
+ ...opts,
185
+ })
184
186
  ),
185
- ];
187
+ });
186
188
  }
187
-
188
- //
189
- // Internal CLI
190
- //
@@ -10,14 +10,7 @@
10
10
  */
11
11
 
12
12
  import type { Task } from "./types";
13
- type CleanTasks = {
14
- android: (androidSrcDir: ?string) => Task[],
15
- cocoapods?: (projectRootDir: string) => Task[],
16
- metro: () => Task[],
17
- npm: (projectRootDir: string, verifyCache?: boolean) => Task[],
18
- watchman: (projectRootDir: string) => Task[],
19
- yarn: (projectRootDir: string) => Task[],
20
- };
13
+ import type { ExecaPromise, Options as ExecaOptions } from "execa";
21
14
 
22
15
  /**
23
16
  * Removes the contents of a directory matching a given pattern, but keeps the directory.
@@ -26,13 +19,13 @@ type CleanTasks = {
26
19
  declare export function deleteDirectoryContents(
27
20
  directory: string,
28
21
  filePattern: RegExp
29
- ): Task["action"];
22
+ ): () => Promise<void>;
30
23
 
31
24
  /**
32
25
  * Removes a directory recursively.
33
26
  * @private
34
27
  */
35
- declare export function deleteDirectory(directory: string): Task["action"];
28
+ declare export function deleteDirectory(directory: string): () => Promise<void>;
36
29
 
37
30
  /**
38
31
  * Deletes the contents of the tmp directory matching a given pattern.
@@ -40,7 +33,45 @@ declare export function deleteDirectory(directory: string): Task["action"];
40
33
  */
41
34
  declare export function deleteTmpDirectoryContents(
42
35
  filepattern: RegExp
43
- ): ReturnType<typeof deleteDirectoryContents>;
36
+ ): () => Promise<void>;
37
+
38
+ type CocoaPodsClean = {
39
+ clean: Task<ExecaPromise>,
40
+ };
41
+ type AndroidClean = {
42
+ validate: Task<void>,
43
+ run: Task<ExecaPromise>,
44
+ };
45
+ type MetroClean = {
46
+ metro: Task<Promise<void>>,
47
+ haste: Task<Promise<void>>,
48
+ react_native: Task<Promise<void>>,
49
+ };
50
+
51
+ type NpmClean = {
52
+ node_modules: Task<Promise<void>>,
53
+ verify_cache: Task<ExecaPromise>,
54
+ };
55
+
56
+ type WatchmanClean = {
57
+ stop: Task<ExecaPromise>,
58
+ cache: Task<ExecaPromise>,
59
+ };
60
+
61
+ type YarnClean = {
62
+ clean: Task<ExecaPromise>,
63
+ };
64
+
65
+ type CleanTasks = {
66
+ android: (andoirdSrcDir: ?string, opts?: ExecaOptions) => AndroidClean,
67
+ cocoapods: CocoaPodsClean,
68
+ metro: () => MetroClean,
69
+ npm: (projectRootDir: string) => NpmClean,
70
+ watchman: (projectRootDir: string) => WatchmanClean,
71
+ yarn: (projectRootDir: string) => YarnClean,
72
+ cocoapods?: (projectRootDir: string) => CocoaPodsClean,
73
+ };
44
74
 
45
75
  // The tasks that cleanup various build artefacts.
76
+ /* eslint sort-keys: "off" */
46
77
  declare export const tasks: CleanTasks;
@@ -9,4 +9,8 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- export type Task = { label: string; action: () => Promise<unknown> };
12
+ export type Task<R = unknown> = {
13
+ order: number;
14
+ label: string;
15
+ action: () => R;
16
+ };
@@ -9,7 +9,8 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- export type Task = {
12
+ export type Task<R = mixed> = {
13
+ order: number,
13
14
  label: string,
14
- action: () => Promise<mixed>,
15
+ action: () => R,
15
16
  };
@@ -10,7 +10,11 @@
10
10
  */
11
11
 
12
12
  import type { Task } from "./types";
13
- export declare function task(label: string, action: Task["action"]): Task;
13
+ export declare function task<R>(
14
+ order: number,
15
+ label: string,
16
+ action: Task<R>["action"]
17
+ ): Task<R>;
14
18
  export declare const isWindows: any;
15
19
  export declare const isMacOS: any;
16
20
  export declare const toPascalCase: (label: string) => string;
@@ -25,10 +25,11 @@ function _interopRequireDefault(obj) {
25
25
  * @oncall react_native
26
26
  */
27
27
 
28
- function task(label, action) {
28
+ function task(order, label, action) {
29
29
  return {
30
30
  action,
31
31
  label,
32
+ order,
32
33
  };
33
34
  }
34
35
  const isWindows = _os.default.platform() === "win32";
@@ -39,12 +40,20 @@ const toPascalCase = (label) =>
39
40
  label.length === 0 ? "" : label[0].toUpperCase() + label.slice(1);
40
41
  exports.toPascalCase = toPascalCase;
41
42
  function isOnPath(dep, description) {
42
- const result = _execa.default.sync(isWindows ? "where" : "which", [dep]);
43
- return {
44
- dep,
45
- description,
46
- found: result.exitCode === 0,
47
- };
43
+ const cmd = isWindows ? ["where", [dep]] : ["command", ["-v", dep]];
44
+ try {
45
+ return {
46
+ dep,
47
+ description,
48
+ found: _execa.default.sync(...cmd).exitCode === 0,
49
+ };
50
+ } catch {
51
+ return {
52
+ dep,
53
+ description,
54
+ found: false,
55
+ };
56
+ }
48
57
  }
49
58
  function assertDependencies(...deps) {
50
59
  for (const { found, dep, description } of deps) {
@@ -11,7 +11,11 @@
11
11
 
12
12
  import type { Task } from "./types";
13
13
 
14
- declare export function task(label: string, action: Task["action"]): Task;
14
+ declare export function task<R>(
15
+ order: number,
16
+ label: string,
17
+ action: Task<R>["action"]
18
+ ): Task<R>;
15
19
 
16
20
  declare export const isWindows: $FlowFixMe;
17
21
  declare export const isMacOS: $FlowFixMe;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@react-native/core-cli-utils",
3
- "version": "0.75.0-nightly-20240425-2876fae8d",
3
+ "version": "0.75.0-nightly-20240426-9c4ee6df0",
4
4
  "description": "React Native CLI library for Frameworks to build on",
5
- "main": "index.js",
5
+ "main": "./src/index.js",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",