UNPKG

@sap/cds-dk

Version:

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

45 lines (37 loc) 1.22 kB
const { readProject } = require('../../projectReader') const { merge } = require('../../merge') const { srv4, redis } = require('../../registries/mta') module.exports = class extends require('../../plugin') { static help() { return 'SAP BTP Redis, Hyperscaler Option' } async canRun() { const { hasMta, hasHelm, hasHelmUnifiedRuntime, isJava } = readProject() const onlyHelm = !hasMta && (hasHelmUnifiedRuntime || hasHelm) if (isJava) throw `'cds add redis' is not available for Java yet` if (onlyHelm) throw `'cds add redis' is not available for Kyma yet` return true } static hasInProduction() { const { dependencies } = readProject() return !!dependencies?.['redis'] } async run() { await merge(__dirname, 'files/package.json.hbs').into('package.json') } async combine() { const project = readProject() const { hasMta, srvPath } = project if (hasMta) { const srv = srv4(srvPath) await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { project, additions: [srv, redis], relationships: [{ insert: [redis, 'name'], into: [srv, 'requires', 'name'] }] }) } } }