utils

package
v0.0.0-...-b4126e9 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

---------------------------------------------------------------------------- The code here is about the configuration of Aldev ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about cancelable contexts, to help gracefully stop some processes ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about local deployment with Containers / Kubernetes / Tilt ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about local deployment without Containers / Kubernetes / Tilt ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about downloading external resources ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about handling HTTP requests ----------------------------------------------------------------------------

---------------------------------------------------------------------------- Downloading translations from a Google sheet into a local, structured file ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about logging in the shell ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about running stuff in parallel ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about executing shell commands ----------------------------------------------------------------------------

---------------------------------------------------------------------------- Creates the required symlinks, if missing ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is about building files from templates, and Aldev config ----------------------------------------------------------------------------

---------------------------------------------------------------------------- The code here is responsible for fetching source code and copy-pasting it into our project, as configured ----------------------------------------------------------------------------

Index

Constants

View Source
const (
	TagHOTSWAPPED = "___HOTSWAPPED___"
)

Variables

This section is empty.

Functions

func Debug

func Debug(str string, params ...any)

func DeployToLocalCluster

func DeployToLocalCluster(ctx CancelableContext)

func DeployWithNoContainer

func DeployWithNoContainer(ctx CancelableContext)

func DownloadExternalResources

func DownloadExternalResources(ctx CancelableContext, withTranslations bool)

Downloading external resources, like translations, vendors, etc

func EnsureConfigmap

func EnsureConfigmap()

Making sure we have a ConfigMap to pass to K8S before deploying to a local cluster

func EnsureFileFromTemplate

func EnsureFileFromTemplate(filepath, tpl string, params ...any)

func Error

func Error(str string, params ...any)

func GenerateDeployConfigs

func GenerateDeployConfigs(ctx CancelableContext, dockerAllowed bool)

func GetBinDir

func GetBinDir() string

func GetCacheDir

func GetCacheDir() string

func GetConfigPath

func GetConfigPath() string

func GetGoSrcDir

func GetGoSrcDir() string

returns the name of the folder where to find the Go source code

func Info

func Info(str string, params ...any)

func InitAldevContext

func InitAldevContext(waitTimeMs int, stopFn func()) *aldevContext

func InstallGitHooks

func InstallGitHooks(ctx CancelableContext)

Installing Git hooks to unify our practices

func IsDevAPI

func IsDevAPI() bool

func IsDevLibrary

func IsDevLibrary() bool

func IsDevNative

func IsDevNative() bool

func IsDevWebApp

func IsDevWebApp() bool

func NewBaseContext

func NewBaseContext() *baseCancelableContext

func QuickRun

func QuickRun(whyRunThis string, commandAsString string, params ...any)

func ReadConfig

func ReadConfig(cfgFileName string)

func Recover

func Recover(ctx CancelableContext, msg string, params ...any)

func Run

func Run(whyRunThis string, ctx CancelableContext, logStart bool, commandAsString string, params ...any)

func RunAndGet

func RunAndGet(whyRunThis string, execDir string, logStart bool, commandAsString string, params ...any) []byte

func RunJobs

func RunJobs(aldevCtx CancelableContext, parallel bool)

func SetCacheDir

func SetCacheDir(cacheDir string)

func SetVerbose

func SetVerbose(isVerbose bool)

func Step

func Step(str string, params ...any)

func StepWithPreamble

func StepWithPreamble(preamble, str string, params ...any)

func UseCodeSwaps

func UseCodeSwaps()

func Warn

func Warn(str string, params ...any)

func WatcherFor

func WatcherFor(filepaths ...string) *fsnotify.Watcher

Types

type AldevConfig

