@sap/cds-dk 7.4.0 → 7.5.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 (179) hide show
  1. package/bin/activate.js +1 -1
  2. package/bin/add.js +6 -4
  3. package/bin/build.js +10 -12
  4. package/bin/cds.js +4 -1
  5. package/bin/deploy/index.js +5 -2
  6. package/bin/eval.js +1 -1
  7. package/bin/extend.js +3 -3
  8. package/bin/login.js +2 -2
  9. package/bin/logout.js +1 -1
  10. package/bin/pull.js +1 -1
  11. package/bin/push.js +5 -5
  12. package/bin/subscribe.js +2 -2
  13. package/bin/unsubscribe.js +2 -2
  14. package/bin/upgrade.js +2 -2
  15. package/bin/version.js +2 -2
  16. package/bin/watch.js +1 -1
  17. package/lib/bind/bindingUtil.js +6 -3
  18. package/lib/bind/cfKeyProvider.js +1 -1
  19. package/lib/bind/userCdsrcJsonStorageProvider.js +1 -1
  20. package/lib/build/buildPlugin.js +6 -12
  21. package/lib/build/buildTaskEngine.js +24 -19
  22. package/lib/build/buildTaskFactory.js +27 -33
  23. package/lib/build/buildTaskProvider.js +1 -1
  24. package/lib/build/buildTaskProviderFactory.js +26 -41
  25. package/lib/build/constants.js +0 -1
  26. package/lib/build/index.js +3 -3
  27. package/lib/build/plugins.js +15 -15
  28. package/lib/build/provider/edmxBuildPlugin.js +6 -7
  29. package/lib/build/provider/fiori/index.js +8 -8
  30. package/lib/build/provider/hana/2migration.js +12 -16
  31. package/lib/build/provider/hana/index.js +5 -7
  32. package/lib/build/provider/hana/template/package.json +1 -1
  33. package/lib/build/provider/internalBuildPlugin.js +0 -8
  34. package/lib/build/provider/internalBuildTaskProvider.js +17 -21
  35. package/lib/build/provider/java/index.js +2 -1
  36. package/lib/build/provider/mtx-extension/index.js +8 -5
  37. package/lib/build/provider/mtx-sidecar/index.js +2 -1
  38. package/lib/build/provider/nodejs/index.js +64 -58
  39. package/lib/compile/openapi/csdl2openapi.js +29 -15
  40. package/lib/compile/openapi/index.js +6 -6
  41. package/lib/deploy/to-hana/hana.js +5 -3
  42. package/lib/env/schema.js +2 -3
  43. package/lib/index.js +68 -28
  44. package/lib/init/add.js +17 -0
  45. package/lib/init/constants.js +5 -3
  46. package/lib/init/index.js +39 -25
  47. package/lib/init/{util/merge.js → merge.js} +32 -20
  48. package/lib/init/{util/mvn.js → mvn.js} +5 -5
  49. package/lib/init/plugin.js +85 -0
  50. package/lib/init/projectReader.js +145 -0
  51. package/lib/init/registries/mta.js +151 -0
  52. package/lib/init/template/{kibana → application-logging}/files/mta.yaml.hbs +3 -3
  53. package/lib/init/template/application-logging/index.js +49 -0
  54. package/lib/init/template/approuter/files/mta.yaml.hbs +11 -11
  55. package/lib/init/template/approuter/files/xs-app.json.hbs +2 -2
  56. package/lib/init/template/approuter/index.js +36 -81
  57. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +3 -3
  58. package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +4 -4
  59. package/lib/init/template/cf-manifest/index.js +4 -4
  60. package/lib/init/template/connectivity/index.js +22 -35
  61. package/lib/init/template/data/index.js +3 -2
  62. package/lib/init/template/destination/files/values.yaml +9 -0
  63. package/lib/init/template/destination/index.js +15 -47
  64. package/lib/init/template/enterprise-messaging/index.js +26 -58
  65. package/lib/init/template/enterprise-messaging-shared/index.js +23 -39
  66. package/lib/init/template/extensibility/index.js +16 -30
  67. package/lib/init/template/file-based-messaging/index.js +7 -8
  68. package/lib/init/template/h2/index.js +4 -4
  69. package/lib/init/template/hana/files/mta.yaml.hbs +8 -8
  70. package/lib/init/template/hana/index.js +29 -115
  71. package/lib/init/template/helm/files/chart/templates/NOTES.txt +12 -0
  72. package/lib/init/template/helm/files/chart/templates/_deployment_helpers.tpl +82 -0
  73. package/lib/init/template/helm/files/chart/templates/_helpers.tpl +28 -0
  74. package/lib/init/template/helm/files/chart/values.root.schema.json +61 -0
  75. package/lib/init/template/helm/files/chart/values.schema.json +366 -0
  76. package/lib/init/template/helm/{subcharts → files}/web-application/Chart.yaml +1 -1
  77. package/lib/init/template/helm/{subcharts → files}/web-application/templates/_api.tpl +1 -1
  78. package/lib/init/template/helm/{subcharts → files}/web-application/values.yaml +1 -1
  79. package/lib/init/template/helm/index.js +84 -85
  80. package/lib/init/template/helm-unified-runtime/files/Chart.yaml.hbs +10 -0
  81. package/lib/init/template/helm-unified-runtime/files/values.yaml.hbs +26 -0
  82. package/lib/init/template/helm-unified-runtime/index.js +91 -0
  83. package/lib/init/template/helm-unified-runtime/lib/build.js +0 -0
  84. package/lib/init/template/helm-unified-runtime/package.json +4 -0
  85. package/lib/init/template/html5-repo/files/values.yaml.hbs +28 -0
  86. package/lib/init/template/html5-repo/index.js +23 -97
  87. package/lib/init/template/java/index.js +3 -3
  88. package/lib/init/template/lint/index.js +2 -2
  89. package/lib/init/template/liquibase/index.js +16 -0
  90. package/lib/init/template/local-messaging/index.js +7 -8
  91. package/lib/init/template/mta/index.js +7 -19
  92. package/lib/init/template/mtx/index.js +2 -2
  93. package/lib/init/template/multitenancy/index.js +38 -89
  94. package/lib/init/template/nodejs/index.js +5 -4
  95. package/lib/init/template/notebook/index.js +1 -1
  96. package/lib/init/template/notifications/index.js +16 -19
  97. package/lib/init/template/pipeline/index.js +1 -1
  98. package/lib/init/template/postgres/index.js +25 -31
  99. package/lib/init/template/redis-messaging/index.js +23 -27
  100. package/lib/init/template/sample/index.js +4 -4
  101. package/lib/init/template/samples/index.js +2 -2
  102. package/lib/init/template/sqlite/files/{package.json.hbs → package.json} +0 -2
  103. package/lib/init/template/sqlite/index.js +6 -10
  104. package/lib/init/template/tiny-sample/index.js +6 -6
  105. package/lib/init/template/toggles/index.js +7 -8
  106. package/lib/init/template/typer/index.js +6 -6
  107. package/lib/init/template/xsuaa/files/mta.yaml.hbs +3 -3
  108. package/lib/init/template/xsuaa/files/values.yaml.hbs +3 -3
  109. package/lib/init/template/xsuaa/index.js +27 -52
  110. package/lib/init/{util/template.js → template.js} +1 -1
  111. package/lib/{client → mtx}/activate.js +15 -11
  112. package/lib/{client → mtx}/auth_manager.js +5 -4
  113. package/lib/{client → mtx}/download_legacy.js +6 -4
  114. package/lib/{client → mtx}/extend.js +14 -9
  115. package/lib/{client → mtx}/index.js +1 -1
  116. package/lib/{client → mtx}/params.js +4 -1
  117. package/lib/{client → mtx}/pull.js +6 -4
  118. package/lib/{client → mtx}/push.js +11 -10
  119. package/lib/{client → mtx}/settings_manager.js +8 -6
  120. package/lib/{client → mtx}/tenant_action.js +9 -8
  121. package/lib/{client/helper/cf_helper.js → mtx/util/cf.js} +4 -3
  122. package/lib/{client/helper/dependency_helper.js → mtx/util/dependencies.js} +1 -0
  123. package/lib/mtx/util/errors.js +27 -0
  124. package/lib/mtx/util/legacy_ext.js +16 -0
  125. package/lib/{client/helper/url_helper.js → mtx/util/urls.js} +12 -1
  126. package/lib/util/fs.js +5 -1
  127. package/lib/util/pruneAxiosErrors.js +35 -18
  128. package/lib/util/write.js +1 -1
  129. package/npm-shrinkwrap.json +27 -27
  130. package/package.json +10 -1
  131. package/lib/client/base_command.js +0 -54
  132. package/lib/init/template/_merging/registry-mta.js +0 -304
  133. package/lib/init/template/helm/Model.d.ts +0 -53
  134. package/lib/init/template/kibana/files/package.json.hbs +0 -17
  135. package/lib/init/template/kibana/index.js +0 -54
  136. package/lib/init/template/templateBase.js +0 -100
  137. package/lib/init/util/md5.js +0 -86
  138. package/lib/init/util/projectReader.js +0 -94
  139. /package/lib/init/{util/indent.js → indent.js} +0 -0
  140. /package/lib/init/template/helm/{subcharts → files}/content-deployment/Chart.yaml +0 -0
  141. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/_helpers.tpl +0 -0
  142. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/job.yaml +0 -0
  143. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/secret.yaml +0 -0
  144. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/service-account.yaml +0 -0
  145. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/service-binding.yaml +0 -0
  146. /package/lib/init/template/helm/{subcharts → files}/content-deployment/values.schema.json +0 -0
  147. /package/lib/init/template/helm/{subcharts → files}/content-deployment/values.yaml +0 -0
  148. /package/lib/init/template/helm/{subcharts → files}/service-instance/Chart.yaml +0 -0
  149. /package/lib/init/template/helm/{subcharts → files}/service-instance/templates/_helpers.tpl +0 -0
  150. /package/lib/init/template/helm/{subcharts → files}/service-instance/templates/serviceinstance.yaml +0 -0
  151. /package/lib/init/template/helm/{subcharts → files}/service-instance/values.schema.json +0 -0
  152. /package/lib/init/template/helm/{subcharts → files}/service-instance/values.yaml +0 -0
  153. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/NOTES.txt +0 -0
  154. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/_helpers.tpl +0 -0
  155. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/api-rule.yaml +0 -0
  156. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/deployment.yaml +0 -0
  157. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/network-policy.yaml +0 -0
  158. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/pod-disruption-budget.yaml +0 -0
  159. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/rbac.yaml +0 -0
  160. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/secret.yaml +0 -0
  161. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/service-account.yaml +0 -0
  162. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/service-binding.yaml +0 -0
  163. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/service.yaml +0 -0
  164. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/virtual-service.yaml +0 -0
  165. /package/lib/init/template/helm/{subcharts → files}/web-application/values.schema.json +0 -0
  166. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/templates/NOTES.txt +0 -0
  167. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/templates/_deployment_helpers.tpl +0 -0
  168. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/templates/_helpers.tpl +0 -0
  169. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/values.root.schema.json +0 -0
  170. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/values.schema.json +0 -0
  171. /package/lib/init/template/postgres/files/{mta.yaml.hbs → mta.yml.hbs} +0 -0
  172. /package/lib/init/{util/xml.js → xml.js} +0 -0
  173. /package/lib/{client/helper/env_helper.js → mtx/util/env.js} +0 -0
  174. /package/lib/{client/helper/fs_helper.js → mtx/util/fs.js} +0 -0
  175. /package/lib/{client/helper → mtx/util}/logging.js +0 -0
  176. /package/lib/{client/helper → mtx/util}/question.js +0 -0
  177. /package/lib/{client/helper/string_helper.js → mtx/util/strings.js} +0 -0
  178. /package/lib/util/{cfUtil.js → cf.js} +0 -0
  179. /package/lib/util/{gitUtil.js → git.js} +0 -0
