UNPKG

@sap/cds-dk

Version:

Command line client and development toolkit for the SAP Cloud Application Programming Model

32 lines (30 loc) 1.19 kB
const cds = require('../cds') const Plugin = require('./plugin') const DEBUG = cds.debug('cli|build') module.exports = new (class Plugins { constructor() { this._plugins = new Map() this._registerDefaults() } get plugins() { return this._plugins } register(id, plugin) { if (!id || !plugin) { throw new Error(`Invalid parameter passed, build plugin id: ${id}`) } if (this._plugins.has(id)) { throw new Error(`CDS build plugin ${id} already registered`) } if(!(plugin.prototype instanceof Plugin)) { // with cds-dk version 7 the following registration format was supported: // cds.build.register("cov2ap", { impl: "@cap-js-community/odata-v2-adapter/src/build.js", taskDefaults: { src: "srv" } }) throw `The cds build plugin '${id}' is not compatible with this @sap/cds-dk version. Update the npm package '${plugin.impl || id}' to the latest version.` } DEBUG?.(`Registering build plugin ${id}`) this._plugins.set(id, plugin) } _registerDefaults() { this.register('helm', require('./plugins/helm')) } })