scaffolder: wrap dry-run log body in an outer object

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-05-31 13:03:55 +02:00
parent c94fb6d666
commit 73e427c405
5 changed files with 14 additions and 10 deletions
@@ -40,7 +40,7 @@ interface DryRunInput {
}
interface DryRunResult {
log: JsonObject[];
log: Array<{ body: JsonObject }>;
directoryContents: SerializedFile[];
output: JsonObject;
}
@@ -81,7 +81,7 @@ export function createDryRunner(options: TemplateTesterCreateOptions) {
});
const dryRunId = uuid();
const log = new Array<JsonObject>();
const log = new Array<{ body: JsonObject }>();
const contentsPath = resolveSafeChildPath(
options.workingDirectory,
`dry-run-content-${dryRunId}`,
@@ -118,8 +118,10 @@ export function createDryRunner(options: TemplateTesterCreateOptions) {
return;
}
log.push({
...logMetadata,
message,
body: {
...logMetadata,
message,
},
});
},
async complete() {
@@ -52,7 +52,7 @@ export function DryRunResultsList() {
return (
<List className={classes.root} dense>
{dryRun.results.map(result => {
const failed = result.log.some(l => l.status === 'failed');
const failed = result.log.some(l => l.body.status === 'failed');
return (
<ListItem
button
@@ -62,7 +62,7 @@ describe('DryRunResultsView', () => {
executable: false,
},
],
log: [{ message: 'Foo Message', stepId: 'foo' }],
log: [{ body: { message: 'Foo Message', stepId: 'foo' } }],
output: {
links: [{ title: 'Foo Link', url: 'http://example.com' }],
},
@@ -110,12 +110,14 @@ function LogContent() {
}
return (
selectedResult.steps.map(step => {
const stepLog = selectedResult.log.filter(l => l.stepId === step.id);
const stepLog = selectedResult.log.filter(
l => l.body.stepId === step.id,
);
return {
id: step.id,
name: step.name,
logString: stepLog.map(l => l.message).join('\n'),
status: stepLog[stepLog.length - 1]?.status ?? 'completed',
logString: stepLog.map(l => l.body.message).join('\n'),
status: stepLog[stepLog.length - 1]?.body.status ?? 'completed',
};
}) ?? []
);
+1 -1
View File
@@ -165,7 +165,7 @@ export interface ScaffolderDryRunResponse {
base64Content: string;
executable: boolean;
}>;
log: Array<LogEvent['body']>;
log: Array<Pick<LogEvent, 'body'>>;
steps: TaskStep[];
output: ScaffolderTaskOutput;
}