@sap/cds-dk 6.8.2 → 7.0.0

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 (218) hide show
  1. package/bin/activate.js +15 -7
  2. package/bin/add.js +29 -15
  3. package/bin/bind.js +49 -116
  4. package/bin/build.js +114 -0
  5. package/bin/cds.js +67 -24
  6. package/bin/compile/index.js +2 -2
  7. package/bin/deploy/index.js +46 -39
  8. package/bin/deploy/to-hana.js +11 -8
  9. package/bin/deploy/to-postgres.js +8 -2
  10. package/bin/deploy/to-sqlite.js +0 -1
  11. package/bin/env.js +75 -41
  12. package/bin/eval.js +3 -3
  13. package/bin/extend.js +17 -10
  14. package/bin/help.js +22 -21
  15. package/bin/import.js +10 -7
  16. package/bin/init.js +38 -17
  17. package/bin/login.js +69 -55
  18. package/bin/logout.js +12 -9
  19. package/bin/migrate.js +10 -4
  20. package/bin/pull.js +12 -5
  21. package/bin/push.js +24 -13
  22. package/bin/repl.js +1 -0
  23. package/bin/run.js +25 -0
  24. package/bin/subscribe.js +13 -8
  25. package/bin/unsubscribe.js +15 -8
  26. package/bin/upgrade.js +15 -9
  27. package/bin/util/log.js +24 -0
  28. package/bin/version.js +124 -0
  29. package/bin/watch.js +1 -35
  30. package/bin/watched.js +39 -0
  31. package/lib/bind/KubernetesApiAccessor.js +2 -2
  32. package/lib/bind/bindingManager.js +1 -1
  33. package/lib/bind/bindingUtil.js +0 -9
  34. package/lib/bind/cfKeyProvider.js +10 -72
  35. package/lib/bind/index.js +114 -0
  36. package/lib/bind/kubernetesCredentialsProvider.js +2 -2
  37. package/lib/bind/userCdsrcJsonStorageProvider.js +7 -44
  38. package/lib/build/buildTaskEngine.js +355 -0
  39. package/lib/build/buildTaskFactory.js +284 -0
  40. package/lib/build/buildTaskHandler.js +240 -0
  41. package/lib/build/buildTaskProvider.js +22 -0
  42. package/lib/build/buildTaskProviderFactory.js +182 -0
  43. package/lib/build/constants.js +56 -0
  44. package/lib/build/index.js +21 -0
  45. package/lib/build/provider/buildTaskHandlerEdmx.js +83 -0
  46. package/lib/build/provider/buildTaskHandlerFeatureToggles.js +132 -0
  47. package/lib/build/provider/buildTaskHandlerInternal.js +228 -0
  48. package/lib/build/provider/buildTaskProviderInternal.js +370 -0
  49. package/lib/build/provider/fiori/index.js +167 -0
  50. package/lib/build/provider/hana/2migration.js +179 -0
  51. package/lib/build/provider/hana/index.js +522 -0
  52. package/lib/build/provider/hana/migrationtable.js +472 -0
  53. package/lib/build/provider/hana/template/.hdiconfig-all +163 -0
  54. package/lib/build/provider/hana/template/.hdiconfig-cloud +137 -0
  55. package/lib/build/provider/hana/template/.hdinamespace +4 -0
  56. package/lib/build/provider/hana/template/package.json +12 -0
  57. package/lib/build/provider/hana/template/undeploy.json +5 -0
  58. package/lib/build/provider/java/index.js +93 -0
  59. package/lib/build/provider/java-cf/index.js +1 -0
  60. package/lib/build/provider/mtx/index.js +37 -0
  61. package/lib/build/provider/mtx/resourcesTarBuilder.js +94 -0
  62. package/lib/build/provider/mtx-extension/index.js +131 -0
  63. package/lib/build/provider/mtx-sidecar/index.js +138 -0
  64. package/lib/build/provider/node-cf/index.js +1 -0
  65. package/lib/build/provider/nodejs/index.js +178 -0
  66. package/lib/build/util.js +263 -0
  67. package/lib/cds.js +9 -21
  68. package/lib/client/auth_manager.js +39 -16
  69. package/lib/client/helper/dependency_helper.js +7 -6
  70. package/lib/client/push.js +2 -1
  71. package/lib/client/settings_manager.js +10 -39
  72. package/lib/deploy/to-hana/hana.js +273 -0
  73. package/lib/deploy/to-hana/hdiDeployUtil.js +68 -0
  74. package/lib/deploy/to-hana/mtaUtil.js +171 -0
  75. package/lib/import/asyncapi/importAsyncAPI.js +3 -2
  76. package/lib/import/asyncapi/index.js +5 -2
  77. package/lib/import/asyncapi/parserContext.js +67 -26
  78. package/lib/import/asyncapi/utils.js +34 -3
  79. package/lib/import/common.js +40 -30
  80. package/lib/import/importapi.js +36 -35
  81. package/lib/index.js +12 -17
  82. package/lib/init/constants.js +36 -71
  83. package/lib/init/index.js +18 -52
  84. package/lib/init/template/_merging/registry-mta.js +21 -3
  85. package/lib/init/template/approuter/files/mta.yaml.hbs +29 -29
  86. package/lib/init/template/approuter/files/values.yaml.hbs +5 -5
  87. package/lib/init/template/approuter/files/xs-app.json.hbs +8 -2
  88. package/lib/init/template/approuter/index.js +7 -8
  89. package/lib/init/template/auditlog/files/mta.yaml.hbs +5 -5
  90. package/lib/init/template/auditlog/files/package.json.hbs +13 -13
  91. package/lib/init/template/auditlog/index.js +3 -3
  92. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +22 -22
  93. package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +3 -3
  94. package/lib/init/template/connectivity/files/mta.yaml.hbs +14 -0
  95. package/lib/init/template/connectivity/files/package.json.hbs +17 -0
  96. package/lib/init/template/connectivity/index.js +21 -4
  97. package/lib/init/template/data/index.js +5 -1
  98. package/lib/init/template/destination/files/mta.yaml.hbs +14 -0
  99. package/lib/init/template/destination/files/package.json.hbs +17 -0
  100. package/lib/init/template/{destinations → destination}/index.js +19 -13
  101. package/lib/init/template/enterprise-messaging/files/event-mesh.json.hbs +3 -3
  102. package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +5 -5
  103. package/lib/init/template/enterprise-messaging/files/package.json.hbs +9 -9
  104. package/lib/init/template/enterprise-messaging/files/xs-security.json.hbs +19 -0
  105. package/lib/init/template/enterprise-messaging/index.js +27 -6
  106. package/lib/init/template/enterprise-messaging-shared/files/event-mesh.json.hbs +3 -3
  107. package/lib/init/template/enterprise-messaging-shared/files/mta.yaml.hbs +5 -5
  108. package/lib/init/template/enterprise-messaging-shared/files/package.json.hbs +9 -9
  109. package/lib/init/template/enterprise-messaging-shared/index.js +4 -5
  110. package/lib/init/template/extensibility/files/package.json.hbs +10 -10
  111. package/lib/init/template/extensibility/index.js +8 -9
  112. package/lib/init/template/file-based-messaging/files/package.json.hbs +9 -9
  113. package/lib/init/template/file-based-messaging/index.js +3 -4
  114. package/lib/init/template/hana/files/db/package.json +1 -1
  115. package/lib/init/template/hana/files/mta.yaml.hbs +21 -21
  116. package/lib/init/template/hana/files/package.json.hbs +16 -22
  117. package/lib/init/template/hana/files/values.yaml.hbs +1 -1
  118. package/lib/init/template/hana/index.js +5 -15
  119. package/lib/init/template/helm/files/Chart.yaml.hbs +4 -4
  120. package/lib/init/template/helm/files/values.yaml.hbs +6 -6
  121. package/lib/init/template/helm/index.js +5 -10
  122. package/lib/init/template/helm/subcharts/content-deployment/Chart.yaml +2 -0
  123. package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +37 -31
  124. package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +13 -14
  125. package/lib/init/template/helm/subcharts/content-deployment/templates/secret.yaml +2 -2
  126. package/lib/init/template/helm/subcharts/content-deployment/templates/service-account.yaml +1 -1
  127. package/lib/init/template/helm/subcharts/content-deployment/templates/service-binding.yaml +3 -3
  128. package/lib/init/template/helm/subcharts/content-deployment/values.md +116 -116
  129. package/lib/init/template/helm/subcharts/service-instance/Chart.yaml +2 -0
  130. package/lib/init/template/helm/subcharts/service-instance/templates/_helpers.tpl +9 -9
  131. package/lib/init/template/helm/subcharts/service-instance/templates/serviceinstance.yaml +2 -2
  132. package/lib/init/template/helm/subcharts/service-instance/values.md +15 -15
  133. package/lib/init/template/helm/subcharts/web-application/Chart.yaml +2 -0
  134. package/lib/init/template/helm/subcharts/web-application/templates/NOTES.txt +15 -0
  135. package/lib/init/template/helm/subcharts/web-application/templates/_helpers.tpl +23 -23
  136. package/lib/init/template/helm/subcharts/web-application/templates/api-rule.yaml +4 -4
  137. package/lib/init/template/helm/subcharts/web-application/templates/deployment.yaml +17 -17
  138. package/lib/init/template/helm/subcharts/web-application/templates/network-policy.yaml +24 -3
  139. package/lib/init/template/helm/subcharts/web-application/templates/pod-disruption-budget.yaml +3 -3
  140. package/lib/init/template/helm/subcharts/web-application/templates/secret.yaml +2 -2
  141. package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +1 -1
  142. package/lib/init/template/helm/subcharts/web-application/templates/service-binding.yaml +3 -3
  143. package/lib/init/template/helm/subcharts/web-application/templates/service.yaml +3 -3
  144. package/lib/init/template/helm/subcharts/web-application/values.md +141 -123
  145. package/lib/init/template/helm/subcharts/web-application/values.schema.json +7 -0
  146. package/lib/init/template/helm/subcharts/web-application/values.yaml +1 -0
  147. package/lib/init/template/html5-repo/index.js +4 -5
  148. package/lib/init/template/java/index.js +5 -5
  149. package/lib/init/template/kibana-logging/files/mta.yaml.hbs +5 -5
  150. package/lib/init/template/kibana-logging/files/package.json.hbs +9 -9
  151. package/lib/init/template/kibana-logging/index.js +3 -4
  152. package/lib/init/template/lint/index.js +3 -3
  153. package/lib/init/template/mta/files/mta.yaml.hbs +14 -14
  154. package/lib/init/template/mta/files/package.json +5 -0
  155. package/lib/init/template/mta/index.js +12 -13
  156. package/lib/init/template/mtx/index.js +2 -2
  157. package/lib/init/template/multitenancy/files/mta.yaml.hbs +29 -27
  158. package/lib/init/template/multitenancy/files/package.json.hbs +17 -14
  159. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +7 -7
  160. package/lib/init/template/multitenancy/files/values.yaml.hbs +19 -19
  161. package/lib/init/template/multitenancy/index.js +14 -16
  162. package/lib/init/template/nodejs/files/package.json.hbs +1 -1
  163. package/lib/init/template/nodejs/index.js +5 -8
  164. package/lib/init/template/redis-messaging/files/mta.yaml.hbs +5 -5
  165. package/lib/init/template/redis-messaging/files/package.json.hbs +9 -9
  166. package/lib/init/template/redis-messaging/index.js +4 -5
  167. package/lib/init/template/sample/files/app/_i18n/i18n.properties +43 -0
  168. package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +14 -0
  169. package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +114 -0
  170. package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +8 -0
  171. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +11 -0
  172. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +129 -0
  173. package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +57 -0
  174. package/lib/init/template/sample/files/app/common.cds +263 -0
  175. package/lib/init/template/sample/files/app/index.html +30 -0
  176. package/lib/init/template/sample/files/app/services.cds +5 -0
  177. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +5 -0
  178. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books.csv +6 -0
  179. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books_texts.csv +5 -0
  180. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Genres.csv +16 -0
  181. package/lib/init/template/sample/files/db/schema.cds +31 -0
  182. package/lib/init/template/sample/files/nodejs/admin-service.js +12 -0
  183. package/lib/init/template/sample/files/nodejs/cat-service.js +26 -0
  184. package/lib/init/template/sample/files/srv/admin-service.cds +5 -0
  185. package/lib/init/template/sample/files/srv/cat-service.cds +16 -0
  186. package/lib/init/template/sample/index.js +24 -0
  187. package/lib/init/template/sample-tiny/index.js +39 -0
  188. package/lib/init/template/samples/index.js +5 -56
  189. package/lib/init/template/sqlite/files/package.json.hbs +13 -13
  190. package/lib/init/template/sqlite/index.js +2 -2
  191. package/lib/init/template/templateBase.js +24 -1
  192. package/lib/init/template/toggles/files/package.json.hbs +10 -10
  193. package/lib/init/template/toggles/index.js +3 -3
  194. package/lib/init/template/typer/files/gitignore +1 -0
  195. package/lib/init/template/typer/files/package.json +8 -0
  196. package/lib/init/template/typer/files/xsconfig.json +9 -0
  197. package/lib/init/template/typer/index.js +36 -0
  198. package/lib/init/template/xsuaa/files/mta.yaml.hbs +12 -12
  199. package/lib/init/template/xsuaa/files/package.json.hbs +13 -13
  200. package/lib/init/template/xsuaa/files/values.yaml.hbs +8 -8
  201. package/lib/init/template/xsuaa/index.js +8 -19
  202. package/lib/init/util/merge.js +73 -59
  203. package/lib/init/util/mvn.js +21 -17
  204. package/lib/init/util/projectReader.js +49 -87
  205. package/lib/init/util/xml.js +14 -23
  206. package/lib/util/cfUtil.js +366 -0
  207. package/lib/util/command.js +3 -3
  208. package/lib/util/gitUtil.js +55 -0
  209. package/lib/util/version.js +27 -0
  210. package/npm-shrinkwrap.json +339 -277
  211. package/package.json +6 -6
  212. package/CHANGELOG.md +0 -1453
  213. package/bin/build/all.js +0 -88
  214. package/bin/build/index.js +0 -82
  215. package/lib/compile/index.js +0 -14
  216. /package/lib/init/template/{samples → sample-tiny}/files/nodejs/db/data/my.bookshop-Books.csv +0 -0
  217. /package/lib/init/template/{samples → sample-tiny}/files/nodejs/db/data-model.cds +0 -0
  218. /package/lib/init/template/{samples → sample-tiny}/files/nodejs/srv/cat-service.cds.hbs +0 -0
