mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
8c41ff539a
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2581 Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com> GitOrigin-RevId: 327c26868102ea1c277b795b9f508847faa2ae8b
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package projectmetadata
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/hasura/graphql-engine/cli/v2"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject"
|
|
)
|
|
|
|
type PrintContextRichDiffBetweenProjectDirectoriesOpts struct {
|
|
EC *cli.ExecutionContext
|
|
MetadataHandler *Handler
|
|
FromDirectory, ToDirectory string
|
|
Writer io.Writer
|
|
DisableColor bool
|
|
}
|
|
|
|
func PrintContextRichDiffBetweenProjectDirectories(opts PrintContextRichDiffBetweenProjectDirectoriesOpts) error {
|
|
fromObjects := GetMetadataObjectsWithDir(opts.EC, opts.FromDirectory)
|
|
toObjects := GetMetadataObjectsWithDir(opts.EC, opts.ToDirectory)
|
|
|
|
toObjectsMap := map[string]metadataobject.Object{}
|
|
for _, object := range toObjects {
|
|
toObjectsMap[object.Key()] = object
|
|
}
|
|
|
|
for _, fromObject := range fromObjects {
|
|
diffOpts := metadataobject.WriteDiffOpts{
|
|
To: toObjectsMap[fromObject.Key()],
|
|
W: opts.Writer,
|
|
DisableColor: opts.DisableColor,
|
|
}
|
|
err := fromObject.WriteDiff(diffOpts)
|
|
if err != nil {
|
|
opts.EC.Logger.Error(err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|