Skip to content

Commit f6aa4e1

Browse files
committed
refactor(cli)!: drop metro prepare --metro-kind and diff snapshot --out
`metro prepare` read `--kind ?? --metro-kind`, so one option had two spellings. The reader now reads `--kind` only, and `--metro-kind` stays in connect's `--metro-*` hint family, which names the launcher kind deferred Metro preparation runs with. The shared METRO_PREPARE_FLAGS declaration splits so metro no longer allows metroKind while connect still does; the saved remote-config/profile `metroKind` field is unchanged. `diff snapshot` reports text and never writes a file, so `out` leaves the CaptureDiffOptions type, the diff command's input metadata, and the CLI reader. `--out` still names the diff PNG for `diff screenshot` and `screenshot`.
1 parent 80c44fe commit f6aa4e1

13 files changed

Lines changed: 70 additions & 14 deletions

File tree

‎packages/command-registry/src/flag-definitions-target.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ export const TARGET_FLAG_DEFINITIONS: readonly FlagDefinition[] = [
217217
type: 'enum',
218218
enumValues: ['auto', 'react-native', 'expo', 'repack'],
219219
usageLabel: '--metro-kind auto|react-native|expo|repack',
220-
usageDescription: 'metro prepare: detect or force the React Native dev-server launcher kind',
220+
usageDescription:
221+
'connect: detect or force the React Native dev-server launcher kind for deferred Metro preparation. `metro prepare` reads --kind instead',
221222
projectConfig: false,
222223
recorded: false,
223224
},

