bedrock-package-manager
v1.2.0
Published
Bedrock package manager
Keywords
Readme
bedrock-package-manager
Usage
A package should register itself using a Bedrock event handler.
bedrock.events.on('bedrock.init', () => {
brPackageManager.register({
alias: 'mockPackage',
meta: {
optional: 'meta values',
},
packageName: 'bedrock-package-manager-mock-package',
type: 'bedrock-mock-plugin',
});
});Use a registered package in an API.
exports.getReports = async ({query = {}, storageApi}) => {
// storageApi === 'mockPackage' would match the registration shown above
const pkg = brPackageManager.get({alias: storageApi, type: 'bedrock-mock-plugin'});
const storage = require(pkg.packageName);
return storage.find(query);
};API Reference
Modules
Typedefs
bedrock-package-manager
bedrock-package-manager.get(options) ⇒ PackageInfo
Get package information. One of alias or packageName is required.
Kind: static method of bedrock-package-manager
Returns: PackageInfo - The package information.
Throws:
- BedrockError Will throw a
NotFoundErrorif the package is not found.
| Param | Type | Description | | --- | --- | --- | | options | Object | The options to use. | | options.type | string | The package type. | | [options.alias] | string | The package alias. | | [options.packageName] | string | The package name. |
bedrock-package-manager.findType(options) ⇒ Array.<PackageInfo>
Find packages by type.
Kind: static method of bedrock-package-manager
Returns: Array.<PackageInfo> - The package information.
| Param | Type | Description | | --- | --- | --- | | options | Object | The options to use. | | options.type | string | The package type to find. |
bedrock-package-manager.register(options) ⇒ undefined
Register a package.
Kind: static method of bedrock-package-manager
Throws:
- BedrockError Will throw a
DuplicateErrorif the package is already registered.
| Param | Type | Default | Description | | --- | --- | --- | --- | | options | Object | | The options to use. | | options.packageName | string | | The NPM package name. | | options.type | string | | The package type. | | [options.meta] | Object | {} | Domain specific meta data. | | [options.alias] | string | | The package alias. A short name for the package (e.g. 'mongodb', 'redis'). |
PackageInfo : Object
Package information.
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | alias | string | The package alias. A short name for the package (e.g. 'mongodb', 'redis'). | | packageName | string | The NPM package name. | | type | string | The package type. | | meta | Object | Domain specific meta data. |
