Skip to content

Commit

Permalink
feat(config): add enable flags for app components and services
Browse files Browse the repository at this point in the history
Introduce boolean 'Enable' fields for various components and services within the
application configuration. This allows for finer-grained control over the application's
modules and services, enabling or disabling them as needed.

BREAKING CHANGE: The configuration structure has been extended with 'Enable' flags.
Users will need to update their configuration files to include these new fields for
each component and service.
  • Loading branch information
godcong committed Aug 16, 2024
1 parent 229a381 commit b56d0a8
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 11 deletions.
1 change: 1 addition & 0 deletions config/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
package config

type App struct {
Enable bool
}
1 change: 1 addition & 0 deletions config/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
package config

type Backend struct {
Enable bool
}
24 changes: 13 additions & 11 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ const Application = `Origen`

// Config is the configuration of admin-cli.
type Config struct {
Application string `json:"application" yaml:"application" toml:"application"` // app_name
PackageName string `json:"package_name" yaml:"package_name" toml:"package_name"` // package_name
Author string `json:"author" yaml:"author" toml:"author"` // author
WirePath string `json:"wire_path" yaml:"wire_path" toml:"wire_path"` // wire_path
SwaggerPath string `json:"swagger_path" yaml:"swagger_path" toml:"swagger_path"` // swagger_path
Fontend Fontend `json:"fontend" yaml:"fontend" toml:"fontend"` // fontend
Backend Backend `json:"backend" yaml:"backend" toml:"backend"` // backend
Database Database `json:"database" yaml:"database" toml:"database"` // database
Extension Extension `json:"extension" yaml:"extension" toml:"extension"` // extension
Description string `json:"description" yaml:"description" toml:"description"` // description
Version string `json:"version" yaml:"version" toml:"version"` // version
Application string
PackageName string
Author string
WirePath string
SwaggerPath string
Description string
Version string
App App `json:"app" yaml:"app" toml:"app"` // app
Fontend Fontend `json:"fontend" yaml:"fontend" toml:"fontend"` // fontend
Backend Backend `json:"backend" yaml:"backend" toml:"backend"` // backend
Database Database `json:"database" yaml:"database" toml:"database"` // database
Extension Extension `json:"extension" yaml:"extension" toml:"extension"` // extension
Services map[string]Service `json:"services" yaml:"services" toml:"services"` // services
}

// Save saves config to file
Expand Down
46 changes: 46 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2024 OrigAdmin. All rights reserved.

// Package config is the config package for origen
package config_test

import (
"testing"

"github.com/origadmin/toolkits/codec"

"github.com/origadmin/origen/config"
)

func TestC(t *testing.T) {
config := config.Config{
Application: "Origen",
PackageName: "origen",
Author: "OrigAdmin",
WirePath: "wire",
SwaggerPath: "swag",
Fontend: config.Fontend{
Enable: false,
},
Backend: config.Backend{
Enable: true,
},
Database: config.Database{
Enable: false,
},
Extension: config.Extension{
Enable: false,
},
Services: map[string]config.Service{
"user": {
Enable: true,
},
},
Description: "Origen is a CLI scaffolding for quickly setting up a project.",
Version: "v0.0.0",
}

err := codec.EncodeTOMLFile("config.toml", config)
if err != nil {
t.Fatal(err)
}
}
1 change: 1 addition & 0 deletions config/extention.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
package config

type Extension struct {
Enable bool
}
1 change: 1 addition & 0 deletions config/fontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
package config

type Fontend struct {
Enable bool
}
5 changes: 5 additions & 0 deletions config/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package config

type Service struct {
Enable bool
}

0 comments on commit b56d0a8

Please sign in to comment.