Class ModuleNameUtil
java.lang.Object
com.liferay.frontend.js.loader.modules.extender.npm.ModuleNameUtil
Provides utility methods to manipulate module names.
There are several concepts that must be understood when using this class:
-
module name: the name of an NPM module deployed to the portal
-
Syntax:
{module name} -
Example:
lib/index
-
Syntax:
-
module file name: the file name implementing an NPM module deployed to
the portal
-
Syntax:
{module file name} -
Example:
lib/index.js
-
Syntax:
-
package ID: the unique ID of an NPM package deployed to the portal
-
Syntax:
{bundle ID}/{package name}@{package version} -
Example:
625/isarray@1.0.0
-
Syntax:
-
module ID: the unique ID of an NPM module deployed to the portal
-
Syntax:
{bundle ID}/{package name}@{package version}/{module name} -
Example:
625/isarray@1.0.0/lib/index
-
Syntax:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDependencyPath(String moduleName, String dependency) Resolve dependency path based on current module's path.static StringgetModuleId(JSPackage jsPackage, String moduleName) Returns the module ID with the NPM package and module name.static StringgetModuleResolvedId(JSPackage jsPackage, String moduleName) Returns the module resolved ID with the NPM package and module name.static StringgetPackageName(String moduleName) Returns the package name portion of a full module name.static StringgetPackagePath(String moduleName) Returns the path portion of a full module name.static booleanisLocalModuleName(String moduleName) static booleanisReservedModuleName(String moduleName) static StringtoFileName(String moduleName) Returns the file name implementing the module.static StringtoModuleName(String fileName) Returns the module's name given the file name implementing it.
-
Constructor Details
-
ModuleNameUtil
public ModuleNameUtil()
-
-
Method Details
-
getDependencyPath
Resolve dependency path based on current module's path.- Parameters:
moduleName- the module's namedependency- the dependency's name- Returns:
- the full path of the dependency if it is local, the given dependency otherwise
-
getModuleId
Returns the module ID with the NPM package and module name.- Parameters:
jsPackage- the NPM packagemoduleName- the module's name- Returns:
- the module ID
-
getModuleResolvedId
Returns the module resolved ID with the NPM package and module name.- Parameters:
jsPackage- the NPM packagemoduleName- the module's name- Returns:
- the module ID
-
getPackageName
Returns the package name portion of a full module name.Example:
getPackageName("isarray/lib/index") returns "isarray"- Parameters:
moduleName- the module's name- Returns:
- the package name or
nullif the module name is a reserved or local one
-
getPackagePath
Returns the path portion of a full module name.Example:
getPackagePath("isarray/lib/index") returns "lib/index"- Parameters:
moduleName- the module's name- Returns:
- the path portion of a full module name or
nullin any other case
-
isLocalModuleName
-
isReservedModuleName
-
toFileName
Returns the file name implementing the module.- Parameters:
moduleName- the module's name- Returns:
- the file name
-
toModuleName
Returns the module's name given the file name implementing it.- Parameters:
fileName- the file name implementing the module- Returns:
- the module's name
-