Home Manual Reference Source
import {ProjectConfigurationFileGenerator} from 'projext/src/services/cli/generators/projectConfigurationFile.js'
public class | source

ProjectConfigurationFileGenerator

Extends:

CLISubCommand → ProjectConfigurationFileGenerator

This is a CLI generator that allows the user to create a configuration file with all the default settings and all the information projext assumes about the project.

Constructor Summary

Public Constructor
public

constructor(appLogger: Logger, appPrompt: Prompt, pathUtils: PathUtils, projectConfiguration: ProjectConfigurationSettings, utils: Utils)

Class constructor.

Member Summary

Public Members
public

A local reference for the appLogger service.

public

A local reference for the appPrompt service.

public

A short description of what the generator does.

public

The resource type the user will have to select on the CLI command that manages the generator.

public

A local reference for the pathUtils service.

public

All the project settings.

public

A local reference for the utils service.

Method Summary

Public Methods
public

This method first prompts the user for the name of configuration file, it needs to be one supported by projext, after that, if the file already exists it asks for confirmation, and then it finally writes it.

Protected Methods
protected

_writeSettings(filepath: string, settings: Object): Promise<undefined, Error>

Formats a settings dictionary in order to write it as a JS object on an specific file.

Inherited Summary

From class CLISubCommand
public

A short description for what the generator does.

public

The name of the sub command for the help interface.

public

A list with the name of the options the generator supports.

public

A dictionary of options settings by their option name.

public

addOption(name: string, instruction: string, description: string, defaultValue: string)

Add a new option for the command.

public

Generates a complete description of the sub command and its options in order to be used on the help interface of the CLICommand that implements it.

public abstract

handle()

The method called by the CLICommand that implements the sub command.

Public Constructors

public constructor(appLogger: Logger, appPrompt: Prompt, pathUtils: PathUtils, projectConfiguration: ProjectConfigurationSettings, utils: Utils) source

Class constructor.

Override:

CLISubCommand#constructor

Params:

NameTypeAttributeDescription
appLogger Logger

To inform the user when the file has been generated, or if something went wrong.

appPrompt Prompt

To ask the user the path to the file.

pathUtils PathUtils

To build the absolute path for the file.

projectConfiguration ProjectConfigurationSettings

To get all the settings that are going to go on the file.

utils Utils

To format some of the options into human readable descriptions.

Public Members

public appLogger: Logger source

A local reference for the appLogger service.

public appPrompt: Prompt source

A local reference for the appPrompt service.

public description: string source

A short description of what the generator does.

Override:

CLISubCommand#description

public name: string source

The resource type the user will have to select on the CLI command that manages the generator.

Override:

CLISubCommand#name

public pathUtils: PathUtils source

A local reference for the pathUtils service.

public projectConfiguration: ProjectConfigurationSettings source

All the project settings.

public utils: Utils source

A local reference for the utils service.

Public Methods

public handle(options: Object): Promise<undefined, Error> source

This method first prompts the user for the name of configuration file, it needs to be one supported by projext, after that, if the file already exists it asks for confirmation, and then it finally writes it.

Override:

CLISubCommand#handle

Params:

NameTypeAttributeDescription
options Object

A dictionary with the received options for the generator.

options.all boolean

Whether to save all the settings or just the targets.

options.include string
  • nullable: true

A list of directory-like paths for specific settings to save.

options.exclude string
  • nullable: true

A list of directory-like paths for specific settings to ignore.

Return:

Promise<undefined, Error>

Protected Methods

protected _writeSettings(filepath: string, settings: Object): Promise<undefined, Error> source

Formats a settings dictionary in order to write it as a JS object on an specific file.

Params:

NameTypeAttributeDescription
filepath string

The path to the file where the configuration should be written.

settings Object

The dictionary of settings to write on the file.

Return:

Promise<undefined, Error>