modules

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

This module is used to build the frontend if the user chooses to do so and it will be used in the m.Run() function. EggCli does not give a hoot about which frontend framework the user is using, so this module will assume that the user will implement the frontend framework of their choice, and integrate

config.Server.Frontend.Dir to hold the {config.Name}/{config.Server.Frontend.Dir} directory

as their distribution directory ie the result of running npm build
e.g. egg_app/web/dist

config.Server.Frontend.API to hold the {config.Name}/{config.Server.Frontend.API} directory

as their api directory generated by ./tmp/{config.Name} swag
e.g. egg_app/web/api

Index

Constants

View Source
const (
	PnpmInstall = "pnpm create rsbuild@latest"
	NpmInstall  = "npm create rsbuild@latest"
	YarnInstall = "yarn create rsbuild"
	BunInstall  = "bun create rsbuild"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapDirectoriesModule

type BootstrapDirectoriesModule struct {
	Directories []string
	Error       error
	Progress    int

	MkdirFunc func(dir string) error // For testing - can be injected to mock directory creation
	// contains filtered or unexported fields
}

func (*BootstrapDirectoriesModule) GetProgress

func (m *BootstrapDirectoriesModule) GetProgress() float64

GetProgress

returns:

float64: the progress

func (*BootstrapDirectoriesModule) IncrProg

func (m *BootstrapDirectoriesModule) IncrProg()

IncrProg

description:

increments the progress

func (*BootstrapDirectoriesModule) IsError

func (m *BootstrapDirectoriesModule) IsError() error

IsError

returns:

error: The stored error in the monad.

func (*BootstrapDirectoriesModule) LoadFromConfig

func (m *BootstrapDirectoriesModule) LoadFromConfig(configuration *configuration.Configuration, eggl *models.EggLog)

LoadFromConfig

params:

configuration: *configuration.Configuration
eggl: *models.EggLog

description:

This function is used to load the module from the configuration and initialize the module
with the needed data

func (*BootstrapDirectoriesModule) Name

Name

returns:

string: the name

description:

This function returns the name of the module

func (*BootstrapDirectoriesModule) Run

func (m *BootstrapDirectoriesModule) Run()

Run

description:

	This function is used to bootstrap the directories for the project.
  this is done by iterating over the directories and creating a goroutine for each directory
  and then waiting for all the goroutines to finish
  and collecting the errors
  and logging the errors
  and canceling the context if there is an error

type BootstrapFrameworkFilesFromTemplatesModule

type BootstrapFrameworkFilesFromTemplatesModule struct {
	PopulateTemplatesFunc func(name string, template *template.Template) error // For testing - can be injected to mock template population
	// contains filtered or unexported fields
}

BootstrapFrameworkFilesFromTemplatesModule

implements:

  • IModule

description:

This struct is used to bootstrap the framework files from the templates found in the templates directory
this is done by iterating over the mapping and creating a goroutine for each template
and then waiting for all the goroutines to finish
and collecting the errors
and logging the errors
canceling the context if there is an error

func (*BootstrapFrameworkFilesFromTemplatesModule) GetProgress

GetProgress

returns:

float64: the progress

func (*BootstrapFrameworkFilesFromTemplatesModule) IncrProg

IncrProg

description:

increments the progress

func (*BootstrapFrameworkFilesFromTemplatesModule) IsError

IsError

returns:

error:

func (*BootstrapFrameworkFilesFromTemplatesModule) LoadFromConfig

func (m *BootstrapFrameworkFilesFromTemplatesModule) LoadFromConfig(configuration *configuration.Configuration, eggl *models.EggLog)

LoadFromConfig

params:

configuration: *configuration.Configuration
eggl: *models.EggLog

description:

This function is used to load the module from the configuration and sets up the empty structure so that it can be used
by m.Run().

func (*BootstrapFrameworkFilesFromTemplatesModule) Name

Name

returns:

string: the name

description:

This function returns the name of the module

func (*BootstrapFrameworkFilesFromTemplatesModule) Run

Run

description:

This function is used to bootstrap the framework files from the templates found in the templates directory
this is done by iterating over the mapping and creating a goroutine for each template
and then waiting for all the goroutines to finish
and collecting the errors
and logging the errors

type GenerateConfigurationModule

type GenerateConfigurationModule struct {
	Configuration *configuration.Configuration
	Error         error
	Progress      int

	GenerateConfigFunc func(environment string) error // For testing - can be injected to mock config generation
	// contains filtered or unexported fields
}

func (*GenerateConfigurationModule) IsError

func (m *GenerateConfigurationModule) IsError() error

func (*GenerateConfigurationModule) LoadFromConfig

func (m *GenerateConfigurationModule) LoadFromConfig(
	configuration *configuration.Configuration,
	eggl *models.EggLog,
)

func (*GenerateConfigurationModule) Name

func (*GenerateConfigurationModule) Run

func (m *GenerateConfigurationModule) Run()

type IModule

type IModule interface {
	Run()
	Name() string
	IsError() error
	LoadFromConfig(configuration *configuration.Configuration, eggl *models.EggLog)
}

func ModuleFactory

func ModuleFactory(moduleName string) IModule

type InitializeModule

type InitializeModule struct {
	Namespace   string
	ProjectName string
	License     string
	Progress    int
	Error       error
	// contains filtered or unexported fields
}

func (*InitializeModule) GetProgress

func (m *InitializeModule) GetProgress() float64

func (*InitializeModule) IncrProg

func (m *InitializeModule) IncrProg()

incrprog increments the progress by 1

func (InitializeModule) IsError

func (m InitializeModule) IsError() error

IsError checks if there is an error in the module. if there is none it returns nil if there is an error it returns the stored error

func (*InitializeModule) LoadFromConfig

func (m *InitializeModule) LoadFromConfig(configuration *configuration.Configuration, eggl *models.EggLog)

func (*InitializeModule) Name

func (m *InitializeModule) Name() string

func (*InitializeModule) Run

func (m *InitializeModule) Run()

type InstallLibrariesModule

type InstallLibrariesModule struct {
	Progress  int
	Error     error
	GoGetFunc func(pac string) error // For testing - can be injected to mock go get
	// contains filtered or unexported fields
}

func (*InstallLibrariesModule) GetProgress

func (m *InstallLibrariesModule) GetProgress() float64

func (*InstallLibrariesModule) GoGet

func (m *InstallLibrariesModule) GoGet(pac string) error

func (*InstallLibrariesModule) IncrProg

func (m *InstallLibrariesModule) IncrProg()

incrprog increments the progress by 1

func (*InstallLibrariesModule) IsError

func (m *InstallLibrariesModule) IsError() error

func (*InstallLibrariesModule) LoadFromConfig

func (m *InstallLibrariesModule) LoadFromConfig(_ *configuration.Configuration, eggl *models.EggLog)

func (*InstallLibrariesModule) Name

func (*InstallLibrariesModule) Run

func (m *InstallLibrariesModule) Run()

type InstallToolsModule

type InstallToolsModule struct {
	Progress        int
	Error           error
	LookPathFunc    func(file string) (string, error) // For testing - can be injected to mock tool lookup
	InstallToolFunc func(tool string) error           // For testing - can be injected to mock tool installation
	// contains filtered or unexported fields
}

func (*InstallToolsModule) GetProgress

func (m *InstallToolsModule) GetProgress() float64

func (*InstallToolsModule) IncrProg

func (m *InstallToolsModule) IncrProg()

func (*InstallToolsModule) IsError

func (m *InstallToolsModule) IsError() error

func (*InstallToolsModule) LoadFromConfig

func (m *InstallToolsModule) LoadFromConfig(_ *configuration.Configuration, eggl *models.EggLog)

func (*InstallToolsModule) Name

func (m *InstallToolsModule) Name() string

func (*InstallToolsModule) Run

func (m *InstallToolsModule) Run()

type RsbuildFrontendModule

type RsbuildFrontendModule struct {
	InputFunc func(prompt string) string                       // For testing - can be injected to mock user input
	ExecFunc  func(cmd string, args ...string) ([]byte, error) // For testing - can be injected to mock command execution
	// contains filtered or unexported fields
}

RsbuildFrontendModule

implements:

  • IModule

description:

This struct is used to build the frontend if the user chooses to do so

func (*RsbuildFrontendModule) GetProgress

func (m *RsbuildFrontendModule) GetProgress() float64

GetProgress

returns:

float64: the progress

func (*RsbuildFrontendModule) IncrProg

func (m *RsbuildFrontendModule) IncrProg()

IncrProg

description:

increments the progress

func (*RsbuildFrontendModule) IsError

func (m *RsbuildFrontendModule) IsError() error

IsError

returns:

error: the error

func (*RsbuildFrontendModule) LoadFromConfig

func (m *RsbuildFrontendModule) LoadFromConfig(configuration *configuration.Configuration, eggl *models.EggLog)

LoadFromConfig

params:

configuration: *configuration.Configuration
eggl: *models.EggLog

description:

This function is used to load the module from the configuration and sets up the empty structure so that it can be used
by m.Run().

func (*RsbuildFrontendModule) Name

func (m *RsbuildFrontendModule) Name() string

Name

returns:

string: the name

description:

This function returns the name of the module

func (*RsbuildFrontendModule) Run

func (m *RsbuildFrontendModule) Run()

Run

description:

	This function is used to build the frontend and uses the following command as a reference
  pnpm create rsbuild@latest || npm create rsbuild@latest || yarn create rsbuild || bun create rsbuild
  we firrst ask the user which frontend framework they are using and then we build the frontend and
  passing off the control flow to rsbuild for the user to interact with the cli interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL