Home Reference Source
import Comptroller from 'comptroller'
public class | source

Comptroller

Extends:

Package → Comptroller

This is the main Comptroller class. It serves as the entry point into all of Comptroller's higher level functionality.

Static Method Summary

Static Public Methods
public static

Merges patches generated by child packages in order to apply to the parent package.

Constructor Summary

Public Constructor
public

Creates a new Comptroller instance.

Member Summary

Public Members
public get

The child packages.

public get

The packages directory.

Method Summary

Public Methods
public

getChildByName(name: string): Package | boolean

A convenience method that locates a package in Comptroller#children by it's name in Package#packageJson.

public

async linkPackages()

Links the packages to node_modules in a way that enables them to be resolved by other packages by name.

public

logPatch(child: Package, patch: Patch)

Logs patch operations.

public

Scans the Comptroller#packages directory, finds package.json files and generates Packages.

public

async updatePackages()

Analyzes the dependencies and inherits of each package and applies the respective patches to each package.

public

updatePatches(patches: Patch[]): Patch[]

Takes an array of raw patches (returned by Package#generateDependencyPatches or Package#generateInheritPatches) and updates them with the information in the Comptroller#packageJson

public

async updateSelf()

Analyzes the dependencies of the root package and applies the respective patches.

public

async writePackages()

Loops through all packages in Comptroller#children and writes it's package.json.

Inherited Summary

From class Package
public static

Generates an exclude array

public get

An object representing the package's dependencies.

public get

The options to pass through to detective.

public get

A glob that matches the package's dev files

public get

An object representing the package's devDependencies.

public get

An array of package names to ignore in all operations.

public get

An array of globs that match files not to be included with the package's source files.

public get

An array of field names the package should inherit from it's parent package.json.

public get

An object representing the package's package.json.

public get

The "maximum fixed character width" parameter to pass to json-beautify.

public get

Whether or not unused dependencies should be pruned from the package.json.

public get

The package's root directory.

public get

A glob that matches the package's source files

public

Analyzes the package's source files and returns all of the invoked dependencies mapped to the files invoking them.

public

applyPatch(patch: Patch)

Applies a given patch to Package#packageJson.

public

Compares a dependency object (as returned from Package#analyzeSourceDependencies) with the dependencies listed in {@link Package@packageJson} and returns an array of patches.

public

Generates the patches that will satisfy Package#inherits

public

resolveDependency(dependency: string): string | boolean

Takes a dependency name and resolves it to the actual dependency name, stripping any subdirectories from the dependency name (retaining @org style dependencies).

public

Writes Package#packageJson to it's respective package.json file.

Static Public Methods

public static mergePatches(a: Patch, b: Patch): Patch source

Merges patches generated by child packages in order to apply to the parent package. This resolves conflicts that occur when applying patches generated by multiple sources.

Params:

NameTypeAttributeDescription
a Patch

A patch

b Patch

Another patch

Return:

Patch

The merged patch

Public Constructors

public constructor() source

Creates a new Comptroller instance. It accepts all of the arguments in Package#constructor as well as...

Override:

Package#constructor

Params:

NameTypeAttributeDescription
opts.config.packages string
  • optional
  • default: packages

The directory name where packages can be found.

Public Members

public get children: Package[] source

The child packages.

public get packages: string source

The packages directory.

Public Methods

public getChildByName(name: string): Package | boolean source

A convenience method that locates a package in Comptroller#children by it's name in Package#packageJson.

Params:

NameTypeAttributeDescription
name string

The name of the child package.

Return:

Package | boolean

The found package, or false if not found.

public async linkPackages() source

Links the packages to node_modules in a way that enables them to be resolved by other packages by name.

public logPatch(child: Package, patch: Patch) source

Logs patch operations.

Params:

NameTypeAttributeDescription
child Package

The child the patch is being applied to.

patch Patch

The patch being applied.

public readChildren(): Package[] source

Scans the Comptroller#packages directory, finds package.json files and generates Packages. Note that all package.json files must be in a direct subdirectory of the packages directory.

Return:

Package[]

The child packages.

public async updatePackages() source

Analyzes the dependencies and inherits of each package and applies the respective patches to each package.

public updatePatches(patches: Patch[]): Patch[] source

Takes an array of raw patches (returned by Package#generateDependencyPatches or Package#generateInheritPatches) and updates them with the information in the Comptroller#packageJson

Params:

NameTypeAttributeDescription
patches Patch[]

The patches to update.

Return:

Patch[]

The updated patches.

public async updateSelf() source

Analyzes the dependencies of the root package and applies the respective patches.

public async writePackages() source

Loops through all packages in Comptroller#children and writes it's package.json.