@sap/cds-dk
Version:
Command line client and development toolkit for the SAP Cloud Application Programming Model
30 lines (25 loc) • 869 B
JavaScript
const cds = require('../../../cds')
const { path, sh: $ } = cds.utils
const { ask4 } = require('../../../util/question')
const { renderAndCopy } = require('../../template')
module.exports = class ReactTemplate extends require('../../plugin') {
options() {
return {
'into': {
type: 'string',
short: 'i',
help: `Name of the app folder in 'app/'. Example: 'catalog' → 'app/catalog'.`
}
}
}
static help() {
return 'user interface for React'
}
async run() {
const app = cds.cli.options.into ?? await ask4([`app name: `])
let into = path.join(cds.env.folders.app, app)
await renderAndCopy(path.join(__dirname, 'files'), into, { app, isJava: cds.env['project-nature'] === 'java' })
if (cds.cli.command === 'init') into = path.join(cds.cli.argv[0], into)
await $`npm i --prefix ${into}`
}
}