Bedrock package manager
npm install @bedrock/package-managerjs
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.
`js
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 = await import(pkg.packageName);
return storage.find(query);
};
`API Reference
Modules
Typedefs
- PackageInfo :
Object
Package information.
bedrock-package-manager
* bedrock-package-manager
* .get(options) ⇒ PackageInfo
* .findType(options) ⇒ Array.<PackageInfo>
* .register(options) ⇒ undefined
$3
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
NotFoundError if 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. |
$3
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. |
$3
Register a package.Kind: static method of bedrock-package-manager
Throws:
- BedrockError Will throw a
DuplicateError` if the package is
| 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'). |
ObjectKind: 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. |