MCPcopy Index your code
hub / github.com/callstack/agent-device / withRemoteDevtoolsCompanion

Function withRemoteDevtoolsCompanion

src/cli/commands/react-devtools.ts:113–156  ·  view source on GitHub ↗
(
  args: string[],
  options: ReactDevtoolsCommandOptions,
  action: () => Promise<T>,
)

Source from the content-addressed store, hash-verified

111}
112
113async function withRemoteDevtoolsCompanion<T>(
114 args: string[],
115 options: ReactDevtoolsCommandOptions,
116 action: () => Promise<T>,
117): Promise<T> {
118 const { flags } = options;
119 const bridgeConfig = resolveRemoteBridgeConfig(flags);
120 if (!bridgeConfig) return action();
121
122 const stateDir = options.stateDir ?? process.cwd();
123 const session = options.session ?? flags?.session ?? 'default';
124 const profileKey =
125 flags?.remoteConfig ?? `${bridgeConfig.tenantId}:${bridgeConfig.runId}:${bridgeConfig.leaseId}`;
126
127 if (args[0] === 'stop') {
128 try {
129 return await action();
130 } finally {
131 await stopReactDevtoolsCompanion({
132 projectRoot: options.cwd ?? process.cwd(),
133 stateDir,
134 profileKey,
135 consumerKey: session,
136 });
137 }
138 }
139
140 await ensureReactDevtoolsCompanion({
141 projectRoot: options.cwd ?? process.cwd(),
142 stateDir,
143 serverBaseUrl: bridgeConfig.serverBaseUrl,
144 bearerToken: bridgeConfig.bearerToken,
145 bridgeScope: {
146 tenantId: bridgeConfig.tenantId,
147 runId: bridgeConfig.runId,
148 leaseId: bridgeConfig.leaseId,
149 },
150 session,
151 profileKey,
152 consumerKey: session,
153 env: options.env ?? process.env,
154 });
155 return await action();
156}
157
158export async function runReactDevtoolsCommand(
159 args: string[],

Callers 1

runReactDevtoolsCommandFunction · 0.85

Calls 4

actionFunction · 0.85

Tested by

no test coverage detected