@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
@@ -10,16 +10,16 @@ using { sap.common, sap.common.Currencies } from '@sap/cds/common';
10
10
  // Books Lists
11
11
  //
12
12
  annotate my.Books with @(
13
- Common.SemanticKey : [ID],
14
- UI : {
15
- Identification : [{ Value: title }],
16
- SelectionFields : [
13
+ Common.SemanticKey: [ID],
14
+ UI: {
15
+ Identification: [{ Value: title }],
16
+ SelectionFields: [
17
17
  ID,
18
18
  author_ID,
19
19
  price,
20
20
  currency_code
21
21
  ],
22
- LineItem : [
22
+ LineItem: [
23
23
  { Value: ID, Label: '{i18n>Title}' },
24
24
  { Value: author.ID, Label: '{i18n>Author}' },
25
25
  { Value: genre.name },
@@ -29,16 +29,16 @@ annotate my.Books with @(
29
29
  ]
30
30
  }
31
31
  ) {
32
- ID @Common: {
33
- SemanticObject : 'Books',
32
+ ID @Common: {
33
+ SemanticObject: 'Books',
34
34
  Text: title,
35
- TextArrangement : #TextOnly
35
+ TextArrangement: #TextOnly
36
36
  };
37
- author @ValueList.entity : 'Authors';
37
+ author @ValueList.entity: 'Authors';
38
38
  };
39
39
 
40
40
  annotate Currencies with {
41
- symbol @Common.Label : '{i18n>Currency}';
41
+ symbol @Common.Label: '{i18n>Currency}';
42
42
  }
43
43
 
44
44
  ////////////////////////////////////////////////////////////////////////////
@@ -46,10 +46,10 @@ annotate Currencies with {
46
46
  // Books Details
47
47
  //
48
48
  annotate my.Books with @(UI : {HeaderInfo : {
49
- TypeName : '{i18n>Book}',
50
- TypeNamePlural : '{i18n>Books}',
51
- Title : { Value: title },
52
- Description : { Value: author.name }
49
+ TypeName : '{i18n>Book}',
50
+ TypeNamePlural: '{i18n>Books}',
51
+ Title : { Value: title },
52
+ Description : { Value: author.name }
53
53
  }, });
54
54
 
55
55
 
@@ -62,9 +62,9 @@ annotate my.Books with {
62
62
  title @title: '{i18n>Title}';
63
63
  genre @title: '{i18n>Genre}' @Common: { Text: genre.name, TextArrangement: #TextOnly };
64
64
  author @title: '{i18n>Author}' @Common: { Text: author.name, TextArrangement: #TextOnly };
65
- price @title: '{i18n>Price}' @Measures.ISOCurrency : currency_code;
65
+ price @title: '{i18n>Price}' @Measures.ISOCurrency: currency_code;
66
66
  stock @title: '{i18n>Stock}';
67
- descr @title: '{i18n>Description}' @UI.MultiLineText;
67
+ descr @title: '{i18n>Description}' @UI.MultiLineText;
68
68
  image @title: '{i18n>Image}';
69
69
  }
70
70
 
@@ -73,13 +73,13 @@ annotate my.Books with {
73
73
  // Genres List
74
74
  //
75
75
  annotate my.Genres with @(
76
- Common.SemanticKey : [name],
77
- UI : {
78
- SelectionFields : [name],
79
- LineItem : [
76
+ Common.SemanticKey: [name],
77
+ UI: {
78
+ SelectionFields: [name],
79
+ LineItem: [
80
80
  { Value: name },
81
81
  {
82
- Value : parent.name,
82
+ Value: parent.name,
83
83
  Label: 'Main Genre'
84
84
  },
85
85
  ],
@@ -95,17 +95,17 @@ annotate my.Genres with {
95
95
  // Genre Details
96
96
  //
97
97
  annotate my.Genres with @(UI : {
98
- Identification : [{ Value: name}],
99
- HeaderInfo : {
100
- TypeName : '{i18n>Genre}',
101
- TypeNamePlural : '{i18n>Genres}',
102
- Title : { Value: name },
103
- Description : { Value: ID }
98
+ Identification: [{ Value: name}],
99
+ HeaderInfo: {
100
+ TypeName : '{i18n>Genre}',
101
+ TypeNamePlural: '{i18n>Genres}',
102
+ Title : { Value: name },
103
+ Description : { Value: ID }
104
104
  },
105
- Facets : [{
106
- $Type : 'UI.ReferenceFacet',
107
- Label : '{i18n>SubGenres}',
108
- Target : 'children/@UI.LineItem'
105
+ Facets: [{
106
+ $Type : 'UI.ReferenceFacet',
107
+ Label : '{i18n>SubGenres}',
108
+ Target: 'children/@UI.LineItem'
109
109
  }, ],
110
110
  });
111
111
 
@@ -123,11 +123,11 @@ annotate my.Genres with {
123
123
  // Authors List
124
124
  //
125
125
  annotate my.Authors with @(
126
- Common.SemanticKey : [ID],
127
- UI : {
128
- Identification : [{ Value: name}],
129
- SelectionFields : [name],
130
- LineItem : [
126
+ Common.SemanticKey: [ID],
127
+ UI: {
128
+ Identification : [{ Value: name}],
129
+ SelectionFields: [ name ],
130
+ LineItem : [
131
131
  { Value: ID },
132
132
  { Value: dateOfBirth },
133
133
  { Value: dateOfDeath },
@@ -136,10 +136,10 @@ annotate my.Authors with @(
136
136
  ],
137
137
  }
138
138
  ) {
139
- ID @Common: {
140
- SemanticObject : 'Authors',
139
+ ID @Common: {
140
+ SemanticObject: 'Authors',
141
141
  Text: name,
142
- TextArrangement : #TextOnly,
142
+ TextArrangement: #TextOnly,
143
143
  };
144
144
  };
145
145
 
@@ -148,16 +148,16 @@ annotate my.Authors with @(
148
148
  // Author Details
149
149
  //
150
150
  annotate my.Authors with @(UI : {
151
- HeaderInfo : {
152
- TypeName : '{i18n>Author}',
153
- TypeNamePlural : '{i18n>Authors}',
154
- Title : { Value: name },
155
- Description : { Value: dateOfBirth }
151
+ HeaderInfo: {
152
+ TypeName : '{i18n>Author}',
153
+ TypeNamePlural: '{i18n>Authors}',
154
+ Title : { Value: name },
155
+ Description : { Value: dateOfBirth }
156
156
  },
157
- Facets : [{
158
- $Type : 'UI.ReferenceFacet',
159
- Target : 'books/@UI.LineItem'
160
- }, ],
157
+ Facets: [{
158
+ $Type : 'UI.ReferenceFacet',
159
+ Target: 'books/@UI.LineItem'
160
+ }],
161
161
  });
162
162
 
163
163
 
@@ -179,14 +179,11 @@ annotate my.Authors with {
179
179
  // Languages List
180
180
  //
181
181
  annotate common.Languages with @(
182
- Common.SemanticKey : [code],
183
- Identification : [{ Value: code}],
184
- UI : {
185
- SelectionFields : [
186
- name,
187
- descr
188
- ],
189
- LineItem : [
182
+ Common.SemanticKey: [code],
183
+ Identification: [{ Value: code }],
184
+ UI: {
185
+ SelectionFields: [ name, descr ],
186
+ LineItem: [
190
187
  { Value: code },
191
188
  { Value: name },
192
189
  ],
@@ -198,18 +195,18 @@ annotate common.Languages with @(
198
195
  // Language Details
199
196
  //
200
197
  annotate common.Languages with @(UI : {
201
- HeaderInfo : {
202
- TypeName : '{i18n>Language}',
203
- TypeNamePlural : '{i18n>Languages}',
204
- Title : { Value: name },
205
- Description : { Value: descr }
198
+ HeaderInfo: {
199
+ TypeName : '{i18n>Language}',
200
+ TypeNamePlural: '{i18n>Languages}',
201
+ Title : { Value: name },
202
+ Description : { Value: descr }
206
203
  },
207
- Facets : [{
208
- $Type : 'UI.ReferenceFacet',
209
- Label : '{i18n>Details}',
210
- Target : '@UI.FieldGroup#Details'
204
+ Facets: [{
205
+ $Type : 'UI.ReferenceFacet',
206
+ Label : '{i18n>Details}',
207
+ Target: '@UI.FieldGroup#Details'
211
208
  }, ],
212
- FieldGroup #Details : {Data : [
209
+ FieldGroup #Details: {Data : [
213
210
  { Value: code },
214
211
  { Value: name },
215
212
  { Value: descr }
@@ -221,14 +218,14 @@ annotate common.Languages with @(UI : {
221
218
  // Currencies List
222
219
  //
223
220
  annotate common.Currencies with @(
224
- Common.SemanticKey : [code],
225
- Identification : [{ Value: code}],
226
- UI : {
227
- SelectionFields : [
221
+ Common.SemanticKey: [code],
222
+ Identification: [{ Value: code}],
223
+ UI: {
224
+ SelectionFields: [
228
225
  name,
229
226
  descr
230
227
  ],
231
- LineItem : [
228
+ LineItem: [
232
229
  { Value: descr },
233
230
  { Value: symbol },
234
231
  { Value: code },
@@ -241,20 +238,20 @@ annotate common.Currencies with @(
241
238
  // Currency Details
242
239
  //
243
240
  annotate common.Currencies with @(UI : {
244
- HeaderInfo : {
245
- TypeName : '{i18n>Currency}',
246
- TypeNamePlural : '{i18n>Currencies}',
247
- Title : { Value: descr },
248
- Description : { Value: code }
241
+ HeaderInfo: {
242
+ TypeName : '{i18n>Currency}',
243
+ TypeNamePlural: '{i18n>Currencies}',
244
+ Title : { Value: descr },
245
+ Description : { Value: code }
249
246
  },
250
- Facets : [
247
+ Facets: [
251
248
  {
252
- $Type : 'UI.ReferenceFacet',
253
- Label : '{i18n>Details}',
254
- Target : '@UI.FieldGroup#Details'
249
+ $Type : 'UI.ReferenceFacet',
250
+ Label : '{i18n>Details}',
251
+ Target: '@UI.FieldGroup#Details'
255
252
  }
256
253
  ],
257
- FieldGroup #Details : {Data : [
254
+ FieldGroup #Details: {Data : [
258
255
  { Value: name },
259
256
  { Value: symbol },
260
257
  { Value: code },
@@ -2,4 +2,5 @@
2
2
  This model controls what gets served to Fiori frontends...
3
3
  */
4
4
  using from './common';
5
+ using from './browse/fiori-service';
5
6
  using from './admin-books/fiori-service';
@@ -1,9 +1,9 @@
1
1
  const term = require('../../../util/term')
2
- const { SAMPLE_TINY } = require('../../constants').OPTIONS
2
+ const { TINY_SAMPLE } = require('../../constants').OPTIONS
3
3
 
4
4
  module.exports = class SamplesTemplate extends require('../templateBase') {
5
5
  getDependencies() {
6
- console.warn(term.warn(`'cds add samples' is deprecated and will be removed in future versions. Please use 'cds add sample-tiny' instead.\n`))
7
- return [SAMPLE_TINY]
6
+ console.warn(term.warn(`'cds add samples' is deprecated and will be removed in future versions. Please use 'cds add tiny-sample' instead.\n`))
7
+ return [TINY_SAMPLE]
8
8
  }
9
9
  }
@@ -1,27 +1,7 @@
1
1
  {
2
2
  {{#isNodejs}}
3
3
  "devDependencies": {
4
- "sqlite3": "^5"
5
- },
6
- "cds": {
7
- {{/isNodejs}}
8
- "requires": {
9
- {{#profile}}
10
- "[{{profile}}]": {
11
- {{/profile}}
12
- {{#shortcut}}
13
- "db": "sqlite"
14
- {{/shortcut}}
15
- {{^shortcut}}
16
- "db": {
17
- "kind": "sqlite"
18
- }
19
- {{/shortcut}}
20
- {{#profile}}
21
- }
22
- {{/profile}}
23
- }
24
- {{#isNodejs}}
4
+ "@cap-js/sqlite": "^1"
25
5
  }
26
6
  {{/isNodejs}}
27
7
  }
@@ -7,9 +7,9 @@ const { mergeJSON } = require('../../util/merge')
7
7
  module.exports = class SQLiteTemplate extends require('../templateBase') {
8
8
 
9
9
  async run() {
10
- const projectDescriptor = await readProject(this.options)
11
- const { configFile } = projectDescriptor
12
- projectDescriptor.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
13
- await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), projectDescriptor)
10
+ const project = await readProject(this.options)
11
+ const { configFile } = project
12
+ project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
13
+ await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), project)
14
14
  }
15
15
  }
@@ -10,7 +10,7 @@ module.exports = class TemplateBase {
10
10
  */
11
11
  constructor(generator) {
12
12
  if (generator.options?.for && typeof generator.options?.for !== 'string') {
13
- throw new Error('The --for argument must not be empty.')
13
+ throw 'The --for argument must not be empty.'
14
14
  }
15
15
  this.projectPath = cds.root;
16
16
  this.options = generator.options || {};
@@ -4,4 +4,4 @@ entity Books {
4
4
  key ID : Integer;
5
5
  title : String;
6
6
  stock : Integer;
7
- }
7
+ }
@@ -2,4 +2,4 @@ using my.bookshop as my from '../{{ dbFolder }}/data-model';
2
2
 
3
3
  service CatalogService {
4
4
  @readonly entity Books as projection on my.Books;
5
- }
5
+ }
@@ -6,7 +6,7 @@ const mvnArchetypes = require('../../util/mvn')
6
6
  const term = require('../../../util/term')
7
7
  const { PROJECT_TYPE: { java, nodejs }, OPTIONS: { JAVA }, URLS } = require('../../constants')
8
8
 
9
- module.exports = class SampleTinyTemplate extends require('../templateBase') {
9
+ module.exports = class TinySampleTemplate extends require('../templateBase') {
10
10
 
11
11
  async run() {
12
12
  switch (this.getProjectType()) {
@@ -24,7 +24,7 @@ module.exports = class SampleTinyTemplate extends require('../templateBase') {
24
24
  await commandUtil.spawnCommand('mvn', mvnAddTestsArgs, { cwd: cds.root })
25
25
  } catch (err) {
26
26
  if (err.code === 'ENOENT' && err.path === 'mvn') {
27
- throw new Error(`Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`)
27
+ throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
28
28
  }
29
29
  throw err
30
30
  }
@@ -9,9 +9,9 @@ module.exports = class TogglesTemplate extends require('../templateBase') {
9
9
  }
10
10
 
11
11
  async run() {
12
- const projectDescriptor = await readProject(this.options)
13
- const { isNodejs , configFile} = projectDescriptor
14
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
12
+ const project = await readProject(this.options)
13
+ const { isNodejs , configFile} = project
14
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
15
15
  if (isNodejs) await sort('package.json', 'dependencies')
16
16
  await this.runDependentMerging()
17
17
  }
@@ -1,14 +1,15 @@
1
1
  const { join } = require('path')
2
2
  const { readProject } = require('../../util/projectReader')
3
3
  const { mergeJSON, mergeGitignore } = require('../../util/merge')
4
+ const { warn, secondary } = require('../../../util/term')
4
5
  const { TYPER } = require('../../constants').OPTIONS
5
6
  const { exists, read } = require('../../../cds').utils
6
7
 
7
8
  module.exports = class TyperTemplate extends require('../templateBase') {
8
9
  async canRun() {
9
- const projectDescriptor = await readProject(this.options)
10
- if (projectDescriptor.isJava) {
11
- console.warn(`WARNING: This appears to be a Java project. ${TYPER} facet is intended to be used in Node.js projects. Proceeding anyway`)
10
+ const { isJava } = await readProject(this.options)
11
+ if (isJava) {
12
+ console.warn(warn(`This appears to be a Java project. 'cds add ${TYPER}' is intended to be used in Node.js projects. Proceeding anyway.\n`))
12
13
  }
13
14
  return true
14
15
  }
@@ -24,13 +25,13 @@ module.exports = class TyperTemplate extends require('../templateBase') {
24
25
  }
25
26
  await mergeJSON('package.json', template('package.json'))
26
27
  await mergeGitignore('.gitignore', template('gitignore'))
27
- console.info('INFO: Adding this facet changed your .gitignore file to ignore generated types')
28
+ console.log(secondary(` > Adding '@cds-models' to .gitignore to ignore generated types`)) // REVISIT: other facets are silent wrt. what they change
28
29
  try {
29
30
  await mergeJSON(target, source)
30
31
  } catch (e) {
31
32
  throw e instanceof SyntaxError
32
33
  ? `SyntaxError in ${target}. This could indicate a JSON file with comments, which is not supported at this time. Remove all comments from ${target} and rerun or add the following entries manually:\n${JSON.stringify(source, null, 2)}`
33
34
  : e
34
- }
35
+ }
35
36
  }
36
37
  }
@@ -17,16 +17,16 @@ module.exports = class XsuaaTemplate extends require('../templateBase') {
17
17
  }
18
18
 
19
19
  async run() {
20
- const projectDescriptor = await readProject(this.options)
21
- const { configFile } = projectDescriptor
22
- projectDescriptor.shortcut = !(await read(configFile)).cds?.requires?.auth?.kind
23
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor, { forceOverwrite: true })
20
+ const project = await readProject(this.options)
21
+ const { configFile } = project
22
+ project.shortcut = !(await read(configFile)).cds?.requires?.auth?.kind
23
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project, { forceOverwrite: true })
24
24
  await this.runDependentMerging()
25
25
  }
26
26
 
27
27
  async runDependentMerging( context = {}) {
28
- const projectDescriptor = await readProject(this.options)
29
- const { isMultitenant, hasMta, hasHelm, isJava, srvPath } = projectDescriptor
28
+ const project = await readProject(this.options)
29
+ const { isMultitenant, hasMta, hasHelm, isJava, srvPath } = project
30
30
 
31
31
  const cds = require('../../../../lib')
32
32
  const xsSecurity = await (async () => { try {
@@ -41,7 +41,7 @@ module.exports = class XsuaaTemplate extends require('../templateBase') {
41
41
  isEqualTo: scope.name
42
42
  }],
43
43
  }))}
44
- await mergeJSON('xs-security.json', xsSecurity, projectDescriptor, mergingSemantics)
44
+ await mergeJSON('xs-security.json', xsSecurity, project, mergingSemantics)
45
45
 
46
46
  if (hasMta) {
47
47
  const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
@@ -58,7 +58,7 @@ module.exports = class XsuaaTemplate extends require('../templateBase') {
58
58
  into: [mtxSidecar, 'requires', 'name']
59
59
  })
60
60
 
61
- await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), projectDescriptor, { additions, relationships })
61
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, { additions, relationships })
62
62
  }
63
63
 
64
64
  if (hasHelm) {
@@ -80,7 +80,7 @@ module.exports = class XsuaaTemplate extends require('../templateBase') {
80
80
  await mergeYAML(
81
81
  join('chart', 'values.yaml'),
82
82
  join(__dirname, 'files', 'values.yaml.hbs'),
83
- projectDescriptor
83
+ project
84
84
  )
85
85
  if(isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
86
86
  }
@@ -6,7 +6,7 @@ const crypto = require('crypto');
6
6
  const os = require('os');
7
7
  const { copyRenderedYAML } = require('../../util/fs');
8
8
 
9
- async function copyAndTrack(source, dest, context = {}, { force = false, projectDescriptor } = {}) {
9
+ async function copyAndTrack(source, dest, context = {}, { force = false, project } = {}) {
10
10
  await mkdirp(dirname(dest));
11
11
  if (isdir(source)) {
12
12
  const dirents = await readdir(source);
@@ -17,7 +17,7 @@ async function copyAndTrack(source, dest, context = {}, { force = false, project
17
17
  console.log('Chart file ' + dest + ' has been modified and will not be updated.');
18
18
  } else {
19
19
  _track(dest, data, context);
20
- if (projectDescriptor) return copyRenderedYAML(source, dest, projectDescriptor)
20
+ if (project) return copyRenderedYAML(source, dest, project)
21
21
  return copy(source).to(dest);
22
22
  }
23
23
  }
@@ -38,23 +38,23 @@ async function sort(path, key) {
38
38
  /**
39
39
  * @param {string} into - file path to merge into
40
40
  * @param {string | string[]} from - either path to file (string) or lines from source gitignore (string[])
41
- * @returns {string[]} the lines of the updated .gitignore
41
+ * @returns {Promise<string[]>} the lines of the updated .gitignore
42
42
  */
43
43
  async function mergeGitignore (into, from) {
44
44
  const source = typeof from === 'string' ? (await read(from)).split(EOL) : from
45
-
45
+
46
46
  if (typeof into === 'string' && !exists(into)) {
47
47
  return write(into, source.join(EOL))
48
48
  }
49
-
49
+
50
50
  const target = (await read(into)).split(EOL)
51
51
  const enhanced = target.concat(source.filter(line => !target.includes(line)))
52
52
  await write(into, enhanced.join(EOL))
53
53
  return enhanced
54
54
  }
55
55
 
56
- async function mergeJSON(into, from, projectDescriptor, semantics) {
57
- const source = typeof from === 'string' ? await readJSON(from, projectDescriptor) : from
56
+ async function mergeJSON(into, from, project, semantics) {
57
+ const source = typeof from === 'string' ? await readJSON(from, project) : from
58
58
 
59
59
  if (typeof into === 'string' && !exists(into)) {
60
60
  return write(into, source, { spaces: 2 })
@@ -65,7 +65,7 @@ async function mergeJSON(into, from, projectDescriptor, semantics) {
65
65
  const target = await read(into)
66
66
  const targetYAML = YAML.parseDocument(YAML.stringify(target))
67
67
  const sourceYAML = YAML.parseDocument(YAML.stringify(source))
68
- const resultYAML = await mergeYAML(targetYAML, sourceYAML, projectDescriptor, semantics)
68
+ const resultYAML = await mergeYAML(targetYAML, sourceYAML, project, semantics)
69
69
  result = YAML.parse(YAML.stringify(resultYAML))
70
70
  } else {
71
71
  const target = typeof into === 'string' ? await read(into) : into
@@ -75,13 +75,13 @@ async function mergeJSON(into, from, projectDescriptor, semantics) {
75
75
  return result
76
76
  }
77
77
 
78
- async function mergeYAML(into, from, projectDescriptor, semantics = {}) {
78
+ async function mergeYAML(into, from, project, semantics = {}) {
79
79
  const target = typeof into === 'string' ? await readYAML(into) : into instanceof YAML.Document ? into : new YAML.Document(into)
80
- const source = typeof from === 'string' ? await readYAML(from, projectDescriptor) : from instanceof YAML.Document ? from : new YAML.Document(from)
80
+ const source = typeof from === 'string' ? await readYAML(from, project) : from instanceof YAML.Document ? from : new YAML.Document(from)
81
81
 
82
82
  if (!target || !target.contents) {
83
83
  if (typeof into === 'string' && typeof from === 'string') {
84
- return projectDescriptor ? writeYAML(into, source) : copy(from, into)
84
+ return project ? writeYAML(into, source) : copy(from, into)
85
85
  }
86
86
  return /* has no YAML */
87
87
  }
@@ -164,7 +164,7 @@ class MvnArchetypeUtil {
164
164
  if (packageFromParam) {
165
165
  // explicitly specified, so do not modify
166
166
  if (!options.force && !packageFromParam.match(REGEX_JAVA_PACKAGE)) {
167
- throw new Error(`Package '${packageFromParam}' is an invalid Java package name. Use --force to use it anyway.`);
167
+ throw `Package '${packageFromParam}' is an invalid Java package name. Use --force to use it anyway.`
168
168
  }
169
169
  } else {
170
170
  // potentially overwritten by mvn param
@@ -43,8 +43,8 @@ module.exports = new class ProjectReader {
43
43
  get hasRequires() { return this.requires.length > 0 },
44
44
  get needsSidecar() { return (options?.add.has('hana') || this.db.length > 0) && (this.isJava || !this.isMultitenant) },
45
45
  get configFile() { return exists('pom.xml') ? '.cdsrc.json' : 'package.json' },
46
- get isNodejs() { return this.language === P_LANGUAGE_NODEJS },
47
- get isJava() { return this.language === P_LANGUAGE_JAVA },
46
+ get isNodejs() { return _hasFacet('nodejs') },
47
+ get isJava() { return _hasFacet('java') },
48
48
  get hasSidecar() { return exists('mtx', 'sidecar') },
49
49
  get isMultitenant() { return _hasFacet('multitenancy') },
50
50
  get isExtensible() { return _hasFacet('extensibility') },
@@ -56,7 +56,7 @@ module.exports = new class ProjectReader {
56
56
  get hasHtml5Repo() { return _hasFacet('html5-repo') },
57
57
  get hasMta() { return _hasFacet('mta') },
58
58
  get hasHelm() { return _hasFacet('helm') },
59
- get appPath() { return env.folders.app },
59
+ get appPath() { return env.folders.app ?? 'app' },
60
60
  }
61
61
 
62
62
  // setting the effective env as it might have changed by already executed 'add' commands, e.g. cds init foo --add hana,mta
@@ -102,7 +102,7 @@ module.exports = new class ProjectReader {
102
102
  const dependencies = pom?.dependencies?.[0]?.dependency
103
103
  const isOldJavaRuntime = [...dependencies].some(d => /com\.sap\.cloud\.servicesdk/.test(d?.groupId?.[0]))
104
104
  if (isOldJavaRuntime) {
105
- throw new Error("Projects using the classic CAP Java SDK are not supported")
105
+ throw "Projects using the classic CAP Java SDK are not supported"
106
106
  }
107
107
 
108
108
  const descriptor = { archiveName: path.basename(cds.root) + "-exec.jar" }
package/lib/util/fs.js CHANGED
@@ -11,7 +11,7 @@ module.exports = new class FsUtil {
11
11
  this.copyRenderedYAML = this.copyRenderedYAML.bind(this)
12
12
  }
13
13
 
14
- async readYAML(src, projectDescriptor) {
14
+ async readYAML(src, project) {
15
15
  let file
16
16
  try {
17
17
  file = await read(src, 'utf8')
@@ -19,9 +19,9 @@ module.exports = new class FsUtil {
19
19
  if (e.code === 'ENOENT') return undefined
20
20
  throw e
21
21
  }
22
- if (projectDescriptor) {
22
+ if (project) {
23
23
  const Mustache = require('mustache')
24
- const renderedFile = Mustache.render(file, projectDescriptor)
24
+ const renderedFile = Mustache.render(file, project)
25
25
  return YAML.parseDocument(renderedFile)
26
26
  }
27
27
  return YAML.parseDocument(file)
@@ -32,16 +32,16 @@ module.exports = new class FsUtil {
32
32
  await write(content).to(dst)
33
33
  }
34
34
 
35
- async copyRenderedYAML(src, dst, projectDescriptor) {
36
- const yaml = await this.readYAML(src, projectDescriptor)
35
+ async copyRenderedYAML(src, dst, project) {
36
+ const yaml = await this.readYAML(src, project)
37
37
  await write(yaml.toString()).to(dst)
38
38
  }
39
39
 
40
- async readJSON(src, projectDescriptor) {
40
+ async readJSON(src, project) {
41
41
  const file = await read(src, 'utf8')
42
- if (projectDescriptor) {
42
+ if (project) {
43
43
  const Mustache = require('mustache')
44
- const renderedFile = Mustache.render(file, projectDescriptor)
44
+ const renderedFile = Mustache.render(file, project)
45
45
  return JSON.parse(renderedFile)
46
46
  }
47
47
  return JSON.parse(file)
@@ -51,8 +51,8 @@ module.exports = new class FsUtil {
51
51
  return JSONC.parse(await read(src, 'utf8'))
52
52
  }
53
53
 
54
- async copyRenderedJSON(src, dst, projectDescriptor) {
55
- const json = await this.readJSON(src, projectDescriptor)
54
+ async copyRenderedJSON(src, dst, project) {
55
+ const json = await this.readJSON(src, project)
56
56
  await write(dst, json, { spaces: 2 })
57
57
  }
58
58
  }