Skip to content

Commit

Permalink
Update packages/apollo/src/commands/client/push.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeDawkins committed Sep 25, 2019
1 parent 579dd7b commit f2e434d
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions packages/apollo/src/commands/client/push.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ClientCommand } from "../../Command";
import { table } from "heroku-cli-util";
import { table } from "table";
import { relative } from "path";
import URI from "vscode-uri";
import { getOperationManifestFromProject } from "../../utils/getOperationManifestFromProject";
Expand Down Expand Up @@ -114,13 +114,29 @@ export default class ClientPush extends ClientCommand {
const { operationName, file } = signatureToOperation[
operation.signature
];
result += `\n${chalk.red(
"FAIL"
)}\t${operationName} ${chalk.blue(file)}`;
operation.errors &&
operation.errors.forEach(
({ message }) => (result += `\n\t${message}`)
);

result += `\nError in: ${chalk.blue(file)}\n`;
result += table(
[
["Status", "Operation", "Errors"],
[
chalk.red("Error"),
operationName,
(operation.errors
? operation.errors.map(({ message }) => message)
: []
).join("\n")
]
],
{
columns: {
2: {
width: 50,
wrapWord: true
}
}
}
);
});
task.title = `Failed to push operations, due to ${pluralize(
invalidOperations.length,
Expand All @@ -143,34 +159,16 @@ export default class ClientPush extends ClientCommand {
newOperations.length,
"operation"
)} to the operation registry`;

table(
newOperations.map(operation => {
result += table([
["Status", "Operation Name"],
...newOperations.map(operation => {
const { operationName, file } = signatureToOperation[
operation.signature
];

return {
added: chalk.green("ADDED"),
name: operationName,
file: chalk.blue(file)
};
}),
{
columns: [
{ key: "added", label: "Added" },
{ key: "name", label: "Operation Name" },
{ key: "file", label: "File Path" }
],
// Override `printHeader` so we don't print a header
printHeader: () => {},
// The default `printLine` will output to the console; we want to capture the output so we can test
// it.
printLine: line => {
result += `\n${line}`;
}
}
);
return [chalk.green("ADDED"), operationName];
})
]);
} else {
task.title = `All operations were already found in the operation registry`;
}
Expand Down

0 comments on commit f2e434d

Please sign in to comment.