Documentation ¶
Overview ¶
Package helpers contains helper functions used across commands.
Index ¶
- func ExecuteCommandC(root *cobra.Command, args ...string) (c *cobra.Command, err error)
- func GetAllResources(fs afero.Fs, path string) []string
- func GetAllRoutes(fs afero.Fs, path string) []string
- func GetResourceContentMap(fs afero.Fs, resources []string, path string) map[string][]string
- func GetResourceMetadataMap(fs afero.Fs, resources []string, path string) map[string][]string
- func GetResourceRouteFilename(txt string, s *config.SveltinSettings) string
- func InitStartersTemplatesMap() map[string]config.StarterTemplate
- func IsValidFileForContent(f fs.FileInfo) bool
- func MakeFileContent(efs *embed.FS, content builder.Content) []byte
- func NewMenuItems(resources []string, content map[string][]string) *tpltypes.MenuItems
- func NewNoPageItems(resources []string, content map[string][]string) *tpltypes.NoPageItems
- func PrepareContent(name string, resources map[string]string, templateID string, ...) builder.Content
- func PublicPageFilename(pageType string) string
- func ResourceExists(fs afero.Fs, name string, s *config.SveltinSettings) error
- func RunPMCommand(pmName string, pmCmd string, mode string, packages []string, silentMode bool) error
- func WriteContentToDisk(fs afero.Fs, saveAs string, fileContent []byte) error
- type TplConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteCommandC ¶
ExecuteCommandC is a @DEPRECATED function, not used anymore.
func GetAllResources ¶
GetAllResources returns a slice of resource names as string.
func GetAllRoutes ¶ added in v0.9.0
GetAllRoutes return a slice of all routes names as string.
func GetResourceContentMap ¶
GetResourceContentMap returns a map of resources and relative contents.
func GetResourceMetadataMap ¶
GetResourceMetadataMap returns a map of metadata and relative name.
func GetResourceRouteFilename ¶
func GetResourceRouteFilename(txt string, s *config.SveltinSettings) string
GetResourceRouteFilename returns a string representing the index and slug routes for a resource.
func InitStartersTemplatesMap ¶ added in v0.8.1
func InitStartersTemplatesMap() map[string]config.StarterTemplate
InitStartersTemplatesMap creates a map[string]string containining project name and repo url used by the `sveltin new` command to clone the starter project.
func IsValidFileForContent ¶
IsValidFileForContent checks is the provided FileInfo has valid extension (.svelte, .svx, .mdx) to be used as content file.
func MakeFileContent ¶
MakeFileContent executes the template file with all its data and functions and returns the content file as []byte
func NewMenuItems ¶ added in v0.10.0
NewMenuItems return a NoPageItems.
func NewNoPageItems ¶
func NewNoPageItems(resources []string, content map[string][]string) *tpltypes.NoPageItems
NewNoPageItems return a NoPageItems.
func PrepareContent ¶
func PrepareContent(name string, resources map[string]string, templateID string, data *config.TemplateData) builder.Content
PrepareContent returns a builder.Content struct used by the builder director.
func PublicPageFilename ¶
PublicPageFilename returns the filename string for a public page based on the page type (svelte or markdown).
func ResourceExists ¶
ResourceExists return nil if a Resource identified by name exists.
Types ¶
type TplConfig ¶ added in v0.10.0
type TplConfig struct { PathToTplFile string Funcs template.FuncMap Data config.TemplateData }
TplConfig is the struct representing all is needed by a template file (path to the template, functions map and template data).
func BuildTemplate ¶ added in v0.3.0
BuildTemplate creates TplConfig struct with all is needed for a golang template to be executed