@sap/cds-dk
Version:
Command line client and development toolkit for the SAP Cloud Application Programming Model
29 lines (23 loc) • 837 B
JavaScript
const cds = require('../../../cds')
const { read } = cds.utils
const { readProject } = require('../../projectReader')
const { merge } = require('../../merge')
module.exports = class LocalMessagingTemplate extends require('../../plugin') {
static help() {
return 'messaging via local event bus'
}
async canRun() {
const { isJava } = readProject()
if (isJava) throw `'cds add local-messaging' is not available for Java yet`
return true
}
static hasInProduction(env) {
return env.requires?.messaging?.kind === 'local-messaging'
}
async run() {
const project = readProject()
const { configFile } = project
project.shortcut = typeof (await read(configFile)).cds?.requires?.messaging !== 'object'
await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
}
}