@sap/cds-dk 6.5.2 → 6.6.1

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 (124) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/bin/activate.js +7 -0
  3. package/bin/add.js +1 -2
  4. package/bin/build/all.js +14 -9
  5. package/bin/cds.js +11 -8
  6. package/bin/compile/index.js +13 -3
  7. package/bin/env.js +16 -25
  8. package/bin/extend.js +8 -0
  9. package/bin/init.js +0 -3
  10. package/bin/login.js +3 -7
  11. package/bin/logout.js +2 -7
  12. package/bin/watch.js +4 -5
  13. package/lib/client/activate.js +1 -1
  14. package/lib/client/helper/errors.js +4 -1
  15. package/lib/client/params.js +4 -3
  16. package/lib/client/pull.js +31 -5
  17. package/lib/client/push.js +3 -3
  18. package/lib/client/settings_manager.js +6 -6
  19. package/lib/client/subscription.js +1 -1
  20. package/lib/compile/asyncapi/channels.js +22 -0
  21. package/lib/compile/asyncapi/components/messageTraits/index.js +89 -0
  22. package/lib/compile/asyncapi/components/messages/index.js +150 -0
  23. package/lib/compile/asyncapi/components/schemas/annotations.js +13 -0
  24. package/lib/compile/asyncapi/components/schemas/array.js +8 -0
  25. package/lib/compile/asyncapi/components/schemas/cache.js +14 -0
  26. package/lib/compile/asyncapi/components/schemas/definition.js +187 -0
  27. package/lib/compile/asyncapi/components/schemas/enum.js +16 -0
  28. package/lib/compile/asyncapi/components/schemas/examples.js +10 -0
  29. package/lib/compile/asyncapi/components/schemas/index.js +14 -0
  30. package/lib/compile/asyncapi/components/schemas/localized.js +29 -0
  31. package/lib/compile/asyncapi/components/schemas/primitiveElement.js +41 -0
  32. package/lib/compile/asyncapi/components/schemas/ref.js +45 -0
  33. package/lib/compile/asyncapi/components/schemas/utils.js +108 -0
  34. package/lib/compile/asyncapi/index.js +226 -0
  35. package/lib/compile/asyncapi/message.js +13 -0
  36. package/lib/compile/asyncapi/utils.js +27 -0
  37. package/lib/compile/index.js +1 -0
  38. package/lib/compile/openapi/csdl2openapi.js +42 -18
  39. package/lib/import/message.js +4 -1
  40. package/lib/import/odata/metadataconverter/MetadataConverter.js +8 -3
  41. package/lib/import/odata/v2parser.js +131 -50
  42. package/lib/import/odata/v4parser.js +292 -112
  43. package/lib/import/openapi/importOpenAPI.js +14 -14
  44. package/lib/init/constants.js +1 -1
  45. package/lib/init/index.js +11 -21
  46. package/lib/init/template/_merging/registry-mta.js +15 -26
  47. package/lib/init/template/approuter/files/package.json +2 -2
  48. package/lib/init/template/approuter/index.js +6 -12
  49. package/lib/init/template/auditlog/files/auditlog.yaml +4 -1
  50. package/lib/init/template/auditlog/index.js +23 -8
  51. package/lib/init/template/cf-manifest/index.js +4 -14
  52. package/lib/init/template/connectivity/files/connectivity-proxy-info.yaml +2 -6
  53. package/lib/init/template/connectivity/files/values.yaml.hbs +5 -8
  54. package/lib/init/template/connectivity/index.js +2 -9
  55. package/lib/init/template/data/index.js +0 -4
  56. package/lib/init/template/destinations/files/destination.yaml +4 -1
  57. package/lib/init/template/destinations/index.js +25 -10
  58. package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +4 -1
  59. package/lib/init/template/enterprise-messaging/files/values.yaml +1 -2
  60. package/lib/init/template/enterprise-messaging/index.js +28 -20
  61. package/lib/init/template/extensibility/index.js +23 -31
  62. package/lib/init/template/hana/files/hana.yaml +4 -1
  63. package/lib/init/template/hana/index.js +44 -24
  64. package/lib/init/template/helm/chart/templates/_helpers.tpl +12 -0
  65. package/lib/init/template/helm/chart/values.root.schema.json +40 -0
  66. package/lib/init/template/helm/chart/values.schema.json +32 -69
  67. package/lib/init/template/helm/index.js +26 -16
  68. package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +13 -26
  69. package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +3 -3
  70. package/lib/init/template/helm/subcharts/content-deployment/templates/service-account.yaml +2 -0
  71. package/lib/init/template/helm/subcharts/content-deployment/templates/service-binding.yaml +3 -3
  72. package/lib/init/template/helm/subcharts/content-deployment/templating.md +37 -0
  73. package/lib/init/template/helm/subcharts/content-deployment/values.md +182 -185
  74. package/lib/init/template/helm/subcharts/content-deployment/values.schema.json +18 -22
  75. package/lib/init/template/helm/subcharts/content-deployment/values.yaml +2 -0
  76. package/lib/init/template/helm/subcharts/service-instance/Chart.yaml +5 -0
  77. package/lib/init/template/helm/subcharts/service-instance/templates/_helpers.tpl +65 -0
  78. package/lib/init/template/helm/subcharts/service-instance/templates/serviceinstance.yaml +23 -0
  79. package/lib/init/template/helm/subcharts/service-instance/templating.md +18 -0
  80. package/lib/init/template/helm/subcharts/service-instance/values-lint.yaml +2 -0
  81. package/lib/init/template/helm/subcharts/service-instance/values.md +186 -0
  82. package/lib/init/template/helm/subcharts/service-instance/values.schema.json +102 -0
  83. package/lib/init/template/helm/subcharts/service-instance/values.yaml +15 -0
  84. package/lib/init/template/html5-repo/files/html5-apps-deployer-configmap.yaml +2 -2
  85. package/lib/init/template/html5-repo/files/html5-apps-repo-host.yaml +4 -1
  86. package/lib/init/template/html5-repo/index.js +30 -21
  87. package/lib/init/template/java/index.js +3 -6
  88. package/lib/init/template/kibana-logging/index.js +7 -10
  89. package/lib/init/template/lint/index.js +2 -3
  90. package/lib/init/template/mta/files/mta.yaml.hbs +4 -2
  91. package/lib/init/template/mta/index.js +7 -11
  92. package/lib/init/template/mtx/index.js +0 -5
  93. package/lib/init/template/multitenancy/files/java/package.json +16 -7
  94. package/lib/init/template/multitenancy/files/mta.yaml.hbs +11 -3
  95. package/lib/init/template/multitenancy/files/saas-registry-secret.yaml +9 -0
  96. package/lib/init/template/multitenancy/files/saas-registry.yaml +4 -17
  97. package/lib/init/template/multitenancy/files/service-manager.yaml +4 -1
  98. package/lib/init/template/multitenancy/files/values.yaml.hbs +15 -3
  99. package/lib/init/template/multitenancy/index.js +56 -31
  100. package/lib/init/template/nodejs/index.js +4 -7
  101. package/lib/init/template/notebook/index.js +1 -3
  102. package/lib/init/template/pipeline/index.js +2 -5
  103. package/lib/init/template/samples/index.js +6 -11
  104. package/lib/init/template/templateBase.js +10 -17
  105. package/lib/init/template/toggles/index.js +2 -6
  106. package/lib/init/template/xsuaa/files/values.yaml.hbs +0 -1
  107. package/lib/init/template/xsuaa/files/xsuaa.yaml +4 -1
  108. package/lib/init/template/xsuaa/index.js +27 -23
  109. package/lib/init/types.d.ts +0 -81
  110. package/lib/init/util/merge.js +23 -25
  111. package/lib/init/util/mvnArchetypeUtil.js +34 -2
  112. package/lib/init/util/projectReader.js +27 -24
  113. package/lib/lint/Linter.js +31 -13
  114. package/lib/watch/livereload-server.js +29 -17
  115. package/lib/watch/node-watch.js +51 -49
  116. package/npm-shrinkwrap.json +548 -467
  117. package/package.json +4 -4
  118. package/readme.md +5 -0
  119. package/lib/init/template/connectivity/files/connectivity-binding.yaml +0 -9
  120. package/lib/init/template/connectivity/files/connectivity.yaml +0 -1
  121. package/lib/init/template/multitenancy/files/xsuaa.yaml +0 -1
  122. /package/lib/init/template/hana/files/{chart.yaml → hana-deployer.yaml} +0 -0
  123. /package/lib/init/template/html5-repo/files/{chart.yaml → html5-apps-deployer.yaml} +0 -0
  124. /package/lib/init/template/multitenancy/files/{chart.yaml → sidecar.yaml} +0 -0
