@sap/cds-dk 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/bin/add.js +34 -38
  2. package/bin/build.js +4 -0
  3. package/bin/cds.js +13 -8
  4. package/bin/compile/index.js +3 -3
  5. package/bin/env.js +4 -1
  6. package/bin/help.js +2 -3
  7. package/lib/bind/bindingManager.js +1 -1
  8. package/lib/bind/bindingResolver.js +1 -1
  9. package/lib/bind/bindingUtil.js +1 -1
  10. package/lib/build/buildTaskEngine.js +1 -1
  11. package/lib/build/provider/buildTaskHandlerFeatureToggles.js +2 -1
  12. package/lib/build/provider/buildTaskHandlerInternal.js +1 -1
  13. package/lib/build/provider/java/index.js +2 -2
  14. package/lib/build/provider/mtx-sidecar/index.js +3 -4
  15. package/lib/build/provider/nodejs/index.js +6 -5
  16. package/lib/build/util.js +8 -0
  17. package/lib/cds.js +2 -2
  18. package/lib/import/asyncapi/parserContext.js +2 -2
  19. package/lib/index.js +6 -0
  20. package/lib/init/constants.js +4 -4
  21. package/lib/init/index.js +37 -38
  22. package/lib/init/template/_merging/registry-mta.js +2 -2
  23. package/lib/init/template/approuter/index.js +12 -8
  24. package/lib/init/template/auditlog/index.js +7 -7
  25. package/lib/init/template/cf-manifest/index.js +5 -5
  26. package/lib/init/template/connectivity/index.js +7 -7
  27. package/lib/init/template/data/index.js +1 -1
  28. package/lib/init/template/destination/index.js +6 -6
  29. package/lib/init/template/enterprise-messaging/index.js +10 -10
  30. package/lib/init/template/enterprise-messaging-shared/index.js +8 -8
  31. package/lib/init/template/extensibility/index.js +6 -6
  32. package/lib/init/template/file-based-messaging/index.js +4 -4
  33. package/lib/init/template/hana/index.js +11 -11
  34. package/lib/init/template/helm/index.js +5 -5
  35. package/lib/init/template/html5-repo/index.js +2 -2
  36. package/lib/init/template/java/index.js +20 -37
  37. package/lib/init/template/kibana/files/mta.yaml.hbs +29 -0
  38. package/lib/init/template/kibana/index.js +55 -0
  39. package/lib/init/template/multitenancy/files/package.json.hbs +0 -3
  40. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
  41. package/lib/init/template/multitenancy/index.js +18 -12
  42. package/lib/init/template/nodejs/files/package.json.hbs +1 -1
  43. package/lib/init/template/nodejs/index.js +12 -19
  44. package/lib/init/template/pipeline/index.js +1 -1
  45. package/lib/init/template/redis-messaging/index.js +7 -7
  46. package/lib/init/template/sample/files/app/_i18n/i18n.properties +3 -32
  47. package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +2 -2
  48. package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +6 -7
  49. package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +3 -3
  50. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +3 -11
  51. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +117 -113
  52. package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +38 -0
  53. package/lib/init/template/sample/files/app/browse/fiori-service.cds +56 -0
  54. package/lib/init/template/sample/files/app/browse/webapp/Component.js +7 -0
  55. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +4 -0
  56. package/lib/init/template/sample/files/app/browse/webapp/manifest.json +139 -0
  57. package/lib/init/template/sample/files/app/common.cds +78 -81
  58. package/lib/init/template/sample/files/app/services.cds +1 -0
  59. package/lib/init/template/samples/index.js +3 -3
  60. package/lib/init/template/sqlite/files/package.json.hbs +1 -21
  61. package/lib/init/template/sqlite/index.js +4 -4
  62. package/lib/init/template/templateBase.js +1 -1
  63. package/lib/init/template/{sample-tiny → tiny-sample}/files/nodejs/db/data-model.cds +1 -1
  64. package/lib/init/template/{sample-tiny → tiny-sample}/files/nodejs/srv/cat-service.cds.hbs +1 -1
  65. package/lib/init/template/{sample-tiny → tiny-sample}/index.js +2 -2
  66. package/lib/init/template/toggles/index.js +3 -3
  67. package/lib/init/template/typer/index.js +6 -5
  68. package/lib/init/template/xsuaa/index.js +9 -9
  69. package/lib/init/util/md5.js +2 -2
  70. package/lib/init/util/merge.js +9 -9
  71. package/lib/init/util/mvn.js +1 -1
  72. package/lib/init/util/projectReader.js +4 -4
  73. package/lib/util/fs.js +10 -10
  74. package/lib/util/term.js +2 -0
  75. package/npm-shrinkwrap.json +281 -334
  76. package/package.json +1 -1
  77. package/lib/init/template/kibana-logging/files/cds.package.json +0 -7
  78. package/lib/init/template/kibana-logging/files/mta.yaml.hbs +0 -14
  79. package/lib/init/template/kibana-logging/index.js +0 -45
  80. /package/lib/init/template/{kibana-logging → kibana}/files/package.json.hbs +0 -0
  81. /package/lib/init/template/{sample-tiny → tiny-sample}/files/nodejs/db/data/my.bookshop-Books.csv +0 -0
