@sap/cds-dk 4.9.5 → 6.0.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 (144) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/bin/activate.js +4 -4
  3. package/bin/add.js +11 -5
  4. package/bin/bind.js +16 -28
  5. package/bin/build/all.js +2 -2
  6. package/bin/build/index.js +12 -19
  7. package/bin/cds.js +16 -17
  8. package/bin/compile/index.js +12 -3
  9. package/bin/deploy/index.js +14 -14
  10. package/bin/deploy/to-hana.js +4 -4
  11. package/bin/deploy/to-sqlite.js +1 -1
  12. package/bin/env.js +13 -4
  13. package/bin/eval.js +1 -1
  14. package/bin/fix-redirects.js +1 -1
  15. package/bin/import.js +44 -179
  16. package/bin/repl.js +1 -1
  17. package/bin/watch.js +10 -15
  18. package/lib/bind/BindingManager.js +87 -0
  19. package/lib/bind/bindingResolver.js +14 -85
  20. package/lib/bind/bindingUtil.js +18 -11
  21. package/lib/bind/cfKeyProvider.js +58 -29
  22. package/lib/bind/kubernetesCredentialsProvider.js +44 -21
  23. package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
  24. package/lib/cds.js +13 -0
  25. package/lib/client/base_command.js +3 -2
  26. package/lib/client/extend.js +6 -7
  27. package/lib/client/helper/fs_helper.js +7 -8
  28. package/lib/client/helper/string_helper.js +6 -1
  29. package/lib/client/settings_manager.js +38 -45
  30. package/lib/compile/index.js +9 -10
  31. package/lib/compile/openapi/csdl2openapi.js +151 -43
  32. package/lib/compile/openapi/index.js +2 -2
  33. package/lib/compile/to-xsuaa.js +3 -2
  34. package/lib/import/common.js +342 -27
  35. package/lib/import/importapi.js +81 -13
  36. package/lib/import/message.js +4 -4
  37. package/lib/import/odata/index.js +141 -0
  38. package/lib/import/{utils → odata/metadataconverter}/MetadataConverter.js +2 -2
  39. package/lib/import/{utils → odata/metadataconverter}/MetadataConverterFactory.js +1 -1
  40. package/lib/import/{utils → odata/util}/MultiMap.js +0 -0
  41. package/lib/import/{v2parser.js → odata/v2parser.js} +405 -468
  42. package/lib/import/{v4parser.js → odata/v4parser.js} +311 -322
  43. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Aggregation.V1.json +0 -0
  44. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Authorization.V1.json +0 -0
  45. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Capabilities.V1.json +0 -0
  46. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Core.V1.json +0 -0
  47. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Measures.V1.json +0 -0
  48. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Validation.V1.json +0 -0
  49. package/lib/import/openapi/importOpenAPI.js +521 -0
  50. package/lib/import/openapi/index.js +19 -0
  51. package/lib/import/openapi/utilities.js +38 -0
  52. package/lib/index.js +1 -1
  53. package/lib/init/constants.js +7 -2
  54. package/lib/init/index.js +10 -3
  55. package/lib/init/template/_merging/existences.js +79 -19
  56. package/lib/init/template/approuter/files/mta.yaml.hbs +25 -11
  57. package/lib/init/template/approuter/files/package.json +1 -1
  58. package/lib/init/template/approuter/files/xs-app.json.hbs +7 -0
  59. package/lib/init/template/approuter/index.js +61 -54
  60. package/lib/init/template/auditlog/index.js +2 -2
  61. package/lib/init/template/data/index.js +2 -2
  62. package/lib/init/template/hana/files/mta.yaml.hbs +17 -17
  63. package/lib/init/template/hana/index.js +8 -4
  64. package/lib/init/template/helm/index.js +39 -0
  65. package/lib/init/template/helm/update/index.js +28 -0
  66. package/lib/init/template/java/index.js +7 -9
  67. package/lib/init/template/kibana-logging/index.js +5 -6
  68. package/lib/init/template/mta/index.js +4 -4
  69. package/lib/init/template/mtx/files/java/package.json +9 -9
  70. package/lib/init/template/mtx/files/mta.yaml.hbs +0 -7
  71. package/lib/init/template/mtx/files/xs-security.json.hbs +11 -20
  72. package/lib/init/template/mtx/index.js +50 -57
  73. package/lib/init/template/nodejs/files/package.json.hbs +2 -2
  74. package/lib/init/template/notebook/index.js +2 -0
  75. package/lib/init/template/templateBase.js +6 -4
  76. package/lib/init/template/xsuaa/index.js +9 -5
  77. package/lib/init/util/fsUtil.js +25 -10
  78. package/lib/init/util/logger.js +1 -1
  79. package/lib/init/util/mvnArchetypeUtil.js +4 -10
  80. package/lib/init/util/projectReader.js +16 -8
  81. package/lib/init/util/templateUtil.js +30 -34
  82. package/lib/k8s/ChartAdder.js +65 -0
  83. package/lib/k8s/ChartBuilder.js +186 -0
  84. package/lib/k8s/Context.js +71 -0
  85. package/lib/k8s/ImageUtil.js +21 -0
  86. package/lib/k8s/Model.d.ts +53 -0
  87. package/lib/k8s/auditlog/index.js +29 -0
  88. package/lib/k8s/auditlog/templates/auditlog.yaml +1 -0
  89. package/lib/k8s/buildModel.js +70 -0
  90. package/lib/k8s/connectivity/index.js +74 -0
  91. package/lib/k8s/connectivity/templates/connectivity-binding.yaml +9 -0
  92. package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +16 -0
  93. package/lib/k8s/connectivity/templates/connectivity.yaml +1 -0
  94. package/lib/k8s/deployment/index.js +81 -0
  95. package/lib/k8s/deployment/subchart/Chart.yaml +6 -0
  96. package/lib/k8s/deployment/subchart/templates/_helpers.tpl +156 -0
  97. package/lib/k8s/deployment/subchart/templates/api-rule.yaml +24 -0
  98. package/lib/k8s/deployment/subchart/templates/deployment.yaml +110 -0
  99. package/lib/k8s/deployment/subchart/templates/network-policy.yaml +16 -0
  100. package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +11 -0
  101. package/lib/k8s/deployment/subchart/templates/secret.yaml +10 -0
  102. package/lib/k8s/deployment/subchart/templates/service-binding.yaml +27 -0
  103. package/lib/k8s/deployment/subchart/templates/service.yaml +11 -0
  104. package/lib/k8s/deployment/subchart/values-lint.yaml +8 -0
  105. package/lib/k8s/deployment/subchart/values.schema.json +449 -0
  106. package/lib/k8s/deployment/subchart/values.yaml +76 -0
  107. package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +81 -0
  108. package/lib/k8s/destinations/index.js +40 -0
  109. package/lib/k8s/destinations/lib.js +16 -0
  110. package/lib/k8s/destinations/templates/destinations.yaml +1 -0
  111. package/lib/k8s/docker/push.js +8 -0
  112. package/lib/k8s/event-mesh/index.js +53 -0
  113. package/lib/k8s/event-mesh/lib.js +9 -0
  114. package/lib/k8s/event-mesh/templates/event-mesh.yaml +1 -0
  115. package/lib/k8s/hana-deployer/index.js +38 -0
  116. package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +41 -0
  117. package/lib/k8s/helm/Release.js +80 -0
  118. package/lib/k8s/html5-apps-deployer/index.js +43 -0
  119. package/lib/k8s/html5-apps-deployer/templates/_html5_deployment_helpers.tpl +16 -0
  120. package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +53 -0
  121. package/lib/k8s/html5-apps-repo-host/index.js +26 -0
  122. package/lib/k8s/html5-apps-repo-host/lib.js +16 -0
  123. package/lib/k8s/html5-apps-repo-host/templates/html5-apps-repo-host.yaml +1 -0
  124. package/lib/k8s/index.js +153 -0
  125. package/lib/k8s/modules.js +36 -0
  126. package/lib/k8s/multitenancy/index.js +24 -0
  127. package/lib/k8s/multitenancy/lib.js +25 -0
  128. package/lib/k8s/multitenancy/templates/saas-registry.yaml +19 -0
  129. package/lib/k8s/readProject.js +14 -0
  130. package/lib/k8s/resources/helm/chart/templates/NOTES.txt +11 -0
  131. package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +221 -0
  132. package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +167 -0
  133. package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +103 -0
  134. package/lib/k8s/util.js +186 -0
  135. package/lib/k8s/wrapFeature.js +55 -0
  136. package/lib/k8s/xsuaa/index.js +64 -0
  137. package/lib/k8s/xsuaa/lib.js +14 -0
  138. package/lib/k8s/xsuaa/templates/xsuaa.yaml +1 -0
  139. package/lib/util/exec.js +1 -1
  140. package/lib/util/write.js +1 -1
  141. package/lib/watch/node-watch.js +43 -14
  142. package/npm-shrinkwrap.json +1272 -2792
  143. package/package.json +5 -5
  144. package/lib/import/index.js +0 -235
