mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
24
cmd/ent/ent.go
Normal file
24
cmd/ent/ent.go
Normal file
@@ -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()
|
||||||
|
}
|
||||||
35
cmd/ent/ent_test.go
Normal file
35
cmd/ent/ent_test.go
Normal file
@@ -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)
|
||||||
|
}
|
||||||
232
cmd/entc/entc.go
232
cmd/entc/entc.go
@@ -6,19 +6,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"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/entc/gen"
|
||||||
"github.com/facebook/ent/schema/field"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -27,220 +20,21 @@ func main() {
|
|||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
cmd := &cobra.Command{Use: "entc"}
|
cmd := &cobra.Command{Use: "entc"}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
func() *cobra.Command {
|
base.InitCmd(),
|
||||||
var (
|
base.DescribeCmd(),
|
||||||
target string
|
base.GenerateCmd(migrate),
|
||||||
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
|
|
||||||
}(),
|
|
||||||
)
|
)
|
||||||
_ = cmd.Execute()
|
_ = cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom implementation for pflag.
|
func migrate(c *gen.Config) {
|
||||||
type idType field.Type
|
var (
|
||||||
|
target = filepath.Join(c.Target, "generate.go")
|
||||||
// Set implements the Set method of the flag.Value interface.
|
oldCmd = []byte("github.com/facebook/ent/cmd/entc")
|
||||||
func (t *idType) Set(s string) error {
|
)
|
||||||
switch s {
|
buf, err := ioutil.ReadFile(target)
|
||||||
case field.TypeInt.String():
|
if err != nil || !bytes.Contains(buf, oldCmd) {
|
||||||
*t = idType(field.TypeInt)
|
return
|
||||||
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")
|
|
||||||
}
|
}
|
||||||
return nil
|
_ = ioutil.WriteFile(target, bytes.ReplaceAll(buf, oldCmd, []byte("github.com/facebook/ent/cmd/ent")), 0644)
|
||||||
}
|
|
||||||
|
|
||||||
// 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")
|
|
||||||
}
|
}
|
||||||
|
|||||||
249
cmd/internal/base/base.go
Normal file
249
cmd/internal/base/base.go
Normal file
@@ -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")
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// This source code is licensed under the Apache 2.0 license found
|
// This source code is licensed under the Apache 2.0 license found
|
||||||
// in the LICENSE file in the root directory of this source tree.
|
// in the LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
package main
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -13,13 +13,13 @@ import (
|
|||||||
"golang.org/x/tools/go/packages"
|
"golang.org/x/tools/go/packages"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultConfig for loading Go packages.
|
// DefaultConfig for loading Go base.
|
||||||
var DefaultConfig = &packages.Config{Mode: packages.NeedName}
|
var DefaultConfig = &packages.Config{Mode: packages.NeedName}
|
||||||
|
|
||||||
// PkgPath returns the Go package name for given target path.
|
// PkgPath returns the Go package name for given target path.
|
||||||
// Even if the existing path is not exist yet in the filesystem.
|
// 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) {
|
func PkgPath(config *packages.Config, target string) (string, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = DefaultConfig
|
config = DefaultConfig
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// This source code is licensed under the Apache 2.0 license found
|
// This source code is licensed under the Apache 2.0 license found
|
||||||
// in the LICENSE file in the root directory of this source tree.
|
// in the LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
package main
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// This source code is licensed under the Apache 2.0 license found
|
// This source code is licensed under the Apache 2.0 license found
|
||||||
// in the LICENSE file in the root directory of this source tree.
|
// in the LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
package main
|
package printer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -16,18 +16,23 @@ import (
|
|||||||
"github.com/olekukonko/tablewriter"
|
"github.com/olekukonko/tablewriter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// printer is a table printer for ent graphs.
|
// A Config controls the output of Fprint.
|
||||||
type printer struct {
|
type Config struct {
|
||||||
io.Writer
|
io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print prints a table description of the graph to the given 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 {
|
for _, n := range g.Nodes {
|
||||||
p.node(n)
|
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:
|
// node returns description of a type. The format of the description is:
|
||||||
//
|
//
|
||||||
// Type:
|
// Type:
|
||||||
@@ -35,7 +40,7 @@ func (p printer) Print(g *gen.Graph) {
|
|||||||
//
|
//
|
||||||
// <Edges Table>
|
// <Edges Table>
|
||||||
//
|
//
|
||||||
func (p printer) node(t *gen.Type) {
|
func (p Config) node(t *gen.Type) {
|
||||||
var (
|
var (
|
||||||
b strings.Builder
|
b strings.Builder
|
||||||
table = tablewriter.NewWriter(&b)
|
table = tablewriter.NewWriter(&b)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// This source code is licensed under the Apache 2.0 license found
|
// This source code is licensed under the Apache 2.0 license found
|
||||||
// in the LICENSE file in the root directory of this source tree.
|
// in the LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
package main
|
package printer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
@@ -171,8 +171,7 @@ Group:
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
b := &strings.Builder{}
|
b := &strings.Builder{}
|
||||||
p := printer{b}
|
Fprint(b, tt.input)
|
||||||
p.Print(tt.input)
|
|
||||||
assert.Equal(t, tt.out, "\n"+b.String())
|
assert.Equal(t, tt.out, "\n"+b.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package entv1
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package entv2
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
package ent
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user