Skip to content

Latest commit

 

History

History
587 lines (349 loc) · 24.5 KB

DOCUMENTATION.md

File metadata and controls

587 lines (349 loc) · 24.5 KB

Table of Contents

PackageInstaller

Method to prepare and install local packages into other local packages

installLocalDependency

Copy all the files of a local dependency to the node_modules folder of the targeted package

Parameters

  • currentPackage LocalPackage
  • dependencyPackage LocalPackage
  • clearDirectory boolean If set to true, the directory in which the dependency is installed is cleared

Returns void

installLocalDependencyBinaries

Create symlinks for the binary commands defined by a local dependency to the node_modules/.bin folder of the targeted package

Parameters

Returns void

getMissingRemoteDependencies

Find all the missing dependencies for the targeted node by checking if the corresponding directory exists in its node_module folder. When computing a list of required dependencies, it also includes the dependencies defined by all of the node's children packages.

Parameters

Returns Array<PackageReference>

installRemoteDependencies

Install the remote dependencies via NPM for the targeted package

Parameters

Returns void

prepublish

Run the prepublish script (if it exists) via NPM for the targeted package

Parameters

PackageWatcher

Extends EventEmitter

Watch the files for the provided list of local packages

Parameters

registerOnChange

Register a callback for the change event

Parameters

unregisterOnChange

Unregister a callback for the change event

Parameters

findPackageByPath

Find the package that best matches the provided file path

Parameters

Returns any

Model

Models used throughout the project

LocalPackage

Extends PackageReference

Contains the information from a parsed npm package

Parameters

  • params Object
    • params.name string The package's name
    • params.version string The package's version
    • params.path string The package's path
    • params.children Array<PackageReference> The package's children (optional, default [])
    • params.devDependencies Array<PackageReference> The package's development children (optional, default [])
    • params.script Array<string> An array of scripts that can be run via NPM and the values are paths to the local file name (optional, default [])
    • params.bin Object<string, string> An object in which the keys are command name (optional, default {})

getBinaries

Get the available command name and their mapping to the local file name

Returns Object<string, string>

getDependencies

Get the children for the package.

Parameters

  • dev boolean If set to true, also include the development children (optional, default false)

Returns Array<PackageReference>

getScripts

Get the scripts that can be run via NPM

Returns Array<string>

getPath

Get the package's path

Returns string

toObject

Convert the instance properties to an object

Returns {name: string, version: string, path: string, dependencies: Array<PackageReference>?, devDependencies: Array<PackageReference>?, scripts: Array<string>?, bin: {}?}

LocalPackageConfig

Extends LocalPackage

A configured local package

Parameters

  • params Object
    • params.name string The package's name
    • params.version string The package's version
    • params.path string The package's path
    • params.children Array<PackageReference> The package's children (optional, default [])
    • params.devDependencies Array<PackageReference> The package's development children (optional, default [])
    • params.script Array<string> An array of scripts that can be run via NPM (optional, default [])
    • params.bin Object<string, string> An object in which the keys are command name (optional, default {})
    • params.watchEnabled boolean If set to true, the package will be watched for changes and the values are paths to the local file name

isWatchEnabled

True if the package should be watched

Returns boolean

LocalPackageDependencyTree

This data structure stores the children (available locally) of packages. Each node is a local package and its children are children of that package which are available locally.

Parameters

iterator

Get an iterator to go over each node in the tree

Parameters

  • includeRoot boolean If set to false, the root node is not part of the iterator (optional, default true)

Returns Iterable<LocalPackageDependencyTreeNode<T>>

create

Build a dependency tree from a root package and a list of local packages available locally.

Parameters

  • rootPackage T
  • localPackages Array<T>

Returns LocalPackageDependencyTree<T>

LocalPackageDependencyTreeNode

A node within the LocalPackageDependencyTree. Each node corresponds to a local package and the node's children are its children

Parameters

getChildren

Get the direct children of this node

Returns Array<LocalPackageDependencyTreeNode<T>>

getPackage

Get the package corresponding to this node

Returns T

