1.2.0 • Published 2 years ago

bedrock-package-manager v1.2.0

Weekly downloads
239
License
SEE LICENSE IN LI...
Repository
github
Last release
2 years ago

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 NotFoundError if the package is not found.
ParamTypeDescription
optionsObjectThe options to use.
options.typestringThe package type.
options.aliasstringThe package alias.
options.packageNamestringThe 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.

ParamTypeDescription
optionsObjectThe options to use.
options.typestringThe 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.
ParamTypeDefaultDescription
optionsObjectThe options to use.
options.packageNamestringThe NPM package name.
options.typestringThe package type.
options.metaObject{}Domain specific meta data.
options.aliasstringThe package alias. A short name for the package (e.g. 'mongodb', 'redis').

PackageInfo : Object

Package information.

Kind: global typedef
Properties

NameTypeDescription
aliasstringThe package alias. A short name for the package (e.g. 'mongodb', 'redis').
packageNamestringThe NPM package name.
typestringThe package type.
metaObjectDomain specific meta data.
1.2.0

2 years ago

1.1.0

3 years ago

1.0.1

4 years ago

1.0.0

5 years ago