@@ -1,56 +1,56 @@
1
1
  # Generated manifest.yml based on template version 0.1.0
2
- # appName = {{cap.appName}}
3
- # language={{cap.language}}
4
- # multitenancy={{cap.isMultitenant}}
2
+ # appName = {{appName}}
3
+ # language={{language}}
4
+ # multitenancy={{isMultitenant}}
5
5
  ---
6
6
  applications:
7
7
  # -----------------------------------------------------------------------------------
8
8
  # Backend Service
9
9
  # -----------------------------------------------------------------------------------
10
- - name: {{cap.appName}}-{{cap.srvName}}
10
+ - name: {{appName}}-{{srvName}}
11
11
  random-route: true # for development only
12
- {{#cap.isNodejs}}
13
- path: {{& cap.srvPath}}
12
+ {{#isNodejs}}
13
+ path: {{& srvPath}}
14
14
  memory: 256M
15
15
  buildpack: nodejs_buildpack
16
- {{/cap.isNodejs}}
17
- {{#cap.isJava}}
18
- path: {{& cap.srvPath}}/target/{{cap.srvExt.archiveName}}
16
+ {{/isNodejs}}
17
+ {{#isJava}}
18
+ path: {{& srvPath}}/target/{{srvExt.archiveName}}
19
19
  memory: 1G
20
20
  disk_quota: 512M
21
21
  env:
22
22
  SPRING_PROFILES_ACTIVE: cloud
23
23
  buildpack: java_buildpack
24
- {{/cap.isJava}}
25
- {{#cap.hasRequires}}
24
+ {{/isJava}}
25
+ {{#hasRequires}}
26
26
  services:
27
- {{#cap.requires}}
27
+ {{#requires}}
28
28
  {{#resource.isHana}}
29
29
  - {{resource.name}}
30
30
  {{/resource.isHana}}
31
31
  {{#resource.isXsuaa}}
32
32
  - {{resource.name}}
33
33
  {{/resource.isXsuaa}}
34
- {{/cap.requires}}
35
- {{/cap.hasRequires}}
34
+ {{/requires}}
35
+ {{/hasRequires}}
36
36
 
37
- {{#cap.needsSidecar}}
37
+ {{#needsSidecar}}
38
38
  # -----------------------------------------------------------------------------------
39
39
  # HANA Database Content Deployer App
40
40
  # -----------------------------------------------------------------------------------
41
- - name: {{cap.appName}}-{{cap.db.0.name}}-deployer
42
- path: {{& cap.db.0.path}}
41
+ - name: {{appName}}-{{db.0.name}}-deployer
42
+ path: {{& db.0.path}}
43
43
  no-route: true
44
44
  health-check-type: process
45
45
  memory: 256M
46
46
  instances: 1
47
47
  buildpack: nodejs_buildpack
48
- {{#cap.hasRequires}}
48
+ {{#hasRequires}}
49
49
  services:
50
- {{#cap.requires}}
50
+ {{#requires}}
51
51
  {{#resource.isHana}}
52
52
  - {{resource.name}}
53
53
  {{/resource.isHana}}
54
- {{/cap.requires}}
55
- {{/cap.hasRequires}}
56
- {{/cap.needsSidecar}}
54
+ {{/requires}}
55
+ {{/hasRequires}}
56
+ {{/needsSidecar}}
@@ -1,8 +1,8 @@
1
1
  # Generated services-manifest.yml based on template version 0.1.0
2
- # appName = {{cap.appName}}
2
+ # appName = {{appName}}
3
3
  ---
4
4
  create-services:
5
- {{#cap.requires}}
5
+ {{#requires}}
6
6
  # ------------------------------------------------------------
7
7
  - name: {{resource.name}}
8
8
  {{#resource.isHana}}
@@ -19,4 +19,4 @@ create-services:
19
19
  broker: {{resource.service}}
20
20
  plan: {{resource.vcap.name}}
21
21
  {{/resource.vcap.name}}
22
- {{/cap.requires}}
22
+ {{/requires}}
@@ -0,0 +1,14 @@
1
+ ---
2
+ modules:
3
+ - name: {{appName}}-srv
4
+ type: {{language}}
5
+ path: {{& srvPath}}
6
+ requires:
7
+ - name: {{appName}}-connectivity
8
+
9
+ resources:
10
+ - name: {{appName}}-connectivity
11
+ type: org.cloudfoundry.managed-service
12
+ parameters:
13
+ service: connectivity
14
+ service-plan: lite
@@ -0,0 +1,17 @@
1
+ {
2
+ {{#isNodejs}}
3
+ "cds": {
4
+ {{/isNodejs}}
5
+ "requires": {
6
+ {{#profile}}
7
+ "[{{profile}}]": {
8
+ {{/profile}}
9
+ "connectivity": true
10
+ {{#profile}}
11
+ }
12
+ {{/profile}}
13
+ }
14
+ {{#isNodejs}}
15
+ }
16
+ {{/isNodejs}}
17
+ }
@@ -1,17 +1,35 @@
1
1
  const { join } = require('path')
2
2
  const { readProject } = require('../../util/projectReader')
3
- const { mergeYAML } = require('../../util/merge')
3
+ const { mergeJSON, mergeYAML } = require('../../util/merge')
4
4
  const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5')
5
+ const { srvJava4, srvNode4, connectivity } = require('../_merging/registry-mta')
5
6
 
6
7
  module.exports = class ConnectivityTemplate extends require('../templateBase') {
7
8
 
9
+ static hasFacet(env) {
10
+ return env.requires.connectivity
11
+ }
12
+
8
13
  async run() {
14
+ const projectDescriptor = await readProject(this.options)
15
+ const { configFile } = projectDescriptor
16
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
9
17
  await this.runDependentMerging()
10
18
  }
11
19
 
12
20
  async runDependentMerging(context = {}) {
13
21
  const projectDescriptor = await readProject(this.options)
14
- const { hasHelm } = projectDescriptor.cap
22
+ const { isJava, srvPath, hasHelm, hasMta } = projectDescriptor
23
+
24
+ if (hasMta) {
25
+ const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
26
+ const additions = [srv, connectivity]
27
+ const relationships = [{
28
+ insert: [connectivity, 'name'],
29
+ into: [srv, 'requires', 'name']
30
+ }]
31
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), projectDescriptor, { additions, relationships })
32
+ }
15
33
 
16
34
  if (hasHelm) {
17
35
  //in case facet is being added to the already exisiting charts folder
@@ -20,13 +38,12 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
20
38
  isIndependentCommand = true
21
39
  context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'))
22
40
  }
23
-
24
41
  await mergeYAML(
25
42
  join('chart', 'values.yaml'),
26
43
  join(__dirname, 'files', 'values.yaml.hbs'),
27
44
  projectDescriptor,
28
45
  { additions: [{
29
- in: `srv.additionalVolumes`,
46
+ in: 'srv.additionalVolumes',
30
47
  where: [{
31
48
  property: 'name',
32
49
  isEqualTo: 'connectivity-secret'
@@ -8,6 +8,10 @@ const DEBUG = cds.debug('cli')
8
8
  module.exports = class DataTemplate extends require('../templateBase') {
9
9
 
10
10
  async run() {
11
+ if (this.options['for']) {
12
+ throw `\nError: Did you mean \`... --data:for\` ?`
13
+ }
14
+
11
15
  const env = await this.getEnv();
12
16
 
13
17
  let dest = (typeof this.options.out === 'string') // target folder
@@ -15,7 +19,7 @@ module.exports = class DataTemplate extends require('../templateBase') {
15
19
  : getDefaultTargetFolder(env);
16
20
  dest = resolve(cds.root, dest);
17
21
 
18
- const nameFilter = asRegex(this.options['data:for'] || this.options.for)
22
+ const nameFilter = asRegex(this.options['data:for'])
19
23
  const force = this.options.force;
20
24
 
21
25
  let csn = await cds.compile.to.csn(cds.env.roots) // normal CSN
@@ -0,0 +1,14 @@
1
+ ---
2
+ modules:
3
+ - name: {{appName}}-srv
4
+ type: {{language}}
5
+ path: {{& srvPath}}
6
+ requires:
7
+ - name: {{appName}}-destination
8
+
9
+ resources:
10
+ - name: {{appName}}-destination
11
+ type: org.cloudfoundry.managed-service
12
+ parameters:
13
+ service: destination
14
+ service-plan: lite
@@ -0,0 +1,17 @@
1
+ {
2
+ {{#isNodejs}}
3
+ "cds": {
4
+ {{/isNodejs}}
5
+ "requires": {
6
+ {{#profile}}
7
+ "[{{profile}}]": {
8
+ {{/profile}}
9
+ "destinations": true
10
+ {{#profile}}
11
+ }
12
+ {{/profile}}
13
+ }
14
+ {{#isNodejs}}
15
+ }
16
+ {{/isNodejs}}
17
+ }
@@ -1,33 +1,39 @@
1
1
  const { join } = require('path')
2
2
  const { readProject } = require('../../util/projectReader')
3
- const { mergeYAML } = require('../../util/merge')
3
+ const { mergeJSON, mergeYAML } = require('../../util/merge')
4
+ const { srvJava4, srvNode4, destination } = require('../_merging/registry-mta')
4
5
  const { parseMd5File, writeMd5File } = require('../../util/md5')
5
6
 
6
- module.exports = class DestinationsTemplate extends require('../templateBase') {
7
-
8
- async canRun() {
9
- const projectDescriptor = await readProject(this.options)
10
- const { hasMta, hasHelm } = projectDescriptor.cap
11
- if (!hasHelm && hasMta) {
12
- throw `'cds add destinations' is not available for Cloud Foundry yet`
13
- }
14
- return true
15
- }
7
+ module.exports = class DestinationTemplate extends require('../templateBase') {
16
8
 
17
9
  static hasFacet(env) {
18
10
  const kinds = { odata: 1, 'odata-v2': 1, 'odata-v4': 1, rest: 1 }
19
11
  const mtxServices = { 'cds.xt.SaasProvisioningService': 1, 'cds.xt.DeploymentService': 1, 'cds.xt.ModelProviderService': 1, 'cds.xt.ExtensibilityService': 1 }
20
12
  const _fromMtx = service => service in mtxServices
21
- return Object.entries(env.requires).some(([service, require]) => !_fromMtx(service) && !kinds[service] && kinds[require.kind])
13
+ const hasDestination = Object.entries(env.requires).some(([service, require]) => !_fromMtx(service) && !kinds[service] && kinds[require.kind])
14
+ return hasDestination || env.requires.destinations
22
15
  }
23
16
 
24
17
  async run() {
18
+ const projectDescriptor = await readProject(this.options)
19
+ const { configFile } = projectDescriptor
20
+ await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), projectDescriptor)
25
21
  await this.runDependentMerging()
26
22
  }
27
23
 
28
24
  async runDependentMerging(context = {}) {
29
25
  const projectDescriptor = await readProject(this.options)
30
- const { hasHelm, hasDestination, hasHtml5Repo } = projectDescriptor.cap
26
+ const { isJava, hasHelm, hasDestination, hasMta, srvPath, hasHtml5Repo } = projectDescriptor
27
+
28
+ if (hasMta) {
29
+ const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
30
+ const additions = [srv, destination]
31
+ const relationships = [{
32
+ insert: [destination, 'name'],
33
+ into: [srv, 'requires', 'name']
34
+ }]
35
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), projectDescriptor, { additions, relationships })
36
+ }
31
37
 
32
38
  if (hasHelm) {
33
39
  //const env = await this.getEnv()
@@ -1,7 +1,7 @@
1
1
  {
2
- "emname": "{{cap.appName}}-emname",
2
+ "emname": "{{appName}}-emname",
3
3
  "version": "1.1.0",
4
- "namespace": "default/sap.myapp/1",
4
+ "namespace": "default/{{appName}}/1",
5
5
  "options": {
6
6
  "management": true,
7
7
  "messagingrest": true,
@@ -10,7 +10,7 @@
10
10
  "rules": {
11
11
  "topicRules": {
12
12
  "publishFilter": [
13
- "${namespace}/sample"
13
+ "${namespace}/*"
14
14
  ],
15
15
  "subscribeFilter": [
16
16
  "*"
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  modules:
3
- - name: {{cap.appName}}-srv
4
- type: {{cap.language}}
5
- path: {{& cap.srvPath}}
3
+ - name: {{appName}}-srv
4
+ type: {{language}}
5
+ path: {{& srvPath}}
6
6
  requires:
7
- - name: {{cap.appName}}-messaging
7
+ - name: {{appName}}-messaging
8
8
 
9
9
  resources:
10
- - name: {{cap.appName}}-messaging
10
+ - name: {{appName}}-messaging
11
11
  type: org.cloudfoundry.managed-service
12
12
  parameters:
13
13
  service: enterprise-messaging
@@ -1,19 +1,19 @@
1
1
  {
2
- {{#cap.isNodejs}}
2
+ {{#isNodejs}}
3
3
  "cds": {
4
- {{/cap.isNodejs}}
4
+ {{/isNodejs}}
5
5
  "requires": {
6
- {{#cap.for}}
7
- "[{{cap.for}}]": {
8
- {{/cap.for}}
6
+ {{#profile}}
7
+ "[{{profile}}]": {
8
+ {{/profile}}
9
9
  "messaging": {
10
10
  "kind": "enterprise-messaging"
11
11
  }
12
- {{#cap.for}}
12
+ {{#profile}}
13
13
  }
14
- {{/cap.for}}
14
+ {{/profile}}
15
15
  }
16
- {{#cap.isNodejs}}
16
+ {{#isNodejs}}
17
17
  }
18
- {{/cap.isNodejs}}
18
+ {{/isNodejs}}
19
19
  }
@@ -0,0 +1,19 @@
1
+ {
2
+ "scopes": [
3
+ {
4
+ "name": "$XSAPPNAME.emmanagement",
5
+ "description": "Enterprise-Messaging Management Access"
6
+ },
7
+ {
8
+ "name": "$XSAPPNAME.emcallback",
9
+ "description": "Enterprise-Messaging Callback Access",
10
+ "grant-as-authority-to-apps": [
11
+ "$XSSERVICENAME({{em-service-name}})"
12
+ ]
13
+ }
14
+ ],
15
+ "authorities": [
16
+ "$XSAPPNAME.emmanagement",
17
+ "$XSAPPNAME.mtcallback"
18
+ ]
19
+ }
@@ -1,3 +1,4 @@
1
+ const YAML = require('@sap/cds-foss')('yaml')
1
2
  const { join } = require('path')
2
3
  const cds = require('../../../cds')
3
4
  const { read } = cds.utils
@@ -9,8 +10,7 @@ const { srvNode4, srvJava4, enterpriseMessaging } = require('../_merging/registr
9
10
  module.exports = class EnterpriseMessagingTemplate extends require('../templateBase') {
10
11
 
11
12
  async canRun() {
12
- const projectDescriptor = await readProject(this.options)
13
- const { isJava } = projectDescriptor.cap
13
+ const { isJava } = await readProject(this.options)
14
14
  if (isJava) throw `'cds add enterprise-messaging' is not available for Java yet`
15
15
  return true
16
16
  }
@@ -21,18 +21,17 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
21
21
 
22
22
  async run() {
23
23
  const projectDescriptor = await readProject(this.options)
24
- const { configFile } = projectDescriptor.cap
25
- projectDescriptor.cap.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
24
+ const { configFile } = projectDescriptor
26
25
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
27
- await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), projectDescriptor)
28
26
  await this.runDependentMerging()
29
27
  }
30
28
 
31
29
  async runDependentMerging(context = {}) {
32
30
  const projectDescriptor = await readProject(this.options)
33
- const { hasHelm, hasMta, isNodejs, srvPath } = projectDescriptor.cap
31
+ const { hasXsuaa, hasHelm, hasMta, isNodejs, srvPath, appName } = projectDescriptor
34
32
 
35
33
  if (hasMta) {
34
+ await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), projectDescriptor)
36
35
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
37
36
  await mergeYAML(
38
37
  'mta.yaml',
@@ -48,6 +47,28 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
48
47
  )
49
48
  }
50
49
 
50
+ if (hasXsuaa) {
51
+ if (hasMta) {
52
+ projectDescriptor['em-service-name'] = YAML.parse(await read('mta.yaml'))?.resources?.find(r => r?.parameters?.service === 'enterprise-messaging')?.name
53
+ } else {
54
+ projectDescriptor['em-service-name'] = `${appName}-messaging`
55
+ }
56
+ await mergeJSON(
57
+ 'xs-security.json',
58
+ join(__dirname, 'files', 'xs-security.json.hbs'),
59
+ projectDescriptor,
60
+ {
61
+ additions: [{
62
+ in: 'scopes',
63
+ where: [{ property: 'name', isEqualTo: '$XSAPPNAME.emcallback' }],
64
+ }, {
65
+ in: 'scopes',
66
+ where: [{ property: 'name', isEqualTo: '$XSAPPNAME.emmanagement' }],
67
+ }]
68
+ }
69
+ )
70
+ }
71
+
51
72
  if (hasHelm) {
52
73
  //in case facet is being added to the already exisiting charts folder
53
74
  let isIndependentCommand = false
@@ -1,7 +1,7 @@
1
1
  {
2
- "emname": "{{cap.appName}}-emname",
2
+ "emname": "{{appName}}-emname",
3
3
  "version": "1.1.0",
4
- "namespace": "default/sap.myapp/1",
4
+ "namespace": "default/{{appName}}/1",
5
5
  "options": {
6
6
  "management": true,
7
7
  "messagingrest": true,
@@ -10,7 +10,7 @@
10
10
  "rules": {
11
11
  "topicRules": {
12
12
  "publishFilter": [
13
- "${namespace}/sample"
13
+ "${namespace}/*"
14
14
  ],
15
15
  "subscribeFilter": [
16
16
  "*"
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  modules:
3
- - name: {{cap.appName}}-srv
4
- type: {{cap.language}}
5
- path: {{& cap.srvPath}}
3
+ - name: {{appName}}-srv
4
+ type: {{language}}
5
+ path: {{& srvPath}}
6
6
  requires:
7
- - name: {{cap.appName}}-messaging
7
+ - name: {{appName}}-messaging
8
8
 
9
9
  resources:
10
- - name: {{cap.appName}}-messaging
10
+ - name: {{appName}}-messaging
11
11
  type: org.cloudfoundry.managed-service
12
12
  parameters:
13
13
  service: enterprise-messaging
@@ -1,22 +1,22 @@
1
1
  {
2
- {{#cap.isNodejs}}
2
+ {{#isNodejs}}
3
3
  "dependencies": {
4
4
  "@sap/xb-msg-amqp-v100": "^0"
5
5
  },
6
6
  "cds": {
7
- {{/cap.isNodejs}}
7
+ {{/isNodejs}}
8
8
  "requires": {
9
- {{#cap.for}}
10
- "[{{cap.for}}]": {
11
- {{/cap.for}}
9
+ {{#profile}}
10
+ "[{{profile}}]": {
11
+ {{/profile}}
12
12
  "messaging": {
13
13
  "kind": "enterprise-messaging-shared"
14
14
  }
15
- {{#cap.for}}
15
+ {{#profile}}
16
16
  }
17
- {{/cap.for}}
17
+ {{/profile}}
18
18
  }
19
- {{#cap.isNodejs}}
19
+ {{#isNodejs}}
20
20
  }
21
- {{/cap.isNodejs}}
21
+ {{/isNodejs}}
22
22
  }
@@ -8,8 +8,7 @@ const { srvNode4, srvJava4, enterpriseMessaging } = require('../_merging/registr
8
8
  module.exports = class EnterpriseMessagingSharedTemplate extends require('../templateBase') {
9
9
 
10
10
  async canRun() {
11
- const projectDescriptor = await readProject(this.options)
12
- const { hasMta, hasHelm, isJava } = projectDescriptor.cap
11
+ const { hasMta, hasHelm, isJava } = await readProject(this.options)
13
12
  if (isJava) throw `'cds add enterprise-messaging-shared' is not available for Java yet`
14
13
  if (hasHelm && !hasMta) throw `'cds add enterprise-messaging-shared' is not available for Kyma yet`
15
14
  return true
@@ -21,8 +20,8 @@ module.exports = class EnterpriseMessagingSharedTemplate extends require('../tem
21
20
 
22
21
  async run() {
23
22
  const projectDescriptor = await readProject(this.options)
24
- const { configFile } = projectDescriptor.cap
25
- projectDescriptor.cap.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
23
+ const { configFile } = projectDescriptor
24
+ projectDescriptor.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
26
25
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
27
26
  await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), projectDescriptor)
28
27
  await this.runDependentMerging()
@@ -30,7 +29,7 @@ module.exports = class EnterpriseMessagingSharedTemplate extends require('../tem
30
29
 
31
30
  async runDependentMerging() {
32
31
  const projectDescriptor = await readProject(this.options)
33
- const { hasMta, isNodejs, srvPath } = projectDescriptor.cap
32
+ const { hasMta, isNodejs, srvPath } = projectDescriptor
34
33
 
35
34
  if (hasMta) {
36
35
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
@@ -1,20 +1,20 @@
1
1
  {
2
- {{#cap.isNodejs}}
2
+ {{#isNodejs}}
3
3
  "dependencies": {
4
- "@sap/cds-mtxs": "^1"
4
+ "@sap/cds-mtxs": "^1.9"
5
5
  },
6
6
  "cds": {
7
- {{/cap.isNodejs}}
7
+ {{/isNodejs}}
8
8
  "requires": {
9
- {{#cap.for}}
10
- "[{{cap.for}}]": {
11
- {{/cap.for}}
9
+ {{#profile}}
10
+ "[{{profile}}]": {
11
+ {{/profile}}
12
12
  "extensibility": true
13
- {{#cap.for}}
13
+ {{#profile}}
14
14
  }
15
- {{/cap.for}}
15
+ {{/profile}}
16
16
  }
17
- {{#cap.isNodejs}}
17
+ {{#isNodejs}}
18
18
  }
19
- {{/cap.isNodejs}}
19
+ {{/isNodejs}}
20
20
  }
@@ -3,13 +3,17 @@ const { exists } = cds.utils
3
3
  const { join } = require('path')
4
4
  const { readProject } = require('../../util/projectReader')
5
5
  const { mergeJSON } = require('../../util/merge')
6
- const { OPTION_MULTITENANCY } = require('../../constants')
6
+ const { MULTITENANCY } = require('../../constants').OPTIONS
7
7
 
8
8
  module.exports = class ExtensibilityTemplate extends require('../templateBase') {
9
9
 
10
10
 
11
11
  getDependencies() {
12
- return exists('pom.xml') ? [OPTION_MULTITENANCY] : [] // REVISIT: Remove this dependency
12
+ return exists('pom.xml') ? [MULTITENANCY] : [] // REVISIT: Remove this dependency
13
+ }
14
+
15
+ getRelatedFacets() {
16
+ return ['approuter']
13
17
  }
14
18
 
15
19
  static hasFacet(env) {
@@ -18,14 +22,14 @@ module.exports = class ExtensibilityTemplate extends require('../templateBase')
18
22
 
19
23
  async run() {
20
24
  const projectDescriptor = await readProject(this.options)
21
- const { configFile } = projectDescriptor.cap
25
+ const { configFile } = projectDescriptor
22
26
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), projectDescriptor)
23
27
  await this.runDependentMerging()
24
28
  }
25
29
 
26
30
  async runDependentMerging() {
27
31
  const projectDescriptor = await readProject(this.options)
28
- const { hasXsuaa, hasApprouter } = projectDescriptor.cap
32
+ const { hasXsuaa } = projectDescriptor
29
33
  if (hasXsuaa) {
30
34
  await mergeJSON(
31
35
  'xs-security.json',
@@ -45,10 +49,5 @@ module.exports = class ExtensibilityTemplate extends require('../templateBase')
45
49
  }
46
50
  )
47
51
  }
48
- if (hasApprouter) {
49
- const ApprouterTemplate = require(`../approuter`)
50
- const approuterTemplate = new ApprouterTemplate(this.generator)
51
- await approuterTemplate.runDependentMerging()
52
- }
53
52
  }
54
53
  }
@@ -1,19 +1,19 @@
1
1
  {
2
- {{#cap.isNodejs}}
2
+ {{#isNodejs}}
3
3
  "cds": {
4
- {{/cap.isNodejs}}
4
+ {{/isNodejs}}
5
5
  "requires": {
6
- {{#cap.for}}
7
- "[{{cap.for}}]": {
8
- {{/cap.for}}
6
+ {{#profile}}
7
+ "[{{profile}}]": {
8
+ {{/profile}}
9
9
  "messaging": {
10
10
  "kind": "file-based-messaging"
11
11
  }
12
- {{#cap.for}}
12
+ {{#profile}}
13
13
  }
14
- {{/cap.for}}
14
+ {{/profile}}
15
15
  }
16
- {{#cap.isNodejs}}
16
+ {{#isNodejs}}
17
17
  }
18
- {{/cap.isNodejs}}
18
+ {{/isNodejs}}
19
19
  }