Name | Description |
---|---|
Loader | Utility to load plugins, presets, and other modules with associated metadata |
PackageIdentifier | Utility class for working with package names and versions |
Resolver | Utility to help resolve and require modules |
Name | Description |
---|---|
pluginIdentifier() | Create package identifiers for Gasket plugins |
presetIdentifier() | Create package identifiers for Gasket presets |
projectIdentifier(projectName, [type]) | Create function used to make instances of PackageIdentifier for a project |
Name | Description |
---|---|
PluginDesc | The package name with or without version of a plugin. |
PresetDesc | The package name with or without version of a preset. |
PluginName | The package name only of a plugin. |
PresetName | The package name only of a preset. |
ModuleInfo | Module with meta data |
PluginInfo | Plugin module with meta data |
PresetInfo | Preset module with meta data |
createPackageIdentifier | Create a new PackageIdentifier instance |
Utility to load plugins, presets, and other modules with associated metadata
Kind: global class
Extends: Resolver
Loads a module with additional metadata
Kind: instance method of Loader
Returns: ModuleInfo
- module
Param | Type | Description |
---|---|---|
module | string |
Module content |
moduleName | string |
Name of module to load |
[meta] | object |
Additional meta data |
Loads a module with additional metadata
Kind: instance method of Loader
Returns: ModuleInfo
- module
Param | Type | Description |
---|---|---|
moduleName | string |
Name of module to load |
[meta] | object |
Additional meta data |
Loads a plugin with additional metadata.
Kind: instance method of Loader
Returns: PluginInfo
- module
Param | Type | Description |
---|---|---|
module | PluginName | object |
Name of module to load (or module content) |
[meta] | object |
Additional meta data |
Loads a preset with additional metadata
Kind: instance method of Loader
Returns: PresetInfo
- module
Param | Type | Description |
---|---|---|
module | PresetName |
Name of module to load |
[meta] | object |
Additional meta data |
[options] | boolean |
Loading options |
[options.shallow] | boolean |
Do not recursively load dependencies |
Loads presets and plugins as configured. Plugins will be filtered and ordered as configuration with priority of:
- added plugins > preset plugins > nested preset plugins
Kind: instance method of Loader
Returns: Object
- results
Param | Type | Description |
---|---|---|
config | object |
Presets and plugins to load |
config.presets | Array.<PresetName> |
Presets to load and add plugins from |
config.add | Array.<PluginName> | Array.<module> |
Names of plugins to load |
config.remove | Array.<string> |
Names of plugins to remove (from presets) |
Returns the resolved module filename
Kind: instance method of Loader
Overrides: resolve
Returns: string
- filename of the module
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Returns the required module
Kind: instance method of Loader
Overrides: require
Returns: object
- module contents
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Returns the resolved module filename, or null if not found
Kind: instance method of Loader
Overrides: tryResolve
Returns: string
⎮ null
- filename of the module
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Returns the required module, or null if not found
Kind: instance method of Loader
Overrides: tryRequire
Returns: object
⎮ null
- module contents
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Utility class for working with package names and versions
Kind: global class
Get the package name as provided to the identifier
Kind: instance property of PackageIdentifier
Returns: string
- rawName
Get the long package name
Examples:
- @gasket/[email protected] -> @gasket/plugin-https
- @gasket/https -> @gasket/plugin-https
- @user/https -> @user/gasket-plugin-https
- https -> gasket-plugin-https
Kind: instance property of PackageIdentifier
Returns: string
- fullName
Alias to this.fullName
Kind: instance property of PackageIdentifier
Returns: string
- fullName
Get the short package name
Examples:
- @gasket/plugin-https -> @gasket/https
- @user/gasket-plugin-https -> @user/https
- [email protected] -> https
Kind: instance property of PackageIdentifier
Returns: string
- fullName
Get only the package name
Examples:
- @gasket/[email protected] -> @gasket/plugin-https
- [email protected] -> https
Kind: instance property of PackageIdentifier
Returns: string
- fullName
Get only the package version
Examples:
- @gasket/[email protected] -> 1.2.3
- @gasket/plugin-https -> ''
Kind: instance property of PackageIdentifier
Returns: string
- fullName
Get the full package name with version
Examples:
- @gasket/[email protected] -> @gasket/[email protected]
- [email protected] -> @gasket/[email protected]
Kind: instance property of PackageIdentifier
Returns: string
- fullName
Returns new PackageIdentifier with version added to desc if missing
Examples:
- @gasket/[email protected] -> @gasket/[email protected]
- @gasket/plugin-https -> @gasket/plugin-https@latest
Kind: instance method of PackageIdentifier
Returns: PackageIdentifier
- identifier
Param | Type | Default | Description |
---|---|---|---|
[defaultVersion] | string |
'latest' |
the version name to add if missing |
If the rawName is a short name, get a new identifier, cycling through formats which can be used to attempt to resolve packages by different name pattern.
Examples:
- example -> gasket-plugin-example > example-gasket-plugin > @gasket/plugin-example > @gasket/example-plugin
- @gasket/example -> @gasket/plugin-example > @gasket/example-plugin
- @user/example -> @user/gasket-plugin-example > @user/example-gasket-plugin
Kind: instance method of PackageIdentifier
Returns: PackageIdentifier
⎮ null
- identifier
Utility to help resolve and require modules
Kind: global class
Param | Type | Description |
---|---|---|
options | object |
Options |
[options.resolveFrom] | string | Array.<string> |
Path(s) to resolve modules from |
[options.require] | require |
Require instance to use |
Returns the resolved module filename
Kind: instance method of Resolver
Returns: string
- filename of the module
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Returns the required module
Kind: instance method of Resolver
Returns: object
- module contents
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Returns the resolved module filename, or null if not found
Kind: instance method of Resolver
Returns: string
⎮ null
- filename of the module
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Returns the required module, or null if not found
Kind: instance method of Resolver
Returns: object
⎮ null
- module contents
Param | Type | Description |
---|---|---|
moduleName | string |
name of the module |
Create package identifiers for Gasket plugins
Kind: global function
Create package identifiers for Gasket presets
Kind: global function
Create function used to make instances of PackageIdentifier for a project
The projectName
and type
are components of the naming convention such as
- @/-
- @/--
- --
If a package belongs to the project, it should use projectName
in its scope.
For user plugins, the projectName
will be paired with the type
.
Kind: global function
Returns: function
- function to make
Param | Type | Default | Description |
---|---|---|---|
projectName | string |
Name of the project scope and base name | |
[type] | string |
'plugin' |
Defaults to 'plugin'. |
Setup project level variables
Kind: inner method of projectIdentifier
Returns: object
- vars
The package name with or without version of a plugin.
For example:
- @gasket/plugin-https - fullName
- @gasket/https - shortName
- @gasket/plugin-https@^1.2.3 - full with version
- @gasket/https@^1.2.3 - short with version
- gasket-plugin-https - user fullName
- https - user shortName
Not intended for use with non-plugin package descriptions. For example, the following patterns will not work:
- @gasket/https
Kind: global typedef
The package name with or without version of a preset.
For example:
- @gasket/preset-nextjs - fullName
- @gasket/nextjs - shortName
- @gasket/preset-nextjs@^1.2.3 - full with version
- @gasket/nextjs@^1.2.3 - short with version
- gasket-preset-nextjs - user fullName
- nextjs - user shortName
Kind: global typedef
The package name only of a plugin.
For example:
- @gasket/plugin-https - fullName
- @gasket/https - shortName
- gasket-plugin-https - user fullName
- https - user shortName
Kind: global typedef
The package name only of a preset.
For example:
- @gasket/preset-nextjs - fullName
- @gasket/nextjs - shortName
- gasket-preset-nextjs - user fullName
- nextjs - user shortName
Kind: global typedef
Module with meta data
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
name | string |
Name of preset |
module | string |
Actual module content |
[package] | string |
Package.json contents |
[version] | string |
Resolved version |
[path] | string |
Path to the root of package |
[from] | string |
Name of module which requires this module |
[range] | string |
Range by which this module was required |
Plugin module with meta data
Kind: global typedef
Preset module with meta data
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
presets | Array.<PresetInfo> |
Presets that this preset extends |
plugins | Array.<PluginInfo> |
Plugins this preset uses |
Create a new PackageIdentifier instance
Kind: global typedef
Returns: PackageIdentifier
- instance
Param | Type | Description |
---|---|---|
rawName | string |
Original input name of a package |
[options] | object |
Options |
[options.prefixed] | boolean |
Set this to force prefixed format for short names |
Static util method to check if a full name is valid
Examples:
- @gasket/plugin-https -> true
- @gasket/[email protected] -> false
- https -> false
Kind: static method of createPackageIdentifier
Returns: boolean
- fullName
Param | Type | Description |
---|---|---|
maybeFullName | string |
Name to check |
Static util method to loop through format options for short names. The handler will be provide the next formatted identifier to try, which should return falsy to continue, or return truthy to end and return the current identifier. If the lookup runs out of formats to try, it will return null.
Kind: static method of createPackageIdentifier
Returns: PackageIdentifier
⎮ null
- identifier if found or null
Param | Type | Description |
---|---|---|
name | string |
Name to check |
handler | function |
Attempt to find package current format |