@@ -1,28 +1,10 @@
1
1
  const { join } = require('path');
2
2
  const cds = require('../../../cds')
3
- const { exists, rimraf } = cds.utils
4
- const { readProject } = require('../../util/projectReader');
5
- const { mergeYAML } = require('../../util/merge')
6
- const { parseMd5File, writeMd5File, copyAndTrack } = require('../../util/md5')
3
+ const { exists, rimraf, copy } = cds.utils
4
+ const { readProject } = require('../../projectReader');
5
+ const { merge } = require('../../merge')
7
6
 
8
- module.exports = class HelmTemplate extends require('../templateBase') {
9
-
10
- constructor(oldTrackingData = undefined, newTrackingData = {}) {
11
- super()
12
- this.oldTrackingData = oldTrackingData;
13
- this.newTrackingData = newTrackingData;
14
- }
15
-
16
- getRelatedFacets() {
17
- return ['hana', 'xsuaa', 'enterprise-messaging', 'enterprise-messaging-shared', 'destination' , 'multitenancy', 'extensibility', 'approuter', 'connectivity']
18
- }
19
-
20
- static hasFacet() {
21
- // REVISIT: this works, but could be semantically nicer with a 'shouldRunDependentMerging' or the like
22
- const { add } = cds.cli.options
23
- if (add.has('mta') && !add.has('helm')) return false
24
- return exists(join('chart', 'values.yaml'))
25
- }
7
+ module.exports = class HelmTemplate extends require('../../plugin') {
26
8
 
27
9
  async canRun() {
28
10
  if (cds.cli.options.force) {
@@ -32,76 +14,93 @@ module.exports = class HelmTemplate extends require('../templateBase') {
32
14
  return true
33
15
  }
34
16
 
35
- async addSubChart(subchart, force = false) {
36
- const subchartPath = join('chart', 'charts', subchart);
37
- const isInternal = !force && await this.isInternal();
38
- if(!exists(subchartPath) && !isInternal) {
39
- await copyAndTrack(
40
- join(__dirname, 'subcharts', subchart),
41
- subchartPath,
42
- this
43
- )
44
-
45
- return true;
46
- }
47
-
48
- return false;
17
+ static hasInProduction() {
18
+ const { add } = cds.cli.options
19
+ return exists(join('chart', 'charts', 'web-application')) && exists(join('chart', 'values.yaml') || add.has('helm'))
49
20
  }
50
21
 
51
- async isInternal() {
52
- return !exists(join('chart', 'charts', 'web-application')) || cds.cli.options['internal-unified-runtime-charts'];
53
- }
22
+ async run() {
23
+ const project = readProject()
24
+ await copy(join(__dirname, 'files', 'chart')).to('chart')
25
+ await merge(__dirname, 'files/Chart.yaml.hbs').into('chart/Chart.yaml', { with: project })
26
+ await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project })
27
+ await this._mergeDependency('web-application', 'srv')
54
28
 
55
- async addDependency(name, alias){
56
- const project = await readProject();
57
- const isInternal = await this.isInternal();
58
- await mergeYAML(
59
- join('chart', 'Chart.yaml'),
60
- {
61
- dependencies: [
62
- {
63
- name,
64
- alias,
65
- version: '>0.0.0',
66
- ...(isInternal) && { repository: 'https://int.repositories.cloud.sap/artifactory/virtual-unified-runtime-helm-dmz' }
67
- }
68
- ]
69
- },
70
- project,
71
- { additions: [{
72
- in: `dependencies`,
73
- where: [{
74
- property: 'alias',
75
- isEqualTo: alias
76
- }]
77
- }]}
78
- )
29
+ await copy(join(__dirname, 'files', 'web-application')).to('chart/charts/web-application')
79
30
  }
80
31
 
81
- async run() {
82
- const project = await readProject()
83
- const isInternal = cds.cli.options['internal-unified-runtime-charts'] !== undefined && cds.cli.options['internal-unified-runtime-charts'];
84
- this.oldTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'));
85
- await this.addSubChart('web-application', !isInternal);
86
- await copyAndTrack(
87
- join(__dirname, 'chart'),
88
- join('chart'),
89
- this
90
- )
32
+ async combine() {
33
+ const { hasDestination, hasEnterpriseMessaging, hasHana, hasMultitenancy, hasXsuaa, hasHtml5Repo, hasApprouter } = readProject()
34
+ let hasContentDeployment = false
91
35
 
92
- await mergeYAML(
93
- join('chart', 'Chart.yaml'),
94
- join(__dirname, 'files', 'Chart.yaml.hbs'),
95
- project
96
- )
36
+ if (!exists('chart/charts/service-instance') && (hasHtml5Repo || hasMultitenancy || hasDestination || hasEnterpriseMessaging || hasXsuaa || hasHana)) {
37
+ await copy(join(__dirname, 'files', 'service-instance')).to('chart/charts/service-instance')
38
+ }
39
+ if (hasApprouter) {
40
+ await this._mergeDependency('web-application', 'approuter')
41
+ }
97
42
 
98
- await this.addDependency('web-application', 'srv');
43
+ if (hasHtml5Repo) {
44
+ hasContentDeployment = true
45
+ await this._mergeDependency('service-instance', 'html5-apps-repo-host')
46
+ await this._mergeDependency('content-deployment', 'html5-apps-deployer')
99
47
 
100
- await mergeYAML(
101
- join('chart', 'values.yaml'),
102
- join(__dirname, 'files', 'values.yaml.hbs'),
103
- project
104
- )
105
- await writeMd5File(join('chart', '.cds-add-helm-files.md5'), this.newTrackingData);
48
+ if (hasApprouter) {
49
+ await this._mergeDependency('service-instance', 'html5-apps-repo-runtime')
50
+ await merge({
51
+ 'html5-apps-repo-runtime': {
52
+ serviceOfferingName: 'html5-apps-repo',
53
+ servicePlanName: 'app-runtime'
54
+ },
55
+ approuter: {
56
+ bindings: {
57
+ 'html5-apps-repo-runtime': { serviceInstanceName: 'html5-apps-repo-runtime' }
58
+ }
59
+ },
60
+ }).into('chart/values.yaml')
61
+ }
62
+ }
63
+ if (hasMultitenancy) {
64
+ await this._mergeDependency('web-application', 'sidecar')
65
+ await this._mergeDependency('service-instance', 'saas-registry')
66
+ }
67
+ if (hasDestination) {
68
+ await this._mergeDependency('service-instance', 'destination')
69
+ }
70
+ if (hasEnterpriseMessaging) {
71
+ await this._mergeDependency('service-instance', 'event-mesh')
72
+ }
73
+ if (hasXsuaa) {
74
+ await this._mergeDependency('service-instance', 'xsuaa')
75
+ }
76
+ if (hasHana) {
77
+ if (hasMultitenancy) {
78
+ await this._mergeDependency('service-instance', 'service-manager')
79
+ } else {
80
+ hasContentDeployment = true
81
+ await this._mergeDependency('service-instance', 'hana')
82
+ await this._mergeDependency('content-deployment', 'hana-deployer')
83
+ }
84
+ }
85
+ if(!exists('chart/charts/content-deployment') && hasContentDeployment) {
86
+ await copy(join(__dirname, 'files', 'content-deployment')).to('chart/charts/content-deployment')
87
+ }
88
+ }
89
+
90
+ async _mergeDependency(name, alias) {
91
+ const project = readProject()
92
+ await merge({
93
+ dependencies: [{
94
+ name,
95
+ alias,
96
+ version: '>0.0.0'
97
+ }]
98
+ }).into('chart/Chart.yaml', {
99
+ project,
100
+ additions: [{
101
+ in: 'dependencies',
102
+ where: { alias }
103
+ }]
104
+ })
106
105
  }
107
106
  }
@@ -0,0 +1,10 @@
1
+ ---
2
+ #
3
+ # This file is generated by "cds add helm"
4
+ apiVersion: v2
5
+ name: {{appName}}
6
+ description: {{appDescription}}
7
+ type: application
8
+ version: {{appVersion}}
9
+ appVersion: {{appVersion}}
10
+
@@ -0,0 +1,26 @@
1
+ ---
2
+ global:
3
+ domain: null
4
+ imagePullSecret: {}
5
+ srv:
6
+ bindings: {}
7
+ image:
8
+ repository: <your-container-registry>/{{appName}}-srv
9
+ tag: latest
10
+ {{#isJava}}
11
+ env:
12
+ SPRING_PROFILES_ACTIVE: cloud
13
+ {{/isJava}}
14
+ resources:
15
+ limits:
16
+ ephemeral-storage: 1G
17
+ memory: {{#isJava}}1G{{/isJava}}{{^isJava}}500M{{/isJava}}
18
+ requests:
19
+ ephemeral-storage: 1G
20
+ cpu: {{#isJava}}1000m{{/isJava}}{{^isJava}}500m{{/isJava}}
21
+ memory: {{#isJava}}1G{{/isJava}}{{^isJava}}500M{{/isJava}}
22
+ health:
23
+ liveness:
24
+ path: /
25
+ readiness:
26
+ path: /
@@ -0,0 +1,91 @@
1
+ const cds = require('../../..')
2
+ const { copy, rimraf, exists } = cds.utils
3
+ const { join } = require('path')
4
+
5
+ // cds.build?.register('helm-unified-runtime', {
6
+ // impl: '@cap-js-community/helm-unified-runtime/lib/build.js'
7
+ // })
8
+
9
+ const { merge, readProject } = cds.add ?? {}
10
+
11
+ module.exports = class HelmUnifiedRuntimeTemplate extends cds.add.Plugin {
12
+
13
+ async canRun() {
14
+ if (cds.cli.options.force) {
15
+ await rimraf(join('chart'))
16
+ return true
17
+ }
18
+ return true
19
+ }
20
+
21
+ static hasInProduction() {
22
+ return exists(join('chart', 'values.yaml')) && !exists(join('chart', 'charts', 'web-application')) || cds.cli.options.add.has('helm-unified-runtime')
23
+ }
24
+
25
+ async run() {
26
+ const project = readProject()
27
+
28
+ await merge(__dirname, 'files/Chart.yaml.hbs').into('chart/Chart.yaml', { with: project })
29
+ await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project })
30
+
31
+ await copy(join(__dirname, 'files', 'templates')).to('chart/templates') // REVISIT: Move to build
32
+ await copy(join(__dirname, 'files', 'values.schema.json')).to('chart/values.schema.json') // REVISIT: Move to build (if possible)
33
+ await copy(join(__dirname, 'files', 'values.root.schema.json')).to('chart/values.root.schema.json') // REVISIT: Move to build (if possible)
34
+
35
+ await this._mergeDependency('web-application', 'srv')
36
+ }
37
+
38
+ async combine() {
39
+ const { hasDestination, hasEnterpriseMessaging, hasHana, hasMultitenancy, hasXsuaa, hasHtml5Repo, hasApprouter } = readProject()
40
+
41
+ if (hasApprouter) {
42
+ await this._mergeDependency('web-application', 'approuter')
43
+ }
44
+ if (hasHtml5Repo) {
45
+ await this._mergeDependency('service-instance', 'html5-apps-repo-host')
46
+ await this._mergeDependency('content-deployment', 'html5-apps-deployer')
47
+ if (hasApprouter) {
48
+ await this._mergeDependency('service-instance', 'html5-apps-repo-runtime')
49
+ }
50
+ }
51
+ if (hasMultitenancy) {
52
+ await this._mergeDependency('web-application', 'sidecar')
53
+ await this._mergeDependency('service-instance', 'saas-registry')
54
+ }
55
+ if (hasDestination) {
56
+ await this._mergeDependency('service-instance', 'destination')
57
+ }
58
+ if (hasEnterpriseMessaging) {
59
+ await this._mergeDependency('service-instance', 'event-mesh')
60
+ }
61
+ if (hasXsuaa) {
62
+ await this._mergeDependency('service-instance', 'xsuaa')
63
+ }
64
+ if (hasHana) {
65
+ if (hasMultitenancy) {
66
+ await this._mergeDependency('service-instance', 'service-manager')
67
+ } else {
68
+ await this._mergeDependency('service-instance', 'hana')
69
+ await this._mergeDependency('content-deployment', 'hana-deployer')
70
+ }
71
+ }
72
+ }
73
+
74
+ async _mergeDependency(name, alias) {
75
+ const project = readProject()
76
+ await merge({
77
+ dependencies: [{
78
+ name,
79
+ alias,
80
+ version: '>0.0.0',
81
+ repository: 'https://int.repositories.cloud.sap/artifactory/virtual-unified-runtime-helm-dmz'
82
+ }]
83
+ }).into('chart/Chart.yaml', {
84
+ with: project,
85
+ additions: [{
86
+ in: 'dependencies',
87
+ where: { alias }
88
+ }]}
89
+ )
90
+ }
91
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "@cap-js-community/helm-unified-runtime",
3
+ "version": "1.0.0"
4
+ }
@@ -0,0 +1,28 @@
1
+ ---
2
+ html5-apps-repo-host:
3
+ serviceOfferingName: html5-apps-repo
4
+ servicePlanName: app-host
5
+ html5-apps-deployer:
6
+ env:
7
+ SAP_CLOUD_SERVICE: null
8
+ image:
9
+ repository: "<your-container-registry>/{{appName}}-html5-deployer"
10
+ tag: latest
11
+ bindings:
12
+ xsuaa:
13
+ serviceInstanceName: xsuaa
14
+ destination:
15
+ serviceInstanceName: destination
16
+ html5-apps-repo:
17
+ serviceInstanceName: html5-apps-repo-host
18
+ resources:
19
+ limits:
20
+ cpu: 2000m
21
+ memory: 1G
22
+ requests:
23
+ cpu: 1000m
24
+ memory: 1G
25
+ backendDestinations: {}
26
+ destination:
27
+ parameters:
28
+ HTML5Runtime_enabled: true
@@ -1,117 +1,43 @@
1
1
  const { join } = require('path')
2
- const { exists } = require('../../../cds').utils
3
- const { readProject } = require('../../util/projectReader')
4
- const { mergeYAML } = require('../../util/merge')
5
- const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5')
6
- const { DESTINATION } = require('../../constants').OPTIONS
2
+ const { exists, copy } = require('../../../cds').utils
3
+ const { readProject } = require('../../projectReader')
4
+ const { merge } = require('../../merge')
7
5
 
8
- module.exports = class Html5RepoTemplate extends require('../templateBase') {
6
+ module.exports = class Html5RepoTemplate extends require('../../plugin') {
9
7
 
10
-
11
- getDependencies() {
12
- return [DESTINATION]
8
+ requires() {
9
+ return ['destination']
13
10
  }
14
11
 
15
12
  async canRun() {
16
- const project = await readProject()
17
- const { hasMta, hasHelm } = project
18
- if (!hasHelm && hasMta) {
13
+ const project = readProject()
14
+ const { hasMta, hasHelm, hasHelmUnifiedRuntime } = project
15
+ if (!(hasHelm || hasHelmUnifiedRuntime) && hasMta) {
19
16
  throw `'cds add html5-repo' is not available for Cloud Foundry yet`
20
17
  }
21
18
  return true
22
19
  }
23
20
 
24
- static hasFacet() {
21
+ static hasInProduction() {
25
22
  // REVISIT: Should be detectable without helm charts
26
23
  return exists(join('chart', 'templates', 'html5-apps-deployer-configmap.yaml'))
27
24
  }
28
25
 
29
- async runDependentMerging(context = {}) {
30
- const { appName, hasHelm, hasApprouter} = await readProject()
31
-
32
- if (hasHelm) {
33
- //in case facet is being added to the already exisiting charts folder
34
- let isIndependentCommand = false
35
- if(Object.keys(context).length == 0){
36
- isIndependentCommand = true
37
- context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'))
38
- }
39
- await mergeYAML(
40
- join('chart', 'values.yaml'),
41
- {
42
- 'html5-apps-repo-host': {
43
- serviceOfferingName: 'html5-apps-repo',
44
- servicePlanName: 'app-host'
45
- },
46
- 'html5-apps-deployer': {
47
- env: {
48
- SAP_CLOUD_SERVICE: null
49
- },
50
- envFrom: [
51
- {
52
- configMapRef: {
53
- name: "{{ .Release.Name }}-html5-apps-deployer-configmap"
54
- }
55
- }
56
- ],
57
- image: {
58
- repository: `<your-container-registry>/${appName}-html5-deployer`,
59
- tag: 'latest'
60
- },
61
- bindings: {
62
- xsuaa: { serviceInstanceName: 'xsuaa' },
63
- destination: { serviceInstanceName: 'destination' },
64
- 'html5-apps-repo': { serviceInstanceName: 'html5-apps-repo-host' }
65
- },
66
- resources: {
67
- limits: { cpu: '2000m', memory: '1G' },
68
- requests: { cpu: '1000m', memory: '1G' }
26
+ async combine() {
27
+ const project = readProject()
28
+ const { hasHelm, hasHelmUnifiedRuntime } = project
29
+ if (hasHelm || hasHelmUnifiedRuntime) {
30
+ await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project })
31
+ await merge({
32
+ 'html5-apps-deployer': {
33
+ envFrom: [{
34
+ configMapRef: {
35
+ name: '{{ .Release.Name }}-html5-apps-deployer-configmap'
69
36
  }
70
- },
71
- backendDestinations: {},
72
- destination: {
73
- parameters: {
74
- HTML5Runtime_enabled: true
75
- }
76
- }
37
+ }]
77
38
  }
78
- )
79
-
80
- // copy content deployment chart if it is not present
81
- const HelmTemplate = require(`../helm`);
82
- const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
83
-
84
- if (hasApprouter) {
85
- await mergeYAML(
86
- join('chart', 'values.yaml'),
87
- {
88
- 'html5-apps-repo-runtime': {
89
- serviceOfferingName: 'html5-apps-repo',
90
- servicePlanName: 'app-runtime'
91
- },
92
- approuter: {
93
- bindings: {
94
- 'html5-apps-repo-runtime': { serviceInstanceName: 'html5-apps-repo-runtime' }
95
- }
96
- },
97
- }
98
- )
99
- await helmTemplate.addDependency('service-instance', 'html5-apps-repo-runtime');
100
- }
101
-
102
- isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('content-deployment');
103
-
104
- // add dependency entry in chart.yaml
105
- await helmTemplate.addDependency('content-deployment', 'html5-apps-deployer');
106
-
107
- // copy service-instance chart
108
- isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
109
-
110
- // add dependency entry in chart.yaml
111
- await helmTemplate.addDependency('service-instance', 'html5-apps-repo-host');
112
-
113
- await copyAndTrack(join(__dirname, 'files', 'html5-apps-deployer-configmap.yaml'), join('chart', 'templates', 'html5-apps-deployer-configmap.yaml'), context)
114
- if(isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
39
+ }).into('chart/values.yaml')
40
+ await copy(join(__dirname, 'files', 'html5-apps-deployer-configmap.yaml')).to('chart', 'templates', 'html5-apps-deployer-configmap.yaml')
115
41
  }
116
42
  }
117
43
  }
@@ -2,13 +2,13 @@ const os = require('os')
2
2
  const cds = require('../../../cds')
3
3
  const { exists, copy, rimraf, fs, path } = cds.utils, { join } = path
4
4
  const cmd = require('../../../util/command')
5
- const mvn = require('../../util/mvn')
5
+ const mvn = require('../../mvn')
6
6
  const term = require('../../../util/term')
7
7
  const { URLS, OPTIONS: { NODEJS, JAVA }, COMMAND_ADD } = require('../../constants')
8
8
 
9
- module.exports = class JavaTemplate extends require('../templateBase') {
9
+ module.exports = class JavaTemplate extends require('../../plugin') {
10
10
 
11
- static hasFacet() {
11
+ static hasInProduction() {
12
12
  return exists('pom.xml') || cds.cli.options?.add?.has(JAVA)
13
13
  }
14
14
 
@@ -5,7 +5,7 @@ const term = require("../../../util/term");
5
5
  const checks = require("../../../lint/checks");
6
6
  const io = require("../../../lint/io");
7
7
  const readline = require("readline");
8
- const { renderAndCopy } = require('../../util/template')
8
+ const { renderAndCopy } = require('../../template')
9
9
  const { LINT_DEV, LINT_GLOBAL } = require("../../constants").OPTIONS;
10
10
  const { getConfigPath, getFileExtensions } = require("@sap/eslint-plugin-cds/lib/api");
11
11
  const cds = require("../../../cds");
@@ -17,7 +17,7 @@ const VSCODE_FILE_ASSOCIATIONS = {
17
17
  "csv": [ "csv", "csv (semicolon)", "tsv", "tab" ]
18
18
  }
19
19
 
20
- module.exports = class LintTemplate extends require('../templateBase') {
20
+ module.exports = class LintTemplate extends require('../../plugin') {
21
21
  constructor() {
22
22
  super();
23
23
  this.customPath = path.join(cds.root, ".eslint");
@@ -0,0 +1,16 @@
1
+ const mvn = require('../../mvn')
2
+ const { readProject } = require('../../projectReader')
3
+
4
+ module.exports = class LiquibaseTemplate extends require('../../plugin') {
5
+
6
+ async canRun() {
7
+ const { isNodejs } = readProject()
8
+ if (isNodejs) throw `'cds add liquibase' is not available for Node.js yet`
9
+ return true
10
+ }
11
+
12
+ async run() {
13
+ const { isJava } = readProject()
14
+ if (isJava) await mvn.add('liquibase')
15
+ }
16
+ }
@@ -1,25 +1,24 @@
1
- const { join } = require('path')
2
1
  const cds = require('../../../cds')
3
2
  const { read } = cds.utils
4
- const { readProject } = require('../../util/projectReader')
5
- const { mergeJSON } = require('../../util/merge')
3
+ const { readProject } = require('../../projectReader')
4
+ const { merge } = require('../../merge')
6
5
 
7
- module.exports = class LocalMessagingTemplate extends require('../templateBase') {
6
+ module.exports = class LocalMessagingTemplate extends require('../../plugin') {
8
7
 
9
8
  async canRun() {
10
- const { isJava } = await readProject()
9
+ const { isJava } = readProject()
11
10
  if (isJava) throw `'cds add local-messaging' is not available for Java yet`
12
11
  return true
13
12
  }
14
13
 
15
- static hasFacet(env) {
14
+ static hasInProduction(env) {
16
15
  return env.requires?.messaging?.kind === 'local-messaging'
17
16
  }
18
17
 
19
18
  async run() {
20
- const project = await readProject()
19
+ const project = readProject()
21
20
  const { configFile } = project
22
21
  project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
23
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
22
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
24
23
  }
25
24
  }
@@ -2,33 +2,21 @@ const { join } = require('path')
2
2
  const cds = require('../../../cds')
3
3
  const { exists } = cds.utils
4
4
  const { copyRenderedYAML } = require('../../../util/fs')
5
- const { readProject } = require('../../util/projectReader')
6
- const { mergeJSON, sort } = require('../../util/merge')
7
- const {
8
- APPROUTER, XSUAA, MULTITENANCY, EXTENSIBILITY,
9
- MTA, HELM,
10
- HANA, POSTGRES,
11
- ENTERPRISE_MESSAGING, ENTERPRISE_MESSAGING_SHARED, REDIS_MESSAGING,
12
- CONNECTIVITY, DESTINATION, NOTIFICATIONS
13
- } = require('../../constants').OPTIONS
14
- module.exports = class MtaTemplate extends require('../templateBase') {
5
+ const { readProject } = require('../../projectReader')
6
+ const { merge, sort } = require('../../merge')
15
7
 
16
- static hasFacet() {
17
- const { options } = cds.cli
18
- if (!options?.add.has(MTA) && options?.add.has(HELM)) return false
19
- return exists('mta.yaml')
20
- }
8
+ module.exports = class MtaTemplate extends require('../../plugin') {
21
9
 
22
- getRelatedFacets() {
23
- return [APPROUTER, XSUAA, MULTITENANCY, HANA, POSTGRES, EXTENSIBILITY, ENTERPRISE_MESSAGING, ENTERPRISE_MESSAGING_SHARED, REDIS_MESSAGING, CONNECTIVITY, DESTINATION, NOTIFICATIONS]
10
+ static hasInProduction() {
11
+ return exists('mta.yaml')
24
12
  }
25
13
 
26
14
  async run() {
27
- const project = await readProject()
15
+ const project = readProject()
28
16
  if (!exists('mta.yaml')) {
29
17
  await copyRenderedYAML(join(__dirname, 'files', 'mta.yaml.hbs'), 'mta.yaml', project)
30
18
  }
31
- await mergeJSON('package.json', join(__dirname, 'files', 'package.json'))
19
+ await merge(__dirname, 'files/package.json').into('package.json')
32
20
  await sort('package.json', 'devDependencies')
33
21
  }
34
22
  }
@@ -1,8 +1,8 @@
1
1
  const { MULTITENANCY, TOGGLES, EXTENSIBILITY } = require('../../constants').OPTIONS
2
2
 
3
- module.exports = class MtxTemplate extends require('../templateBase') {
3
+ module.exports = class MtxTemplate extends require('../../plugin') {
4
4
 
5
- getDependencies() {
5
+ requires() {
6
6
  return [MULTITENANCY, TOGGLES, EXTENSIBILITY]
7
7
  }
8
8
  }