From b77d2d42779428c1bb299b1eba541efa7ed69abc Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Sun, 29 Nov 2020 10:23:24 +0200 Subject: [PATCH] cmd/ent: replace entc with ent (#989) See #981 --- cmd/ent/ent.go | 24 ++ cmd/ent/ent_test.go | 35 +++ cmd/entc/entc.go | 232 +--------------- cmd/internal/base/base.go | 249 ++++++++++++++++++ cmd/{entc => internal/base}/packages.go | 6 +- cmd/{entc => internal/base}/packages_test.go | 2 +- .../print.go => internal/printer/printer.go} | 15 +- .../printer/printer_test.go} | 5 +- entc/integration/config/ent/generate.go | 2 +- entc/integration/customid/ent/generate.go | 2 +- entc/integration/ent/generate.go | 2 +- entc/integration/gremlin/ent/generate.go | 2 +- entc/integration/hooks/ent/generate.go | 2 +- entc/integration/idtype/ent/generate.go | 2 +- entc/integration/json/ent/generate.go | 2 +- entc/integration/migrate/entv1/generate.go | 2 +- entc/integration/migrate/entv2/generate.go | 2 +- entc/integration/privacy/ent/generate.go | 2 +- entc/integration/template/ent/generate.go | 2 +- examples/edgeindex/ent/generate.go | 2 +- examples/m2m2types/ent/generate.go | 2 +- examples/m2mbidi/ent/generate.go | 2 +- examples/m2mrecur/ent/generate.go | 2 +- examples/o2m2types/ent/generate.go | 2 +- examples/o2mrecur/ent/generate.go | 2 +- examples/o2o2types/ent/generate.go | 2 +- examples/o2obidi/ent/generate.go | 2 +- examples/o2orecur/ent/generate.go | 2 +- examples/privacyadmin/ent/generate.go | 2 +- examples/privacytenant/ent/generate.go | 2 +- examples/start/ent/generate.go | 2 +- examples/traversal/ent/generate.go | 2 +- 32 files changed, 361 insertions(+), 255 deletions(-) create mode 100644 cmd/ent/ent.go create mode 100644 cmd/ent/ent_test.go create mode 100644 cmd/internal/base/base.go rename cmd/{entc => internal/base}/packages.go (91%) rename cmd/{entc => internal/base}/packages_test.go (99%) rename cmd/{entc/print.go => internal/printer/printer.go} (86%) rename cmd/{entc/print_test.go => internal/printer/printer_test.go} (99%) diff --git a/cmd/ent/ent.go b/cmd/ent/ent.go new file mode 100644 index 000000000..bbca228a1 --- /dev/null +++ b/cmd/ent/ent.go @@ -0,0 +1,24 @@ +// Copyright 2019-present Facebook Inc. All rights reserved. +// This source code is licensed under the Apache 2.0 license found +// in the LICENSE file in the root directory of this source tree. + +package main + +import ( + "log" + + "github.com/facebook/ent/cmd/internal/base" + + "github.com/spf13/cobra" +) + +func main() { + log.SetFlags(0) + cmd := &cobra.Command{Use: "ent"} + cmd.AddCommand( + base.InitCmd(), + base.DescribeCmd(), + base.GenerateCmd(), + ) + _ = cmd.Execute() +} diff --git a/cmd/ent/ent_test.go b/cmd/ent/ent_test.go new file mode 100644 index 000000000..358584214 --- /dev/null +++ b/cmd/ent/ent_test.go @@ -0,0 +1,35 @@ +// Copyright 2019-present Facebook Inc. All rights reserved. +// This source code is licensed under the Apache 2.0 license found +// in the LICENSE file in the root directory of this source tree. + +package main + +import ( + "bytes" + "os" + "os/exec" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestCmd(t *testing.T) { + defer os.RemoveAll("ent") + cmd := exec.Command("go", "run", "github.com/facebook/ent/cmd/ent", "init", "User") + stderr := bytes.NewBuffer(nil) + cmd.Stderr = stderr + require.NoError(t, cmd.Run(), stderr.String()) + + _, err := os.Stat("ent/generate.go") + require.NoError(t, err) + _, err = os.Stat("ent/schema/user.go") + require.NoError(t, err) + + cmd = exec.Command("go", "run", "github.com/facebook/ent/cmd/ent", "generate", "./ent/schema") + stderr = bytes.NewBuffer(nil) + cmd.Stderr = stderr + require.NoError(t, cmd.Run(), stderr.String()) + + _, err = os.Stat("ent/user.go") + require.NoError(t, err) +} diff --git a/cmd/entc/entc.go b/cmd/entc/entc.go index e8ac2a1c9..ae003d16a 100644 --- a/cmd/entc/entc.go +++ b/cmd/entc/entc.go @@ -6,19 +6,12 @@ package main import ( "bytes" - "errors" - "fmt" "io/ioutil" "log" - "os" "path/filepath" - "strings" - "text/template" - "unicode" - "github.com/facebook/ent/entc" + "github.com/facebook/ent/cmd/internal/base" "github.com/facebook/ent/entc/gen" - "github.com/facebook/ent/schema/field" "github.com/spf13/cobra" ) @@ -27,220 +20,21 @@ func main() { log.SetFlags(0) cmd := &cobra.Command{Use: "entc"} cmd.AddCommand( - func() *cobra.Command { - var ( - target string - cmd = &cobra.Command{ - Use: "init [flags] [schemas]", - Short: "initialize an environment with zero or more schemas", - Example: examples( - "entc init Example", - "entc init --target entv1/schema User Group", - ), - Args: func(_ *cobra.Command, names []string) error { - for _, name := range names { - if !unicode.IsUpper(rune(name[0])) { - return errors.New("schema names must begin with uppercase") - } - } - return nil - }, - Run: func(cmd *cobra.Command, names []string) { - if err := initEnv(target, names); err != nil { - log.Fatalln(err) - } - }, - } - ) - cmd.Flags().StringVar(&target, "target", defaultSchema, "target directory for schemas") - return cmd - }(), - &cobra.Command{ - Use: "describe [flags] path", - Short: "print a description of the graph schema", - Example: examples( - "entc describe ./ent/schema", - "entc describe github.com/a8m/x", - ), - Args: cobra.ExactArgs(1), - Run: func(cmd *cobra.Command, path []string) { - graph, err := entc.LoadGraph(path[0], &gen.Config{}) - if err != nil { - log.Fatalln(err) - } - printer{os.Stdout}.Print(graph) - }, - }, - func() *cobra.Command { - var ( - cfg gen.Config - storage string - features []string - templates []string - idtype = idType(field.TypeInt) - cmd = &cobra.Command{ - Use: "generate [flags] path", - Short: "generate go code for the schema directory", - Example: examples( - "entc generate ./ent/schema", - "entc generate github.com/a8m/x", - ), - Args: cobra.ExactArgs(1), - Run: func(cmd *cobra.Command, path []string) { - opts := []entc.Option{ - entc.Storage(storage), - entc.FeatureNames(features...), - } - for _, tmpl := range templates { - typ := "dir" - if parts := strings.SplitN(tmpl, "=", 2); len(parts) > 1 { - typ, tmpl = parts[0], parts[1] - } - switch typ { - case "dir": - opts = append(opts, entc.TemplateDir(tmpl)) - case "file": - opts = append(opts, entc.TemplateFiles(tmpl)) - case "glob": - opts = append(opts, entc.TemplateGlob(tmpl)) - default: - log.Fatalln("unsupported template type", typ) - } - } - // If the target directory is not inferred from - // the schema path, resolve its package path. - if cfg.Target != "" { - pkgPath, err := PkgPath(DefaultConfig, cfg.Target) - if err != nil { - log.Fatalln(err) - } - cfg.Package = pkgPath - } - cfg.IDType = &field.TypeInfo{Type: field.Type(idtype)} - if err := entc.Generate(path[0], &cfg, opts...); err != nil { - log.Fatalln(err) - } - }, - } - ) - cmd.Flags().Var(&idtype, "idtype", "type of the id field") - cmd.Flags().StringVar(&storage, "storage", "sql", "storage driver to support in codegen") - cmd.Flags().StringVar(&cfg.Header, "header", "", "override codegen header") - cmd.Flags().StringVar(&cfg.Target, "target", "", "target directory for codegen") - cmd.Flags().StringSliceVarP(&features, "feature", "", nil, "extend codegen with additional features") - cmd.Flags().StringSliceVarP(&templates, "template", "", nil, "external templates to execute") - return cmd - }(), + base.InitCmd(), + base.DescribeCmd(), + base.GenerateCmd(migrate), ) _ = cmd.Execute() } -// custom implementation for pflag. -type idType field.Type - -// Set implements the Set method of the flag.Value interface. -func (t *idType) Set(s string) error { - switch s { - case field.TypeInt.String(): - *t = idType(field.TypeInt) - case field.TypeInt64.String(): - *t = idType(field.TypeInt64) - case field.TypeUint.String(): - *t = idType(field.TypeUint) - case field.TypeUint64.String(): - *t = idType(field.TypeUint64) - case field.TypeString.String(): - *t = idType(field.TypeString) - default: - return errors.New("invalid type") +func migrate(c *gen.Config) { + var ( + target = filepath.Join(c.Target, "generate.go") + oldCmd = []byte("github.com/facebook/ent/cmd/entc") + ) + buf, err := ioutil.ReadFile(target) + if err != nil || !bytes.Contains(buf, oldCmd) { + return } - return nil -} - -// Type returns the type representation of the id option for help command. -func (idType) Type() string { - return fmt.Sprintf("%v", []field.Type{ - field.TypeInt, - field.TypeInt64, - field.TypeUint, - field.TypeUint64, - field.TypeString, - }) -} - -// String returns the default value for the help command. -func (idType) String() string { - return field.TypeInt.String() -} - -// initEnv initialize an environment for ent codegen. -func initEnv(target string, names []string) error { - if err := createDir(target); err != nil { - return err - } - for _, name := range names { - b := bytes.NewBuffer(nil) - if err := tmpl.Execute(b, name); err != nil { - log.Fatalln(err) - } - target := filepath.Join(target, strings.ToLower(name+".go")) - if err := ioutil.WriteFile(target, b.Bytes(), 0644); err != nil { - log.Fatalln(err) - } - } - return nil -} - -func createDir(target string) error { - _, err := os.Stat(target) - if err == nil || !os.IsNotExist(err) { - return err - } - if err := os.MkdirAll(target, os.ModePerm); err != nil { - return fmt.Errorf("creating schema directory: %w", err) - } - if target != defaultSchema { - return nil - } - if err := ioutil.WriteFile("ent/generate.go", []byte(genFile), 0644); err != nil { - return fmt.Errorf("creating generate.go file: %w", err) - } - return nil -} - -// schema template for the "init" command. -var tmpl = template.Must(template.New("schema"). - Parse(`package schema - -import "github.com/facebook/ent" - -// {{ . }} holds the schema definition for the {{ . }} entity. -type {{ . }} struct { - ent.Schema -} - -// Fields of the {{ . }}. -func ({{ . }}) Fields() []ent.Field { - return nil -} - -// Edges of the {{ . }}. -func ({{ . }}) Edges() []ent.Edge { - return nil -} -`)) - -const ( - // default schema package path. - defaultSchema = "ent/schema" - // ent/generate.go file used for "go generate" command. - genFile = "package ent\n\n//go:generate go run github.com/facebook/ent/cmd/entc generate ./schema\n" -) - -// examples formats the given examples to the cli. -func examples(ex ...string) string { - for i := range ex { - ex[i] = " " + ex[i] // indent each row with 2 spaces. - } - return strings.Join(ex, "\n") + _ = ioutil.WriteFile(target, bytes.ReplaceAll(buf, oldCmd, []byte("github.com/facebook/ent/cmd/ent")), 0644) } diff --git a/cmd/internal/base/base.go b/cmd/internal/base/base.go new file mode 100644 index 000000000..7485945df --- /dev/null +++ b/cmd/internal/base/base.go @@ -0,0 +1,249 @@ +// Copyright 2019-present Facebook Inc. All rights reserved. +// This source code is licensed under the Apache 2.0 license found +// in the LICENSE file in the root directory of this source tree. + +// Package base defines shared basic pieces of the ent command. +package base + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" + "text/template" + "unicode" + + "github.com/facebook/ent/cmd/internal/printer" + "github.com/facebook/ent/entc" + "github.com/facebook/ent/entc/gen" + "github.com/facebook/ent/schema/field" + + "github.com/spf13/cobra" +) + +// custom implementation for pflag. +type IDType field.Type + +// Set implements the Set method of the flag.Value interface. +func (t *IDType) Set(s string) error { + switch s { + case field.TypeInt.String(): + *t = IDType(field.TypeInt) + case field.TypeInt64.String(): + *t = IDType(field.TypeInt64) + case field.TypeUint.String(): + *t = IDType(field.TypeUint) + case field.TypeUint64.String(): + *t = IDType(field.TypeUint64) + case field.TypeString.String(): + *t = IDType(field.TypeString) + default: + return fmt.Errorf("invalid type %q", s) + } + return nil +} + +// Type returns the type representation of the id option for help command. +func (IDType) Type() string { + return fmt.Sprintf("%v", []field.Type{ + field.TypeInt, + field.TypeInt64, + field.TypeUint, + field.TypeUint64, + field.TypeString, + }) +} + +// String returns the default value for the help command. +func (IDType) String() string { + return field.TypeInt.String() +} + +// InitCmd returns the init command for ent/c packages. +func InitCmd() *cobra.Command { + var target string + cmd := &cobra.Command{ + Use: "init [flags] [schemas]", + Short: "initialize an environment with zero or more schemas", + Example: examples( + "ent init Example", + "ent init --target entv1/schema User Group", + ), + Args: func(_ *cobra.Command, names []string) error { + for _, name := range names { + if !unicode.IsUpper(rune(name[0])) { + return errors.New("schema names must begin with uppercase") + } + } + return nil + }, + Run: func(cmd *cobra.Command, names []string) { + if err := initEnv(target, names); err != nil { + log.Fatalln(err) + } + }, + } + cmd.Flags().StringVar(&target, "target", defaultSchema, "target directory for schemas") + return cmd +} + +// DescribeCmd returns the describe command for ent/c packages. +func DescribeCmd() *cobra.Command { + return &cobra.Command{ + Use: "describe [flags] path", + Short: "printer a description of the graph schema", + Example: examples( + "ent describe ./ent/schema", + "ent describe github.com/a8m/x", + ), + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, path []string) { + graph, err := entc.LoadGraph(path[0], &gen.Config{}) + if err != nil { + log.Fatalln(err) + } + printer.Fprint(os.Stdout, graph) + }, + } +} + +// GenerateCmd returns the generate command for ent/c packages. +func GenerateCmd(postRun ...func(*gen.Config)) *cobra.Command { + var ( + cfg gen.Config + storage string + features []string + templates []string + idtype = IDType(field.TypeInt) + cmd = &cobra.Command{ + Use: "generate [flags] path", + Short: "generate go code for the schema directory", + Example: examples( + "ent generate ./ent/schema", + "ent generate github.com/a8m/x", + ), + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, path []string) { + opts := []entc.Option{ + entc.Storage(storage), + entc.FeatureNames(features...), + } + for _, tmpl := range templates { + typ := "dir" + if parts := strings.SplitN(tmpl, "=", 2); len(parts) > 1 { + typ, tmpl = parts[0], parts[1] + } + switch typ { + case "dir": + opts = append(opts, entc.TemplateDir(tmpl)) + case "file": + opts = append(opts, entc.TemplateFiles(tmpl)) + case "glob": + opts = append(opts, entc.TemplateGlob(tmpl)) + default: + log.Fatalln("unsupported template type", typ) + } + } + // If the target directory is not inferred from + // the schema path, resolve its package path. + if cfg.Target != "" { + pkgPath, err := PkgPath(DefaultConfig, cfg.Target) + if err != nil { + log.Fatalln(err) + } + cfg.Package = pkgPath + } + cfg.IDType = &field.TypeInfo{Type: field.Type(idtype)} + if err := entc.Generate(path[0], &cfg, opts...); err != nil { + log.Fatalln(err) + } + for _, fn := range postRun { + fn(&cfg) + } + }, + } + ) + cmd.Flags().Var(&idtype, "idtype", "type of the id field") + cmd.Flags().StringVar(&storage, "storage", "sql", "storage driver to support in codegen") + cmd.Flags().StringVar(&cfg.Header, "header", "", "override codegen header") + cmd.Flags().StringVar(&cfg.Target, "target", "", "target directory for codegen") + cmd.Flags().StringSliceVarP(&features, "feature", "", nil, "extend codegen with additional features") + cmd.Flags().StringSliceVarP(&templates, "template", "", nil, "external templates to execute") + return cmd +} + +// initEnv initialize an environment for ent codegen. +func initEnv(target string, names []string) error { + if err := createDir(target); err != nil { + return err + } + for _, name := range names { + b := bytes.NewBuffer(nil) + if err := tmpl.Execute(b, name); err != nil { + log.Fatalln(err) + } + target := filepath.Join(target, strings.ToLower(name+".go")) + if err := ioutil.WriteFile(target, b.Bytes(), 0644); err != nil { + log.Fatalln(err) + } + } + return nil +} + +func createDir(target string) error { + _, err := os.Stat(target) + if err == nil || !os.IsNotExist(err) { + return err + } + if err := os.MkdirAll(target, os.ModePerm); err != nil { + return fmt.Errorf("creating schema directory: %w", err) + } + if target != defaultSchema { + return nil + } + if err := ioutil.WriteFile("ent/generate.go", []byte(genFile), 0644); err != nil { + return fmt.Errorf("creating generate.go file: %w", err) + } + return nil +} + +// schema template for the "init" command. +var tmpl = template.Must(template.New("schema"). + Parse(`package schema + +import "github.com/facebook/ent" + +// {{ . }} holds the schema definition for the {{ . }} entity. +type {{ . }} struct { + ent.Schema +} + +// Fields of the {{ . }}. +func ({{ . }}) Fields() []ent.Field { + return nil +} + +// Edges of the {{ . }}. +func ({{ . }}) Edges() []ent.Edge { + return nil +} +`)) + +const ( + // default schema package path. + defaultSchema = "ent/schema" + // ent/generate.go file used for "go generate" command. + genFile = "package ent\n\n//go:generate go run github.com/facebook/ent/cmd/ent generate ./schema\n" +) + +// examples formats the given examples to the cli. +func examples(ex ...string) string { + for i := range ex { + ex[i] = " " + ex[i] // indent each row with 2 spaces. + } + return strings.Join(ex, "\n") +} diff --git a/cmd/entc/packages.go b/cmd/internal/base/packages.go similarity index 91% rename from cmd/entc/packages.go rename to cmd/internal/base/packages.go index 8d4ebcae1..6188b460d 100644 --- a/cmd/entc/packages.go +++ b/cmd/internal/base/packages.go @@ -2,7 +2,7 @@ // This source code is licensed under the Apache 2.0 license found // in the LICENSE file in the root directory of this source tree. -package main +package base import ( "fmt" @@ -13,13 +13,13 @@ import ( "golang.org/x/tools/go/packages" ) -// DefaultConfig for loading Go packages. +// DefaultConfig for loading Go base. var DefaultConfig = &packages.Config{Mode: packages.NeedName} // PkgPath returns the Go package name for given target path. // Even if the existing path is not exist yet in the filesystem. // -// If packages.Config is nil, DefaultConfig will be used to load packages. +// If base.Config is nil, DefaultConfig will be used to load base. func PkgPath(config *packages.Config, target string) (string, error) { if config == nil { config = DefaultConfig diff --git a/cmd/entc/packages_test.go b/cmd/internal/base/packages_test.go similarity index 99% rename from cmd/entc/packages_test.go rename to cmd/internal/base/packages_test.go index a64344ae4..ed756d269 100644 --- a/cmd/entc/packages_test.go +++ b/cmd/internal/base/packages_test.go @@ -2,7 +2,7 @@ // This source code is licensed under the Apache 2.0 license found // in the LICENSE file in the root directory of this source tree. -package main +package base import ( "path/filepath" diff --git a/cmd/entc/print.go b/cmd/internal/printer/printer.go similarity index 86% rename from cmd/entc/print.go rename to cmd/internal/printer/printer.go index 894d73fbb..37f2729c2 100644 --- a/cmd/entc/print.go +++ b/cmd/internal/printer/printer.go @@ -2,7 +2,7 @@ // This source code is licensed under the Apache 2.0 license found // in the LICENSE file in the root directory of this source tree. -package main +package printer import ( "fmt" @@ -16,18 +16,23 @@ import ( "github.com/olekukonko/tablewriter" ) -// printer is a table printer for ent graphs. -type printer struct { +// A Config controls the output of Fprint. +type Config struct { io.Writer } // Print prints a table description of the graph to the given writer. -func (p printer) Print(g *gen.Graph) { +func (p Config) Print(g *gen.Graph) { for _, n := range g.Nodes { p.node(n) } } +// Fprint executes "pretty-printer" on the given writer. +func Fprint(w io.Writer, g *gen.Graph) { + Config{Writer: w}.Print(g) +} + // node returns description of a type. The format of the description is: // // Type: @@ -35,7 +40,7 @@ func (p printer) Print(g *gen.Graph) { // // // -func (p printer) node(t *gen.Type) { +func (p Config) node(t *gen.Type) { var ( b strings.Builder table = tablewriter.NewWriter(&b) diff --git a/cmd/entc/print_test.go b/cmd/internal/printer/printer_test.go similarity index 99% rename from cmd/entc/print_test.go rename to cmd/internal/printer/printer_test.go index 154ba88b4..c44057fc7 100644 --- a/cmd/entc/print_test.go +++ b/cmd/internal/printer/printer_test.go @@ -2,7 +2,7 @@ // This source code is licensed under the Apache 2.0 license found // in the LICENSE file in the root directory of this source tree. -package main +package printer import ( "strings" @@ -171,8 +171,7 @@ Group: } for _, tt := range tests { b := &strings.Builder{} - p := printer{b} - p.Print(tt.input) + Fprint(b, tt.input) assert.Equal(t, tt.out, "\n"+b.String()) } } diff --git a/entc/integration/config/ent/generate.go b/entc/integration/config/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/entc/integration/config/ent/generate.go +++ b/entc/integration/config/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/customid/ent/generate.go b/entc/integration/customid/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/entc/integration/customid/ent/generate.go +++ b/entc/integration/customid/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/ent/generate.go b/entc/integration/ent/generate.go index 6b7fa1503..b23b49ae2 100644 --- a/entc/integration/ent/generate.go +++ b/entc/integration/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --feature entql --template ./template --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --feature entql --template ./template --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/gremlin/ent/generate.go b/entc/integration/gremlin/ent/generate.go index 87209f4fc..f948e1e58 100644 --- a/entc/integration/gremlin/ent/generate.go +++ b/entc/integration/gremlin/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --target . --storage=gremlin --idtype string --template ../../ent/template --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ../../ent/schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --target . --storage=gremlin --idtype string --template ../../ent/template --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ../../ent/schema diff --git a/entc/integration/hooks/ent/generate.go b/entc/integration/hooks/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/entc/integration/hooks/ent/generate.go +++ b/entc/integration/hooks/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/idtype/ent/generate.go b/entc/integration/idtype/ent/generate.go index f02db2771..4e3ad9ab3 100644 --- a/entc/integration/idtype/ent/generate.go +++ b/entc/integration/idtype/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." --idtype uint64 ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." --idtype uint64 ./schema diff --git a/entc/integration/json/ent/generate.go b/entc/integration/json/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/entc/integration/json/ent/generate.go +++ b/entc/integration/json/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/migrate/entv1/generate.go b/entc/integration/migrate/entv1/generate.go index 444f0310c..e2915444a 100644 --- a/entc/integration/migrate/entv1/generate.go +++ b/entc/integration/migrate/entv1/generate.go @@ -4,4 +4,4 @@ package entv1 -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/migrate/entv2/generate.go b/entc/integration/migrate/entv2/generate.go index 86f065459..f560553d2 100644 --- a/entc/integration/migrate/entv2/generate.go +++ b/entc/integration/migrate/entv2/generate.go @@ -4,4 +4,4 @@ package entv2 -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/privacy/ent/generate.go b/entc/integration/privacy/ent/generate.go index eacf92312..6edfb9d86 100644 --- a/entc/integration/privacy/ent/generate.go +++ b/entc/integration/privacy/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --feature privacy,entql,schema/snapshot --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --feature privacy,entql,schema/snapshot --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/entc/integration/template/ent/generate.go b/entc/integration/template/ent/generate.go index e13be41ef..0f1f100f3 100644 --- a/entc/integration/template/ent/generate.go +++ b/entc/integration/template/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --template=./template --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --template=./template --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/edgeindex/ent/generate.go b/examples/edgeindex/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/edgeindex/ent/generate.go +++ b/examples/edgeindex/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/m2m2types/ent/generate.go b/examples/m2m2types/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/m2m2types/ent/generate.go +++ b/examples/m2m2types/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/m2mbidi/ent/generate.go b/examples/m2mbidi/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/m2mbidi/ent/generate.go +++ b/examples/m2mbidi/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/m2mrecur/ent/generate.go b/examples/m2mrecur/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/m2mrecur/ent/generate.go +++ b/examples/m2mrecur/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/o2m2types/ent/generate.go b/examples/o2m2types/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/o2m2types/ent/generate.go +++ b/examples/o2m2types/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/o2mrecur/ent/generate.go b/examples/o2mrecur/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/o2mrecur/ent/generate.go +++ b/examples/o2mrecur/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/o2o2types/ent/generate.go b/examples/o2o2types/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/o2o2types/ent/generate.go +++ b/examples/o2o2types/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/o2obidi/ent/generate.go b/examples/o2obidi/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/o2obidi/ent/generate.go +++ b/examples/o2obidi/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/o2orecur/ent/generate.go b/examples/o2orecur/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/o2orecur/ent/generate.go +++ b/examples/o2orecur/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/privacyadmin/ent/generate.go b/examples/privacyadmin/ent/generate.go index e3d65fb5d..37a897805 100644 --- a/examples/privacyadmin/ent/generate.go +++ b/examples/privacyadmin/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --feature privacy --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --feature privacy --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/privacytenant/ent/generate.go b/examples/privacytenant/ent/generate.go index 7f1583128..b2f326f08 100644 --- a/examples/privacytenant/ent/generate.go +++ b/examples/privacytenant/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --feature privacy,entql --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --feature privacy,entql --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/start/ent/generate.go b/examples/start/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/start/ent/generate.go +++ b/examples/start/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema diff --git a/examples/traversal/ent/generate.go b/examples/traversal/ent/generate.go index f6c2769de..505aca0a3 100644 --- a/examples/traversal/ent/generate.go +++ b/examples/traversal/ent/generate.go @@ -4,4 +4,4 @@ package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema