Documentation ¶
Overview ¶
Package modules implements all logic needed for interacting with stencil modules and their interaction with a project generated by stencil.
Index ¶
- type Module
- func (m *Module) ApplyDirReplacements(path string) string
- func (m *Module) GetFS(ctx context.Context) (billy.Filesystem, error)
- func (m *Module) GetTemplate() *template.Template
- func (m *Module) RegisterExtensions(ctx context.Context, ext *nativeext.Host) error
- func (m *Module) StoreDirReplacements(reps map[string]string)
- type ModuleResolveOptions
- type NewModuleOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct { // Manifest is the module's manifest information/configuration Manifest *configuration.TemplateRepositoryManifest // Name is the name of a module. This should be a valid go // import path. For example: github.com/rgst-io/stencil-base Name string // URI is the location of the module for fetching purposes. By // default, it's equal to the name with the HTTPS scheme. URI string // Version is the version of the module to use. Version *resolver.Version // contains filtered or unexported fields }
Module is a stencil module that contains template files.
func FetchModules ¶ added in v0.7.0
func FetchModules(ctx context.Context, opts *ModuleResolveOptions) ([]*Module, error)
FetchModules fetches modules for a given Manifest. See ModuleResolveOptions for more information on the various options that this function supports.
func New ¶
New creates a new module from a TemplateRepository. Version must be set and can be obtained via the internal/modules/resolver package, or by using the FetchModules function.
uri is the URI for the module. If it is an empty string https://+name is used instead.
func (*Module) ApplyDirReplacements ¶ added in v0.6.0
ApplyDirReplacements hops through the incoming path dir by dir, starting at the end (because the raw paths won't match if you replace the earlier path segments first), and see if there's any replacements to apply
func (*Module) GetFS ¶
GetFS returns a billy.Filesystem that contains the contents of this module. If we've already fetched the filesystem, it will not be fetched again.
func (*Module) GetTemplate ¶
GetTemplate returns the go template for this module
func (*Module) RegisterExtensions ¶
RegisterExtensions registers all extensions provided by the given module. If the module is a local file URI then extensions will be sourced from the `./bin` directory of the base of the path.
func (*Module) StoreDirReplacements ¶ added in v0.6.0
StoreDirReplacements pokes the template-rendered output from the stencil render function for use by the module rendering later on via ApplyDirReplacements.
type ModuleResolveOptions ¶
type ModuleResolveOptions struct { // Log is the logger to use Log slogext.Logger // Manifest is the project manifest to resolve modules for Manifest *configuration.Manifest // Replacements is a map of modules to use instead of ones specified // in the manifest. This is mainly used by tests but also in cases // where a specific version of a module should be used (e.g., // lockfile). Replacements map[string]*Module }
ModuleResolveOptions contains options for resolving modules
type NewModuleOpts ¶ added in v0.7.0
type NewModuleOpts struct { // ImportPath is the import path of the module. This should be the // Name field of [configuration.TemplateRepository]. ImportPath string // Version is the version of the module to use. This should be a // parsed version of the Version field of // [configuration.TemplateRepository]. Version *resolver.Version // FS is an optional filesystem to use for the module. When set, it // will be used instead of fetching the module from the network/disk. FS billy.Filesystem }
Directories ¶
Path | Synopsis |
---|---|
Package modulestest contains code for interacting with modules in tests.
|
Package modulestest contains code for interacting with modules in tests. |
Package nativeext contains the logic for interacting with native extensions in stencil.
|
Package nativeext contains the logic for interacting with native extensions in stencil. |
apiv1
Package apiv1 implements the bridge between a extension and go-plugin providing most of the implementation for the extension if it's written in Go.
|
Package apiv1 implements the bridge between a extension and go-plugin providing most of the implementation for the extension if it's written in Go. |