Utility methods that aids in running NPM
| Modifiers | Name | Description |
|---|---|---|
static boolean |
FORCE_NODE_DEFAULT_FOR_NPM |
Use this value to force the use of the bundled NPM rather than the version supplied by an NPM extension. |
static java.lang.String |
NPM_INSTALL |
| Constructor and description |
|---|
NpmExecutor
(org.ysb33r.grolifant.api.core.ProjectOperations projectOperations, NodeJSExtension nodeJS, NpmExtension npm, boolean forceNodeDefaultForNpm = false
)@param projectOperations Operations for the specific project context |
| Type Params | Return Type | Name and description |
|---|---|---|
|
org.gradle.api.file.FileTree |
calculateInstallableFiles(java.io.File rootPackageJson)Returns a live set of installable files. |
|
static org.ysb33r.gradle.nodejs.NpmExecSpec |
createNpmExecSpec(org.ysb33r.grolifant.api.core.ProjectOperations projectOperations, NodeJSExtension nodeJS, NpmExtension npm, boolean forceNodeDefaultForNpm = false
)Creates a org.ysb33r.gradle.nodejs.NpmExecSpec with default node & npm-cli.js locations. |
|
static org.ysb33r.gradle.nodejs.NpmExecSpec |
createNpmExecSpecWithDefaultEnvironment(org.ysb33r.grolifant.api.core.ProjectOperations projectOperations, NodeJSExtension nodeJS, NpmExtension npm, boolean forceNodeDefaultForNpm = false
)Creates an org.ysb33r.gradle.nodejs.NpmExecSpec with default node & npm-cli.js locations and then configure
an appropriate default environment. |
|
static java.util.Map<java.lang.String, java.lang.Object> |
environmentFromExtensions(NodeJSExtension nodeJS, NpmExtension npm)Creates an environment based up on extensions. |
|
java.io.File |
getPackageInstallationFolder(NpmPackageDescriptor npmPackageDescriptor)Works out where the installation folder will be for a executable. |
|
java.io.File |
initPkgJson(java.lang.String projectName, org.gradle.api.provider.Provider<java.lang.String> projectVersion)Creates a template package.json file. |
|
org.gradle.api.file.FileTree |
installNpmPackage(NpmPackageDescriptor npmPackageDescriptor, NpmDependencyGroup installGroup, java.lang.Iterable<java.lang.String> additionalArgs, java.util.Map<java.lang.String, java.lang.Object> additionalEnvironment = [:]
)Installs an NPM executable by running npmExt install in a controlled environment. |
|
org.gradle.api.file.FileTree |
installPackagesFromDescription(java.io.File packageJson, java.lang.Iterable<java.lang.String> additionalArgs, boolean productionOnly = false
)Installs packages from a package.json description. |
|
org.gradle.process.ExecResult |
runNpm(org.ysb33r.gradle.nodejs.NpmExecSpec es)Runs NPM given a fully-configured execution specification. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Use this value to force the use of the bundled NPM rather than the version supplied by an NPM extension. This is used with createNpmExecSpec and in the constructor
projectOperations - Operations for the specific project contextnodeJS - NodeJSExtension to use for resolving node location.npm - NpmExtension to use for resolving NPM-related activities.forceNodeDefaultForNpm - Whether to force the NPM to be used from the bundled NPM rather than
the one supplied by the NPM extension. Default is to use the version supplied by the NPM extension.Returns a live set of installable files.
This is an approximation. It parses the package.json file to discover dependencies, then
recursively parses all other package.json files it find in those dependencies.
rootPackageJson - Initial package.json file to start traversal.packageJson does not exist or is not in the
npmExtension.homeDirectoryProperty. Creates a org.ysb33r.gradle.nodejs.NpmExecSpec with default node & npm-cli.js locations.
projectOperations - Grolifant ProjectOperations instance to attach to specification.nodeJS - Node extensionnpm - NPM extensionforceNodeDefaultForNpm - Set to true to use the default NPM shipped with Node, rather than the
configured NPM version. Creates an org.ysb33r.gradle.nodejs.NpmExecSpec with default node & npm-cli.js locations and then configure
an appropriate default environment.
projectOperations - Grolifant ProjectOperations instance to attach to specification.nodeJS - Node extensionnpm - NPM extensionforceNodeDefaultForNpm - Set to true to use the default NPM shipped with Node, rather than the
configured NPM version.Creates an environment based up on extensions.
nodeJS - NodeJSExtension.npm - NpmExtension.Works out where the installation folder will be for a executable.
npmPackageDescriptor - Description of NPM executable Creates a template package.json file.
projectName - Name of the project.projectVersion - Version/tag of the project. Installs an NPM executable by running npmExt install in a controlled environment.
npmPackageDescriptor - Description of NPM executable.installGroup - Production, development of optional installation.additionalArgs - Any additional arguments that might be deemed necessary to customise the installation.
This is here to provide flexibility as the author cannot foresee all common use cases.
Should rarely be used. Should you find using this method regular occurrence it might be prudent to
to raise an issue to ask to a feature update and explaining the context in which this is needed.additionalEnvironment - Additional environmental settings when installing. This can be used to set the
system path variable if need be. Installs packages from a package.json description.
packageJson - Path to a package.json file.additionalArgs - Additional arguments to be passed to NPM install command.productionOnly - Only install the production packages.packageJson does not exist or is not in the
npmExtension.homeDirectoryProperty.Runs NPM given a fully-configured execution specification.
es - Specification to execute