Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- `apollo`
- Relax graphql version, resolve missing types "Boolean", "String" [#1355](https://github.com/apollographql/apollo-tooling/pull/1355)
- Add `service:list` and tests [#1358](https://github.com/apollographql/apollo-tooling/pull/1358)
- Update `service:list` test to use a simulated time to prevent relative dates causing snapshot failures [#1374](https://github.com/apollographql/apollo-tooling/pull/1374)
- `apollo-codegen-core`
- <First `apollo-codegen-core` related entry goes here>
- `apollo-codegen-flow`
Expand Down
16 changes: 13 additions & 3 deletions packages/apollo/src/commands/service/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ interface TasksOutput {
}

const formatImplementingService = (
implementingService: ListServices_service_implementingServices_FederatedImplementingServices_services
implementingService: ListServices_service_implementingServices_FederatedImplementingServices_services,
effectiveDate: Date = new Date()
) => {
return {
name: implementingService.name,
url: implementingService.url || "",
updatedAt: `${moment(implementingService.updatedAt).format(
"D MMMM YYYY"
)} (${moment(implementingService.updatedAt).fromNow()})`
)} (${moment(implementingService.updatedAt).from(effectiveDate)})`
};
};

Expand Down Expand Up @@ -57,7 +58,16 @@ function formatHumanReadable({
>(implementingServices.services, [service => service.name.toUpperCase()]);

table(
sortedImplementingServices.map(formatImplementingService).filter(Boolean),
sortedImplementingServices
.map(sortedImplementingService =>
formatImplementingService(
sortedImplementingService,
// Force the time to a specific value if we're running tests. Otherwise the snapshots will break
// when the relative time changes.
process.env.NODE_ENV === "test" ? new Date("2019-06-13") : undefined
)
)
.filter(Boolean),
{
columns: [
{ key: "name", label: "Name" },
Expand Down