@sap/cds-dk
Version:
Command line client and development toolkit for the SAP Cloud Application Programming Model
36 lines (30 loc) • 1.11 kB
JavaScript
const { join } = require('path')
const cds = require('../../../cds')
const { exists } = require('../../../cds').utils
const { readProject } = require('../../projectReader')
const { renderAndCopy } = require('../../template')
const mvn = require('../../mvn')
const MANIFEST_FILE = 'manifest.yml'
const SERVICES_MANIFEST_FILE = 'services-manifest.yml'
module.exports = class CfManifestTemplate extends require('../../plugin') {
static help() {
return 'Cloud Foundry deployment using manifest files'
}
static hasInProduction() {
return exists(MANIFEST_FILE)
}
async canRun() {
if (cds.cli.options.force) {
return true
}
if (exists(MANIFEST_FILE) || exists(SERVICES_MANIFEST_FILE)) {
throw `File ${MANIFEST_FILE} or ${SERVICES_MANIFEST_FILE} already exist in current folder. Use --force to overwrite.`
}
return true
}
async run() {
const project = readProject()
await renderAndCopy(join(__dirname, 'files'), cds.root, project)
if (project.isJava) await mvn.add('CF')
}
}