@groovy.transform.CompileStatic @groovy.util.logging.Slf4j class BaseNpmExtension<T extends BaseNodeJSExtension<T>, S extends BaseNpmExtension<T, S>> extends org.ysb33r.grolifant5.api.core.runnable.AbstractToolExtension<S> implements NpmExtensionMethods, org.ysb33r.grolifant5.api.core.runnable.ProvisionedExecMethods<NpmExecSpec>
Set up global config or task-based config for NPM.
| Type | Name and description |
|---|---|
org.ysb33r.grolifant5.api.core.ConfigCacheSafeOperations |
configCacheSafeOperations |
File |
globalConfig |
File |
homeDirectory |
File |
localConfig |
| Constructor and description |
|---|
protected BaseNpmExtension
(Project project, T nodejs)Adds the extension to the project. |
protected BaseNpmExtension
(Task task, T nodejs, S altNpmExt)Adds the extension to a NpmTask task. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
NpmExecSpec |
createExecSpec()Create execution specification. |
|
void |
executableIsBundled()Use the NPM that is bundled with Node. |
|
protected org.ysb33r.grolifant5.api.core.downloader.ExecutableDownloader |
getDownloader()Gets the downloader implementation. |
|
File |
getGlobalConfig()Location & name of global NPM config file. |
|
Provider<File> |
getGlobalConfigProvider()Location & name of global NPM config file. |
|
File |
getHomeDirectory()The NPM home directory - the parent directory of node_modules, |
|
Provider<File> |
getHomeDirectoryProvider()The NPM home directory - the parent directory of node_modules, |
|
File |
getLocalConfig()Location & name of local NPM config file. |
|
Provider<File> |
getLocalConfigProvider()Location & name of local NPM config file. |
|
protected String |
getNodeJsExtensionName()Returns the name of the extension to look for when trying to find the Node.js extension. |
|
protected String |
getNpmProjectExtensionName()Returns the name of the extension to look for when trying to find the Npm extension. |
|
Provider<File> |
getNpxCliJsProvider()The location of NPX. |
|
Provider<File> |
getProjectConfig()Location of .npmrc for a project. |
|
Provider<File> |
getProjectConfigProvider() |
|
Provider<String> |
getVersionProvider()Provides the version as specified in package.json. |
|
void |
globalConfig(Object path)Set global config file. |
|
void |
homeDirectory(Object homeDir)Sets the home directory. |
|
void |
localConfig(Object path)Set local config file. |
|
protected String |
runExecutableAndReturnVersion()Runs the executable and returns the version. |
|
void |
setGlobalConfig(Object path)Set global config file. |
|
void |
setHomeDirectory(Object homeDir)Sets the home directory. |
|
void |
setLocalConfig(Object path)Set local config file. |
|
Provider<File> |
useGlobalGradleLocation()Sets it to use the equivalent of getGradleHomeDir()/.npmrc. |
|
Provider<File> |
useGlobalSystemLocation()Tries to determine the location where global config will typically be places. |
|
Provider<File> |
useLocalProjectLocation()Use to indicate that userconfig should be retrieved from the NPM home directory as configured by getHomeDirectory(). |
|
Provider<File> |
useLocalUserProfileLocation()Use to indicate that userconfig should be retrieved from the user's home directory. |
|
void |
usePackageJsonVersionAsProjectVersion()Use the version specified in package.json as the version of the project. |
Adds the extension to the project.
project - Project to link to.nodejs - NodeJS extension to use.Adds the extension to a NpmTask task.
Links the executable resolving to the global instance, but allows it to be overridden on a per-task basis.
task - Task to be extended.nodejs - Alternative NodeJS extension to use as project extension.altNpmExt - Alternative Npm extension to use as project extension.Create execution specification.
Use the NPM that is bundled with Node. This is the default and should rarely be required.
Gets the downloader implementation. Can throw an exception if downloading is not supported.
Location & name of global NPM config file.
When this extension is attached to a project, the default location is set to
"${project.gradle.gradleUserHomeDir/npmrc"}
Location & name of global NPM config file.
When this extension is attached to a project, the default location is set to
"${project.gradle.gradleUserHomeDir/npmrc"}
The NPM home directory - the parent directory of node_modules,
node_modules. Never null if the extension is tied to a project,
in which case it defaults to project.projectDir.The NPM home directory - the parent directory of node_modules,
node_modules. Never null if the extension is tied to a project,
in which case it defaults to project.projectDir. Location & name of local NPM config file.
When this extension is attached to a project, the default location is set to
"${project.rootProject.projectDir/npmrc"}
Location & name of local NPM config file.
When this extension is attached to a project, the default location is set to
"${project.rootProject.projectDir/npmrc"}
Returns the name of the extension to look for when trying to find the Node.js extension.
Returns the name of the extension to look for when trying to find the Npm extension.
The location of NPX.
Provides the version as specified in package.json.
Set global config file.
path - Anything that can be converted using project.file.Sets the home directory.
homeDir - A directory in which node_modules will be created as a child folder.
Anything that can be resolved with project.file is acceptableSet local config file.
path - Anything that can be converted using project.file.Runs the executable and returns the version. See org.ysb33r.grolifant5.internal.core.executable.ExecUtils#parseVersionFromOutput as a helper to implement this method.
Set global config file.
path - Anything that can be converted using project.file.Sets the home directory.
homeDir - A directory in which node_modules will be created as a child folder.
Anything that can be resolved with project.file is acceptableSet local config file.
path - Anything that can be converted using project.file. Sets it to use the equivalent of getGradleHomeDir()/.npmrc.
This allows Gradle projects to be custom configured on local system without being affected by any system-wide
node installations.
Tries to determine the location where global config will typically be places.
Use to indicate that userconfig should be retrieved from the NPM home directory as configured by getHomeDirectory().
.npmrc Use to indicate that userconfig should be retrieved from the user's home directory.
Typically this is ~/.npmrc or %APPDATA\npm\.npmrc
.npmrc Use the version specified in package.json as the version of the project.
If package.json does not exist, then undefined is used as the version.
Groovy Documentation