@@ -129,32 +129,32 @@ function operations(context, csn, input) {
129
129
  if (param.description) cdsParam["@description"] = param.description;
130
130
  cdsParam["@openapi.in"] = param.in;
131
131
 
132
+ // only add the annotation "@openapi.explode" for true scenario
133
+ if (param.explode || param.style === "form")
134
+ cdsParam["@openapi.explode"] = true;
135
+ if (!param.explode)
136
+ delete cdsParam["@openapi.explode"];
137
+
132
138
  if ((param.in === "path" && param.style && param.style !== "simple") ||
133
139
  (param.in === "query" && param.style && param.style !== "form")
134
140
  )
135
141
  cdsParam["@openapi.style"] = param.style;
136
-
137
- if (param.explode && param.style !== "form")
138
- cdsParam["@openapi.explode"] = true;
139
-
140
- if (param.explode === false &&
141
- (param.style === "form" || (!param.style && param.in === "query"))
142
- )
143
- cdsParam["@openapi.explode"] = false;
144
-
145
- if (param.in === "query" && param.collectionFormat === "csv")
146
- cdsParam["@openapi.explode"] = false;
147
142
  if (param.in === "query" && param.collectionFormat === "ssv")
148
143
  cdsParam["@openapi.style"] = "spaceDelimited";
149
144
  if (param.in === "query" && param.collectionFormat === "pipes")
150
145
  cdsParam["@openapi.style"] = "pipeDelimited";
146
+
151
147
  if (param.in === "query" && param.allowReserved === true)
152
148
  cdsParam["@openapi.allowReserved"] = true;
149
+
153
150
  if (param.required && param.in !== "path")
154
151
  cdsParam["@openapi.required"] = true;
155
- if (!param.required)
156
- delete cdsParam.notNull;
157
152
 
153
+ if (!param.required) {
154
+ delete param.notNull;
155
+ if (param.default !== undefined)
156
+ cdsParam["default"] = { "val": param.default };
157
+ }
158
158
  const name = cdsName(param.name);
159
159
  if (name !== param.name) cdsParam["@openapi.name"] = param.name;
160
160
  cdsOperation.params[name] = cdsParam;
@@ -382,8 +382,8 @@ function cdsType(
382
382
  }
383
383
 
384
384
  function addDefault(type, schema, forParameter) {
385
+ if (schema.default !== undefined) type.default = { val: schema.default };
385
386
  if (forParameter) return;
386
- if (schema.default) type.default = { val: schema.default };
387
387
  }
388
388
 
389
389
  function addPrimitiveExample(type, schema) {
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '1.31.1';
3
+ const MAVEN_ARCHETYPE_VERSION = '1.32.0';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
package/lib/init/index.js CHANGED
@@ -133,7 +133,7 @@ module.exports = class CDSGenerator {
133
133
  this._initialize(null, options);
134
134
  this._greetings(options._cmd);
135
135
 
136
- if (!(await this._findProjectFile(this.projectPath))) {
136
+ if (!PROJECT_FILES.find(exists)) {
137
137
  throw new Error(`The current folder doesn't seem to contain a project. None of the following files found: ${PROJECT_FILES.join(', ')}.`);
138
138
  }
139
139
 
@@ -159,16 +159,6 @@ module.exports = class CDSGenerator {
159
159
  await this._process();
160
160
  }
161
161
 
162
- async _findProjectFile(projectPath) {
163
- for (const file of PROJECT_FILES) {
164
- if (exists(path.join(projectPath, file))) {
165
- return file;
166
- }
167
- }
168
-
169
- return null;
170
- }
171
-
172
162
  _initialize(projectName, options = {}) {
173
163
  // deprecated, only for compatibility
174
164
  if (options.verbose) {
@@ -176,8 +166,8 @@ module.exports = class CDSGenerator {
176
166
  }
177
167
 
178
168
  this.cwd = options.cwd || process.cwd();
179
- this.projectPath = path.resolve(this.cwd, projectName || '.');
180
- this.projectName = path.basename(this.projectPath);
169
+ cds.root = path.resolve(this.cwd, projectName || '.');
170
+ this.projectName = path.basename(cds.root);
181
171
 
182
172
  this.options = options;
183
173
  this._cleanupOptions();
@@ -186,7 +176,7 @@ module.exports = class CDSGenerator {
186
176
  _greetings(cmd) {
187
177
  switch (cmd) {
188
178
  case COMMAND_INIT: {
189
- const relativeProjectPath = path.relative(this.cwd, this.projectPath);
179
+ const relativeProjectPath = path.relative(this.cwd, cds.root);
190
180
  const folderName = (relativeProjectPath ? `.${path.sep}${relativeProjectPath}` : 'current folder');
191
181
  LOG.info(`Creating new cap project in ${folderName}`);
192
182
  break;
@@ -204,7 +194,7 @@ module.exports = class CDSGenerator {
204
194
  }
205
195
 
206
196
  async _process() {
207
- DEBUG && DEBUG(`Project path: ${this.projectPath}`);
197
+ DEBUG && DEBUG(`Project path: ${cds.root}`);
208
198
 
209
199
  await this._validateOptions();
210
200
  await this._fillTemplateList();
@@ -222,7 +212,7 @@ module.exports = class CDSGenerator {
222
212
  async _createTemplate(filename) {
223
213
  try {
224
214
  const TemplateClass = require(`./template/${filename}`);
225
- return new TemplateClass(this.projectPath, this);
215
+ return new TemplateClass(this);
226
216
  } catch (err) {
227
217
  if (err.code === 'MODULE_NOT_FOUND') {
228
218
  const entries = (await readdir(path.join(__dirname, 'template')))
@@ -234,7 +224,7 @@ module.exports = class CDSGenerator {
234
224
  );
235
225
  const fuzzySearch = require('../../bin/util/fuzzySearch');
236
226
  const [bestMatch] = fuzzySearch(filename, entries);
237
- console.log(`Unknown facet '${term.bold(filename)}'. Did you mean ${term.bold(`cds add ${bestMatch}`)}?\n\nHaven't found the proper facet yet? Here are all supported facets:\n\n ${term.bold(entries.join('\n '))}\n`);
227
+ LOG.info(`Unknown facet '${term.bold(filename)}'. Did you mean ${term.bold(`cds add ${bestMatch}`)}?\n\nHaven't found the proper facet yet? Here are all supported facets:\n\n ${term.bold(entries.join('\n '))}\n`);
238
228
  process.exit(1);
239
229
  }
240
230
  throw err;
@@ -330,7 +320,7 @@ module.exports = class CDSGenerator {
330
320
 
331
321
  if (this.options._cmd === COMMAND_INIT) {
332
322
  await this._validateProjectName(this.projectName);
333
- await this._validateProjectFolder(this.projectPath, this.cwd);
323
+ await this._validateProjectFolder(this.cwd);
334
324
  }
335
325
  }
336
326
 
@@ -351,11 +341,11 @@ module.exports = class CDSGenerator {
351
341
  }
352
342
  }
353
343
 
354
- async _validateProjectFolder(projectPath, cwd) {
355
- const existingProjectFile = await this._findProjectFile(projectPath);
344
+ async _validateProjectFolder(cwd) {
345
+ const existingProjectFile = PROJECT_FILES.find(exists)
356
346
  if (existingProjectFile) {
357
347
  let message;
358
- if (cwd === projectPath) {
348
+ if (cwd === cds.root) {
359
349
  message = `You seem to be working in a project which is already initialized. Use ${term.bold('cds add')} to add more features.`;
360
350
  } else {
361
351
  message = `You seem to be trying to initialize an existing project. Use a different project name instead.`;
@@ -1,7 +1,6 @@
1
1
  // Registry of sequence matchers in mta.yaml files
2
2
 
3
3
  const srvNode = {
4
- ref: 'srv',
5
4
  in: 'modules',
6
5
  where: [{
7
6
  property: 'type',
@@ -10,7 +9,6 @@ const srvNode = {
10
9
  }
11
10
 
12
11
  const srvJava = {
13
- ref: 'srv',
14
12
  in: 'modules',
15
13
  where: [{
16
14
  property: 'type',
@@ -19,7 +17,6 @@ const srvJava = {
19
17
  }
20
18
 
21
19
  const approuter = {
22
- ref: 'approuter',
23
20
  in: 'modules',
24
21
  where: [{
25
22
  property: 'type',
@@ -28,7 +25,6 @@ const approuter = {
28
25
  }
29
26
 
30
27
  const xsuaa = {
31
- ref: 'uaa-resource',
32
28
  in: 'resources',
33
29
  where: [{
34
30
  property: 'type',
@@ -43,7 +39,6 @@ const xsuaa = {
43
39
  }
44
40
 
45
41
  const auditlog = {
46
- ref: 'auditlog-resource',
47
42
  in: 'resources',
48
43
  where: [{
49
44
  property: 'type',
@@ -55,7 +50,6 @@ const auditlog = {
55
50
  }
56
51
 
57
52
  const enterpriseMessaging = {
58
- ref: 'enterprise-messaging-resource',
59
53
  in: 'resources',
60
54
  where: [{
61
55
  property: 'type',
@@ -67,7 +61,6 @@ const enterpriseMessaging = {
67
61
  }
68
62
 
69
63
  const kibanaLogging = {
70
- ref: 'cf-logging',
71
64
  in: 'resources',
72
65
  where: [{
73
66
  property: 'type',
@@ -82,7 +75,6 @@ const kibanaLogging = {
82
75
  }
83
76
 
84
77
  const hdbDeployer = {
85
- ref: 'deployer',
86
78
  in: 'modules',
87
79
  where: [{
88
80
  property: 'type',
@@ -91,7 +83,6 @@ const hdbDeployer = {
91
83
  }
92
84
 
93
85
  const hdiContainer = {
94
- ref: 'hdi-container-resource',
95
86
  in: 'resources',
96
87
  where: [{
97
88
  property: 'type',
@@ -100,7 +91,6 @@ const hdiContainer = {
100
91
  }
101
92
 
102
93
  const serviceManager = {
103
- ref: 'service-manager-resource',
104
94
  in: 'resources',
105
95
  where: [{
106
96
  property: 'type',
@@ -115,7 +105,6 @@ const serviceManager = {
115
105
  }
116
106
 
117
107
  const saasRegistry = {
118
- ref: 'registry-resource',
119
108
  in: 'resources',
120
109
  where: [{
121
110
  property: 'type',
@@ -127,7 +116,6 @@ const saasRegistry = {
127
116
  }
128
117
 
129
118
  const srvAPI = {
130
- ref: 'srvAPI',
131
119
  in: 'provides',
132
120
  where: [{
133
121
  property: 'name',
@@ -139,7 +127,6 @@ const srvAPI = {
139
127
  }
140
128
 
141
129
  const mtxSidecar = {
142
- ref: 'sidecar',
143
130
  in: 'modules',
144
131
  where: [{
145
132
  property: 'type',
@@ -150,9 +137,19 @@ const mtxSidecar = {
150
137
  }]
151
138
  }
152
139
 
153
- const providedMtxAPI = {
154
- ref: 'provided-mtx-api',
155
- in: 'provides',
140
+ const providedMtxAPISrv = {
141
+ in: [srvNode, 'provides'],
142
+ where: [{
143
+ property: 'name',
144
+ isEqualTo: 'mtx-api'
145
+ }, {
146
+ property: 'properties.mtx-url',
147
+ isEqualTo: '${default-url}'
148
+ }]
149
+ }
150
+
151
+ const providedMtxAPISidecar = {
152
+ in: [mtxSidecar, 'provides'],
156
153
  where: [{
157
154
  property: 'name',
158
155
  isEqualTo: 'mtx-api'
@@ -163,7 +160,6 @@ const providedMtxAPI = {
163
160
  }
164
161
 
165
162
  const requiredMtxAPI = {
166
- ref: 'required-mtx-api',
167
163
  in: [approuter, 'requires'],
168
164
  where: [{
169
165
  property: 'properties.name',
@@ -175,7 +171,6 @@ const requiredMtxAPI = {
175
171
  }
176
172
 
177
173
  const providedAppAPI = {
178
- ref: 'provided-app-api',
179
174
  in: [approuter, 'provides'],
180
175
  where: [{
181
176
  property: 'name',
@@ -190,7 +185,6 @@ const providedAppAPI = {
190
185
  }
191
186
 
192
187
  const requiredAppAPI = {
193
- ref: 'required-app-api',
194
188
  in: [srvNode, 'requires'],
195
189
  where: [{
196
190
  property: 'name',
@@ -202,7 +196,6 @@ const requiredAppAPI = {
202
196
  }
203
197
 
204
198
  const providedMtxSidecarAPI = {
205
- ref: 'provided-mtx-sidecar-api',
206
199
  in: [mtxSidecar, 'provides'],
207
200
  where: [{
208
201
  property: 'properties.url',
@@ -211,7 +204,6 @@ const providedMtxSidecarAPI = {
211
204
  }
212
205
 
213
206
  const requiredMtxSidecarAPI = {
214
- ref: 'required-mtx-sidecar-api',
215
207
  in: [srvJava, 'requires'],
216
208
  where: [{
217
209
  property: 'properties.CDS_MULTITENANCY_SIDECAR_URL',
@@ -220,7 +212,6 @@ const requiredMtxSidecarAPI = {
220
212
  }
221
213
 
222
214
  const requiredJavaApprouterAPI = {
223
- ref: 'required-java-approuter-api',
224
215
  in: [srvJava, 'requires'],
225
216
  where: [{
226
217
  property: 'properties.CDS_MULTITENANCY_APPUI_URL',
@@ -229,7 +220,6 @@ const requiredJavaApprouterAPI = {
229
220
  }
230
221
 
231
222
  const providedJavaApprouterAPI = {
232
- ref: 'provided-java-approuter-api',
233
223
  in: [approuter, 'requires'],
234
224
  where: [{
235
225
  property: 'properties.url',
@@ -238,7 +228,6 @@ const providedJavaApprouterAPI = {
238
228
  }
239
229
 
240
230
  const approuterExtensibility = {
241
- ref: 'approuter-extensibility',
242
231
  in: 'routes',
243
232
  where: [{
244
233
  property: 'source',
@@ -253,7 +242,6 @@ const approuterExtensibility = {
253
242
  }
254
243
 
255
244
  const approuterExtensibilityJava = {
256
- ref: 'approuter-extensibility-java',
257
245
  in: 'routes',
258
246
  where: [{
259
247
  property: 'source',
@@ -280,7 +268,8 @@ module.exports = {
280
268
  saasRegistry,
281
269
  srvAPI,
282
270
  mtxSidecar,
283
- providedMtxAPI,
271
+ providedMtxAPISrv,
272
+ providedMtxAPISidecar,
284
273
  requiredMtxAPI,
285
274
  providedMtxSidecarAPI,
286
275
  requiredMtxSidecarAPI,
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "approuter",
3
3
  "dependencies": {
4
- "@sap/approuter": "^13.0.0"
4
+ "@sap/approuter": "^14.0.0"
5
5
  },
6
6
  "engines": {
7
- "node": "^16"
7
+ "node": "^18.0.0"
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node node_modules/@sap/approuter/approuter.js"
@@ -1,5 +1,5 @@
1
1
  const { join } = require('path')
2
- const ProjectReader = require('../../util/projectReader')
2
+ const { readProject } = require('../../util/projectReader')
3
3
  const { mergeJSON, mergeYAML, sortDependencies } = require('../../util/merge')
4
4
  const { OPTION_XSUAA, PROJECT_TYPE } = require('../../constants')
5
5
  const {
@@ -13,11 +13,6 @@ const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5Trac
13
13
 
14
14
  module.exports = class ApprouterTemplate extends require('../templateBase') {
15
15
 
16
- constructor(projectPath, generator) {
17
- super(projectPath, generator, __dirname)
18
- this.projectReader = new ProjectReader(projectPath)
19
- }
20
-
21
16
  static hasFacet(env) {
22
17
  return !!env.requires?.approuter
23
18
  }
@@ -27,9 +22,9 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
27
22
  }
28
23
 
29
24
  async run() {
30
- const projectDescriptor = await this.projectReader.read(this.options)
25
+ const projectDescriptor = await readProject(this.options)
31
26
  const { for: forProfile } = projectDescriptor.cap
32
- const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
27
+ const appPath = join(this.projectPath, projectDescriptor.ui.appPath ?? 'app')
33
28
  const appPackageJSONPath = join(appPath, 'package.json')
34
29
 
35
30
  await mergeJSON(appPackageJSONPath, join(__dirname, 'files', 'package.json'))
@@ -37,7 +32,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
37
32
 
38
33
  await mergeJSON(join(appPath, 'default-env.json'), join(__dirname, 'files', 'default-env.json'))
39
34
 
40
- const projectType = await this.getProjectType()
35
+ const projectType = this.getProjectType()
41
36
  switch (projectType) {
42
37
  case PROJECT_TYPE.java: {
43
38
  const cdsrcJSONPath = join(this.projectPath, '.cdsrc.json')
@@ -59,7 +54,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
59
54
  }
60
55
 
61
56
  async runDependentMerging(context = {}) {
62
- const projectDescriptor = await this.projectReader.read(this.options)
57
+ const projectDescriptor = await readProject(this.options)
63
58
  const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm } = projectDescriptor.cap
64
59
 
65
60
  if (hasMta) {
@@ -100,7 +95,6 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
100
95
  join(__dirname, 'files', 'chart.yaml'),
101
96
  projectDescriptor,
102
97
  { additions: [{
103
- ref: `web-application-approuter`,
104
98
  in: `dependencies`,
105
99
  where: [{
106
100
  property: 'alias',
@@ -136,7 +130,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
136
130
  if (isIndependentCommand) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData);
137
131
  }
138
132
 
139
- const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
133
+ const appPath = join(this.projectPath, projectDescriptor.ui.appPath ?? 'app')
140
134
  const additions = isExtensible && isJava ? [{ ...approuterExtensibilityJava, at: 0 }] :
141
135
  isExtensible && isNodejs ? [{ ...approuterExtensibility, at: 0 }] : []
142
136
  await mergeJSON(join(appPath, 'xs-app.json'), join(__dirname, 'files', 'xs-app.json.hbs'), projectDescriptor, { additions })
@@ -1 +1,4 @@
1
- {{- include "cap.service-instance" . }}
1
+ dependencies:
2
+ - name: service-instance
3
+ alias: auditlog
4
+ version: 0.1.0
@@ -1,14 +1,10 @@
1
1
  const { join } = require('path')
2
- const ProjectReader = require('../../util/projectReader')
2
+ const { readProject } = require('../../util/projectReader')
3
3
  const { mergeYAML } = require('../../util/merge')
4
- const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5Tracking')
4
+ const { parseMd5File, writeMd5File } = require('../../util/md5Tracking')
5
5
  const { srvNode, srvJava, auditlog } = require('../_merging/registry-mta')
6
6
 
7
7
  module.exports = class AuditlogTemplate extends require('../templateBase') {
8
- constructor(projectPath, generator) {
9
- super(projectPath, generator, __dirname)
10
- this.projectReader = new ProjectReader(projectPath)
11
- }
12
8
 
13
9
  static hasFacet() {
14
10
  return false // TODO: Need a `cds.requires.auditlog` or some other way to detect if enabled.
@@ -19,7 +15,7 @@ module.exports = class AuditlogTemplate extends require('../templateBase') {
19
15
  }
20
16
 
21
17
  async runDependentMerging(context = {}) {
22
- const projectDescriptor = await this.projectReader.read(this.options)
18
+ const projectDescriptor = await readProject(this.options)
23
19
  const { isNodejs, hasMta, hasHelm } = projectDescriptor.cap
24
20
 
25
21
  if (hasMta) {
@@ -60,7 +56,26 @@ module.exports = class AuditlogTemplate extends require('../templateBase') {
60
56
  }
61
57
  }
62
58
  )
63
- await copyAndTrack(join(__dirname, 'files', 'auditlog.yaml'), join(this.projectPath, 'chart', 'templates', 'auditlog.yaml'), context)
59
+
60
+ // copy service instance chart if it is not present
61
+ const HelmTemplate = require(`../helm`);
62
+ const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
63
+ isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
64
+
65
+ // add dependency entry in chart.yaml
66
+ await mergeYAML(
67
+ join(this.projectPath, 'chart', 'Chart.yaml'),
68
+ join(__dirname, 'files', 'auditlog.yaml'),
69
+ projectDescriptor,
70
+ { additions: [{
71
+ in: `dependencies`,
72
+ where: [{
73
+ property: 'alias',
74
+ isEqualTo: 'auditlog'
75
+ }]
76
+ }]}
77
+ )
78
+
64
79
  if(isIndependentCommand) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData)
65
80
  }
66
81
  }
@@ -1,34 +1,24 @@
1
1
  const { join } = require('path')
2
2
  const { exists } = require('../../../cds').utils
3
- const ProjectReader = require('../../util/projectReader');
3
+ const { readProject } = require('../../util/projectReader')
4
4
  const { copyFiles } = require('../../util/templateUtil')
5
- const { OPTION_CF_MANIFEST } = require('../../constants')
6
5
  const MANIFEST_FILE = 'manifest.yml'
7
6
  const SERVICES_MANIFEST_FILE = 'services-manifest.yml'
8
7
 
9
- module.exports = class ManifestTemplate extends require('../templateBase') {
10
- constructor(projectPath, generator) {
11
- super(projectPath, generator, __dirname)
12
- this.projectReader = new ProjectReader(projectPath)
13
- }
8
+ module.exports = class CfManifestTemplate extends require('../templateBase') {
14
9
 
15
10
  async canRun() {
16
- if (!this.options.add.has(OPTION_CF_MANIFEST)) {
17
- return false;
18
- }
19
-
20
11
  if (this.options.force) {
21
12
  return true;
22
13
  }
23
-
24
- if (exists(join(this.projectPath, MANIFEST_FILE)) || exists(join(this.projectPath, SERVICES_MANIFEST_FILE))) {
14
+ if (exists(MANIFEST_FILE) || exists(SERVICES_MANIFEST_FILE)) {
25
15
  throw new Error(`File ${MANIFEST_FILE} or ${SERVICES_MANIFEST_FILE} already exist in current folder. Use --force to overwrite.`);
26
16
  }
27
17
  return true;
28
18
  }
29
19
 
30
20
  async run() {
31
- const projectDescriptor = await this.projectReader.read()
21
+ const projectDescriptor = await readProject()
32
22
  await copyFiles(join(__dirname, 'files'), this.projectPath, projectDescriptor, this.options.force);
33
23
  }
34
24
  }
@@ -1,10 +1,8 @@
1
- {{- if .Values.connectivity }}
2
- {{- if or (not (hasKey .Values.connectivity "enabled")) .Values.connectivity.enabled }}
3
- {{- $ := merge (dict "name" "connectivity-proxy-info") . }}
1
+ {{- $ := merge (dict "name" "connectivity-proxy-info") . }}
4
2
  apiVersion: v1
5
3
  kind: ConfigMap
6
4
  metadata:
7
- name: {{ .Values.connectivity.configMapName }}
5
+ name: {{ .Release.Name }}-connectivity-proxy-info
8
6
  namespace: {{ .Release.Namespace }}
9
7
  labels: {{- include "cap.labels" $ | nindent 4 }}
10
8
  data:
@@ -16,5 +14,3 @@ data:
16
14
  onpremise_proxy_port: "20003"
17
15
  onpremise_proxy_rfc_port: "20001"
18
16
  onpremise_socks5_proxy_port: "20004"
19
- {{- end }}
20
- {{- end }}
@@ -8,19 +8,16 @@ srv:
8
8
  projected:
9
9
  sources:
10
10
  - secret:
11
- name: {{cap.appName}}-connectivity-binding
11
+ name: <your-connectivity-binding>
12
12
  optional: false
13
13
  - secret:
14
- name: {{cap.appName}}-connectivity-binding
14
+ name: <your-connectivity-binding>
15
15
  optional: false
16
16
  items:
17
17
  - key: token_service_url
18
18
  path: url
19
+ {{=<% %>=}}
19
20
  - configMap:
20
- name: {{cap.appName}}-connectivity-proxy-info
21
+ name: "{{ .Release.Name }}-connectivity-proxy-info"
21
22
  optional: false
22
- connectivity:
23
- serviceOfferingName: connectivity
24
- servicePlanName: connectivity_proxy
25
- secretName: {{cap.appName}}-connectivity-binding
26
- configMapName: {{cap.appName}}-connectivity-proxy-info
23
+ <%={{ }}=%>
@@ -1,20 +1,16 @@
1
1
  const { join } = require('path')
2
- const ProjectReader = require('../../util/projectReader')
2
+ const { readProject } = require('../../util/projectReader')
3
3
  const { mergeYAML } = require('../../util/merge')
4
4
  const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5Tracking')
5
5
 
6
6
  module.exports = class ConnectivityTemplate extends require('../templateBase') {
7
- constructor(projectPath, generator) {
8
- super(projectPath, generator, __dirname)
9
- this.projectReader = new ProjectReader(projectPath)
10
- }
11
7
 
12
8
  async run() {
13
9
  await this.runDependentMerging()
14
10
  }
15
11
 
16
12
  async runDependentMerging(context = {}) {
17
- const projectDescriptor = await this.projectReader.read(this.options)
13
+ const projectDescriptor = await readProject(this.options)
18
14
  const { hasHelm } = projectDescriptor.cap
19
15
 
20
16
  if (hasHelm) {
@@ -31,7 +27,6 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
31
27
  join(__dirname, 'files', 'values.yaml.hbs'),
32
28
  projectDescriptor,
33
29
  { additions: [{
34
- ref: `srv-additional-volumes`,
35
30
  in: `srv.additionalVolumes`,
36
31
  where: [{
37
32
  property: 'name',
@@ -41,9 +36,7 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
41
36
  )
42
37
  const filesPath = join(__dirname, 'files')
43
38
  const templatesPath = join(this.projectPath, 'chart', 'templates')
44
- await copyAndTrack(join(filesPath, 'connectivity-binding.yaml'), join(templatesPath, 'connectivity-binding.yaml'), context)
45
39
  await copyAndTrack(join(filesPath, 'connectivity-proxy-info.yaml'), join(templatesPath, 'connectivity-proxy-info.yaml'), context)
46
- await copyAndTrack(join(filesPath, 'connectivity.yaml'), join(templatesPath, 'connectivity.yaml'), context)
47
40
  if(isIndependentCommand) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData)
48
41
  }
49
42
  }
@@ -6,9 +6,6 @@ const LOG = console
6
6
  const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) && console.debug
7
7
 
8
8
  module.exports = class DataTemplate extends require('../templateBase') {
9
- constructor(projectPath, generator) {
10
- super(projectPath, generator, __dirname);
11
- }
12
9
 
13
10
  async run() {
14
11
  const env = await this.getEnv();
@@ -21,7 +18,6 @@ module.exports = class DataTemplate extends require('../templateBase') {
21
18
  const nameFilter = asRegex(this.options['data:for'] || this.options.for)
22
19
  const force = this.options.force;
23
20
 
24
- cds.root = this.projectPath;
25
21
  let csn = await cds.compile.to.csn(cds.env.roots); // normal CSN
26
22
 
27
23
  // Also include 'external' entities w/ cds.persistence.skip (similar to 'mocked' option of serve).
@@ -1 +1,4 @@
1
- {{- include "cap.service-instance" . }}
1
+ dependencies:
2
+ - name: service-instance
3
+ alias: destination
4
+ version: 0.1.0