getDepth

Get the depth of the node

Returns number

iterator

Get an iterator to go over all children under this node

Returns Iterable<LocalPackageDependencyTreeNode<T>>

LocalPackageState

Extends LocalPackage

A configured local package

Parameters

  • params Object
    • params.name string The package's name
    • params.version string The package's version
    • params.path string The package's path
    • params.children Array<PackageReference> The package's children (optional, default [])
    • params.devDependencies Array<PackageReference> The package's development children (optional, default [])
    • params.script Array<string> An array of scripts that can be run via NPM (optional, default [])
    • params.bin Object<string, string> An object in which the keys are command name and the values are paths to the local file name (optional, default {})

isReady

True if the package is ready to be installed

Returns boolean

setReady

Update the ready state of the package

Parameters

Returns LocalPackageState

isWatchEnabled

True if watching the package for changes is enabled

Returns boolean

setWatchEnabled

Enable/disable watching the package

Parameters

  • enabled boolean (optional, default true)

Returns LocalPackageState

getTimeoutHandle

Get the timeout handle

Returns number?

setTimeoutHandle

Set the timeout handle

Parameters

Returns LocalPackageState

PackageReference

A reference to an external npm package

Parameters

  • params Object
    • params.name string The package's name
    • params.version string The package's version

getName

Get the package's name

Returns string

getVersion

Get the package's version

Returns string

toString

Convert the package reference to a descriptive string including its name and version.

Returns string

IO

Classes to read/write files

FSUtil

Utility methods to interact with the local file system

exists

Check if a file or directory exists

Parameters

  • absolutePath string {string} The absolute path to the file or directory

Returns boolean True if the file or directory exists

isFile

Check if a file exists

Parameters

  • absolutePath string {string} The absolute path to the file

Returns boolean True if the file exists

isDirectory

Check if a directory exists

Parameters

  • absolutePath string {string} The absolute path to the directory

Returns boolean True if the directory exists

PackageConfigReader

Utility methods to interact with the .ucrc file

read

Read the .ucrc file and instantiate an array of LocalPackageConfig

Parameters

Returns Array<LocalPackageConfig>

PackageConfigWriter

Utility method for writing the .ldrc

write

Write the configuration to the .ldrc file

Parameters

PackageFinder

Contains utility methods to find local packages

findPackages

Recursively search the provided paths for valid npm packages. It ignores any 'node_modules' folder.

Parameters

  • searchPaths Array<string> {Array} The paths in which npm packages will be looked up

Returns Array<LocalPackage> The local packages found

PackageReader

Utility method to read/parse npm modules

read

Parse the package.json file in the provided package path and create an instance of LocalPackage

Parameters

Returns LocalPackage

exists

Determines if the provided path contains a valid npm module

Parameters

Returns boolean

parseDependencies

Create an array of PackageReference from the 'devDependencies' or 'children' entry of a package.json file.

Parameters

  • dependencies Object<string, string> An object in which the keys are the package names and the values are the package version

Returns Array<PackageReference>

UI

Classes to interact with the user

PromptUtil

Utility methods to interact with the user via command line prompts

confirm

Prompt the user to confirm a message. If the message is accepted, the returned promise resolves successfully otherwise it is rejected.

Parameters

  • message string The message to be displayed to the user
  • skip boolean If set to true, the prompt is not be displayed and the message is accepted

Returns Promise

getPackagePath

Prompt the user to select a valid package path.

Parameters

  • defaultPath string {string} The default path to the package

Returns Promise<string> A promise that resolves to a valid npm package path

getPackageSearchPath

Prompt the user to select 1 or more directories in which local project will be located

Parameters

  • defaultPath string {string} The default path

Returns Promise<Array<string>> A promise that resolves to 1 or more existing directories

confirmDependencyPackages

Show a prompt allowing the user to select a list of local packages that will be installed by this module.

Parameters

Returns Promise<Array<LocalPackage>>

selectWatchedPackages

Show a prompt allowing the user to select a list of local packages that will be watched by this module.

Parameters

Returns Promise