@@ -27,8 +27,7 @@ const approuter = {
27
27
  constraints: [{
28
28
  comparisonKeyPath: ["type"],
29
29
  value: "approuter.nodejs"
30
- }],
31
- spaceBefore: true
30
+ }]
32
31
  }
33
32
 
34
33
  const xsuaa = {
@@ -43,8 +42,7 @@ const xsuaa = {
43
42
  }, {
44
43
  comparisonKeyPath: ["parameters", "service-plan"],
45
44
  value: "application"
46
- }],
47
- spaceBefore: true
45
+ }]
48
46
  }
49
47
 
50
48
  const auditlog = {
@@ -56,8 +54,7 @@ const auditlog = {
56
54
  }, {
57
55
  comparisonKeyPath: ["parameters", "service"],
58
56
  value: "auditlog-api",
59
- }],
60
- spaceBefore: true
57
+ }]
61
58
  }
62
59
 
63
60
  const kibanaLogging = {
@@ -72,8 +69,7 @@ const kibanaLogging = {
72
69
  }, {
73
70
  comparisonKeyPath: ["parameters", "service-plan"],
74
71
  value: "lite",
75
- }],
76
- spaceBefore: true
72
+ }]
77
73
  }
78
74
 
79
75
  const hdbDeployer = {
@@ -82,8 +78,7 @@ const hdbDeployer = {
82
78
  constraints: [{
83
79
  comparisonKeyPath: ["type"],
84
80
  value: "hdb"
85
- }],
86
- spaceBefore: true
81
+ }]
87
82
  }
