From 2d0e446a7d875c02c4ef5781e1b79215785f0615 Mon Sep 17 00:00:00 2001 From: Yuanlin Lin Date: Fri, 15 Sep 2023 12:28:33 +0800 Subject: [PATCH] fix(lib): Fix lint warnings --- internal/nodejs/nextjs/function.go | 4 ++-- internal/nodejs/nextjs/main.go | 2 +- internal/nodejs/plan.go | 4 ++-- pkg/types/config.go | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/nodejs/nextjs/function.go b/internal/nodejs/nextjs/function.go index e6dfa74a..7f7ecc15 100644 --- a/internal/nodejs/nextjs/function.go +++ b/internal/nodejs/nextjs/function.go @@ -49,14 +49,14 @@ func constructNextFunction(zeaburOutputDir, firstFuncPage string) error { var deps []string err = filepath.Walk(".next", func(path string, info os.FileInfo, err error) error { if strings.HasSuffix(path, ".nft.json") { - type nftJson struct { + type nftJSON struct { Files []string `json:"files"` } b, err := os.ReadFile(path) if err != nil { return fmt.Errorf("read nft.json: %w", err) } - var nft nftJson + var nft nftJSON err = json.Unmarshal(b, &nft) if err != nil { return fmt.Errorf("unmarshal nft.json: %w", err) diff --git a/internal/nodejs/nextjs/main.go b/internal/nodejs/nextjs/main.go index 355187af..9e7091b6 100644 --- a/internal/nodejs/nextjs/main.go +++ b/internal/nodejs/nextjs/main.go @@ -1,7 +1,7 @@ +// Package nextjs is used to transform build output of Next.js app to the serverless build output format of Zeabur package nextjs import ( - _ "embed" "encoding/json" "fmt" "os" diff --git a/internal/nodejs/plan.go b/internal/nodejs/plan.go index 65de93cf..05cc311c 100644 --- a/internal/nodejs/plan.go +++ b/internal/nodejs/plan.go @@ -537,7 +537,7 @@ func GetStaticOutputDir(ctx *nodePlanContext) string { return dir.Unwrap() } -func GetServerless(ctx *nodePlanContext) bool { +func getServerless(ctx *nodePlanContext) bool { expEnv := os.Getenv("EXPERIMENTAL_SERVERLESS") if expEnv != "true" && expEnv != "1" { return false @@ -632,7 +632,7 @@ func GetMeta(opt GetMetaOptions) types.PlanMeta { } meta["startCmd"] = startCmd - serverless := GetServerless(ctx) + serverless := getServerless(ctx) if serverless { meta["serverless"] = strconv.FormatBool(serverless) } diff --git a/pkg/types/config.go b/pkg/types/config.go index 5b63a6d8..b68676aa 100644 --- a/pkg/types/config.go +++ b/pkg/types/config.go @@ -11,6 +11,7 @@ type ZeaburOutputConfigRoute struct { Dest string `json:"dest"` } +// ZeaburOutputConfig is the output config of Zeabur type ZeaburOutputConfig struct { // Routes is a list of routes to override the default route Routes []ZeaburOutputConfigRoute `json:"routes"`