Skip to content

Commit 2b5f2d9

Browse files
committed
fix: cr comments
1 parent 2da44ea commit 2b5f2d9

File tree

7 files changed

+112
-28
lines changed

7 files changed

+112
-28
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,3 @@ Thumbs.db
4545

4646
vite.config.*.timestamp*
4747
vitest.config.*.timestamp*
48-
49-
# Nx
50-
.nx

packages/platform-android/src/lib/commands/runAndroid/__tests__/runAndroid.test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const androidProject: AndroidProjectConfig = {
3232
const OLD_ENV = process.env;
3333
let adbDevicesCallsCount = 0;
3434

35+
const mockPlatforms = { ios: {}, android: {} };
36+
3537
beforeEach(() => {
3638
adbDevicesCallsCount = 0;
3739
vi.clearAllMocks();
@@ -313,8 +315,9 @@ test.each([['release'], ['debug'], ['staging']])(
313315
undefined,
314316
{ extraSources: [], ignorePaths: [], env: [] },
315317
vi.fn(), // startDevServer mock
316-
'0.79.0', // reactNativeVersion
317318
'/path/to/react-native', // reactNativePath
319+
'0.79.0', // reactNativeVersion
320+
mockPlatforms,
318321
);
319322

320323
expect(tools.outro).toBeCalledWith('Success 🎉.');
@@ -365,8 +368,9 @@ test('runAndroid runs gradle build with custom --appId, --appIdSuffix and --main
365368
undefined,
366369
{ extraSources: [], ignorePaths: [], env: [] },
367370
vi.fn(), // startDevServer mock
368-
'0.79.0', // reactNativeVersion
369371
'/path/to/react-native', // reactNativePath
372+
'0.79.0', // reactNativeVersion
373+
mockPlatforms,
370374
);
371375

372376
expect(tools.outro).toBeCalledWith('Success 🎉.');
@@ -395,8 +399,9 @@ test('runAndroid fails to launch an app on not-connected device when specified w
395399
undefined,
396400
{ extraSources: [], ignorePaths: [], env: [] },
397401
vi.fn(), // startDevServer mock
398-
'0.79.0', // reactNativeVersion
399402
'/path/to/react-native', // reactNativePath
403+
'0.79.0', // reactNativeVersion
404+
mockPlatforms,
400405
);
401406
expect(logWarnSpy).toBeCalledWith(
402407
'No devices or emulators found matching "emulator-5554". Using available one instead.',
@@ -467,8 +472,9 @@ test.each([['release'], ['debug']])(
467472
undefined,
468473
{ extraSources: [], ignorePaths: [], env: [] },
469474
vi.fn(), // startDevServer mock
470-
'0.79.0', // reactNativeVersion
471475
'/path/to/react-native', // reactNativePath
476+
'0.79.0', // reactNativeVersion
477+
mockPlatforms,
472478
);
473479

474480
// we don't want to run installDebug when a device is selected, because gradle will install the app on all connected devices
@@ -529,7 +535,7 @@ test('runAndroid launches an app on all connected devices', async () => {
529535
extraSources: [],
530536
ignorePaths: [],
531537
env: [],
532-
}, vi.fn(), '0.79.0', '/path/to/react-native');
538+
}, vi.fn(), '/path/to/react-native', '0.79.0', mockPlatforms);
533539

534540
// Runs assemble debug task with active architectures arm64-v8a, armeabi-v7a
535541
expect(spawn).toBeCalledWith(
@@ -597,8 +603,9 @@ test('runAndroid skips building when --binary-path is passed', async () => {
597603
undefined,
598604
{ extraSources: [], ignorePaths: [], env: [] },
599605
vi.fn(), // startDevServer mock
600-
'0.79.0', // reactNativeVersion
601606
'/path/to/react-native', // reactNativePath
607+
'0.79.0', // reactNativeVersion
608+
mockPlatforms,
602609
);
603610

604611
// Skips gradle

packages/platform-android/src/lib/commands/runAndroid/command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export function registerRunCommand(
2323
api.getFingerprintOptions(),
2424
api.getBundlerStart(),
2525
api.getReactNativeVersion(),
26-
api.getReactNativePath()
26+
api.getReactNativePath(),
27+
api.getPlatforms()
2728
);
2829
},
2930
options: runOptions,

packages/platform-android/src/lib/commands/runAndroid/runAndroid.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface Flags extends BuildFlags {
3838
binaryPath?: string;
3939
user?: string;
4040
local?: boolean;
41+
clientLogs?: boolean;
4142
}
4243

4344
export type AndroidProject = NonNullable<Config['project']['android']>;
@@ -53,7 +54,8 @@ export async function runAndroid(
5354
fingerprintOptions: FingerprintSources,
5455
startDevServer: (options: StartDevServerArgs) => void,
5556
reactNativeVersion: string,
56-
reactNativePath: string
57+
reactNativePath: string,
58+
platforms: { [platform: string]: object }
5759
) {
5860
intro('Running Android app');
5961

@@ -86,10 +88,10 @@ export async function runAndroid(
8688
root: projectRoot,
8789
reactNativePath,
8890
reactNativeVersion,
89-
platforms: { ios: {}, android: {} },
91+
platforms,
9092
args: {
9193
interactive: isInteractive(),
92-
clientLogs: true,
94+
clientLogs: args.clientLogs ?? true,
9395
},
9496
});
9597

@@ -295,4 +297,8 @@ export const runOptions = [
295297
name: '--user <number>',
296298
description: 'Id of the User Profile you want to install the app on.',
297299
},
300+
{
301+
name: '--client-logs',
302+
description: 'Enable client logs in dev server.',
303+
},
298304
];

packages/platform-apple-helpers/src/lib/commands/run/createRun.ts

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const createRun = async ({
3636
fingerprintOptions,
3737
reactNativePath,
3838
reactNativeVersion,
39+
platforms,
3940
startDevServer,
4041
}: {
4142
platformName: ApplePlatform;
@@ -46,24 +47,11 @@ export const createRun = async ({
4647
fingerprintOptions: FingerprintSources;
4748
reactNativePath: string;
4849
reactNativeVersion: string;
50+
platforms: { [platform: string]: object };
4951
startDevServer?: (options: StartDevServerArgs) => void;
5052
}) => {
5153
validateArgs(args, projectRoot);
5254

53-
if (startDevServer) {
54-
logger.info('Starting dev server...');
55-
startDevServer({
56-
root: projectRoot,
57-
reactNativePath,
58-
reactNativeVersion,
59-
platforms: { ios: {}, android: {} },
60-
args: {
61-
interactive: isInteractive(),
62-
clientLogs: true,
63-
},
64-
});
65-
}
66-
6755
const deviceOrSimulator = args.destination
6856
? // there can be multiple destinations, so we'll pick the first one
6957
args.destination[0].match(/simulator/i)
@@ -111,6 +99,21 @@ export const createRun = async ({
11199
deviceOrSimulator,
112100
fingerprintOptions,
113101
});
102+
103+
if (startDevServer) {
104+
logger.info('Starting dev server...');
105+
startDevServer({
106+
root: projectRoot,
107+
reactNativePath,
108+
reactNativeVersion,
109+
platforms,
110+
args: {
111+
interactive: isInteractive(),
112+
clientLogs: args.clientLogs ?? true,
113+
},
114+
});
115+
}
116+
114117
await runOnMac(appPath);
115118
return;
116119
} else if (args.catalyst) {
@@ -127,6 +130,22 @@ export const createRun = async ({
127130
deviceOrSimulator,
128131
fingerprintOptions,
129132
});
133+
134+
// Start dev server after build completes to avoid log clashing
135+
if (startDevServer) {
136+
logger.info('Starting dev server...');
137+
startDevServer({
138+
root: projectRoot,
139+
reactNativePath,
140+
reactNativeVersion,
141+
platforms,
142+
args: {
143+
interactive: isInteractive(),
144+
clientLogs: args.clientLogs ?? true,
145+
},
146+
});
147+
}
148+
130149
if (scheme) {
131150
await runOnMacCatalyst(appPath, scheme);
132151
return;
@@ -147,7 +166,7 @@ export const createRun = async ({
147166
if (device) {
148167
if (device.type !== deviceOrSimulator) {
149168
throw new RockError(
150-
`Selected device "${device.name}" is not a ${deviceOrSimulator}.
169+
`Selected device "${device.name}" is not a ${deviceOrSimulator}.
151170
Please either use "--destination ${
152171
deviceOrSimulator === 'simulator' ? 'device' : 'simulator'
153172
}" flag or select available ${deviceOrSimulator}:
@@ -174,6 +193,22 @@ ${devices
174193
fingerprintOptions,
175194
}),
176195
]);
196+
197+
// Start dev server after build completes to avoid log clashing
198+
if (startDevServer) {
199+
logger.info('Starting dev server...');
200+
startDevServer({
201+
root: projectRoot,
202+
reactNativePath,
203+
reactNativeVersion,
204+
platforms,
205+
args: {
206+
interactive: isInteractive(),
207+
clientLogs: args.clientLogs ?? true,
208+
},
209+
});
210+
}
211+
177212
await runOnSimulator(device, appPath, infoPlistPath);
178213
} else if (device.type === 'device') {
179214
const { appPath, bundleIdentifier } = await buildApp({
@@ -188,6 +223,22 @@ ${devices
188223
deviceOrSimulator,
189224
fingerprintOptions,
190225
});
226+
227+
// Start dev server after build completes to avoid log clashing
228+
if (startDevServer) {
229+
logger.info('Starting dev server...');
230+
startDevServer({
231+
root: projectRoot,
232+
reactNativePath,
233+
reactNativeVersion,
234+
platforms,
235+
args: {
236+
interactive: isInteractive(),
237+
clientLogs: args.clientLogs ?? true,
238+
},
239+
});
240+
}
241+
191242
await runOnDevice(
192243
device,
193244
appPath,
@@ -242,6 +293,22 @@ ${devices
242293
fingerprintOptions,
243294
}),
244295
]);
296+
297+
// Start dev server after build completes to avoid log clashing
298+
if (startDevServer) {
299+
logger.info('Starting dev server...');
300+
startDevServer({
301+
root: projectRoot,
302+
reactNativePath,
303+
reactNativeVersion,
304+
platforms,
305+
args: {
306+
interactive: isInteractive(),
307+
clientLogs: args.clientLogs ?? true,
308+
},
309+
});
310+
}
311+
245312
if (bootedDevice.type === 'simulator') {
246313
await runOnSimulator(bootedDevice, appPath, infoPlistPath);
247314
} else {

packages/platform-apple-helpers/src/lib/commands/run/runOptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface RunFlags extends BuildFlags {
88
device?: string;
99
catalyst?: boolean;
1010
local?: boolean;
11+
clientLogs?: boolean;
1112
}
1213

1314
export const getRunOptions = ({ platformName }: BuilderCommand) => {
@@ -30,6 +31,10 @@ export const getRunOptions = ({ platformName }: BuilderCommand) => {
3031
name: '--catalyst',
3132
description: 'Run on Mac Catalyst.',
3233
},
34+
{
35+
name: '--client-logs',
36+
description: 'Enable client logs in dev server.',
37+
},
3338
...getBuildOptions({ platformName }),
3439
];
3540
};

packages/platform-ios/src/lib/platformIOS.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const platformIOS =
6262
fingerprintOptions: api.getFingerprintOptions(),
6363
reactNativePath: api.getReactNativePath(),
6464
reactNativeVersion: api.getReactNativeVersion(),
65+
platforms: api.getPlatforms(),
6566
startDevServer: api.getBundlerStart(),
6667
});
6768
outro('Success 🎉.');

0 commit comments

Comments
 (0)