Skip to main content

XpmInitTemplateBase class

Base class for xpm initialisation templates.

Signature

export declare abstract class XpmInitTemplateBase

Remarks

This abstract class provides the foundation for template-based project initialisation. It handles the complete workflow: property validation, interactive user prompts for missing mandatory values, variable substitution, and file generation using the Liquid templating engine.

Template workflow:

  1. Properties are validated against their definitions
  2. Missing mandatory properties trigger interactive prompts (if TTY)
  3. Substitution variables are prepared from properties
  4. The XpmInitTemplateBase.generate() method creates project files

Derived classes must implement XpmInitTemplateBase.generate() to define the specific files and folder structure to create.

Constructors

Constructor

Modifiers

Description

(constructor)({ context, __dirname, templatesPath, propertiesDefinitions, process: _process, })

Constructs an xpm initialisation template instance.

Properties

Property

Modifiers

Type

Description

__dirname

protected

string

The absolute path to the module folder.

_context

protected

XpmContext

The xpm context containing configuration and logging utilities.

_engine

protected

Liquid

The Liquid templating engine instance.

_isInteractive

protected

boolean

_log

protected

Logger

The logger instance for output and diagnostics.

_process

protected

NodeJS.Process

_propertiesDefinitions

protected

XpmInitTemplatePropertiesDefinitions

Definitions of all properties supported by this template.

_substitutionsVariables?

protected

XpmInitTemplateSubstitutionsVariables

(Optional) The variables to be used for template substitutions.

_templatesPath

protected

string

The absolute path to the templates folder.

Methods

Method

Modifiers

Description

_copyFolderRecursively(sourceFolderPath, destinationFolderPath)

protected

Recursively copies all contents of a source folder to a destination folder.

_validatePropertiesDefinitions()

protected

_validatePropertyValue(name, value)

protected

Validates a property value against its definition.

askForMoreValues()

Prompts the user interactively for missing property values.

copyFile(sourceFileRelativePath, destinationFilePath)

Copies a single file from the templates folder to the destination.

copyFolder(source, destination)

Copies an entire folder from the templates folder to the destination.

generate()

abstract

Generates the project files from the template.

isPlatformSupported(platforms)

Determines whether the current platform is supported.

render(inputFileRelativePath, outputFileRelativePath, substitutionsVariables)

Renders a template file using Liquid and writes the output.

run()

Executes the template initialisation process.


Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.