@sap/cds-dk
Version:
Command line client and development toolkit for the SAP Cloud Application Programming Model
54 lines (44 loc) • 1.54 kB
JavaScript
const { readProject } = require('../../projectReader')
const { merge } = require('../../merge')
const { srv4, attachments } = require('../../registries/mta')
module.exports = class AttachmentsTemplate extends require('../../plugin') {
static help() {
return 'SAP BTP Object Store Service'
}
requires() {
return ['malware-scanner']
}
static hasInProduction(env) {
return !!env.requires?.attachments
}
async canRun() {
const { isJava } = readProject()
if (isJava) throw `'cds add attachments' is not available for Java yet`
return true
}
async run() {
const project = readProject()
const { isNodejs } = project
if (isNodejs) {
await merge(__dirname, 'files/package.json.hbs').into('package.json')
}
}
async combine() {
const project = readProject()
const { hasMta, hasHelm, hasHelmUnifiedRuntime, srvPath } = project
if (hasMta) {
const srv = srv4(srvPath)
const additions = [srv, attachments]
const relationships = [{
insert: [attachments, 'name'],
into: [srv, 'requires', 'name']
}]
await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', {
with: project, additions, relationships
})
}
if (hasHelm || hasHelmUnifiedRuntime) {
await merge(__dirname, 'files', 'values.yaml').into('chart/values.yaml')
}
}
}