88
83
 
89
84
  const hdiContainer = {
@@ -92,8 +87,7 @@ const hdiContainer = {
92
87
  constraints: [{
93
88
  comparisonKeyPath: ["type"],
94
89
  value: "com.sap.xs.hdi-container",
95
- }],
96
- spaceBefore: true
90
+ }]
97
91
  }
98
92
 
99
93
  const serviceManager = {
@@ -108,8 +102,7 @@ const serviceManager = {
108
102
  }, {
109
103
  comparisonKeyPath: ["parameters", "service-plan"],
110
104
  value: "container"
111
- }],
112
- spaceBefore: true
105
+ }]
113
106
  }
114
107
 
115
108
  const saasRegistry = {
@@ -124,8 +117,7 @@ const saasRegistry = {
124
117
  }, {
125
118
  comparisonKeyPath: ["parameters", "service-plan"],
126
119
  value: "application"
127
- }],
128
- spaceBefore: true
120
+ }]
129
121
  }
130
122
 
131
123
  const srvAPI = {
@@ -146,8 +138,7 @@ const mtxSidecar = {
146
138
  constraints: [{
147
139
  comparisonKeyPath: ["type"],
148
140
  value: `nodejs`
149
- }],
150
- spaceBefore: true
141
+ }]
151
142
  }
152
143
 
153
144
  const providedMtxAPI = {
@@ -175,6 +166,35 @@ const requiredMtxAPI = {
175
166
  }]
176
167
  }
177
168
 
169
+ const providedAppAPI = {
170
+ ref: "provided-app-api",
171
+ in: approuter,
172
+ keyPath: ["provides"],
173
+ constraints: [{
174
+ comparisonKeyPath: ["name"],
175
+ value: "app-api"
176
+ }, {
177
+ comparisonKeyPath: ["properties", "app-protocol"],
178
+ value: "${protocol}"
179
+ }, {
180
+ comparisonKeyPath: ["properties", "app-uri"],
181
+ value: "${default-uri}"
182
+ }],
183
+ }
184
+
185
+ const requiredAppAPI = {
186
+ ref: "required-app-api",
187
+ in: srvNode,
188
+ keyPath: ["requires"],
189
+ constraints: [{
190
+ comparisonKeyPath: ["name"],
191
+ value: "app-api"
192
+ }, {
193
+ comparisonKeyPath: ["properties", "SUBSCRIPTION_URL"],
194
+ value: "~{app-protocol}://\\${tenant_subdomain}-~{app-uri}"
195
+ }]
196
+ }
197
+
178
198
  const providedMtxSidecarAPI = {
179
199
  ref: "provided-mtx-sidecar-api",
180
200
  in: mtxSidecar,
@@ -215,6 +235,42 @@ const providedJavaApprouterAPI = {
215
235
  }]
216
236
  }
217
237
 
