@react-native/core-cli-utils 0.75.0-nightly-20240601-033a55f7f → 0.75.0-nightly-20240603-a6a7cdf0b

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/core-cli-utils",
3
- "version": "0.75.0-nightly-20240601-033a55f7f",
3
+ "version": "0.75.0-nightly-20240603-a6a7cdf0b",
4
4
  "description": "React Native CLI library for Frameworks to build on",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.flow.js",
@@ -41,14 +41,17 @@ type BundlerOptions = {
41
41
  outputBundle: string,
42
42
  cwd: string,
43
43
 
44
- target: 'hermes' | 'jsc',
44
+ jsvm: 'hermes' | 'jsc',
45
45
  hermes?: HermesConfig,
46
46
 
47
47
  ...Bundler,
48
48
  };
49
49
 
50
50
  type HermesConfig = {
51
- // iOS: Pods/hermes-engine/destroot/bin/hermesc
51
+ // Path where hermes is is installed
52
+ // iOS: Pods/hermes-engine
53
+ path: string,
54
+ // iOS: <hermes.path>/destroot/bin/hermesc
52
55
  hermesc: string,
53
56
  };
54
57
 
@@ -124,7 +127,7 @@ const bundleApp = (
124
127
  // to then be converted to bytecode in the outputBundle. Otherwise just write to
125
128
  // the outputBundle directly.
126
129
  let output =
127
- options.target === 'hermes' ? options.outputJsBundle : options.outputBundle;
130
+ options.jsvm === 'hermes' ? options.outputJsBundle : options.outputBundle;
128
131
 
129
132
  // TODO: Fix this by not using Metro CLI, which appends a .js extension
130
133
  if (output === options.outputJsBundle && !output.endsWith('.js')) {
@@ -146,7 +149,7 @@ const bundleApp = (
146
149
  '--out',
147
150
  output,
148
151
  ];
149
- if (options.target === 'hermes' && !options.dev) {
152
+ if (options.jsvm === 'hermes' && !options.dev) {
150
153
  // Hermes doesn't require JS minification
151
154
  args.push('--minify', 'false');
152
155
  } else {
@@ -159,12 +162,25 @@ const bundleApp = (
159
162
  }),
160
163
  };
161
164
 
162
- if (options.target === 'jsc') {
165
+ if (options.jsvm === 'jsc') {
163
166
  return bundle;
164
167
  }
165
168
 
166
- // $FlowIgnore[incompatible-use] We know it's a Hermes config
167
- const hermesc: string = options.hermes.hermesc;
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);
168
184
 
169
185
  /*
170
186
  * Hermes only tasks:
@@ -24,7 +24,7 @@ type AppleBuildOptions = {
24
24
  name: string,
25
25
  mode: AppleBuildMode,
26
26
  scheme?: string,
27
- destination?: string, // Device or Simulator or UUID
27
+ destination: 'device' | 'simulator' | string,
28
28
  ...AppleOptions,
29
29
  };
30
30
 
@@ -32,6 +32,7 @@ type AppleBootstrapOption = {
32
32
  // Enabled by default
33
33
  hermes: boolean,
34
34
  newArchitecture: boolean,
35
+ frameworks?: 'static' | 'dynamic',
35
36
  ...AppleOptions,
36
37
  };
37
38
 
@@ -51,6 +52,23 @@ type AppleOptions = {
51
52
  env?: {[key: string]: string | void, ...},
52
53
  };
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
+
54
72
  const FIRST = 1,
55
73
  SECOND = 2,
56
74
  THIRD = 3;
@@ -79,8 +97,12 @@ export const tasks = {
79
97
  installDependencies: task(THIRD, 'Install CocoaPods dependencies', () => {
80
98
  const env = {
81
99
  RCT_NEW_ARCH_ENABLED: options.newArchitecture ? '1' : '0',
82
- HERMES: options.hermes ? '1' : '0',
100
+ USE_FRAMEWORKS: options.frameworks,
101
+ USE_HERMES: options.hermes ? '1' : '0',
83
102
  };
103
+ if (options.frameworks == null) {
104
+ delete env.USE_FRAMEWORKS;
105
+ }
84
106
  return execa('bundle', ['exec', 'pod', 'install'], {
85
107
  cwd: options.cwd,
86
108
  env,
@@ -112,22 +134,38 @@ export const tasks = {
112
134
  /* eslint-disable-next-line no-bitwise */
113
135
  fs.constants.F_OK | fs.constants.R_OK,
114
136
  );
115
- } catch {
116
- throw new Error('Please run: yarn run boostrap ios');
137
+ } catch (e) {
138
+ throw new Error('Please run: yarn run boostrap ios: ' + e.message);
117
139
  }
118
140
  }
141
+ checkPodfileInSyncWithManifest(
142
+ path.join(options.cwd, 'Podfile.lock'),
143
+ path.join(options.cwd, 'Pods/Manifest.lock'),
144
+ );
119
145
  }),
120
146
  build: task(SECOND, 'build an app artifact', () => {
121
147
  const _args = [
122
148
  options.isWorkspace ? '-workspace' : '-project',
123
149
  options.name,
150
+ '-configuration',
151
+ options.mode,
124
152
  ];
125
153
  if (options.scheme != null) {
126
154
  _args.push('-scheme', options.scheme);
127
155
  }
128
156
  if (options.destination != null) {
129
- _args.push('-destination', options.destination);
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
+ }
130
167
  }
168
+
131
169
  _args.push(...args);
132
170
  return execa('xcodebuild', _args, {cwd: options.cwd, env: options.env});
133
171
  }),