UNPKG

@sap/cds-dk

Version:

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

51 lines (41 loc) 1.72 kB
const { join } = require('path') const cds = require('../../../cds') const { exists, copy } = cds.utils const { readProject } = require('../../projectReader') const { merge } = require('../../merge') const { URLS } = require('../../constants') module.exports = class PipelineTemplate extends require('../../plugin') { static help() { return 'CI/CD pipeline via Jenkins (Piper)' } async canRun() { if (cds.cli.options.force) { return true; } if (exists('Jenkinsfile') || exists(join('.pipeline', 'config.yml'))) { throw `Pipeline support file exists. Use --force to overwrite.` } return true; } async run() { await Promise.all([ copy(join(__dirname, 'files', '.pipeline')).to(join(cds.root, '.pipeline')), copy(join(__dirname, 'files', 'Jenkinsfile')).to(join(cds.root, 'Jenkinsfile')) ]) const project = readProject() const { apps, appPath, hasUI5 } = project if (hasUI5) { // UI5 integration might be needed even without HTML5 repo console.log('Adding UI5 integration to the pipeline for the detected UI5 apps...') for (const { app } of apps) { project.app = app await Promise.all([ merge(__dirname, 'files/app-package.json.hbs').into(join(appPath, app, 'package.json'), { project }), merge(__dirname, 'files/ui5.yaml.hbs').into(join(appPath, app, 'ui5.yaml'), { project }) ]) } } } async finalize() { console.log(`for information on project "Piper" and its pipelines see ${URLS.PIPELINE_HELP}`); } }