238
+ const approuterExtensibility = {
239
+ ref: "approuter-extensibility",
240
+ keyPath: ["routes"],
241
+ constraints: [{
242
+ comparisonKeyPath: ["source"],
243
+ value: "^/extend/(.*)"
244
+ }, {
245
+ comparisonKeyPath: ["destination"],
246
+ value: "mtx-api",
247
+ }, {
248
+ comparisonKeyPath: ["target"],
249
+ value: "$1",
250
+ }, {
251
+ comparisonKeyPath: ["authenticationType"],
252
+ value: "none",
253
+ }]
254
+ }
255
+
256
+ const approuterExtensibilityJava = {
257
+ ref: "approuter-extensibility-java",
258
+ keyPath: ["routes"],
259
+ constraints: [{
260
+ comparisonKeyPath: ["source"],
261
+ value: "^/extend/(.*)"
262
+ }, {
263
+ comparisonKeyPath: ["destination"],
264
+ value: "mtx-api",
265
+ }, {
266
+ comparisonKeyPath: ["target"],
267
+ value: "$1",
268
+ }, {
269
+ comparisonKeyPath: ["authenticationType"],
270
+ value: "none",
271
+ }]
272
+ }
273
+
218
274
  module.exports = {
219
275
  srvNode,
220
276
  srvJava,
@@ -231,7 +287,11 @@ module.exports = {
231
287
  requiredMtxAPI,
232
288
  providedMtxSidecarAPI,
233
289
  requiredMtxSidecarAPI,
290
+ providedAppAPI,
291
+ requiredAppAPI,
234
292
  requiredJavaApprouterAPI,
235
293
  providedJavaApprouterAPI,
236
- kibanaLogging
294
+ kibanaLogging,
295
+ approuterExtensibility,
296
+ approuterExtensibilityJava
237
297
  }
@@ -10,6 +10,13 @@ modules:
10
10
  {{/cap.isJava}}
11
11
  requires:
12
12
  - name: {{cap.appName}}-auth
13
+ {{#cap.isNodejs}}
14
+ {{#cap.isMultitenant}}
15
+ - name: app-api
16
+ properties:
17
+ SUBSCRIPTION_URL: ~{app-protocol}://\${tenant_subdomain}-~{app-uri}
18
+ {{/cap.isMultitenant}}
19
+ {{/cap.isNodejs}}
13
20
  {{#cap.isJava}}
14
21
  - name: app-api
15
22
  properties:
@@ -35,14 +42,21 @@ modules:
35
42
  url: ~{srv-url}
36
43
  forwardAuthToken: true
37
44
  {{#cap.isMultitenant}}
38
- {{#cap.isNodejs}}
39
45
  - name: mtx-api
40
46
  group: destinations
41
47
  properties:
42
48
  name: mtx-api # must be used in xs-app.json as well
43
49
  url: ~{mtx-url}
44
- {{/cap.isNodejs}}
45
50
  {{/cap.isMultitenant}}
51
+ {{#cap.isMultitenant}}
52
+ {{#cap.isNodejs}}
53
+ provides:
54
+ - name: app-api
55
+ properties:
56
+ app-protocol: ${protocol}
57
+ app-uri: ${default-uri}
58
+ {{/cap.isNodejs}}
59
+ {{/cap.isMultitenant}}
46
60
  {{#cap.isJava}}
47
61
  provides:
48
62
  - name: app-api
@@ -51,12 +65,12 @@ modules:
51
65
  {{/cap.isJava}}
52
66
 
53
67
  resources:
54
- - name: {{cap.appName}}-auth
55
- type: org.cloudfoundry.managed-service
56
- parameters:
57
- service: xsuaa
58
- service-plan: application
59
- path: ./xs-security.json
60
- config:
61
- xsappname: {{cap.appName}}-${org}-${space}
62
- tenant-mode: {{#cap.isMultitenant}}shared{{/cap.isMultitenant}}{{^cap.isMultitenant}}dedicated{{/cap.isMultitenant}}
68
+ - name: {{cap.appName}}-auth
69
+ type: org.cloudfoundry.managed-service
70
+ parameters:
71
+ service: xsuaa
72
+ service-plan: application
73
+ path: ./xs-security.json
74
+ config:
75
+ xsappname: {{cap.appName}}-${org}-${space}
76
+ tenant-mode: {{#cap.isMultitenant}}shared{{/cap.isMultitenant}}{{^cap.isMultitenant}}dedicated{{/cap.isMultitenant}}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "approuter",
3
3
  "dependencies": {
4
- "@sap/approuter": "^10"
4
+ "@sap/approuter": "^11.0.0"
5
5
  },
6
6
  "engines": {
7
7
  "node": "^16"
@@ -14,6 +14,13 @@
14
14
  "destination": "srv-api",
15
15
  "authenticationType": "xsuaa",
16
16
  "csrfProtection": true
17
+ }{{#cap.isMultitenant}},
18
+ {
19
+ "source": "^/extend/(.*)",
20
+ "destination": "mtx-api",
21
+ "target": "$1",
22
+ "authenticationType": "none"
17
23
  }
24
+ {{/cap.isMultitenant}}
18
25
  ]
19
26
  }
@@ -1,78 +1,85 @@
1
- const fs = require('fs');
2
- const { join } = require('path');
3
- const TemplateBase = require('../templateBase');
4
- const ProjectReader = require('../../util/projectReader');
5
- const { OPTION_XSUAA, PROJECT_TYPE } = require('../../constants');
1
+ const fs = require('fs')
2
+ const { join } = require('path')
3
+ const TemplateBase = require('../templateBase')
4
+ const ProjectReader = require('../../util/projectReader')
5
+ const { OPTION_XSUAA, PROJECT_TYPE } = require('../../constants')
6
6
  const {
7
7
  srvNode, srvJava, approuter, // Modules
8
8
  xsuaa, // BTP Services
9
- requiredMtxAPI, requiredJavaApprouterAPI, providedJavaApprouterAPI // APIs
10
- } = require('../_merging/existences');
9
+ requiredMtxAPI, requiredJavaApprouterAPI, providedJavaApprouterAPI, // APIs
10
+ requiredAppAPI, providedAppAPI,
11
+ approuterExtensibility, approuterExtensibilityJava // xs-app.json config
12
+ } = require('../_merging/existences')
11
13
 
12
14
  module.exports = class ApprouterTemplate extends TemplateBase {
15
+
13
16
  constructor(projectPath, generator) {
14
- super(projectPath, generator, __dirname);
15
- this.projectReader = new ProjectReader(this);
17
+ super(projectPath, generator, __dirname)
18
+ this.projectReader = new ProjectReader(this)
16
19
  }
17
20
 
18
21
  async getDependencies() {
19
- return [OPTION_XSUAA];
22
+ return [OPTION_XSUAA]
20
23
  }
21
24
 
22
- async runMTAMerging() {
23
- const projectDescriptor = await this.projectReader.read(this.options);
24
- const mtaYAMLPath = join(this.projectPath, 'mta.yaml');
25
- if (!fs.existsSync(mtaYAMLPath)) return;
25
+ async runDependentMerging() {
26
+ const projectDescriptor = await this.projectReader.read(this.options)
27
+ const mtaYAMLPath = join(this.projectPath, 'mta.yaml')
26
28
  const { isNodejs, isJava, isMultitenant } = projectDescriptor.cap
27
- const srv = isNodejs ? srvNode : srvJava
28
- const apis = isJava ? [requiredJavaApprouterAPI, providedJavaApprouterAPI] : []
29
- if (isNodejs && isMultitenant) apis.push(requiredMtxAPI)
30
- const existences = [srv, approuter, xsuaa, ...apis]
31
- await this.templateUtil.mergeYAML(
32
- mtaYAMLPath,
33
- `${__dirname}/files/mta.yaml.hbs`,
29
+ if (fs.existsSync(mtaYAMLPath)) {
30
+ const srv = isNodejs ? srvNode : srvJava
31
+ const apis = isJava ? [requiredJavaApprouterAPI, providedJavaApprouterAPI] : []
32
+ if (isNodejs && isMultitenant) apis.push(requiredMtxAPI, requiredAppAPI, providedAppAPI)
33
+ if (isJava && isMultitenant) apis.push(requiredMtxAPI)
34
+ const existences = [srv, approuter, xsuaa, ...apis]
35
+ await this.templateUtil.mergeYAML(
36
+ mtaYAMLPath,
37
+ `${__dirname}/files/mta.yaml.hbs`,
38
+ projectDescriptor,
39
+ {
40
+ existences,
41
+ relationships: [{
42
+ in: srv,
43
+ inKeyPath: ["requires"],
44
+ into: "name",
45
+ existences: [xsuaa],
46
+ existenceKeyPath: ["name"],
47
+ }, {
48
+ in: approuter,
49
+ inKeyPath: ["requires"],
50
+ into: "name",
51
+ existences: [xsuaa],
52
+ existenceKeyPath: ["name"],
53
+ }],
54
+ }
55
+ )
56
+ }
57
+
58
+ const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
59
+ const existences = isMultitenant && isJava ? [approuterExtensibilityJava] :
60
+ isMultitenant && isNodejs ? [approuterExtensibility] : []
61
+ await this.templateUtil.mergeJSON(
62
+ `${appPath}/xs-app.json`,
63
+ `${__dirname}/files/xs-app.json.hbs`,
34
64
  projectDescriptor,
35
- {
36
- existences,
37
- relationships: [{
38
- in: srv,
39
- inKeyPath: ["requires"],
40
- into: "name",
41
- existences: [xsuaa],
42
- existenceKeyPath: ["name"],
43
- }, {
44
- in: approuter,
45
- inKeyPath: ["requires"],
46
- into: "name",
47
- existences: [xsuaa],
48
- existenceKeyPath: ["name"],
49
- }],
50
- }
51
- );
65
+ { existences }
66
+ )
52
67
  }
53
68
 
54
69
  async run() {
55
- const projectDescriptor = await this.projectReader.read(this.options);
56
- const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app');
57
- const appPackageJSONPath = join(appPath, 'package.json');
58
-
59
- await this.templateUtil.mergeJSON(appPackageJSONPath, join(__dirname, 'files', 'package.json'));
60
- await this.templateUtil.sortDependencies(appPackageJSONPath);
70
+ const projectDescriptor = await this.projectReader.read(this.options)
71
+ const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
72
+ const appPackageJSONPath = join(appPath, 'package.json')
61
73
 
62
- await this.templateUtil.mergeJSON(
63
- `${appPath}/xs-app.json`,
64
- `${__dirname}/files/xs-app.json.hbs`,
65
- projectDescriptor
66
- );
74
+ await this.templateUtil.mergeJSON(appPackageJSONPath, join(__dirname, 'files', 'package.json'))
75
+ await this.templateUtil.sortDependencies(appPackageJSONPath)
67
76
 
68
77
  await this.templateUtil.mergeJSON(
69
78
  `${appPath}/default-env.json`,
70
79
  `${__dirname}/files/default-env.json`
71
- );
72
-
73
- // await this.fsUtil.copy(join(__dirname, 'files', 'index.html'), join(appPath, 'index.html'));
80
+ )
74
81
 
75
- const projectType = await this.getProjectType();
82
+ const projectType = await this.getProjectType()
76
83
  switch (projectType) {
77
84
  case PROJECT_TYPE.java: {
78
85
  const cdsrcJSONPath = join(this.projectPath, '.cdsrc.json')
@@ -90,6 +97,6 @@ module.exports = class ApprouterTemplate extends TemplateBase {
90
97
  }
91
98
  }
92
99
 
93
- await this.runMTAMerging()
100
+ await this.runDependentMerging()
94
101
  }
95
102
  }
@@ -10,7 +10,7 @@ module.exports = class AuditlogTemplate extends TemplateBase {
10
10
  this.projectReader = new ProjectReader(this);
11
11
  }
12
12
 
13
- async runMTAMerging() {
13
+ async runDependentMerging() {
14
14
  const projectDescriptor = await this.projectReader.read(this.options);
15
15
  const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
16
16
  if (!fs.existsSync(mtaYAMLPath)) return;
@@ -33,6 +33,6 @@ module.exports = class AuditlogTemplate extends TemplateBase {
33
33
  }
34
34
 
35
35
  async run() {
36
- await this.runMTAMerging()
36
+ await this.runDependentMerging()
37
37
  }
38
38
  }
@@ -1,5 +1,5 @@
1
1
  const TemplateBase = require('../templateBase');
2
- const cds = require('@sap/cds');
2
+ const cds = require('../../../cds');
3
3
  const {resolve, join, relative} = require('path');
4
4
  const fs = require('fs');
5
5
 
@@ -16,7 +16,7 @@ module.exports = class DataTemplate extends TemplateBase {
16
16
  : getDefaultTargetFolder(env, this.projectPath);
17
17
  dest = resolve(this.projectPath, dest);
18
18
 
19
- const nameFilter = asRegex(this.options.for)
19
+ const nameFilter = asRegex(this.options['data:for'] || this.options.for)
20
20
  const force = this.options.force;
21
21
  const logger = this.logger;
22
22
 
@@ -16,20 +16,20 @@ modules:
16
16
  {{/cap.isMultitenant}}
17
17
 
18
18
  resources:
19
- - name: {{cap.appName}}-db
20
- {{^cap.isMultitenant}}
21
- type: com.sap.xs.hdi-container
22
- parameters:
23
- service: hana # or 'hanatrial' on trial landscapes
24
- service-plan: hdi-shared
25
- {{/cap.isMultitenant}}
26
- {{#cap.isMultitenant}} {{! enable automatic switching to 'hanatrial' on trial accounts}}
27
- type: org.cloudfoundry.managed-service
28
- parameters:
29
- service: service-manager
30
- service-plan: container
31
- {{/cap.isMultitenant}}
32
- {{#cap.isJava}}
33
- properties:
34
- hdi-service-name: ${service-name}
35
- {{/cap.isJava}}
19
+ - name: {{cap.appName}}-db
20
+ {{^cap.isMultitenant}}
21
+ type: com.sap.xs.hdi-container
22
+ parameters:
23
+ service: hana
24
+ service-plan: hdi-shared
25
+ {{/cap.isMultitenant}}
26
+ {{#cap.isMultitenant}}
27
+ type: org.cloudfoundry.managed-service
28
+ parameters:
29
+ service: service-manager
30
+ service-plan: container
31
+ {{/cap.isMultitenant}}
32
+ {{#cap.isJava}}
33
+ properties:
34
+ hdi-service-name: ${service-name}
35
+ {{/cap.isJava}}
@@ -8,7 +8,7 @@ const ProjectReader = require('../../util/projectReader');
8
8
 
9
9
  const TemplateBase = require('../templateBase');
10
10
 
11
- const { PROJECT_TYPE, OPTION_JAVA, URLS, KIND_HANA } = require('../../constants');
11
+ const { PROJECT_TYPE, OPTION_JAVA, URLS, OPTION_HELM_UPDATE } = require('../../constants');
12
12
  const { nullLogger } = require('../../util/logger');
13
13
  const { srvNode, srvJava, hdbDeployer, serviceManager, hdiContainer } = require('../_merging/existences');
14
14
 
@@ -18,6 +18,10 @@ module.exports = class HanaTemplate extends TemplateBase {
18
18
  this.projectReader = new ProjectReader(this);
19
19
  }
20
20
 
21
+ async getDependencies() {
22
+ return [OPTION_HELM_UPDATE];
23
+ }
24
+
21
25
  // read env from project
22
26
  async getEnv() {
23
27
  const cdsEnvVar = process.env.CDS_ENV;
@@ -31,14 +35,14 @@ module.exports = class HanaTemplate extends TemplateBase {
31
35
 
32
36
  async checkEnabled() {
33
37
  const { lt } = require('semver')
34
- const cds = require('@sap/cds/lib')
38
+ const cds = require('../../../cds')
35
39
  if (lt(cds.version, '5.9.0')) {
36
40
  cds.error('The added configuration requires @sap/cds 5.9.0 or higher. Please update @sap/cds to the latest version and run \x1b[1mcds add hana\x1b[0m again.')
37
41
  }
38
42
  return true
39
43
  }
40
44
 
41
- async runMTAMerging() {
45
+ async runDependentMerging() {
42
46
  const projectDescriptor = await this.projectReader.read(this.options);
43
47
 
44
48
  const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
@@ -118,7 +122,7 @@ module.exports = class HanaTemplate extends TemplateBase {
118
122
 
119
123
  default: break;
120
124
  }
121
- await this.runMTAMerging()
125
+ await this.runDependentMerging()
122
126
  }
123
127
 
124
128
  async _updatePomXml() {
@@ -0,0 +1,39 @@
1
+ /* eslint-disable no-unused-vars */
2
+ /* eslint-disable no-unreachable */
3
+ const path = require('path');
4
+ const TemplateBase = require('../templateBase');
5
+ const ProjectReader = require('../../util/projectReader');
6
+ const { exec } = require('../../../k8s/util');
7
+ const {context, addChart, hasChart } = require('../../../k8s');
8
+ const { rimraf } = require('@sap/cds/lib').utils;
9
+ module.exports = class HelmTemplate extends TemplateBase {
10
+ constructor(projectPath, generator) {
11
+ super(projectPath, generator, __dirname);
12
+ this.projectReader = new ProjectReader(this);
13
+ }
14
+
15
+ async checkEnabled() {
16
+
17
+ if (this.options.force) {
18
+ await rimraf(this.chartPath());
19
+ return true;
20
+ }
21
+
22
+ return true;
23
+ }
24
+
25
+ chartPath() {
26
+ return path.join(this.projectPath, 'chart');
27
+ }
28
+
29
+ async run() {
30
+ const PREFIX = 'helm:';
31
+ const features = new Set();
32
+ for (const option of this.options.helm && this.options.helm.values() || []) {
33
+ if (option.startsWith(PREFIX)) features.add(option.substr(PREFIX.length));
34
+ }
35
+
36
+ const project = await context(this.projectPath, features);
37
+ await addChart(project, path.join(this.projectPath, '/chart'));
38
+ }
39
+ };
@@ -0,0 +1,28 @@
1
+ /* eslint-disable no-unused-vars */
2
+ /* eslint-disable no-unreachable */
3
+ const path = require('path');
4
+ const TemplateBase = require('../../templateBase');
5
+ const ProjectReader = require('../../../util/projectReader');
6
+ const { OPTION_HELM } = require('../../../constants');
7
+
8
+ module.exports = class HelmUpdateTemplate extends TemplateBase {
9
+ constructor(projectPath, generator) {
10
+ super(projectPath, generator, __dirname, true);
11
+ this.projectReader = new ProjectReader(this);
12
+ }
13
+
14
+ async getDependencies() {
15
+ return [ OPTION_HELM ];
16
+ }
17
+
18
+ async checkEnabled() {
19
+ return await this.fsUtil.pathExists(this.chartPath());
20
+ }
21
+
22
+ chartPath() {
23
+ return path.join(this.projectPath, 'chart');
24
+ }
25
+
26
+ async run() {
27
+ }
28
+ };
@@ -2,15 +2,12 @@ const fs = require('fs').promises;
2
2
  const os = require('os');
3
3
  const path = require('path');
4
4
 
5
- const { fse } = require('@sap/cds-foss');
6
-
7
-
8
5
  const commandUtil = require('../../util/commandUtil');
9
6
  const mvnArchetypeUtil = require('../../util/mvnArchetypeUtil');
10
7
  const term = require('../../../util/term');
11
8
 
12
9
  const TemplateBase = require('../templateBase');
13
- const { COMMAND_ADD, URLS, OPTION_JAVA, OPTION_NODEJS, MAVEN_ARCHETYPE_VERSION } = require('../../constants');
10
+ const { COMMAND_ADD, URLS, OPTION_JAVA, OPTION_NODEJS } = require('../../constants');
14
11
  const { nullLogger } = require('../../util/logger');
15
12
 
16
13
 
@@ -32,24 +29,25 @@ module.exports = class JavaTemplate extends TemplateBase {
32
29
  }
33
30
 
34
31
  async run() {
35
- this.logger.log(`Using Maven archetype version ${MAVEN_ARCHETYPE_VERSION}`);
36
-
37
32
  const mvnCmdArgs = mvnArchetypeUtil.getGenerateCmdArgs(this.projectName, this.options, this.logger);
33
+ const { cmdLine, artifactId, archetypeVersion } = mvnCmdArgs
34
+
35
+ this.logger.log(`Using Maven archetype version ${archetypeVersion}`);
38
36
 
39
37
  const tempFolder = await fs.mkdtemp(path.join(os.tmpdir(), `${this.projectName}_`));
40
38
  try {
41
- await commandUtil.spawnCommand('mvn', mvnCmdArgs.cmdLine, {
39
+ await commandUtil.spawnCommand('mvn', cmdLine, {
42
40
  cwd: tempFolder
43
41
  }, (this.logger.isDebug ? this.logger : nullLogger));
44
42
 
45
- await this.fsUtil.copy(path.join(tempFolder, mvnCmdArgs.artifactId), this.projectPath);
43
+ await this.fsUtil.copy(path.join(tempFolder, artifactId), this.projectPath);
46
44
  } catch (err) {
47
45
  if (err.code === 'ENOENT' && err.path === 'mvn') {
48
46
  throw new Error(`Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`);
49
47
  }
50
48
  throw err;
51
49
  } finally {
52
- await fse.remove(tempFolder);
50
+ await fs.rm(tempFolder, { force: true, recursive: true });
53
51
  }
54
52
  }
55
53
 
@@ -1,4 +1,4 @@
1
- const cds = require('@sap/cds')
1
+ const cds = require('../../../cds')
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
 
@@ -15,11 +15,10 @@ module.exports = class KibanaTemplate extends TemplateBase {
15
15
  this.projectReader = new ProjectReader(this);
16
16
  }
17
17
 
18
- async runMTAMerging() {
18
+ async runDependentMerging() {
19
19
  const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
20
20
 
21
21
  if (!fs.existsSync(mtaYAMLPath)) {
22
- console.warn(`Cannot add Kibana Logging as there is no 'mta.yaml' deploy descriptor in your project. Run 'cds add mta' to add it.`)
23
22
  return;
24
23
  }
25
24
 
@@ -45,7 +44,7 @@ module.exports = class KibanaTemplate extends TemplateBase {
45
44
 
46
45
  async run() {
47
46
  const projectType = await this.getProjectType();
48
-
47
+
49
48
  switch (projectType) {
50
49
  case PROJECT_TYPE.java:
51
50
  default:
@@ -58,7 +57,7 @@ module.exports = class KibanaTemplate extends TemplateBase {
58
57
  const cdsTemplatePath = path.join(__dirname, 'files', cdsTemplateFile)
59
58
  await this.templateUtil.mergeJSON(path.join(this.projectPath, 'package.json'), cdsTemplatePath, projectDescriptor)
60
59
  }
61
- }
62
- await this.runMTAMerging()
60
+ }
61
+ await this.runDependentMerging()
63
62
  }
64
63
  }