type AldevConfig struct {
	AppName   string // the name of the app - beware: the key has to be "appname" in the YAML file
	Languages string // the languages available for this app, seperated by a comma - for example: en,fr,it,de,zh,es
	Lib       *struct {
		SrcDir  string // where the library source code can be found
		Config  string // the path to the config file for the API, from the API's folder
		Install string // command that should be run to install stuff, like needed dependencies, etc.
		Develop string // command that should be run to allow for continuously developping & building the library
		BinDir  string // the directory where to find the library's compiled binary, as seen from the library source folder (srcdir)
		// contains filtered or unexported fields
	}
	API *struct {
		SrcDir  string // where the API's Goald-based code should be found
		Config  string // the path to the config file for the API, from the API's folder
		Port    int    // the port used to expose the whole load-balanced API service
		I18n    *I18nConfig
		DataDir string // where to find bootstraping data to run the app
		BinDir  string // the directory where to find the API's compiled binary, as seen from the API source folder (srcdir)
		// contains filtered or unexported fields
	}
	// APIOnly bool      // if true, then no web app is handled
	Web *struct {
		SrcDir  string // where the Web app's GoaldR-based code should be found
		Port    int    // the port used to expose the app's frontend
		EnvVars []*struct {
			Name  string // the variable name; must start with "WEB_"
			Desc  string // a description for the
			Value string // the value we're using for the local dev environment
		}
	}
	Native *struct {
		SrcDir  string      // where the Native app's GoaldN-based code should be found
		I18n    *I18nConfig //
		DataDir string      // where to find bootstraping data to run the app
	}
	Vendors   []*VendorConfig // external projects to vendor into our project
	Deploying *struct {
		Dir string // where all the deploying config should be
	}
	CodeSwaps []*CodeSwapsConfig // Automatically, temporarily swapping bits of code
	Jobs      []*JobConfig       // Jobs to run
}

func Config

func Config() *AldevConfig

func (*AldevConfig) ResolvedBinDir

func (cfg *AldevConfig) ResolvedBinDir() string

computed property on an Aldev config object

type AldevContext

type AldevContext interface {
	CancelableContext
	GetLoopCtx() CancelableContext
	RestartLoop()
}

an Aldev Context has a loop and allows to restart it

type AldevTask

type AldevTask func(ctx CancelableContext)

characterises the functions run during an aldev command or subcommand

type CancelableContext

type CancelableContext interface {
	context.Context
	WithExecDir(...string) CancelableContext

	WithStdOutWriter(io.Writer) CancelableContext

	WithStdErrWriter(io.Writer) CancelableContext

	// WithErrLogFn(errLogFn) CancelableContext
	// getErrLogFn() errLogFn
	WithEnvVars(...string) CancelableContext

	WithReRun() CancelableContext

	WithAllowFailure(bool) CancelableContext

	CancelAll()
	NewChildContext() CancelableContext
	// contains filtered or unexported methods
}

type CmdConfig

type CmdConfig struct {
	Exec   string // the command to run
	From   string // the path from which to run the command
	FailOK bool   // if true, then the command is allowed to fail
}

type CodeSwapsConfig

type CodeSwapsConfig struct {
	From string   // the path from which to look for swaps; "." for the current project, "../../dependency" to swap in another lib
	For  []string // the file paths for which to apply the same swaps; can be provided as a glob, e.g. "./src/**/*.ts?",
	Do   []*struct {
		Replace string // the substring to look for and replace
		With    string // the replacement
		EOFCom  bool   // should the added comment (HOTSWAPPED) be at the end of the line (// ...) rather than inline (/* ... */) ?
	}
}

type I18nConfig

type I18nConfig struct {
	Links   []string // the link to download the translations from; each new file can override previous translations
	KeySize int      // the max size of the key in the translation UID namespace.key
	Folder  string   // the path of the file where to write the downloaded translations
}

type JobConfig

type JobConfig struct {
	Description string       // a short description of the job
	Cmds        []*CmdConfig // a list of commands to run
}

type VendorConfig

type VendorConfig struct {
	Repo    string // the repo of the external project
	Branch  string // the branch to use; if provided, then the version is ignored
	Version string // the maximal version (tag) to fetch; can also be the "latest"
	From    string // the path inside the repo to copy; if void, then all the repo is copied
	To      string // the place where to paste the copied cod
}

Jump to

Keyboard shortcuts

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