Add markers to all ServerQueryResponse types
MODIFY
packages/@romefrontend/cli/cli.ts
packages/@romefrontend/cli/cli.ts
@@ -469,9 +469,8 @@ export default async function cli() {
});
await client.end();
- if (res.type === "SUCCESS") {
// Write markers if we were collecting them
- if (requestFlags.collectMarkers) {
+ if (requestFlags.collectMarkers && res.markers.length > 0) {
const markersPath = clientFlags.cwd.resolve(
cliFlags.markersPath === undefined
? `Markers-${getFilenameTimestamp()}.json`
@@ -484,7 +483,6 @@ export default async function cli() {
markup`Wrote markers to <emphasis>${markersPath.toMarkup()}</emphasis>`,
);
}
- }
switch (res.type) {
case "ERROR": {

MODIFY
packages/@romefrontend/core/client/ClientRequest.ts
packages/@romefrontend/core/client/ClientRequest.ts
@@ -52,6 +52,7 @@ export default class ClientRequest {
name: err.name,
message: err.message,
stack: err.stack,
+ markers: [],
};
}
}
@@ -100,6 +101,7 @@ export default class ClientRequest {
name: "Error",
message: "Command was not successful",
stack: undefined,
+ markers: [],
};
} else {
return res;
@@ -121,6 +123,7 @@ export default class ClientRequest {
name: "Error",
message: "Server died while processing command. Results may be incomplete.",
stack: undefined,
+ markers: [],
};
} else {
throw err;

MODIFY
packages/@romefrontend/core/common/bridges/ServerBridge.ts
packages/@romefrontend/core/common/bridges/ServerBridge.ts
@@ -36,14 +36,17 @@ export type PartialServerQueryRequest = Partial<Omit<
commandName: string;
};
-export type ServerQueryResponseSuccess = {
+type ServerQueryResponseBase = {
+ markers: Array<ServerMarker>;
+};
+
+export type ServerQueryResponseSuccess = ServerQueryResponseBase & {
type: "SUCCESS";
hasData: boolean;
data: JSONPropertyValue;
- markers: Array<ServerMarker>;
};
-export type ServerQueryResponseError = {
+export type ServerQueryResponseError = ServerQueryResponseBase & {
type: "ERROR";
fatal: boolean;
handled: boolean;
@@ -52,19 +55,19 @@ export type ServerQueryResponseError = {
stack: undefined | string;
};
-export type ServerQueryResponseDiagnostics = {
+export type ServerQueryResponseDiagnostics = ServerQueryResponseBase & {
type: "DIAGNOSTICS";
hasDiagnostics: boolean;
diagnostics: Diagnostics;
};
-export type ServerQueryResponseInvalid = {
+export type ServerQueryResponseInvalid = ServerQueryResponseBase & {
type: "INVALID_REQUEST";
diagnostics: Diagnostics;
showHelp: boolean;
};
-export type ServerQueryResponseCancelled = {
+export type ServerQueryResponseCancelled = ServerQueryResponseBase & {
type: "CANCELLED";
};

MODIFY
packages/@romefrontend/core/server/Server.ts
packages/@romefrontend/core/server/Server.ts
@@ -959,22 +959,26 @@ export default class Server {
name: err.name,
message: err.message,
stack: err.stack,
+ markers: [],
};
} else if (err instanceof ServerRequestCancelled) {
return {
type: "CANCELLED",
+ markers: [],
};
} else if (err instanceof ServerRequestInvalid) {
return {
type: "INVALID_REQUEST",
diagnostics,
showHelp: err.showHelp,
+ markers: [],
};
} else {
return {
type: "DIAGNOSTICS",
hasDiagnostics: diagnostics.length > 0,
diagnostics,
+ markers: [],
};
}
}

MODIFY
packages/@romefrontend/core/server/ServerRequest.ts
packages/@romefrontend/core/server/ServerRequest.ts
@@ -234,6 +234,7 @@ export default class ServerRequest {
this.cancelled = true;
this.teardown({
type: "CANCELLED",
+ markers: [],
});
}
@@ -268,24 +269,24 @@ export default class ServerRequest {
type: "DIAGNOSTICS",
hasDiagnostics: res.hasDiagnostics,
diagnostics: [],
+ markers: [],
};
} else if (res.type === "INVALID_REQUEST") {
res = {
type: "INVALID_REQUEST",
diagnostics: [],
+ markers: [],
showHelp: res.showHelp,
};
}
}
// Add on markers
- if (res.type === "SUCCESS") {
res = {
...res,
markers: this.markers,
};
}
- }
this.reporter.teardown();
this.endEvent.send(res);

Add markers to all ServerQueryResponse types (#745)