Oops that shouldn't have happened! Please enable Java-Script to use our site!
  • Class: KipperConfigInterpreter

    An abstract class that interprets a configuration file and returns a configuration object.

    Since

    0.11.0

    Hierarchy

    Table of contents

    Constructors

    Properties

    Methods

    Constructors

    constructor

    new KipperConfigInterpreter()

    Overrides

    ConfigInterpreter.constructor

    Defined in

    kipper/config/src/kipper-config-interpreter.ts:170

    Properties

    scheme

    scheme: Object

    Type declaration

    Name Type Description
    basePath { required: false = false; type: "string" = "string" } The base path of the project. This is the path that all other paths are relative to. This is optional and if not provided, the working directory of the invoked Kipper CLI command will be used. Since 0.11.0
    basePath.required false -
    basePath.type "string" -
    compiler { properties: { target: { required: false = false; type: "string" = "string" } ; version: { required: false = false; type: "string" = "string" } } ; required: false = false; type: "object" = "object" } Compiler-specific options. These can be heavily dependent on the compiler version, and as such, the compiler version is also required. Since 0.11.0
    compiler.properties { target: { required: false = false; type: "string" = "string" } ; version: { required: false = false; type: "string" = "string" } } -
    compiler.properties.target { required: false = false; type: "string" = "string" } The target of the compiler. Defaults to "js". Since 0.11.0
    compiler.properties.target.required false -
    compiler.properties.target.type "string" -
    compiler.properties.version { required: false = false; type: "string" = "string" } The version of the compiler. Defaults to "" i.e. any version. Standard NPM-like versioning is used, i.e. the following rules apply: - "1.2.3" will match only "1.2.3". - "~1.2.3", "1.2" and "1.2.x" will match any version from "1.2.3" to "1.2.9999" (inclusive). - "^1.2.3", "1" and "1.x.x" will match any version from "1.2.3" to "1.9999.9999" (inclusive). - "" will match any version. (This is heavily discourage and should only be used for testing.) - … and many more. (Visit the npm docs for more information.) Since 0.11.0
    compiler.properties.version.required false -
    compiler.properties.version.type "string" -
    compiler.required false -
    compiler.type "object" -
    extends { possibilities: ({ itemType?: undefined = "string"; type: "string" = "string" } | { itemType: "string" = "string"; type: "array" = "array" })[] ; required: false = false; type: "union" = "union" } The file that this config file extends. Since 0.11.0
    extends.possibilities ({ itemType?: undefined = "string"; type: "string" = "string" } | { itemType: "string" = "string"; type: "array" = "array" })[] -
    extends.required false -
    extends.type "union" -
    files { itemType: "string" = "string"; required: true = true; type: "array" = "array" } An array of files to compile. They will be all placed in the output directory with preserved directory structure. Note that if a srcDir is provided, the files will be emitted with preserved directory structure relative to the srcDir. This reflects the natural behaviour and means "srcDir/index.kip" is outputted as "outDir/index.smth". This although means any files outside will cause an error. If not provided, the basePath will be used as the source directory and all files are compiled and emitted with preserved directory structure relative to the basePath. (This would mean that even if a "src" is provided, the files would still be emitted with preserved directory structure i.e. "outDir/src/…"). Since 0.11.0
    files.itemType "string" -
    files.required true -
    files.type "array" -
    outDir { required: true = true; type: "string" = "string" } The output directory of the project. This is used as the output directory for all compiled files and resources. Since 0.11.0
    outDir.required true -
    outDir.type "string" -
    resources { itemType: "string" = "string"; required: true = true; type: "array" = "array" } Any resources that are required for the project. They will be copied and placed in the output directory with preserved directory structure. As such, this also means that the compiler enforces a strict "same-origin" policy for resources i.e. resources must be within the basePath of the project. Example: - "logo.png" will be copied to "outDir/logo.png" - "img/" will be copied to "outDir/img/" - "img/logo.png" will be copied to "outDir/img/logo.png" To avoid this behaviour the "origin:dest" syntax can be used. This will copy the origin file to the destination directory (if a directory is provided) or file (can be also used to rename the file). This is useful for resources that should not be placed in the output directory with preserved directory structure. Since 0.11.0
    resources.itemType "string" -
    resources.required true -
    resources.type "array" -
    srcDir { required: false = false; type: "string" = "string" } The source directory of the project. This is optional, as not always a "src" directory is needed. If not provided, the basePath will be used as the source directory and all files are compiled and emitted with preserved directory structure relative to the basePath. (This would mean that even if a "src" is provided, the files would still be emitted with preserved directory structure i.e. "outDir/src/…"). If provided, the files will be emitted with preserved directory structure relative to the srcDir. This reflects the natural behaviour and means "srcDir/index.kip" is outputted as "outDir/index.smth". This although means any files outside will cause an error.
    srcDir.required false -
    srcDir.type "string" -

    Inherited from

    ConfigInterpreter.scheme

    Defined in

    kipper/config/src/abstract/config-interpreter.ts:80

    Methods

    loadConfig

    loadConfig(configFile, envInfo?, refChain?): Promise<EvaluatedKipperConfigFile>

    Loads and interprets a Kipper config file.

    This method will load the config file, validate it, resolve any "extends" fields, and process the config file.

    NOTE: If an "extends" fields is present, the encoding of the provided configFile will be used for the extended config file i.e. all extended config files must have the same encoding as the base config file. This is a limitation to simplify the algorithm.

    Parameters

    Name Type Default value Description
    configFile KipperConfigFile undefined The config file to load.
    envInfo KipperConfigEnvInfo undefined The environment information that is used to interpret the config file. This is needed as the interpreter needs to know the working directory of the invoked Kipper CLI command to resolve relative paths and other information.
    refChain string[] [] The parent files of the provided config files. This will be used to indicate where the config file was referenced from and will be used to provide more descriptive error messages (e.g. "fileA -> fileB -> fileC -> …"). This will usually not be needed by the user and is primarily used for internal purposes.

    Returns

    Promise<EvaluatedKipperConfigFile>

    Overrides

    ConfigInterpreter.loadConfig

    Defined in

    kipper/config/src/kipper-config-interpreter.ts:190


    processFiles

    Private processFiles(files, basePath, src, outDir, meta): Promise<{ outDir: string ; src: string }[]>

    Parameters

    Name Type
    files "string"[]
    basePath string
    src undefined | string
    outDir string
    meta ConfigErrorMetaData

    Returns

    Promise<{ outDir: string ; src: string }[]>

    Defined in

    kipper/config/src/kipper-config-interpreter.ts:333


    processResources

    Private processResources(resources, basePath, outDir, meta): Promise<{ out: string ; src: string }[]>

    Parameters

    Name Type
    resources "string"[]
    basePath string
    outDir string
    meta ConfigErrorMetaData

    Returns

    Promise<{ out: string ; src: string }[]>

    Defined in

    kipper/config/src/kipper-config-interpreter.ts:295


    validateCompilerTarget

    Private validateCompilerTarget(target, meta): Promise<KipperCompileTarget>

    Parameters

    Name Type
    target string
    meta ConfigErrorMetaData

    Returns

    Promise<KipperCompileTarget>

    Defined in

    kipper/config/src/kipper-config-interpreter.ts:396


    validateCompilerVersion

    Private validateCompilerVersion(providedVersion, meta): Promise<SemVer>

    Parameters

    Name Type
    providedVersion undefined | string
    meta ConfigErrorMetaData

    Returns

    Promise<SemVer>

    Defined in

    kipper/config/src/kipper-config-interpreter.ts:367


    validateConfigBasedOffScheme

    Protected validateConfigBasedOffScheme(rawConfig, meta, parentConfig?): void

    Validate a configuration file based off a scheme.

    This is intended for basic validation, and should not be used for complex validation. There a custom validation methods should be implemented depending on the complexity of the configuration file.

    Throws

    ConfigValidationError If the configuration file is invalid.

    Since

    0.11.0

    Parameters

    Name Type Description
    rawConfig Object The configuration file to validate.
    meta ConfigErrorMetaData The metadata for any error that may be thrown.
    parentConfig? RawEvaluatedKipperConfigFile The parent configuration file of the configuration file. If provided any required errors will be ignored if the parent configuration file has the required field.

    Returns

    void

    Inherited from

    ConfigInterpreter.validateConfigBasedOffScheme

    Defined in

    kipper/config/src/abstract/config-interpreter.ts:99