@sap/cds-dk 7.0.1 → 7.0.3

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 (90) hide show
  1. package/bin/add.js +36 -40
  2. package/bin/bind.js +0 -1
  3. package/bin/build.js +4 -0
  4. package/bin/cds.js +14 -8
  5. package/bin/compile/index.js +3 -3
  6. package/bin/deploy/to-hana.js +1 -1
  7. package/bin/help.js +2 -3
  8. package/bin/init.js +2 -2
  9. package/lib/bind/cfKeyProvider.js +1 -0
  10. package/lib/bind/index.js +3 -0
  11. package/lib/bind/userCdsrcJsonStorageProvider.js +2 -10
  12. package/lib/build/buildTaskEngine.js +1 -1
  13. package/lib/build/constants.js +16 -14
  14. package/lib/build/provider/buildTaskHandlerFeatureToggles.js +2 -1
  15. package/lib/build/provider/java/index.js +2 -2
  16. package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -6
  17. package/lib/build/provider/mtx-sidecar/index.js +15 -11
  18. package/lib/build/util.js +8 -0
  19. package/lib/cds.js +2 -2
  20. package/lib/client/base_command.js +3 -6
  21. package/lib/compile/asyncapi/components/messages/index.js +41 -18
  22. package/lib/compile/asyncapi/index.js +23 -2
  23. package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -0
  24. package/lib/init/constants.js +5 -5
  25. package/lib/init/index.js +68 -76
  26. package/lib/init/template/_merging/registry-mta.js +2 -2
  27. package/lib/init/template/approuter/index.js +10 -7
  28. package/lib/init/template/auditlog/index.js +3 -4
  29. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +15 -23
  30. package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +22 -17
  31. package/lib/init/template/cf-manifest/index.js +5 -5
  32. package/lib/init/template/connectivity/index.js +2 -3
  33. package/lib/init/template/data/index.js +6 -6
  34. package/lib/init/template/destination/index.js +3 -5
  35. package/lib/init/template/enterprise-messaging/index.js +4 -5
  36. package/lib/init/template/enterprise-messaging-shared/index.js +3 -4
  37. package/lib/init/template/extensibility/index.js +2 -3
  38. package/lib/init/template/file-based-messaging/index.js +2 -2
  39. package/lib/init/template/hana/files/mta.yaml.hbs +1 -1
  40. package/lib/init/template/hana/index.js +39 -63
  41. package/lib/init/template/helm/index.js +15 -14
  42. package/lib/init/template/html5-repo/index.js +3 -7
  43. package/lib/init/template/java/index.js +6 -6
  44. package/lib/init/template/kibana/files/mta.yaml.hbs +29 -0
  45. package/lib/init/template/kibana/index.js +54 -0
  46. package/lib/init/template/lint/index.js +8 -7
  47. package/lib/init/template/mta/index.js +3 -2
  48. package/lib/init/template/multitenancy/files/package.json.hbs +0 -3
  49. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
  50. package/lib/init/template/multitenancy/index.js +25 -40
  51. package/lib/init/template/nodejs/index.js +4 -5
  52. package/lib/init/template/pipeline/index.js +3 -3
  53. package/lib/init/template/redis-messaging/index.js +3 -4
  54. package/lib/init/template/sample/files/app/_i18n/i18n.properties +3 -32
  55. package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +2 -2
  56. package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +6 -7
  57. package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +3 -3
  58. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +3 -11
  59. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +117 -113
  60. package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +38 -0
  61. package/lib/init/template/sample/files/app/browse/fiori-service.cds +56 -0
  62. package/lib/init/template/sample/files/app/browse/webapp/Component.js +7 -0
  63. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +4 -0
  64. package/lib/init/template/sample/files/app/browse/webapp/manifest.json +139 -0
  65. package/lib/init/template/sample/files/app/common.cds +78 -81
  66. package/lib/init/template/sample/files/app/services.cds +1 -0
  67. package/lib/init/template/sample/files/srv/admin-service.cds +1 -1
  68. package/lib/init/template/sample/files/srv/cat-service.cds +1 -1
  69. package/lib/init/template/sample/index.js +6 -5
  70. package/lib/init/template/sqlite/index.js +1 -1
  71. package/lib/init/template/templateBase.js +9 -19
  72. package/lib/init/template/tiny-sample/index.js +6 -6
  73. package/lib/init/template/toggles/index.js +1 -2
  74. package/lib/init/template/typer/files/xsconfig.json +0 -1
  75. package/lib/init/template/typer/index.js +1 -1
  76. package/lib/init/template/xsuaa/index.js +3 -4
  77. package/lib/init/util/indent.js +57 -0
  78. package/lib/init/util/merge.js +71 -15
  79. package/lib/init/util/mvn.js +24 -10
  80. package/lib/init/util/projectReader.js +53 -169
  81. package/lib/init/util/template.js +12 -11
  82. package/lib/init/util/xml.js +6 -6
  83. package/lib/util/pruneAxiosErrors.js +22 -0
  84. package/lib/watch/open.js +6 -3
  85. package/npm-shrinkwrap.json +20 -37
  86. package/package.json +1 -2
  87. package/lib/init/template/kibana-logging/files/cds.package.json +0 -7
  88. package/lib/init/template/kibana-logging/files/mta.yaml.hbs +0 -14
  89. package/lib/init/template/kibana-logging/index.js +0 -45
  90. /package/lib/init/template/{kibana-logging → kibana}/files/package.json.hbs +0 -0