‎packages/command-registry/src/flag-groups.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const SELECTOR_SNAPSHOT_FLAGS = flagKeys('snapshotDepth', 'snapshotScope'
1919
export const METRO_PREPARE_FLAGS = flagKeys(
2020
'metroProjectRoot',
2121
'kind',
22-
'metroKind',
2322
'metroPublicBaseUrl',
2423
'metroProxyBaseUrl',
2524
'metroBearerToken',
@@ -33,6 +32,10 @@ export const METRO_PREPARE_FLAGS = flagKeys(
3332
'metroNoInstallDeps',
3433
);
3534

35+
// The `--metro-*` connect hint family `connect` saves for deferred Metro preparation. `metro
36+
// prepare` reads `--kind` and not the `--metro-kind` alias, so only connect allows this key.
37+
export const CONNECT_METRO_HINT_FLAGS = flagKeys('metroKind');
38+
3639
export const METRO_RELOAD_FLAGS = flagKeys('metroHost', 'metroPort', 'bundleUrl');
3740
// The device spec a proxy lease is allocated by; the commands that allocate a proxy lease take it.
3841
export const LEASE_DEVICE_SPEC_FLAGS = flagKeys(

‎packages/command-surface/src/capture/diff.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const diffCommandDescription =
6969

7070
const diffCommandMetadata = defineFieldCommandMetadata(DIFF_COMMAND_NAME, diffCommandDescription, {
7171
kind: requiredField(jsonSchemaField<'snapshot'>({ type: 'string', const: 'snapshot' })),
72-
out: stringField(),
7372
interactiveOnly: booleanField(),
7473
depth: integerField(),
7574
scope: stringField(),
@@ -101,7 +100,6 @@ export const diffCliReader: CliReader = (positionals, flags) => {
101100
return {
102101
...commonInputFromFlags(flags),
103102
kind: 'snapshot',
104-
out: flags.out,
105103
interactiveOnly: flags.snapshotInteractiveOnly,
106104
depth: flags.snapshotDepth,
107105
scope: flags.snapshotScope,
@@ -120,7 +118,7 @@ export const diffCommandFacet = defineCommandFacet({
120118
summary: 'Diff snapshot or screenshot',
121119
searchHint: 'visual regression baseline',
122120
cliDetail:
123-
'Screenshot --threshold is a per-pixel RGB tolerance: 0 requires exact colors and 1 ignores color differences; the current image scales proportionally to the baseline width and aligns top-left. Scaled height rounds to the nearest pixel (minimum 1). Extra or missing bottom rows always count as differences, even at threshold 1. The originals remain unchanged. When dimensions differ, normalization metadata reports original, scaled and compared sizes; region coordinates use comparison pixels. Both screenshot inputs are decoded from their bytes, so a baseline or current image may be PNG or JPEG, and the diff image is always PNG. JPEG is lossy, so keep --threshold above 0 whenever either input is JPEG. Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines. Use --screen-mask black for a live iOS simulator capture with a black screen outline, and use the same option when creating its baseline. --screen-mask is refused when current.png is supplied; saved images are compared unchanged.',
121+
'Snapshot comparisons report text only: --out is the diff PNG path screenshot comparisons write, and `diff snapshot` never writes a file. Screenshot --threshold is a per-pixel RGB tolerance: 0 requires exact colors and 1 ignores color differences; the current image scales proportionally to the baseline width and aligns top-left. Scaled height rounds to the nearest pixel (minimum 1). Extra or missing bottom rows always count as differences, even at threshold 1. The originals remain unchanged. When dimensions differ, normalization metadata reports original, scaled and compared sizes; region coordinates use comparison pixels. Both screenshot inputs are decoded from their bytes, so a baseline or current image may be PNG or JPEG, and the diff image is always PNG. JPEG is lossy, so keep --threshold above 0 whenever either input is JPEG. Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines. Use --screen-mask black for a live iOS simulator capture with a black screen outline, and use the same option when creating its baseline. --screen-mask is refused when current.png is supplied; saved images are compared unchanged.',
124122
},
125123
metadata: diffCommandMetadata,
126124
run: (client, input) => client.capture.diff(input),

‎packages/command-surface/src/capture/index.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ describe('capture command interface', () => {
102102
});
103103

104104
test('reads diff snapshot input only', () => {
105-
expect(
106-
diffCliReader(['snapshot'], flags({ snapshotDepth: 4, out: './diff.json' })),
107-
).toMatchObject({
105+
const input = diffCliReader(['snapshot'], flags({ snapshotDepth: 4, out: './diff.json' }));
106+
expect(input).toMatchObject({
108107
kind: 'snapshot',
109108
depth: 4,
110-
out: './diff.json',
111109
});
110+
// `diff snapshot` never writes a file, so the reader carries no out for it.
111+
expect(input).not.toHaveProperty('out');
112112
expectInvalidArgs(() => diffCliReader(['screenshot'], flags()), 'Only diff snapshot');
113113
});
114114

‎packages/command-surface/src/metro/index.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ describe('metro command interface', () => {
8787
});
8888
});
8989

90+
test('prepare reads --kind and not the retired --metro-kind alias', () => {
91+
expect(
92+
metroCliReader(
93+
['prepare'],
94+
flags({ metroPublicBaseUrl: 'https://public.example.test', kind: 'expo' }),
95+
),
96+
).toMatchObject({ kind: 'expo' });
97+
// The parser refuses --metro-kind for metro, so a value that reaches the reader from
98+
// connect's saved profile must not leak into a prepare request either.
99+
expect(
100+
metroCliReader(
101+
['prepare'],
102+
flags({ metroPublicBaseUrl: 'https://public.example.test', metroKind: 'expo' }),
103+
).kind,
104+
).toBeUndefined();
105+
});
106+
90107
test('rejects invalid metro input', () => {
91108
expectInvalidArgs(() => metroCliReader(['start'], flags()), 'metro requires a subcommand');
92109
expectInvalidArgs(

‎packages/command-surface/src/metro/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const metroCliReader: CliReader = (positionals, flags) => {
108108
return {
109109
action,
110110
projectRoot: flags.metroProjectRoot,
111-
kind: readMetroPrepareKind(flags.kind ?? flags.metroKind),
111+
kind: readMetroPrepareKind(flags.kind),
112112
port: flags.metroPreparePort,
113113
listenHost: flags.metroListenHost,
114114
statusHost: flags.metroStatusHost,

‎packages/command-surface/src/schema/command-overrides.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { LocalCliCommandName } from '@agent-device/command-registry/catalog
44
import type { CommandSchema } from '@agent-device/command-registry/command-schema';
55
import {
66
COMMON_COMMAND_SUPPORTED_FLAG_KEYS,
7+
CONNECT_METRO_HINT_FLAGS,
78
LEASE_DEVICE_SPEC_FLAGS,
89
METRO_PREPARE_FLAGS,
910
} from '@agent-device/command-registry/flag-groups';
@@ -126,6 +127,7 @@ const SCHEMA_ONLY_CLI_COMMAND_SCHEMAS = {
126127
'platform',
127128
'device',
128129
...METRO_PREPARE_FLAGS,
130+
...CONNECT_METRO_HINT_FLAGS,
129131
'launchUrl',
130132
],
131133
},

‎packages/command-surface/src/schema/option-schema.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ test('isFlagSupportedForCommand consults option schema support map', () => {
106106
assert.equal(isFlagSupportedForCommand('delayMs', 'type'), true);
107107
assert.equal(isFlagSupportedForCommand('delayMs', 'fill'), true);
108108
assert.equal(isFlagSupportedForCommand('delayMs', 'press'), false);
109+
// `metro prepare` reads --kind; --metro-kind belongs to connect's hint family only.
110+
assert.equal(isFlagSupportedForCommand('metroKind', 'metro'), false);
111+
assert.equal(isFlagSupportedForCommand('metroKind', 'connect'), true);
109112
});
110113

111114
test('option schema parses enum options from env/config sources', () => {

‎packages/contracts/src/client-capture.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ export type CaptureScreenshotResult = ScreenshotResultData & {
145145
export type CaptureDiffOptions = DeviceCommandBaseOptions &
146146
Pick<CaptureSnapshotOptions, 'interactiveOnly' | 'depth' | 'scope' | 'raw'> & {
147147
kind: 'snapshot';
148-
out?: string;
149148
};
150149

151150
export type CaptureAuditOptions = DeviceCommandBaseOptions;

‎src/__tests__/cli-client-commands.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ test('metro prepare forwards normalized options to client.metro.prepare', async
169169
runId: 'run-1',
170170
leaseId: 'lease-1',
171171
metroPreparePort: 9090,
172-
metroKind: 'expo',
172+
kind: 'expo',
173173
metroRuntimeFile: './.agent-device/metro-runtime.json',
174174
metroNoReuseExisting: true,
175175
metroNoInstallDeps: true,

0 commit comments

Comments
 (0)