helpers

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package helpers ...

Package helpers ...

Package helpers ...

Package helpers ...

Package helpers ...

Package helpers ...

Package helpers ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTemplate added in v0.3.0

func BuildTemplate(tplPath string, funcs template.FuncMap, data *config.TemplateData) *config.TplConfig

BuildTemplate creates TplConfig struct with all is needed for a golang template to be executed

func ExecuteCommandC

func ExecuteCommandC(root *cobra.Command, args ...string) (c *cobra.Command, err error)

ExecuteCommandC is a @DEPRECATED function, not used anymore.

func GetAllPublicPages

func GetAllPublicPages(fs afero.Fs, path string) []string

GetAllPublicPages return a slice of all available public page names as string.

func GetAllResources

func GetAllResources(fs afero.Fs, path string) []string

GetAllResources returns a slice of resource names as string.

func GetAllResourcesWithContentName

func GetAllResourcesWithContentName(fs afero.Fs, path string, children bool) []*config.ResourceItem

GetAllResourcesWithContentName traverses the resource contents and returns a slice of ResourceItem.

func GetResourceContentMap

func GetResourceContentMap(fs afero.Fs, resources []string, path string) map[string][]string

GetResourceContentMap returns a map of resources and relative contents.

func GetResourceMetadataMap

func GetResourceMetadataMap(fs afero.Fs, resources []string, path string) map[string][]string

GetResourceMetadataMap returns a map of metadata and relative name.

func GetResourceRouteFilename

func GetResourceRouteFilename(txt string, c *config.SveltinConfig) string

GetResourceRouteFilename returns a string representing the index and slug routes for a resource.

func InitAppTemplatesMap

func InitAppTemplatesMap() map[string]config.AppTemplate

InitAppTemplatesMap creates a map[string]string containining project name and repo url used by the `sveltin new` command to clone the starter project.

func IsValidFileForContent

func IsValidFileForContent(f fs.FileInfo) bool

IsValidFileForContent checks is the provided FileInfo has valid extension (.svelte, .svx, .mdx) to be used as content file.

func MakeFileContent

func MakeFileContent(efs *embed.FS, content builder.Content) []byte

MakeFileContent executes the template file with all its data and functions and returns the content file as []byte

func NewNoPageItems

func NewNoPageItems(resources []string, content map[string][]string, metadata map[string][]string, pages []string) *config.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

func PublicPageFilename(name string, pageType string) string

PublicPageFilename returns the filename string for a public page based on the page type (svelte or markdown).

func ResourceExists

func ResourceExists(fs afero.Fs, name string, c *config.SveltinConfig) error

ResourceExists return nil if a Resource identified by name exists.

func RunPMCommand

func RunPMCommand(pmName string, pmCmd string, mode string, packages []string, silentMode bool) error

RunPMCommand executes package manager (npm, pnpm, yarn) commands.

func WriteContentToDisk

func WriteContentToDisk(fs afero.Fs, saveAs string, fileContent []byte) error

WriteContentToDisk saves content file to the file system.

Types

This section is empty.

Directories

Path Synopsis
Package factory ...
Package factory ...

Jump to

Keyboard shortcuts

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