Package
Direct Subclass:
This is the package class. It serves as encapsulation for individual packages, as a means of querying for package info, and as an outlet for changes to a package.
Static Method Summary
Static Public Methods | ||
public static |
generateExcludes(excludes: Array<string|object>): * Generates an exclude array |
Constructor Summary
Public Constructor | ||
public |
constructor(opts: object) Creates a new package instance. |
Member Summary
Public Members | ||
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 |
Method Summary
Public Methods | ||
public |
async analyzeSourceDependencies(): Map<string, object> 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 |
generateDependencyPatches(dependencies: object): Patch[] 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 |
async writePackageJson() Writes Package#packageJson to it's respective package.json file. |
Static Public Methods
Public Constructors
public constructor(opts: object) source
Creates a new package instance. It can accept it's configuration either through the package.json file or through the constructor arguments.
Params:
Name | Type | Attribute | Description |
opts | object | The package options. |
|
opts.root | string | The root directory of the package. |
|
opts.packageJson | object |
|
The package's package.json. If not specified, it's read from the root directory. |
opts.config | object |
|
The Comptroller configurations options. |
opts.config.source | glob |
|
A glob that selects the packages source files. |
opts.config.dev | glob |
|
A glob that selects the packages that should also include devDependencies |
opts.config.ignore | glob[] |
|
An array
of globs to pass into glob's |
opts.config.exclude | Array<string|object> |
|
An array of package names to ignore in all operations. Defaults to builtin-modules. |
opts.config.inherits | string[] |
|
An array of field names to inherit from the parent package.json. This is useful for values that remain the same across all packages. |
opts.config.detective | object |
|
The options to pass through to detective. |
opts.config.prune | boolean |
|
Whether or not unused dependencies should be pruned from the package.json. |
opts.config.pretty | boolean | number |
|
The "maximum fixed character width" parameter to pass to json-beautify. |
Public Members
public get ignore: glob[] source
An array of globs that match files not to be included with the package's source files.
public get inherits: string[] source
An array of field names the package should inherit from it's parent package.json.
public get pretty: boolean | number source
The "maximum fixed character width" parameter to pass to json-beautify.
Public Methods
public async analyzeSourceDependencies(): Map<string, object> source
Analyzes the package's source files and returns all of the invoked dependencies mapped to the files invoking them.
public applyPatch(patch: Patch) source
Applies a given patch to Package#packageJson.
Params:
Name | Type | Attribute | Description |
patch | Patch | The patch to apply, |
public generateDependencyPatches(dependencies: object): Patch[] source
Compares a dependency object (as returned from Package#analyzeSourceDependencies) with the dependencies listed in {@link Package@packageJson} and returns an array of patches.
Params:
Name | Type | Attribute | Description |
dependencies | object | The dependencies to generate a patch for. |
public generateInheritPatches(): Patch[] source
Generates the patches that will satisfy Package#inherits
public resolveDependency(dependency: string): string | boolean source
Takes a dependency name and resolves it to the actual dependency name, stripping any subdirectories from the dependency name (retaining @org style dependencies). It also excludes dependencies with relative paths (./ or ../ style) and any dependencies listed in Package#exclude
Params:
Name | Type | Attribute | Description |
dependency | string | The dependency to resolve |
Return:
string | boolean | The resolved dependency name, or false if the the dependency is excluded. |
public async writePackageJson() source
Writes Package#packageJson to it's respective package.json file.