@@ -1,6 +1,6 @@
1
1
  const csnToJSONSchema = require('./components/schemas');
2
2
  const getMessageTraits = require('./components/messageTraits');
3
- const definitionsToMessages = require('./components/messages');
3
+ const { definitionsToMessages, nestedAnnotation } = require('./components/messages');
4
4
  const getChannels = require('./channels');
5
5
  const cds = require('../../cds');
6
6
  const messages = require("./message");
@@ -75,13 +75,14 @@ function _getAsyncApi(csn, events, serviceName, applicationNamespace, presets) {
75
75
  const infoObject = getInfoObject(csn.definitions[serviceName]);
76
76
  const stateObj = getStateInfo(csn.definitions[serviceName]);
77
77
  const shortTextObj = getShortText(csn.definitions[serviceName]);
78
-
78
+ const extensionAnnotationObj = getExtensions(csn.definitions[serviceName], shortTextObj, stateObj);
79
79
  return {
80
80
  asyncapi: '2.0.0',
81
81
  'x-sap-catalog-spec-version': '1.2',
82
82
  'x-sap-application-namespace': applicationNamespace,
83
83
  ...Object.keys(stateObj).length && { 'x-sap-stateInfo': stateObj },
84
84
  ...Object.keys(shortTextObj).length && { 'x-sap-shortText': shortTextObj },
85
+ ...Object.keys(extensionAnnotationObj).length && extensionAnnotationObj,
85
86
  info: infoObject,
86
87
  defaultContentType: 'application/json',
87
88
  channels: getChannels(csn.definitions, events),
@@ -89,6 +90,26 @@ function _getAsyncApi(csn, events, serviceName, applicationNamespace, presets) {
89
90
  };
90
91
  }
91
92
 
93
+ function getExtensions(serviceCsn, shortTextObj, stateObj) {
94
+ let extensionObj = {};
95
+ for (const [key, value] of Object.entries(serviceCsn)) {
96
+ if (key.startsWith('@AsyncAPI.Extensions')) {
97
+ const annotationProperties = key.split('@AsyncAPI.Extensions.')[1];
98
+ const keys = annotationProperties.split('.');
99
+ keys[0] = "x-" + keys[0];
100
+ if ((keys[0] === 'x-sap-shortText' && Object.keys(shortTextObj).length > 0) ||
101
+ (keys[0] === 'x-sap-stateInfo' && Object.keys(stateObj).length > 0)
102
+ ) continue;
103
+ if (keys.length === 1) {
104
+ extensionObj[keys[0]] = value;
105
+ } else {
106
+ nestedAnnotation(extensionObj, keys[0], keys, value);
107
+ }
108
+ }
109
+ }
110
+ return extensionObj;
111
+ }
112
+
92
113
  function getShortText(serviceCsn, presetValue = undefined) {
93
114
  let shortTextValue = presetValue || serviceCsn["@AsyncAPI.ShortText"];
94
115
  if (shortTextValue) {
@@ -371,6 +371,7 @@ class Expression {
371
371
  annotate(prefix = '', target, annotationExpressionResult) {
372
372
  let _target = target;
373
373
  for (const key of Object.keys(annotationExpressionResult)) {
374
+ if (prefix !== '') prefix = prefix + ".";
374
375
  _target[prefix + key] = annotationExpressionResult[key];
375
376
  }
376
377
  return target;
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '2.0.1';
3
+ const MAVEN_ARCHETYPE_VERSION = '2.0.2';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
@@ -15,6 +15,9 @@ const constants = {
15
15
  JAVA_MVN: 'java:mvn',
16
16
  JAVA_PACKAGE: 'java:package',
17
17
  NODEJS: 'nodejs',
18
+ SAMPLES: 'samples', // deprecated
19
+ TINY_SAMPLE: 'tiny-sample',
20
+ SAMPLE: 'sample',
18
21
  PIPELINE: 'pipeline',
19
22
  MTA: 'mta',
20
23
  CONNECTIVITY: 'connectivity',
@@ -33,11 +36,8 @@ const constants = {
33
36
  REDIS_MESSAGING: 'redis-messaging',
34
37
  APPROUTER: 'approuter',
35
38
  DESTINATION: 'destination',
36
- SAMPLES: 'samples', // deprecated
37
- TINY_SAMPLE: 'tiny-sample',
38
- SAMPLE: 'sample',
39
39
  DATA: 'data',
40
- KIBANA_LOGGING: 'kibana-logging',
40
+ KIBANA: 'kibana',
41
41
  LINT: 'lint',
42
42
  LINT_GLOBAL: 'lint:global',
43
43
  LINT_DEV: 'lint:dev',
package/lib/init/index.js CHANGED
@@ -2,7 +2,7 @@ const path = require('path');
2
2
 
3
3
  const term = require('../util/term');
4
4
 
5
- const { OPTIONS, COMMAND_ADD, COMMAND_INIT, PROJECT_FILES, REGEX_PROJECT_NAME } = require('./constants')
5
+ const { OPTIONS, COMMAND_INIT, PROJECT_FILES, REGEX_PROJECT_NAME } = require('./constants')
6
6
  const { NODEJS, JAVA, HANA, MTA,PIPELINE, SAMPLES, CF_MANIFEST } = OPTIONS
7
7
 
8
8
  const cds = require('../cds'), { exists, readdir } = cds.utils
@@ -90,67 +90,56 @@ module.exports = class CDSGenerator {
90
90
  * @param {string} facets, comma separated list of templates, no blanks
91
91
  * @param {any} options, additional options
92
92
  */
93
- async addCmd(facets, options = {}) {
94
- options._cmd = COMMAND_ADD;
95
- options.add = facets;
96
-
93
+ async addCmd(facets) {
97
94
  if (!facets) throw 'You must specify a facet to add to the project.'
98
95
 
99
- this._initialize(null, options);
100
- this._greetings(options._cmd);
96
+ this._initialize(null);
97
+ this._greetings();
101
98
 
102
99
  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(', ')}.`);
100
+ throw `The current folder doesn't seem to contain a project. None of the following files found: ${PROJECT_FILES.join(', ')}.`
104
101
  }
105
102
 
106
- await this._process(options);
107
- await this.stepEnd(options);
103
+ await this._process();
104
+ await this.stepEnd();
108
105
  }
109
106
 
110
107
  /**
111
108
  * @param {string} projectName, the project name
112
- * @param {any} options, additional options
113
109
  */
114
- async initCmd(projectName, options = {}) {
115
- await this.stepInit(projectName, options);
110
+ async initCmd(projectName) {
111
+ await this.stepInit(projectName);
116
112
  await this.stepEnd();
117
113
  }
118
114
 
119
- async stepInit(projectName, options = {}) {
120
- options._cmd = COMMAND_INIT;
115
+ async stepInit(projectName) {
121
116
 
122
- this._initialize(projectName, options);
123
- this._greetings(options._cmd);
117
+ this._initialize(projectName);
118
+ this._greetings();
124
119
 
125
120
  await this._process();
126
121
  }
127
122
 
128
- _initialize(projectName, options = {}) {
129
- // deprecated, only for compatibility
130
- if (options.verbose) {
131
- LOG.warn(`Parameter 'verbose' is no longer supported. Use environment variable 'DEBUG=true' to obtain detailed output.`);
132
- }
133
-
123
+ _initialize(projectName) {
124
+ const { options } = cds.cli
134
125
  this.cwd = options.cwd || process.cwd();
135
126
  cds.root = path.resolve(this.cwd, projectName || '.');
136
127
  this.projectName = path.basename(cds.root);
137
128
 
138
- this.options = options;
139
129
  this._cleanupOptions();
140
130
  }
141
131
 
142
132
  _greetings() {
143
- switch (cds.cli.command) {
144
- case COMMAND_INIT: {
145
- const relativeProjectPath = path.relative(this.cwd, cds.root);
146
- const folderName = (relativeProjectPath ? `.${path.sep}${relativeProjectPath}` : 'current folder');
147
- LOG.info(`Creating new CAP project in ${term.bold(folderName)}\n`);
148
- break;
149
- }
133
+ if (cds.cli.command === COMMAND_INIT) {
134
+ const relativeProjectPath = path.relative(this.cwd, cds.root)
135
+ const folderName = relativeProjectPath ? `.${path.sep}${relativeProjectPath}` : 'current folder'
136
+ LOG.info(`Creating new CAP project in ${term.bold(folderName)}\n`)
150
137
  }
151
-
152
- if (this.options.force) {
153
- LOG.info(`Using '--force' ... existing files will be overwritten`);
138
+ if (cds.cli.options.for && typeof cds.cli.options.for !== 'string') {
139
+ throw 'The --for argument must not be empty.'
140
+ }
141
+ if (cds.cli.options.force) {
142
+ LOG.info(`Using '--force' ... existing files will be overwritten`)
154
143
  }
155
144
  }
156
145
 
@@ -161,9 +150,9 @@ module.exports = class CDSGenerator {
161
150
  await this._fillTemplateList();
162
151
 
163
152
  for (const template of this.templateList) {
164
- const msg = `Adding feature '${template.name}'...`;
165
- LOG.info(msg);
153
+ LOG.info(`Adding feature '${template.name}'...`);
166
154
  await template.run();
155
+ await template.runDependentMerging();
167
156
  await template.runRelatedMerging();
168
157
  }
169
158
 
@@ -176,9 +165,6 @@ module.exports = class CDSGenerator {
176
165
  }
177
166
 
178
167
  async _createTemplate(filename) {
179
- // Compat
180
- if (filename === 'sample-tiny') filename = 'tiny-sample'
181
-
182
168
  try {
183
169
  const TemplateClass = require(`./template/${filename}`);
184
170
  return new TemplateClass(this);
@@ -201,27 +187,30 @@ module.exports = class CDSGenerator {
201
187
  }
202
188
 
203
189
  async _fillTemplateList() {
204
- const templates = new Map();
205
- for (const option of this.options.add) {
206
- if (!templates.has(option)) {
207
- const template = await this._createTemplate(option);
190
+ const templates = new Map
191
+ const { command, options, argv } = cds.cli
192
+ const facets = command === COMMAND_INIT ? options.add : new Set(argv[0].split(','))
208
193
 
209
- if (await template.canRun()) {
210
- DEBUG?.(`Adding feature '${template.name}'`);
194
+ for (let facet of facets) {
195
+ // Compat
196
+ if (facet === 'sample-tiny') facet = 'tiny-sample'
197
+ if (facet === 'kibana-logging') facet = 'kibana'
211
198
 
212
- templates.set(option, template);
213
- const deps = await template.getDependencies();
214
- if (deps) {
215
- deps.forEach(this.options.add.add, this.options.add)
216
- }
199
+ if (!templates.has(facet)) {
200
+ const template = await this._createTemplate(facet)
201
+ if (await template.canRun()) {
202
+ DEBUG?.(`Adding feature '${template.name}'`)
203
+ templates.set(facet, template)
204
+ const dependencies = await template.getDependencies()
205
+ dependencies?.forEach(d => facets.add(d))
217
206
  }
218
207
  }
219
208
  }
220
209
 
221
- const cmds = Object.values(OPTIONS);
222
- this.templateList = Array.from(templates.entries()).sort(([a], [b]) => {
223
- return cmds.indexOf(a) - cmds.indexOf(b);
224
- }).map((entry) => entry[1]);
210
+ const cmds = Object.values(OPTIONS)
211
+ this.templateList = Array.from(templates.entries())
212
+ .sort(([a], [b]) => cmds.indexOf(a) - cmds.indexOf(b))
213
+ .map((entry) => entry[1])
225
214
 
226
215
  // check debug to avoid lengthy computation when not in debug mode
227
216
  DEBUG?.(`Features: ${this.templateList.map(({name}) => name).join(', ')}`);
@@ -236,56 +225,59 @@ module.exports = class CDSGenerator {
236
225
  _cleanupOptions() {
237
226
  let tokens = [];
238
227
 
239
- if (typeof this.options.add === 'string') {
240
- tokens = this.options.add.split(/[,\s+]/g);
228
+ const { options } = cds.cli
229
+ if (typeof options.add === 'string') {
230
+ tokens = options.add.split(/[,\s+]/g);
241
231
 
242
- } else if (Array.isArray(this.options.add)) {
243
- tokens = this.options.add
232
+ } else if (Array.isArray(options.add)) {
233
+ tokens = options.add
244
234
 
245
- } else if (this.options.add instanceof Set) {
246
- tokens = [...this.options.add];
235
+ } else if (options.add instanceof Set) {
236
+ tokens = [...options.add];
247
237
  }
248
238
 
249
239
  const trimmedTokens = tokens.map((token) => {
250
240
  token = token.replace(/\s+/g, '');
251
241
  const tokens = token.split(':'), [facet] = tokens
252
242
  if (tokens.length > 1) {
253
- if (this.options[facet]) {
254
- this.options[facet].add(token);
243
+ if (options[facet]) {
244
+ options[facet].add(token);
255
245
  } else {
256
- this.options[facet] = new Set([token]);
246
+ options[facet] = new Set([token]);
257
247
  }
258
248
  }
259
249
  return facet;
260
250
  }).filter(Boolean);
261
251
 
262
252
  // set is ordered ... always
263
- this.options.add = new Set(trimmedTokens);
253
+ options.add = new Set(trimmedTokens);
264
254
 
265
- if (this.options._cmd === COMMAND_INIT && !this.options.add.has(JAVA)) {
266
- this.options.add.add(NODEJS);
255
+ if (cds.cli.command === COMMAND_INIT && !options.add.has(JAVA)) {
256
+ options.add.add(NODEJS);
267
257
  }
268
258
 
269
259
  this._checkAdditionalOptions();
270
260
  }
271
261
 
272
262
  _checkAdditionalOptions() {
273
- for (const [key] of Object.entries(this.options)) {
274
- const keySplit = key.split(/:/);
263
+ const { options } = cds.cli
264
+ for (const [key] of Object.entries(options)) {
265
+ const keySplit = key.split(/:/)
275
266
  if (keySplit.length === 2) {
276
- if (!this.options.add.has(keySplit[0])) {
277
- LOG.warn(`ignoring option ${key} since ${keySplit[0]} is not part of specified feature list: ${Array.from(this.options.add).join(', ')}`);
267
+ if (!options.add.has(keySplit[0])) {
268
+ console.log(`ignoring option ${key} since ${keySplit[0]} is not part of specified feature list: ${Array.from(options.add).join(', ')}`)
278
269
  }
279
270
  }
280
271
  }
281
272
  }
282
273
 
283
274
  async _validateOptions() {
284
- if (this.options.force) {
275
+ const { options, command } = cds.cli
276
+ if (options.force) {
285
277
  return;
286
278
  }
287
279
 
288
- if (this.options._cmd === COMMAND_INIT) {
280
+ if (command === COMMAND_INIT) {
289
281
  await this._validateProjectName(this.projectName);
290
282
  await this._validateProjectFolder(this.cwd);
291
283
  }
@@ -293,7 +285,7 @@ module.exports = class CDSGenerator {
293
285
 
294
286
  async _validateProjectName(projectName) {
295
287
  if (!projectName) {
296
- throw new Error('Specify a project name.');
288
+ throw 'Specify a project name.'
297
289
  }
298
290
 
299
291
  // remove duplicates by using a set
@@ -302,9 +294,9 @@ module.exports = class CDSGenerator {
302
294
  case 0:
303
295
  break;
304
296
  case 1:
305
- throw new Error(`Project name ${projectName} contains an invalid character (${[...invalidChars].join(', ')}). Specify a different project name.`);
297
+ throw `Project name ${projectName} contains an invalid character (${[...invalidChars].join(', ')}). Specify a different project name.`
306
298
  default:
307
- throw new Error(`Project name ${projectName} contains invalid characters (${[...invalidChars].join(', ')}). Specify a different project name.`);
299
+ throw `Project name ${projectName} contains invalid characters (${[...invalidChars].join(', ')}). Specify a different project name.`
308
300
  }
309
301
  }
310
302
 
@@ -317,7 +309,7 @@ module.exports = class CDSGenerator {
317
309
  } else {
318
310
  message = `You seem to be trying to initialize an existing project. Use a different project name instead.`;
319
311
  }
320
- 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.`);
312
+ throw `${message}\nDetails: File '${existingProjectFile}' exists in the project folder which indicates an existing project. Use ${term.bold('cds add')} to add more features.`
321
313
  }
322
314
  }
323
315
  }
@@ -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,18 +23,21 @@ 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
- const { appPath = 'app' } = await readProject(this.options)
31
+ const { appPath = 'app' } = await readProject()
28
32
  const appPackageJSONPath = join(appPath, 'package.json')
29
33
  await mergeJSON(appPackageJSONPath, join(__dirname, 'files', 'package.json'))
30
34
  await sort(appPackageJSONPath, 'dependencies')
31
35
  await mergeJSON(join(appPath, 'default-env.json'), join(__dirname, 'files', 'default-env.json'))
32
- await this.runDependentMerging()
33
36
  }
34
37
 
35
38
  async runDependentMerging(context = {}) {
36
- const project = await readProject(this.options)
37
- const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath } = project
39
+ const project = await readProject()
40
+ const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath, appPath } = project
38
41
 
39
42
  if (hasMta) {
40
43
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
@@ -72,7 +75,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
72
75
 
73
76
  // add dependency entry in chart.yaml
74
77
  const HelmTemplate = require(`../helm`);
75
- const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
78
+ const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
76
79
  await helmTemplate.addDependency('web-application', 'approuter');
77
80
 
78
81
  await mergeYAML(
@@ -113,7 +116,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
113
116
  if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
114
117
  }
115
118
 
116
- const xsAppPath = join(project.appPath ?? 'app', 'xs-app.json')
119
+ const xsAppPath = join(appPath, 'xs-app.json')
117
120
  const additions = isExtensible ? [{ ...approuterExtensibility, at: 0 }] : []
118
121
  await mergeJSON(xsAppPath, join(__dirname, 'files', 'xs-app.json.hbs'), project, { additions })
119
122
  }
@@ -13,15 +13,14 @@ module.exports = class AuditlogTemplate extends require('../templateBase') {
13
13
  }
14
14
 
15
15
  async run() {
16
- const project = await readProject(this.options)
16
+ const project = await readProject()
17
17
  const { configFile } = project
18
18
  project.shortcut = !(await read(configFile)).cds?.requires?.['audit-log']?.kind
19
19
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
20
- await this.runDependentMerging()
21
20
  }
22
21
 
23
22
  async runDependentMerging(context = {}) {
24
- const project = await readProject(this.options)
23
+ const project = await readProject()
25
24
  const { isNodejs, hasMta, hasHelm, srvPath } = project
26
25
 
27
26
  if (hasMta) {
@@ -63,7 +62,7 @@ module.exports = class AuditlogTemplate extends require('../templateBase') {
63
62
 
64
63
  // copy service instance chart if it is not present
65
64
  const HelmTemplate = require(`../helm`);
66
- const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
65
+ const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
67
66
  isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
68
67
 
69
68
  // add dependency entry in chart.yaml
@@ -7,7 +7,7 @@ applications:
7
7
  # -----------------------------------------------------------------------------------
8
8
  # Backend Service
9
9
  # -----------------------------------------------------------------------------------
10
- - name: {{appName}}-{{srvName}}
10
+ - name: {{appName}}-srv
11
11
  random-route: true # for development only
12
12
  {{#isNodejs}}
13
13
  path: {{& srvPath}}
@@ -15,42 +15,34 @@ applications:
15
15
  buildpack: nodejs_buildpack
16
16
  {{/isNodejs}}
17
17
  {{#isJava}}
18
- path: {{& srvPath}}/target/{{srvExt.archiveName}}
18
+ path: {{& srvPath}}/target/{{archiveName}}
19
19
  memory: 1G
20
20
  disk_quota: 512M
21
21
  env:
22
22
  SPRING_PROFILES_ACTIVE: cloud
23
23
  buildpack: java_buildpack
24
24
  {{/isJava}}
25
- {{#hasRequires}}
26
25
  services:
27
- {{#requires}}
28
- {{#resource.isHana}}
29
- - {{resource.name}}
30
- {{/resource.isHana}}
31
- {{#resource.isXsuaa}}
32
- - {{resource.name}}
33
- {{/resource.isXsuaa}}
34
- {{/requires}}
35
- {{/hasRequires}}
26
+ {{#hasHana}}
27
+ - {{appName}}-db
28
+ {{/hasHana}}
29
+ {{#hasXsuaa}}
30
+ - {{appNames}}-auth
31
+ {{/hasXsuaa}}
36
32
 
37
- {{#needsSidecar}}
33
+ {{#hasHana}}
34
+ {{^isMultitenant}}
38
35
  # -----------------------------------------------------------------------------------
39
36
  # HANA Database Content Deployer App
40
37
  # -----------------------------------------------------------------------------------
41
- - name: {{appName}}-{{db.0.name}}-deployer
42
- path: {{& db.0.path}}
38
+ - name: {{appName}}-{{db.name}}-deployer
39
+ path: {{& db.path}}
43
40
  no-route: true
44
41
  health-check-type: process
45
42
  memory: 256M
46
43
  instances: 1
47
44
  buildpack: nodejs_buildpack
48
- {{#hasRequires}}
49
45
  services:
50
- {{#requires}}
51
- {{#resource.isHana}}
52
- - {{resource.name}}
53
- {{/resource.isHana}}
54
- {{/requires}}
55
- {{/hasRequires}}
56
- {{/needsSidecar}}
46
+ - {{appName}}-db
47
+ {{/isMultitenant}}
48
+ {{/hasHana}}
@@ -2,21 +2,26 @@
2
2
  # appName = {{appName}}
3
3
  ---
4
4
  create-services:
5
- {{#requires}}
6
- # ------------------------------------------------------------
7
- - name: {{resource.name}}
8
- {{#resource.isHana}}
9
- {{#resource.isPlainHana}}
10
- broker: {{resource.service}} # 'hanatrial' on trial landscapes
11
- plan: "hdi-shared"
12
- {{/resource.isPlainHana}}
13
- {{/resource.isHana}}
14
- {{#resource.isXsuaa}}
15
- broker: {{resource.service}}
5
+ {{#hasHana}}
6
+ {{#isMultitenant}}
7
+ - name: {{appName}}-db
8
+ broker: service-manager
9
+ plan: container
10
+ {{/isMultitenant}}
11
+ {{^isMultitenant}}
12
+ - name: {{appName}}-db
13
+ broker: hana
14
+ plan: hdi-shared
15
+ {{/isMultitenant}}
16
+ {{/hasHana}}
17
+ {{#hasXsuaa}}
18
+ - name: {{appName}}-auth
19
+ broker: xsuaa
16
20
  plan: application
17
- {{/resource.isXsuaa}}
18
- {{#resource.vcap.name}}
19
- broker: {{resource.service}}
20
- plan: {{resource.vcap.name}}
21
- {{/resource.vcap.name}}
22
- {{/requires}}
21
+ parameters: xs-security.json
22
+ {{/hasXsuaa}}
23
+ {{#hasAuditlog}}
24
+ - name: {{appName}}-auditlog
25
+ broker: auditlog
26
+ plan: application
27
+ {{/hasAuditlog}}
@@ -9,17 +9,17 @@ const SERVICES_MANIFEST_FILE = 'services-manifest.yml'
9
9
  module.exports = class CfManifestTemplate extends require('../templateBase') {
10
10
 
11
11
  async canRun() {
12
- if (this.options.force) {
13
- return true;
12
+ if (cds.cli.options.force) {
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
22
  const project = await readProject()
23
- await copyFiles(join(__dirname, 'files'), cds.root, project, this.options.force);
23
+ await copyFiles(join(__dirname, 'files'), cds.root, project, true)
24
24
  }
25
25
  }
@@ -11,14 +11,13 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
11
11
  }
12
12
 
13
13
  async run() {
14
- const project = await readProject(this.options)
14
+ const project = await readProject()
15
15
  const { configFile } = project
16
16
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
17
- await this.runDependentMerging()
18
17
  }
19
18
 
20
19
  async runDependentMerging(context = {}) {
21
- const project = await readProject(this.options)
20
+ const project = await readProject()
22
21
  const { isJava, srvPath, hasHelm, hasMta } = project
23
22
 
24
23
  if (hasMta) {
@@ -8,19 +8,19 @@ const DEBUG = cds.debug('cli')
8
8
  module.exports = class DataTemplate extends require('../templateBase') {
9
9
 
10
10
  async run() {
11
- if (this.options['for']) {
11
+ if (cds.cli.options.for) {
12
12
  throw `\nError: Did you mean \`... --data:for\` ?`
13
13
  }
14
14
 
15
15
  const env = await this.getEnv();
16
16
 
17
- let dest = (typeof this.options.out === 'string') // target folder
18
- ? this.options.out
17
+ let dest = (typeof cds.cli.options.out === 'string') // target folder
18
+ ? cds.cli.options.out
19
19
  : getDefaultTargetFolder(env);
20
20
  dest = resolve(cds.root, dest);
21
21
 
22
- const nameFilter = asRegex(this.options['data:for'])
23
- const force = this.options.force;
22
+ const nameFilter = asRegex(cds.cli.options['data:for'])
23
+ const { force } = cds.cli.options
24
24
 
25
25
  let csn = await cds.compile.to.csn(cds.env.roots) // normal CSN
26
26
 
@@ -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 /.*/