Skip to content

Commit

Permalink
fix(planner/bun): Allow overriding Bun framework
Browse files Browse the repository at this point in the history
  • Loading branch information
pan93412 committed Dec 1, 2024
1 parent e38cf5c commit b63931b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/bun/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import (

"github.com/moznion/go-optional"
"github.com/spf13/afero"
"github.com/spf13/cast"
"github.com/zeabur/zbpack/internal/nodejs"
"github.com/zeabur/zbpack/internal/utils"
"github.com/zeabur/zbpack/pkg/plan"
"github.com/zeabur/zbpack/pkg/types"
)

// PlanContext is the context for Bun project planning.
type PlanContext struct {
PackageJSON nodejs.PackageJSON
Src afero.Fs
Config plan.ImmutableProjectConfiguration

Framework optional.Option[types.BunFramework]
}
Expand Down Expand Up @@ -62,6 +65,7 @@ func CreateBunContext(opt GetMetaOptions) *PlanContext {
return &PlanContext{
PackageJSON: packageJSON,
Src: opt.Src,
Config: opt.Config,
}
}

Expand All @@ -74,6 +78,17 @@ func DetermineFramework(ctx *PlanContext) types.BunFramework {
return framework
}

// Return None if Node.js framework is specified.
if ctx.Config.Get("node.framework").IsSome() {
*fw = optional.Some(types.BunFrameworkNone)
return fw.Unwrap()
}

if framework, err := plan.Cast(ctx.Config.Get("bun.framework"), cast.ToStringE).Take(); err == nil {
*fw = optional.Some(types.BunFramework(framework))
return fw.Unwrap()
}

if _, isBaojs := packageJSON.Dependencies["baojs"]; isBaojs {
*fw = optional.Some(types.BunFrameworkBaojs)
return fw.Unwrap()
Expand Down

0 comments on commit b63931b

Please sign in to comment.