Files
upstream-ent/cmd/entc/entc.go
upstream-mirror 4b3ad0b611
Some checks failed
Atlas CI Public / lint (push) Failing after 13s
Atlas CI Public / sync (push) Has been skipped
snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:12:36 +05:00

42 lines
866 B
Go

// 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"
"log"
"os"
"path/filepath"
"entgo.io/ent/cmd/internal/base"
"entgo.io/ent/entc/gen"
"github.com/spf13/cobra"
)
func main() {
log.SetFlags(0)
cmd := &cobra.Command{Use: "entc"}
cmd.AddCommand(
base.NewCmd(),
base.DescribeCmd(),
base.GenerateCmd(migrate),
base.InitCmd(),
)
_ = cmd.Execute()
}
func migrate(c *gen.Config) {
var (
target = filepath.Join(c.Target, "generate.go")
oldCmd = []byte("entgo.io/ent/cmd/entc")
)
buf, err := os.ReadFile(target)
if err != nil || !bytes.Contains(buf, oldCmd) {
return
}
_ = os.WriteFile(target, bytes.ReplaceAll(buf, oldCmd, []byte("entgo.io/ent/cmd/ent")), 0644)
}