Function
| Static Public Summary | ||
| public |
addPadding(string: string, length: number): string Pads a string to a given length with spaces. |
|
| public |
appendConfig(configObject: rocConfig): rocConfig Appends to the configuration object. |
|
| public |
appendSettings(settingsObject: rocSettings): rocSettings Appends settings to the configuration object. |
|
| public |
buildCompleteConfig(debug: boolean, config: rocConfig, meta: rocMetaConfig, newConfig: rocConfig, newMeta: rocMetaConfig, directory: string, validate: boolean): Object Builds the complete configuration objects. |
|
| public |
buildDocumentationObject(initalObject: Object, meta: rocMetaSettings, initalFilter: string[]): rocDocumentationObject Creates a rocDocumentationObject. |
|
| public |
Formats a string suitable for error output. |
|
| public |
errorLabel(text: string): string Formats a string suitable for error labels. |
|
| public |
Executes a command string. |
|
| public |
fileExists(filepath: string, directory: string): boolean Verifys if a file exists. |
|
| public |
generateCommandDocumentation(settings: rocConfig, commands+meta: rocMetaConfig, command: string, name: string): string Generates a string with information about a specific command. |
|
| public |
generateCommandsDocumentation(commands: rocConfig, commandsmeta: rocMetaConfig): string Generates a string with information about all the possible commands. |
|
| public |
generateMarkdownDocumentation(config: rocConfig, metaConfig: rocMetaConfig, filter: string[]): string Generates markdown documentation for the provided configuration object. |
|
| public |
generateTable(initalDocumentationObject: rocDocumentationObject, header: rocTableHeader, settings: rocTableSettings): string Creates a table based on a rocDocumentationObject. |
|
| public |
generateTextDocumentation(config: rocConfig, metaConfig: rocMetaConfig, filter: string[]): string Generates plain text documentation for the provided configuration object. |
|
| public |
Fetches the tarball for a repository on Github. |
|
| public |
getAbsolutePath(filepath: string, directory: string): string Makes a path absolute if not already is that. |
|
| public |
getApplicationConfig(applicationConfigPath: string, directory: string, debug: boolean): object Gets the application configuration by reading a file. |
|
| public |
Gets the current configuration object. |
|
| public |
getDefaultValue(object: Object): string | null Converts an object to a string. |
|
| public |
getMappings(documentationObject: rocDocumentationObject): Object Creates mappings between cli commands to their "path" in the configuration structure, their validator and type convertor. |
|
| public |
getPackageJson(directory: string): Object | undefined Reads a |
|
| public |
getRocDependencies(packageJson: Object): string[] Gets the Roc dependencies from a |
|
| public |
getSettings(key: string): rocSettings | Object Gets the settings in the configuration object. |
|
| public |
getSuggestions(current: string[], possible: string[], command: boolean): string Will create a string with suggestions for possible typos. |
|
| public |
getVersions(packageName: string): object[] Fetches an array of all the tags for a Github repo, used as possible versions for a template. |
|
| public |
Formats a string suitable for important messages. |
|
| public |
importantLabel(text: string): string Formats a string suitable for important labels. |
|
| public |
init(parsedArguments: rocCommandObject): Promise Command used to init a new Roc project. |
|
| public |
Validates an array using a validator. |
|
| public |
isArrayOrSingle(validator: function | RegExp): function Validates an pontential array using a validator. |
|
| public |
Validates an string. |
|
| public |
Validates an string. |
|
| public |
Validates an object using a validator. |
|
| public |
Validates an string. |
|
| public |
Validates an string. |
|
| public |
Helper to use a validator. |
|
| public |
Merges two configuration objects. |
|
| public |
Formats a string suitable for confirmations. |
|
| public |
Formats a string suitable for confirmation labels. |
|
| public |
Validates against a list of validators. |
|
| public |
Returns a string to pad with. |
|
| public |
parseArguments(args: Object, mappings: Object): Object Converts a set of arguments to rocConfigSettings object. |
|
| public |
parseOptions(command: string, commands: Object, options: Object[]): Object Parses options and validates them. |
|
| public |
Marks that the value is required |
|
| public |
runCli(info: {version: string, name: string}, initalConfig: rocConfig, initalMeta: rocMetaConfig, args: string[]): undefined Invokes the Roc cli. |
|
| public |
throwError(name: string, message: string, value: object, type: string) Throws error for failed validations. |
|
| public |
Takes a configuration path array and convertes it to a cli flag. |
|
| public |
validRocProject(directory: string): boolean Validates if a directory seems to be a Roc application project. |
|
| public |
validate(settings: rocSettings, metaSettings: rocMetaSettings, toValidate: array | boolean) Validates the provided configuration object. |
|
| public |
validateMightThrow(settings: rocSettings, validations: Object) Validates the provided configuration object. |
|
| public |
Formats a string suitable for warnings. |
|
| public |
warningLabel(text: string): string Formats a string suitable for warning labels. |
|
Static Public
public addPadding(string: string, length: number): string source
import {addPadding} from 'roc/lib/documentation/helpers.js'Pads a string to a given length with spaces.
public appendConfig(configObject: rocConfig): rocConfig source
import {appendConfig} from 'roc/lib/configuration/index.js'Appends to the configuration object.
Will merge with the already existing configuration object meaning that this function can be called multiple times and the configuration will be a merge of all those calls.
Params:
| Name | Type | Attribute | Description |
| configObject | rocConfig |
|
A configuration object. |
public appendSettings(settingsObject: rocSettings): rocSettings source
import {appendSettings} from 'roc/lib/configuration/index.js'Appends settings to the configuration object.
Will merge with the already existing settings object meaning that this function can be called multiple times and the settings will be a merge of all those calls.
Params:
| Name | Type | Attribute | Description |
| settingsObject | rocSettings |
|
A settings object. |
public buildCompleteConfig(debug: boolean, config: rocConfig, meta: rocMetaConfig, newConfig: rocConfig, newMeta: rocMetaConfig, directory: string, validate: boolean): Object source
import {buildCompleteConfig} from 'roc/lib/cli/helpers.js'Builds the complete configuration objects.
Params:
| Name | Type | Attribute | Description |
| debug | boolean | If debug mode should be enabled, logs some extra information. |
|
| config | rocConfig | The base configuration. |
|
| meta | rocMetaConfig | The base meta configuration. |
|
| newConfig | rocConfig | The new configuration to base the merge on. |
|
| newMeta | rocMetaConfig | The new meta configuration to base the merge on. |
|
| directory | string |
|
The directory to resolve relative paths from. |
| validate | boolean |
|
If the newConfig and the newMeta structure should be validated. |
Return:
| Object | The result of with the built configurations. |
Return Properties:
| Name | Type | Attribute | Description |
| extensionConfig | rocConfig | The extensions merged configurations |
|
| config | rocConfig | The final configuration, with application configuration. |
|
| meta | rocMetaConfig | The merged meta configuration. |
public buildDocumentationObject(initalObject: Object, meta: rocMetaSettings, initalFilter: string[]): rocDocumentationObject source
import buildDocumentationObject from 'roc/lib/documentation/build-documentation-object.js'Creates a rocDocumentationObject.
Params:
| Name | Type | Attribute | Description |
| initalObject | Object | The object to create a rocDocumentationObject of. |
|
| meta | rocMetaSettings | The meta object to use. |
|
| initalFilter | string[] |
|
The groups that should be used, will default to all groups. |
public error(text: string): string source
import {error} from 'roc/lib/helpers/style.js'Formats a string suitable for error output.
Params:
| Name | Type | Attribute | Description |
| text | string | The text to format for errors. |
public errorLabel(text: string): string source
import {errorLabel} from 'roc/lib/helpers/style.js'Formats a string suitable for error labels.
Params:
| Name | Type | Attribute | Description |
| text | string | The text to format for error labels. |
public execute(command: string): Promise source
import {execute} from 'roc/lib/cli/execute.js'Executes a command string.
Quite simple in its current state and should be expected to change in the future. Can manage multiple commands if they are divided by either & or &&. Important that there is spacing on both sides.
Params:
| Name | Type | Attribute | Description |
| command | string | A command string that should run. |
public fileExists(filepath: string, directory: string): boolean source
import {fileExists} from 'roc/lib/helpers/index.js'Verifys if a file exists.
Params:
| Name | Type | Attribute | Description |
| filepath | string | The filepath to check. Will make it absolute if not already using getAbsolutePath. |
|
| directory | string |
|
The directory to base the filepath on. |
public generateCommandDocumentation(settings: rocConfig, commands+meta: rocMetaConfig, command: string, name: string): string source
import {generateCommandDocumentation} from 'roc/lib/cli/helpers.js'Generates a string with information about a specific command.
Params:
| Name | Type | Attribute | Description |
| settings | rocConfig | The Roc config object, uses settings from it. |
|
| commands+meta | rocMetaConfig | The Roc meta config object, uses commands and settings from it. |
|
| command | string | The selected command. |
|
| name | string | The name of the cli. |
public generateCommandsDocumentation(commands: rocConfig, commandsmeta: rocMetaConfig): string source
import {generateCommandsDocumentation} from 'roc/lib/cli/helpers.js'Generates a string with information about all the possible commands.
Params:
| Name | Type | Attribute | Description |
| commands | rocConfig | The Roc config object, uses commands from it. |
|
| commandsmeta | rocMetaConfig | The Roc meta config object, uses commands from it. |
public generateMarkdownDocumentation(config: rocConfig, metaConfig: rocMetaConfig, filter: string[]): string source
import {generateMarkdownDocumentation} from 'roc/lib/documentation/index.js'Generates markdown documentation for the provided configuration object.
Params:
| Name | Type | Attribute | Description |
| config | rocConfig | The configuration object to generate documentation for. |
|
| metaConfig | rocMetaConfig | The meta configuration object that has information about the config object. |
|
| filter | string[] |
|
The groups that should be includes, by default all will be used. |
public generateTable(initalDocumentationObject: rocDocumentationObject, header: rocTableHeader, settings: rocTableSettings): string source
import generateTable from 'roc/lib/documentation/generate-table.js'Creates a table based on a rocDocumentationObject.
Params:
| Name | Type | Attribute | Description |
| initalDocumentationObject | rocDocumentationObject | The documentation object to create a table of. |
|
| header | rocTableHeader | Header object to use. |
|
| settings | rocTableSettings | The settings to use. |
public generateTextDocumentation(config: rocConfig, metaConfig: rocMetaConfig, filter: string[]): string source
import {generateTextDocumentation} from 'roc/lib/documentation/index.js'Generates plain text documentation for the provided configuration object.
Params:
| Name | Type | Attribute | Description |
| config | rocConfig | The configuration object to generate documentation for. |
|
| metaConfig | rocMetaConfig | The meta configuration object that has information about the config object. |
|
| filter | string[] |
|
The groups that should be includes, by default all will be used. |
public get(packageName: string, version: string): string source
import {get} from 'roc/lib/commands/helpers/github.js'Fetches the tarball for a repository on Github.
public getAbsolutePath(filepath: string, directory: string): string source
import {getAbsolutePath} from 'roc/lib/helpers/index.js'Makes a path absolute if not already is that.
public getApplicationConfig(applicationConfigPath: string, directory: string, debug: boolean): object source
import {getApplicationConfig} from 'roc/lib/configuration/helpers.js'Gets the application configuration by reading a file.
Will give a warning if ROC_CONFIG_PATH has been set since that will then be used as the path to get the configuration file, even if one is provided to the function.
Reads configuration files in this manner:
- Environment variable ROC_CONFIG_PATH.
- Path given as applicationConfigPath.
- Default by trying to read "roc.config.js" in the current working directory.
- Return a empty object along with a warning.
Params:
| Name | Type | Attribute | Description |
| applicationConfigPath | string | Path to application configuration file. Can be either relative or absolute. |
|
| directory | string |
|
The directory to resolve realative paths to. By default will use the current working directory. |
| debug | boolean |
|
If extra information should be printed. |
Throw:
When an invalid path override is specified. |
public getConfig(): rocConfig source
import {getConfig} from 'roc/lib/configuration/index.js'Gets the current configuration object.
public getDefaultValue(object: Object): string | null source
import {getDefaultValue} from 'roc/lib/documentation/helpers.js'Converts an object to a string.
Params:
| Name | Type | Attribute | Description |
| object | Object | The object to convert to a string. |
public getMappings(documentationObject: rocDocumentationObject): Object source
import {getMappings} from 'roc/lib/cli/helpers.js'Creates mappings between cli commands to their "path" in the configuration structure, their validator and type convertor.
Params:
| Name | Type | Attribute | Description |
| documentationObject | rocDocumentationObject | Documentation object to create mappings for. |
public getPackageJson(directory: string): Object | undefined source
import {getPackageJson} from 'roc/lib/helpers/index.js'Reads a package.json file.
Params:
| Name | Type | Attribute | Description |
| directory | string |
|
In what directory to look for the |
public getRocDependencies(packageJson: Object): string[] source
import {getRocDependencies} from 'roc/lib/helpers/index.js'Gets the Roc dependencies from a package.json.
Params:
| Name | Type | Attribute | Description |
| packageJson | Object | A package.json file to fetch Roc dependencies from. |
public getSettings(key: string): rocSettings | Object source
import {getSettings} from 'roc/lib/configuration/index.js'Gets the settings in the configuration object.
Will by default get all settings.
Params:
| Name | Type | Attribute | Description |
| key | string |
|
The settings key to fetch. |
public getSuggestions(current: string[], possible: string[], command: boolean): string source
import {getSuggestions} from 'roc/lib/cli/helpers.js'Will create a string with suggestions for possible typos.
public getVersions(packageName: string): object[] source
import {getVersions} from 'roc/lib/commands/helpers/github.js'Fetches an array of all the tags for a Github repo, used as possible versions for a template.
Params:
| Name | Type | Attribute | Description |
| packageName | string | A package name, expected to match "username/repo" |
public important(text: string): string source
import {important} from 'roc/lib/helpers/style.js'Formats a string suitable for important messages.
Params:
| Name | Type | Attribute | Description |
| text | string | The text to format for important messages. |
public importantLabel(text: string): string source
import {importantLabel} from 'roc/lib/helpers/style.js'Formats a string suitable for important labels.
Params:
| Name | Type | Attribute | Description |
| text | string | The text to format for important labels. |
public init(parsedArguments: rocCommandObject): Promise source
import init from 'roc/lib/commands/init.js'Command used to init a new Roc project.
Params:
| Name | Type | Attribute | Description |
| parsedArguments | rocCommandObject | The Roc command object, uses parsedArguments from it. |
public isArray(validator: function | RegExp): function source
import {isArray} from 'roc/lib/validation/validators.js'Validates an array using a validator.
public isArrayOrSingle(validator: function | RegExp): function source
import {isArrayOrSingle} from 'roc/lib/validation/validators.js'Validates an pontential array using a validator.
Allows that a single value is given.
public isBoolean(value: object, info: boolean): infoObject | boolean | string source
import {isBoolean} from 'roc/lib/validation/validators.js'Validates an string.
public isInteger(value: object, info: boolean): infoObject | boolean | string source
import {isInteger} from 'roc/lib/validation/validators.js'Validates an string.
public isObject(validator: function | RegExp): function source
import {isObject} from 'roc/lib/validation/validators.js'Validates an object using a validator.
public isPath(value: object, info: boolean): infoObject | boolean | string source
import {isPath} from 'roc/lib/validation/validators.js'Validates an string.
public isString(value: object, info: boolean): infoObject | boolean | string source
import {isString} from 'roc/lib/validation/validators.js'Validates an string.
public isValid(value: object, validator: function | RegExp): boolean source
import {isValid} from 'roc/lib/validation/index.js'Helper to use a validator.
public merge(a: Object, b: Object): Object source
import {merge} from 'roc/lib/configuration/index.js'Merges two configuration objects.
public ok(text: string): string source
import {ok} from 'roc/lib/helpers/style.js'Formats a string suitable for confirmations.
Params:
| Name | Type | Attribute | Description |
| text | string | The text to format for confirmations. |
public okLabel(text: string): string source
import {okLabel} from 'roc/lib/helpers/style.js'Formats a string suitable for confirmation labels.
Params:
| Name | Type | Attribute | Description |
| text | string | The text to format for confirmation labels. |
public oneOf(validators: ...function): function source
import {oneOf} from 'roc/lib/validation/validators.js'Validates against a list of validators.
Params:
| Name | Type | Attribute | Description |
| validators | ...function | Validators to validate against. |
public pad(length: number, character: string): string source
import {pad} from 'roc/lib/documentation/helpers.js'Returns a string to pad with.
public parseArguments(args: Object, mappings: Object): Object source
import {parseArguments} from 'roc/lib/cli/helpers.js'Converts a set of arguments to rocConfigSettings object.
Params:
| Name | Type | Attribute | Description |
| args | Object | Arguments parsed from minimist. |
|
| mappings | Object | Result from getMappings. |
public parseOptions(command: string, commands: Object, options: Object[]): Object source
import {parseOptions} from 'roc/lib/cli/helpers.js'Parses options and validates them.
Params:
| Name | Type | Attribute | Description |
| command | string | The command to parse options for. |
|
| commands | Object | commands from rocMetaConfig. |
|
| options | Object[] | Options parsed by minimist. |
public required(validator: function): function source
import {required} from 'roc/lib/validation/validators.js'Marks that the value is required
Params:
| Name | Type | Attribute | Description |
| validator | function | Validator to validate against |
public runCli(info: {version: string, name: string}, initalConfig: rocConfig, initalMeta: rocMetaConfig, args: string[]): undefined source
import {runCli} from 'roc/lib/cli/index.js'Invokes the Roc cli.
Params:
| Name | Type | Attribute | Description |
| info | {version: string, name: string} | Information about the cli. |
|
| initalConfig | rocConfig | The inital configuration, will be merged with the selected extensions and application. |
|
| initalMeta | rocMetaConfig | The inital meta configuration, will be merged with the selected extensions. |
|
| args | string[] |
|
From where it should parse the arguments. |
public throwError(name: string, message: string, value: object, type: string) source
import {throwError} from 'roc/lib/validation/index.js'Throws error for failed validations.
Throw:
Throws error if the configuration is invalid. |
public toCliFlag(configPaths: string[]): string source
import {toCliFlag} from 'roc/lib/documentation/helpers.js'Takes a configuration path array and convertes it to a cli flag.
Params:
| Name | Type | Attribute | Description |
| configPaths | string[] | The configuration path, a array consiting of properties. |
public validRocProject(directory: string): boolean source
import {validRocProject} from 'roc/lib/commands/helpers/general.js'Validates if a directory seems to be a Roc application project.
A valid Roc project should have a package.json file that contains some dependecy that match 'roc-*' or
a roc.config.js file.
Params:
| Name | Type | Attribute | Description |
| directory | string | The directory to validate. |
public validate(settings: rocSettings, metaSettings: rocMetaSettings, toValidate: array | boolean) source
import {validate} from 'roc/lib/validation/index.js'Validates the provided configuration object.
Params:
| Name | Type | Attribute | Description |
| settings | rocSettings | The settings object to validate. |
|
| metaSettings | rocMetaSettings | The meta settings object that has information about how to validate. |
|
| toValidate | array | boolean | What groups on settings that should be validated. |
Emit:
process.exit |
If the config was invalid it will print the reason and terminate with status 1. |
public validateMightThrow(settings: rocSettings, validations: Object) source
import {validateMightThrow} from 'roc/lib/validation/index.js'Validates the provided configuration object.
Params:
| Name | Type | Attribute | Description |
| settings | rocSettings | The settings object to validate. |
|
| validations | Object | The meta configuration object that has information about how to validate. |
Throw:
throws error if the configuration is invalid |
public warning(text: string): string source
import {warning} from 'roc/lib/helpers/style.js'Formats a string suitable for warnings.
Params:
| Name | Type | Attribute | Description |
| text | string | The text to format for warnings. |