bedrock-package-manager

1.2.0 • Public • Published

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

bedrock-package-manager

Typedefs

PackageInfo : Object

Package information.

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 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.

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 DuplicateError if 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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.2.0
    1
  • 1.1.0
    0
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i bedrock-package-manager

Weekly Downloads

3

Version

1.2.0

License

SEE LICENSE IN LICENSE.md

Unpacked Size

24 kB

Total Files

16

Last publish

Collaborators

  • davidlehn
  • msporny
  • dlongley
  • mattcollier
  • gannan