UNPKG

@sap/cds-dk

Version:

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

45 lines (38 loc) 1.63 kB
const fs = require('fs') const path = require('path') const cds = require('../../../cds') const EdmxBuildPlugin = require('../edmxBuildPlugin') const ResourcesTarBuilder = require('./resourcesTarBuilder') const { FOLDER_GEN } = require('../../constants') const { BuildError } = require('../../util') class MtxBuildPlugin extends EdmxBuildPlugin { get priority() { // must run after 'hana' build task return super.priority - 10 } init() { super.init() // this build task only supports nodejs mtxs apps without sidecar if (cds.env['project-nature'] === 'java') { throw new BuildError(`@sap/cds-mtx is deprecated and not supported by @sap/cds-dk >= 7. This also applies to the 'mtx' build task in Java projects. Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/docs/guides/multitenancy/old-mtx-migration.`) } } async build() { // Only create resources TAR, compiled CSN(s) are created by the Nodejs app build task. const dest = cds.env.build.target !== '.' ? this.task.dest : path.join(this.task.dest, FOLDER_GEN) const model = await this.model() if (!model) { return } return new ResourcesTarBuilder(this).createTar(dest, model) } async clean() { // staging build content is deleted by BuildTaskEngine if (cds.env.build.target === '.') { // remove 'gen' folder return fs.promises.rm(path.join(this.task.dest, FOLDER_GEN), { force: true, recursive: true }) } } } module.exports = MtxBuildPlugin