package/lib/init/index.js CHANGED
@@ -87,20 +87,20 @@ module.exports = class CDSGenerator {
87
87
  }
88
88
 
89
89
  /**
90
- * @param {string} templates, comma separated list of templates, no blanks
90
+ * @param {string} facets, comma separated list of templates, no blanks
91
91
  * @param {any} options, additional options
92
92
  */
93
- async addCmd(templates, options = {}) {
93
+ async addCmd(facets, options = {}) {
94
94
  options._cmd = COMMAND_ADD;
95
- options.add = templates;
95
+ options.add = facets;
96
96
 
97
- if (!templates) throw 'You must specify a facet to add to the project.'
97
+ if (!facets) throw 'You must specify a facet to add to the project.'
98
98
 
99
99
  this._initialize(null, options);
100
100
  this._greetings(options._cmd);
101
101
 
102
102
  if (!PROJECT_FILES.find(exists)) {
103
- throw new Error(`The current folder doesn't seem to contain a project. None of the following files found: ${PROJECT_FILES.join(', ')}.`);
103
+ throw `The current folder doesn't seem to contain a project. None of the following files found: ${PROJECT_FILES.join(', ')}.`
104
104
  }
105
105
 
106
106
  await this._process(options);
@@ -139,24 +139,19 @@ module.exports = class CDSGenerator {
139
139
  this._cleanupOptions();
140
140
  }
141
141
 
142
- _greetings(cmd) {
143
- switch (cmd) {
142
+ _greetings() {
143
+ switch (cds.cli.command) {
144
144
  case COMMAND_INIT: {
145
145
  const relativeProjectPath = path.relative(this.cwd, cds.root);
146
146
  const folderName = (relativeProjectPath ? `.${path.sep}${relativeProjectPath}` : 'current folder');
147
- LOG.info(`Creating new cap project in ${folderName}`);
147
+ LOG.info(`Creating new CAP project in ${term.bold(folderName)}\n`);
148
148
  break;
149
149
  }
150
- case COMMAND_ADD:
151
- LOG.info(`Adding feature(s) to project in current folder`);
152
- break;
153
150
  }
154
151
 
155
152
  if (this.options.force) {
156
- LOG.info(`Using '--force' ... existing files will be overwritten...!`);
153
+ LOG.info(`Using '--force' ... existing files will be overwritten`);
157
154
  }
158
-
159
- LOG.info();
160
155
  }
161
156
 
162
157
  async _process() {
@@ -172,11 +167,16 @@ module.exports = class CDSGenerator {
172
167
  await template.runRelatedMerging();
173
168
  }
174
169
 
175
- LOG.info(`Done adding features`);
176
- LOG.info();
170
+ if (cds.cli.command === COMMAND_INIT) {
171
+ const relativeProjectPath = path.relative(this.cwd, cds.root)
172
+ LOG.info(`\nSuccessfully created project. Continue with '${term.bold('cd '+relativeProjectPath)}'.\n`)
173
+ } else {
174
+ LOG.info(`\nSuccessfully added features to your project.`)
175
+ }
177
176
  }
178
177
 
179
178
  async _createTemplate(filename) {
179
+
180
180
  try {
181
181
  const TemplateClass = require(`./template/${filename}`);
182
182
  return new TemplateClass(this);
@@ -200,26 +200,28 @@ module.exports = class CDSGenerator {
200
200
 
201
201
  async _fillTemplateList() {
202
202
  const templates = new Map();
203
- for (const option of this.options.add) {
203
+ for (let option of this.options.add) {
204
+ // Compat
205
+ if (option === 'sample-tiny') option = 'tiny-sample'
206
+ if (option === 'kibana-logging') option = 'kibana'
207
+
204
208
  if (!templates.has(option)) {
205
209
  const template = await this._createTemplate(option);
206
-
207
210
  if (await template.canRun()) {
208
211
  DEBUG?.(`Adding feature '${template.name}'`);
209
-
210
212
  templates.set(option, template);
211
213
  const deps = await template.getDependencies();
212
214
  if (deps) {
213
- deps.forEach(this.options.add.add, this.options.add)
215
+ deps.forEach(this.options.add.add, this.options.add) // REVISIT: Ugly add.add
214
216
  }
215
217
  }
216
218
  }
217
219
  }
218
220
 
219
- const cmds = Object.values(OPTIONS);
220
- this.templateList = Array.from(templates.entries()).sort(([a], [b]) => {
221
- return cmds.indexOf(a) - cmds.indexOf(b);
222
- }).map((entry) => entry[1]);
221
+ const cmds = Object.values(OPTIONS)
222
+ this.templateList = Array.from(templates.entries())
223
+ .sort(([a], [b]) => cmds.indexOf(a) - cmds.indexOf(b))
224
+ .map((entry) => entry[1])
223
225
 
224
226
  // check debug to avoid lengthy computation when not in debug mode
225
227
  DEBUG?.(`Features: ${this.templateList.map(({name}) => name).join(', ')}`);
@@ -229,7 +231,6 @@ module.exports = class CDSGenerator {
229
231
  for (const template of this.templateList) {
230
232
  await template.finalize();
231
233
  }
232
- LOG.info();
233
234
  }
234
235
 
235
236
  _cleanupOptions() {
@@ -247,18 +248,16 @@ module.exports = class CDSGenerator {
247
248
 
248
249
  const trimmedTokens = tokens.map((token) => {
249
250
  token = token.replace(/\s+/g, '');
250
- const tokenSplit = token.split(':');
251
- if (tokenSplit.length > 1) {
252
- if (this.options[tokenSplit[0]]) {
253
- this.options[tokenSplit[0]].add(token);
251
+ const tokens = token.split(':'), [facet] = tokens
252
+ if (tokens.length > 1) {
253
+ if (this.options[facet]) {
254
+ this.options[facet].add(token);
254
255
  } else {
255
- this.options[tokenSplit[0]] = new Set([token]);
256
+ this.options[facet] = new Set([token]);
256
257
  }
257
258
  }
258
- return tokenSplit[0];
259
- }).filter((token) => {
260
- return !!token;
261
- });
259
+ return facet;
260
+ }).filter(Boolean);
262
261
 
263
262
  // set is ordered ... always
264
263
  this.options.add = new Set(trimmedTokens);
@@ -294,7 +293,7 @@ module.exports = class CDSGenerator {
294
293
 
295
294
  async _validateProjectName(projectName) {
296
295
  if (!projectName) {
297
- throw new Error('Specify a project name.');
296
+ throw 'Specify a project name.'
298
297
  }
299
298
 
300
299
  // remove duplicates by using a set
@@ -303,9 +302,9 @@ module.exports = class CDSGenerator {
303
302
  case 0:
304
303
  break;
305
304
  case 1:
306
- throw new Error(`Project name ${projectName} contains an invalid character (${[...invalidChars].join(', ')}). Specify a different project name.`);
305
+ throw `Project name ${projectName} contains an invalid character (${[...invalidChars].join(', ')}). Specify a different project name.`
307
306
  default:
308
- throw new Error(`Project name ${projectName} contains invalid characters (${[...invalidChars].join(', ')}). Specify a different project name.`);
307
+ throw `Project name ${projectName} contains invalid characters (${[...invalidChars].join(', ')}). Specify a different project name.`
309
308
  }
310
309
  }
311
310
 
@@ -318,7 +317,7 @@ module.exports = class CDSGenerator {
318
317
  } else {
319
318
  message = `You seem to be trying to initialize an existing project. Use a different project name instead.`;
320
319
  }
321
- throw new Error(`${message}\nDetails: File '${existingProjectFile}' exists in the project folder which indicates an existing project. Use ${term.bold('cds add')} to add more features.`);
320
+ throw `${message}\nDetails: File '${existingProjectFile}' exists in the project folder which indicates an existing project. Use ${term.bold('cds add')} to add more features.`
322
321
  }
323
322
  }
324
323
  }
@@ -93,7 +93,7 @@ const enterpriseMessaging = {
93
93
  }]
94
94
  }
95
95
 
96
- const kibanaLogging = {
96
+ const kibana = {
97
97
  in: 'resources',
98
98
  where: [{
99
99
  property: 'type',
@@ -278,6 +278,6 @@ module.exports = {
278
278
  requiredAppApi4,
279
279
  providedJavaApprouterApi4,
280
280
  providedJavaApprouterApi,
281
- kibanaLogging,
281
+ kibana,
282
282
  approuterExtensibility
283
283
  }
@@ -3,7 +3,7 @@ const { exists } = cds.utils
3
3
  const { join } = require('path')
4
4
  const { readProject } = require('../../util/projectReader')
5
5
  const { mergeJSON, mergeYAML, sort } = require('../../util/merge')
6
- const { XSUAA } = require('../../constants').OPTIONS
6
+ const { XSUAA, KIBANA } = require('../../constants').OPTIONS
7
7
  const {
8
8
  srvNode4, srvJava4, mtxSidecar4, approuter, // Modules
9
9
  xsuaa, // BTP Services
@@ -23,6 +23,10 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
23
23
  return [XSUAA]
24
24
  }
25
25
 
26
+ getRelatedFacets() {
27
+ return [KIBANA]
28
+ }
29
+
26
30
  async run() {
27
31
  const { appPath = 'app' } = await readProject(this.options)
28
32
  const appPackageJSONPath = join(appPath, 'package.json')
@@ -33,8 +37,8 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
33
37
  }
34
38
 
35
39
  async runDependentMerging(context = {}) {
36
- const projectDescriptor = await readProject(this.options)
37
- const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath } = projectDescriptor
40
+ const project = await readProject(this.options)
41
+ const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath, appPath } = project
38
42
 
39
43
  if (hasMta) {
40
44
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
@@ -45,7 +49,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
45
49
  const modules = [srv, approuter]
46
50
  if (isMultitenant) modules.push(mtxSidecar)
47
51
  const additions = [...modules, xsuaa, ...apis]
48
- await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), projectDescriptor, {
52
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, {
49
53
  additions,
50
54
  relationships: [{
51
55
  insert: [xsuaa, 'name'],
@@ -67,7 +71,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
67
71
  await mergeYAML(
68
72
  join('chart', 'values.yaml'),
69
73
  join(__dirname, 'files', 'values.yaml.hbs'),
70
- projectDescriptor
74
+ project
71
75
  )
72
76
 
73
77
  // add dependency entry in chart.yaml
@@ -88,7 +92,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
88
92
  ]
89
93
  }
90
94
  },
91
- projectDescriptor
95
+ project
92
96
  )
93
97
 
94
98
  const fileName = isMultitenant ? 'approuter-mtxs-configmap.yaml' : 'approuter-configmap.yaml';
@@ -113,8 +117,8 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
113
117
  if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
114
118
  }
115
119
 
116
- const xsAppPath = join(projectDescriptor.appPath ?? 'app', 'xs-app.json')
120
+ const xsAppPath = join(appPath, 'xs-app.json')
117
121
  const additions = isExtensible ? [{ ...approuterExtensibility, at: 0 }] : []
118
- await mergeJSON(xsAppPath, join(__dirname, 'files', 'xs-app.json.hbs'), projectDescriptor, { additions })
122
+ await mergeJSON(xsAppPath, join(__dirname, 'files', 'xs-app.json.hbs'), project, { additions })
119
123
  }
120
124
  }
@@ -13,23 +13,23 @@ module.exports = class AuditlogTemplate extends require('../templateBase') {
13
13
  }
14
14
 
15
15
  async run() {
16
- const projectDescriptor = await readProject(this.options)
17
- const { configFile } = projectDescriptor
18
- projectDescriptor.shortcut = !(await read(configFile)).cds?.requires?.['audit-log']?.kind
19
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
16
+ const project = await readProject(this.options)
17
+ const { configFile } = project
18
+ project.shortcut = !(await read(configFile)).cds?.requires?.['audit-log']?.kind
19
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
20
20
  await this.runDependentMerging()
21
21
  }
22
22
 
23
23
  async runDependentMerging(context = {}) {
24
- const projectDescriptor = await readProject(this.options)
25
- const { isNodejs, hasMta, hasHelm, srvPath } = projectDescriptor
24
+ const project = await readProject(this.options)
25
+ const { isNodejs, hasMta, hasHelm, srvPath } = project
26
26
 
27
27
  if (hasMta) {
28
28
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
29
29
  await mergeYAML(
30
30
  'mta.yaml',
31
31
  join(__dirname, 'files', 'mta.yaml.hbs'),
32
- projectDescriptor,
32
+ project,
33
33
  {
34
34
  additions: [srv, auditlog],
35
35
  relationships: [{
@@ -10,16 +10,16 @@ module.exports = class CfManifestTemplate extends require('../templateBase') {
10
10
 
11
11
  async canRun() {
12
12
  if (this.options.force) {
13
- return true;
13
+ return true
14
14
  }
15
15
  if (exists(MANIFEST_FILE) || exists(SERVICES_MANIFEST_FILE)) {
16
- throw new Error(`File ${MANIFEST_FILE} or ${SERVICES_MANIFEST_FILE} already exist in current folder. Use --force to overwrite.`);
16
+ throw `File ${MANIFEST_FILE} or ${SERVICES_MANIFEST_FILE} already exist in current folder. Use --force to overwrite.`
17
17
  }
18
- return true;
18
+ return true
19
19
  }
20
20
 
21
21
  async run() {
22
- const projectDescriptor = await readProject()
23
- await copyFiles(join(__dirname, 'files'), cds.root, projectDescriptor, this.options.force);
22
+ const project = await readProject()
23
+ await copyFiles(join(__dirname, 'files'), cds.root, project, this.options.force)
24
24
  }
25
25
  }
@@ -11,15 +11,15 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
11
11
  }
12
12
 
13
13
  async run() {
14
- const projectDescriptor = await readProject(this.options)
15
- const { configFile } = projectDescriptor
16
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
14
+ const project = await readProject(this.options)
15
+ const { configFile } = project
16
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
17
17
  await this.runDependentMerging()
18
18
  }
19
19
 
20
20
  async runDependentMerging(context = {}) {
21
- const projectDescriptor = await readProject(this.options)
22
- const { isJava, srvPath, hasHelm, hasMta } = projectDescriptor
21
+ const project = await readProject(this.options)
22
+ const { isJava, srvPath, hasHelm, hasMta } = project
23
23
 
24
24
  if (hasMta) {
25
25
  const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
@@ -28,7 +28,7 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
28
28
  insert: [connectivity, 'name'],
29
29
  into: [srv, 'requires', 'name']
30
30
  }]
31
- await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), projectDescriptor, { additions, relationships })
31
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, { additions, relationships })
32
32
  }
33
33
 
34
34
  if (hasHelm) {
@@ -41,7 +41,7 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
41
41
  await mergeYAML(
42
42
  join('chart', 'values.yaml'),
43
43
  join(__dirname, 'files', 'values.yaml.hbs'),
44
- projectDescriptor,
44
+ project,
45
45
  { additions: [{
46
46
  in: 'srv.additionalVolumes',
47
47
  where: [{
@@ -63,7 +63,7 @@ function asRegex(spec) {
63
63
  return new RegExp('^'+spec+'.*')
64
64
  }
65
65
  } catch (err) {
66
- throw new Error (err.message) // user error, so cut off stack trace
66
+ throw err.message // user error, so cut off stack trace
67
67
  }
68
68
  }
69
69
  return /.*/
@@ -15,15 +15,15 @@ module.exports = class DestinationTemplate extends require('../templateBase') {
15
15
  }
16
16
 
17
17
  async run() {
18
- const projectDescriptor = await readProject(this.options)
19
- const { configFile } = projectDescriptor
20
- await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), projectDescriptor)
18
+ const project = await readProject(this.options)
19
+ const { configFile } = project
20
+ await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), project)
21
21
  await this.runDependentMerging()
22
22
  }
23
23
 
24
24
  async runDependentMerging(context = {}) {
25
- const projectDescriptor = await readProject(this.options)
26
- const { isJava, hasHelm, hasDestination, hasMta, srvPath, hasHtml5Repo } = projectDescriptor
25
+ const project = await readProject(this.options)
26
+ const { isJava, hasHelm, hasDestination, hasMta, srvPath, hasHtml5Repo } = project
27
27
 
28
28
  if (hasMta) {
29
29
  const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
@@ -32,7 +32,7 @@ module.exports = class DestinationTemplate extends require('../templateBase') {
32
32
  insert: [destination, 'name'],
33
33
  into: [srv, 'requires', 'name']
34
34
  }]
35
- await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), projectDescriptor, { additions, relationships })
35
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, { additions, relationships })
36
36
  }
37
37
 
38
38
  if (hasHelm) {
@@ -20,23 +20,23 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
20
20
  }
21
21
 
22
22
  async run() {
23
- const projectDescriptor = await readProject(this.options)
24
- const { configFile } = projectDescriptor
25
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
23
+ const project = await readProject(this.options)
24
+ const { configFile } = project
25
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
26
26
  await this.runDependentMerging()
27
27
  }
28
28
 
29
29
  async runDependentMerging(context = {}) {
30
- const projectDescriptor = await readProject(this.options)
31
- const { hasXsuaa, hasHelm, hasMta, isNodejs, srvPath, appName } = projectDescriptor
30
+ const project = await readProject(this.options)
31
+ const { hasXsuaa, hasHelm, hasMta, isNodejs, srvPath, appName } = project
32
32
 
33
33
  if (hasMta) {
34
- await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), projectDescriptor)
34
+ await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), project)
35
35
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
36
36
  await mergeYAML(
37
37
  'mta.yaml',
38
38
  join(__dirname, 'files', 'mta.yaml.hbs'),
39
- projectDescriptor,
39
+ project,
40
40
  {
41
41
  additions: [srv, enterpriseMessaging],
42
42
  relationships: [{
@@ -49,14 +49,14 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
49
49
 
50
50
  if (hasXsuaa) {
51
51
  if (hasMta) {
52
- projectDescriptor['em-service-name'] = YAML.parse(await read('mta.yaml'))?.resources?.find(r => r?.parameters?.service === 'enterprise-messaging')?.name
52
+ project['em-service-name'] = YAML.parse(await read('mta.yaml'))?.resources?.find(r => r?.parameters?.service === 'enterprise-messaging')?.name
53
53
  } else {
54
- projectDescriptor['em-service-name'] = `${appName}-messaging`
54
+ project['em-service-name'] = `${appName}-messaging`
55
55
  }
56
56
  await mergeJSON(
57
57
  'xs-security.json',
58
58
  join(__dirname, 'files', 'xs-security.json.hbs'),
59
- projectDescriptor,
59
+ project,
60
60
  {
61
61
  additions: [{
62
62
  in: 'scopes',
@@ -19,24 +19,24 @@ module.exports = class EnterpriseMessagingSharedTemplate extends require('../tem
19
19
  }
20
20
 
21
21
  async run() {
22
- const projectDescriptor = await readProject(this.options)
23
- const { configFile } = projectDescriptor
24
- projectDescriptor.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
25
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
26
- await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), projectDescriptor)
22
+ const project = await readProject(this.options)
23
+ const { configFile } = project
24
+ project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
25
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
26
+ await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), project)
27
27
  await this.runDependentMerging()
28
28
  }
29
29
 
30
30
  async runDependentMerging() {
31
- const projectDescriptor = await readProject(this.options)
32
- const { hasMta, isNodejs, srvPath } = projectDescriptor
31
+ const project = await readProject(this.options)
32
+ const { hasMta, isNodejs, srvPath } = project
33
33
 
34
34
  if (hasMta) {
35
35
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
36
36
  await mergeYAML(
37
37
  'mta.yaml',
38
38
  join(__dirname, 'files', 'mta.yaml.hbs'),
39
- projectDescriptor,
39
+ project,
40
40
  {
41
41
  additions: [srv, enterpriseMessaging],
42
42
  relationships: [{
@@ -21,20 +21,20 @@ module.exports = class ExtensibilityTemplate extends require('../templateBase')
21
21
  }
22
22
 
23
23
  async run() {
24
- const projectDescriptor = await readProject(this.options)
25
- const { configFile } = projectDescriptor
26
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
24
+ const project = await readProject(this.options)
25
+ const { configFile } = project
26
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
27
27
  await this.runDependentMerging()
28
28
  }
29
29
 
30
30
  async runDependentMerging() {
31
- const projectDescriptor = await readProject(this.options)
32
- const { hasXsuaa } = projectDescriptor
31
+ const project = await readProject(this.options)
32
+ const { hasXsuaa } = project
33
33
  if (hasXsuaa) {
34
34
  await mergeJSON(
35
35
  'xs-security.json',
36
36
  join(__dirname, 'files', 'xs-security.json.hbs'),
37
- projectDescriptor,
37
+ project,
38
38
  {
39
39
  additions: [{
40
40
  in: 'scopes',
@@ -16,9 +16,9 @@ module.exports = class FileBasedMessagingTemplate extends require('../templateBa
16
16
  }
17
17
 
18
18
  async run() {
19
- const projectDescriptor = await readProject(this.options)
20
- const { configFile } = projectDescriptor
21
- projectDescriptor.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
22
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
19
+ const project = await readProject(this.options)
20
+ const { configFile } = project
21
+ project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
22
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
23
23
  }
24
24
  }
@@ -20,11 +20,11 @@ module.exports = class HanaTemplate extends require('../templateBase') {
20
20
  }
21
21
 
22
22
  async run() {
23
- const projectDescriptor = await readProject(this.options)
24
- const { isJava, configFile } = projectDescriptor
25
- projectDescriptor.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
23
+ const project = await readProject(this.options)
24
+ const { isJava, configFile } = project
25
+ project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
26
26
 
27
- const env = await this.getEnv() // REVISIT: Get info from projectDescriptor
27
+ const env = await this.getEnv() // REVISIT: Get info from project
28
28
 
29
29
  // REVISIT: Let cds build generate by default
30
30
  const hdiConfigPath = join(env.folders.db, 'src', '.hdiconfig')
@@ -41,7 +41,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
41
41
  await this._updatePomXml()
42
42
  }
43
43
 
44
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor, { forceOverwrite: true })
44
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project, { forceOverwrite: true })
45
45
 
46
46
  const packageJson = exists('package.json') ? await read('package.json') : undefined
47
47
  if (packageJson?.dependencies) {
@@ -66,8 +66,8 @@ module.exports = class HanaTemplate extends require('../templateBase') {
66
66
  }
67
67
 
68
68
  async runDependentMerging(context = {}) {
69
- const projectDescriptor = await readProject(this.options)
70
- const { hasMta, hasHelm, hasHtml5Repo, isJava, isMultitenant, srvPath } = projectDescriptor
69
+ const project = await readProject(this.options)
70
+ const { hasMta, hasHelm, hasHtml5Repo, isJava, isMultitenant, srvPath } = project
71
71
 
72
72
 
73
73
  if (hasMta) {
@@ -109,7 +109,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
109
109
  await mergeYAML(
110
110
  'mta.yaml',
111
111
  join(__dirname, 'files', 'mta.yaml.hbs'),
112
- projectDescriptor,
112
+ project,
113
113
  { additions: [...modules, db].filter(a => a), deletions, relationships }
114
114
  )
115
115
  }
@@ -159,7 +159,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
159
159
  }
160
160
  ]
161
161
  },
162
- projectDescriptor,
162
+ project,
163
163
  { deletions: [{
164
164
  item: {
165
165
  in: `dependencies`,
@@ -174,7 +174,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
174
174
  await mergeYAML(
175
175
  join('chart', 'values.yaml'),
176
176
  join(__dirname, 'files', 'values.yaml.hbs'),
177
- projectDescriptor
177
+ project
178
178
  )
179
179
 
180
180
  // copy content deployment chart if it is not present
@@ -204,7 +204,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
204
204
  } catch (err) {
205
205
  // REVISIT: This should not have to be checked and tested in a facet implementation, move to Maven util
206
206
  if (err.code === 'ENOENT' && err.path === 'mvn') {
207
- throw new Error(`Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`);
207
+ throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
208
208
  }
209
209
  throw err;
210
210
  }
@@ -51,7 +51,7 @@ module.exports = class HelmTemplate extends require('../templateBase') {
51
51
  }
52
52
 
53
53
  async addDependency(name, alias){
54
- const projectDescriptor = await readProject(this.options);
54
+ const project = await readProject(this.options);
55
55
  const isInternal = await this.isInternal();
56
56
  await mergeYAML(
57
57
  join('chart', 'Chart.yaml'),
@@ -65,7 +65,7 @@ module.exports = class HelmTemplate extends require('../templateBase') {
65
65
  }
66
66
  ]
67
67
  },
68
- projectDescriptor,
68
+ project,
69
69
  { additions: [{
70
70
  in: `dependencies`,
71
71
  where: [{
@@ -77,7 +77,7 @@ module.exports = class HelmTemplate extends require('../templateBase') {
77
77
  }
78
78
 
79
79
  async run() {
80
- const projectDescriptor = await readProject(this.options)
80
+ const project = await readProject(this.options)
81
81
  const isInternal = this.options['internal-unified-runtime-charts'] !== undefined && this.options['internal-unified-runtime-charts'];
82
82
  this.oldTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'));
83
83
  await this.addSubChart('web-application', !isInternal);
@@ -90,7 +90,7 @@ module.exports = class HelmTemplate extends require('../templateBase') {
90
90
  await mergeYAML(
91
91
  join('chart', 'Chart.yaml'),
92
92
  join(__dirname, 'files', 'Chart.yaml.hbs'),
93
- projectDescriptor
93
+ project
94
94
  )
95
95
 
96
96
  await this.addDependency('web-application', 'srv');
@@ -98,7 +98,7 @@ module.exports = class HelmTemplate extends require('../templateBase') {
98
98
  await mergeYAML(
99
99
  join('chart', 'values.yaml'),
100
100
  join(__dirname, 'files', 'values.yaml.hbs'),
101
- projectDescriptor
101
+ project
102
102
  )
103
103
  await this.runDependentMerging();
104
104
  await writeMd5File(join('chart', '.cds-add-helm-files.md5'), this.newTrackingData);
@@ -13,8 +13,8 @@ module.exports = class Html5RepoTemplate extends require('../templateBase') {
13
13
  }
14
14
 
15
15
  async canRun() {
16
- const projectDescriptor = await readProject(this.options)
17
- const { hasMta, hasHelm } = projectDescriptor
16
+ const project = await readProject(this.options)
17
+ const { hasMta, hasHelm } = project
18
18
  if (!hasHelm && hasMta) {
19
19
  throw `'cds add html5-repo' is not available for Cloud Foundry yet`
20
20
  }