UNPKG

@sap/cds-dk

Version:

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

35 lines (28 loc) 1.05 kB
const cds = require('../../../cds') const { read } = cds.utils const { readProject } = require('../../projectReader') const { merge } = require('../../merge') module.exports = class RedisMessagingTemplate extends require('../../plugin') { static help() { return 'messaging via Redis' } requires() { return ['redis'] } async canRun() { const { hasMta, hasHelm, hasHelmUnifiedRuntime, isJava } = readProject() const onlyHelm = !hasMta && (hasHelmUnifiedRuntime || hasHelm) if (isJava) throw `'cds add redis-messaging' is not available for Java yet` if (onlyHelm) throw `'cds add redis-messaging' is not available for Kyma yet` return true } static hasInProduction(env) { return env.requires?.messaging?.kind === 'redis-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, { project }) } }