UNPKG

@sap/cds-dk

Version:

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

61 lines (53 loc) 2.19 kB
const { readProject } = require('../../projectReader') const { merge } = require('../../merge') const { srv4, mtxSidecar4, applicationLogging, approuter } = require('../../registries/mta') const mvn = require('../../mvn') module.exports = class ApplicationLoggingTemplate extends require('../../plugin') { static help() { return 'SAP BTP Application Logging Service' } static hasInProduction(env) { return !!env.requires?.['application-logging'] } async canRun() { const { hasMta, hasHelm, hasHelmUnifiedRuntime } = readProject() if ((hasHelmUnifiedRuntime || hasHelm) && !hasMta) throw `'cds add application-logging' is not available for Kyma yet` return true } async run() { const project = readProject() const { isJava, configFile } = project await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project }) if (isJava) await mvn.add('APPLICATION_LOGGING') } async combine() { const project = readProject() const { hasMta, hasApprouter, isJava, hasMultitenancy, srvPath } = project if (hasMta) { const srv = srv4(srvPath) const additions = [srv, applicationLogging] const relationships = [{ insert: [applicationLogging, 'name'], into: [srv, 'requires', 'name'] }] if (hasMultitenancy) { const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar') additions.push(mtxSidecar) relationships.push({ insert: [applicationLogging, 'name'], into: [mtxSidecar, 'requires', 'name'] }) } if (hasApprouter) { additions.push(approuter) relationships.push({ insert: [applicationLogging, 'name'], into: [approuter, 'requires', 'name'] }) } await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { with: project, additions, relationships }) } } }