Skip to content

Commit

Permalink
feat(forestadmin-client): add schema hash to startup logs (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
DayTF committed Nov 3, 2023
1 parent 4dca8b0 commit d13a671
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 1 addition & 6 deletions packages/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,6 @@ export default class Agent<S extends TSchema = TSchema> extends FrameworkMounter
}

// Send schema to forest servers
const updated = await this.options.forestAdminClient.postSchema(schema);
const message = updated
? 'Schema was updated, sending new version'
: 'Schema was not updated since last run';

this.options.logger('Info', message);
await this.options.forestAdminClient.postSchema(schema);
}
}
6 changes: 6 additions & 0 deletions packages/forestadmin-client/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export default class SchemaService {
await ServerUtils.query(this.options, 'post', '/forest/apimaps', {}, apimap);
}

const message = shouldSend
? 'Schema was updated, sending new version'
: 'Schema was not updated since last run';

this.options.logger('Info', `${message} (hash: ${apimap.meta.schemaFileHash})`);

return shouldSend;
}

Expand Down
10 changes: 10 additions & 0 deletions packages/forestadmin-client/test/schema/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ describe('SchemaService', () => {
},
}),
);
expect(options.logger).toHaveBeenCalledTimes(1);
expect(options.logger).toHaveBeenCalledWith(
'Info',
'Schema was updated, sending new version (hash: f61f747c5f1de29c3aa2a93da76a723ee3f50785)',
);
});
});

Expand Down Expand Up @@ -98,6 +103,11 @@ describe('SchemaService', () => {
{},
expect.objectContaining({}),
);
expect(options.logger).toHaveBeenCalledTimes(1);
expect(options.logger).toHaveBeenCalledWith(
'Info',
'Schema was not updated since last run (hash: f61f747c5f1de29c3aa2a93da76a723ee3f50785)',
);
});
});
});

0 comments on commit d13a671

Please sign in to comment.