@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,35 +1,29 @@
1
1
  const { join } = require('path')
2
2
  const cds = require('../../../cds')
3
- const { read, write } = cds.utils
4
- const { APPROUTER, HANA, KIBANA } = require('../../constants').OPTIONS
5
- const mvn = require('../../util/mvn')
6
- const { readProject } = require('../../util/projectReader')
7
- const { mergeJSON, mergeYAML, sort } = require('../../util/merge')
8
- const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5')
3
+ const { read, write, copy } = cds.utils
4
+ const mvn = require('../../mvn')
5
+ const { readProject } = require('../../projectReader')
6
+ const { merge, sort } = require('../../merge')
9
7
  const { copyRenderedJSON } = require('../../../util/fs')
10
8
  const {
11
- srvNode4, srvJava4, // Server
9
+ srv4, // Server
12
10
  mtxSidecar4, // Additional Modules
13
11
  saasRegistry, serviceManager, xsuaa, // BTP Services
14
12
  srvApi4, providedMtxApiSidecar4, requiredMtxSidecarApi4 // APIs
15
- } = require('../_merging/registry-mta')
13
+ } = require('../../registries/mta')
16
14
 
17
- module.exports = class MultitenancyTemplate extends require('../templateBase') {
15
+ module.exports = class MultitenancyTemplate extends require('../../plugin') {
18
16
 
19
- static hasFacet(env) {
17
+ static hasInProduction(env) {
20
18
  const { options } = cds.cli.options
21
19
  // REVISIT: Check if this can be simplified
22
20
  return options?.add?.has('mtx') || options?.add?.has('multitenancy') || !!env.requires?.multitenancy || false
23
21
  }
24
22
 
25
- getRelatedFacets() {
26
- return [APPROUTER, HANA, KIBANA]
27
- }
28
-
29
23
  async run() {
30
- const project = await readProject()
24
+ const project = readProject()
31
25
  const { isNodejs, isJava, configFile } = project
32
- await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), project)
26
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
33
27
  if (isJava) {
34
28
  const packageJson = await read('package.json')
35
29
  packageJson.workspaces = ['mtx/sidecar']
@@ -40,12 +34,12 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
40
34
  await copyRenderedJSON(join(__dirname, 'files', 'package.sidecar.json.hbs'), join('mtx', 'sidecar', 'package.json'), project)
41
35
  }
42
36
 
43
- async runDependentMerging(context = {}) {
44
- const project = await readProject()
45
- const { isNodejs, isJava, hasMta, hasHelm, hasXsuaa, hasHana, srvPath } = project
37
+ async combine() {
38
+ const project = readProject()
39
+ const { isNodejs, isJava, hasMta, hasHelm, hasHelmUnifiedRuntime, hasXsuaa, hasHana, srvPath } = project
46
40
 
47
41
  if (hasMta) {
48
- const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
42
+ const srv = srv4(srvPath)
49
43
  const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar')
50
44
  const modules = [srv, mtxSidecar]
51
45
  const services = [saasRegistry]
@@ -80,91 +74,46 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
80
74
  }
81
75
 
82
76
  const templateMtaPath = join(__dirname, 'files', 'mta.yaml.hbs')
83
- const mergingRules = { additions, overwrites, relationships }
84
- await mergeYAML('mta.yaml', templateMtaPath, project, mergingRules)
77
+ await merge(templateMtaPath).into('mta.yaml', { with: project, additions, overwrites, relationships })
85
78
  }
86
79
 
87
- // REVISIT: Why not just pass a Boolean from run() to indicate the merging isn't run transitively?
88
- let isIndependentCommand = false
89
- if (hasHelm) {
90
- // in case facet is being added to the already existing charts folder
91
- if (Object.keys(context).length == 0) {
92
- isIndependentCommand = true
93
- context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'))
94
- }
95
-
96
- await mergeYAML(join('chart', 'values.yaml'), join(__dirname, 'files', 'values.yaml.hbs'), project)
80
+ if (hasHelm || hasHelmUnifiedRuntime) {
81
+ await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project })
97
82
 
98
83
  const envFromObject = {
99
- envFrom: [
100
- {
101
- configMapRef: {
102
- name: "{{ .Release.Name }}-mtxs-configmap"
103
- }
84
+ envFrom: [{
85
+ configMapRef: {
86
+ name: "{{ .Release.Name }}-mtxs-configmap"
104
87
  }
105
- ]
88
+ }]
106
89
  }
107
90
 
108
- await mergeYAML(
109
- join('chart', 'values.yaml'),
110
- {
111
- ...(isNodejs) && { sidecar: envFromObject },
112
- ...(isJava) && { srv: envFromObject },
113
- "saas-registry": {
114
- parametersFrom: [
115
- {
116
- secretKeyRef: {
117
- name: "{{ .Release.Name }}-saas-registry-secret",
118
- key: "parameters"
119
- }
91
+ await merge({
92
+ ...(isNodejs) && { sidecar: envFromObject },
93
+ ...(isJava) && { srv: envFromObject },
94
+ 'saas-registry': {
95
+ parametersFrom: [
96
+ {
97
+ secretKeyRef: {
98
+ name: "{{ .Release.Name }}-saas-registry-secret",
99
+ key: "parameters"
120
100
  }
121
- ]
122
- }
123
- },
124
- project
125
- )
126
-
127
- // REVISIT: Don't reference other templates except for the safe `runDependentMerging` -> low coupling, high cohesion
128
- const HelmTemplate = require(`../helm`);
129
- const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
130
-
131
- await helmTemplate.addDependency('web-application', 'sidecar');
132
-
133
- // copy service-instance chart
134
- isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
135
-
136
- // add dependency entry in chart.yaml
137
- await helmTemplate.addDependency('service-instance', 'saas-registry');
138
- await helmTemplate.addDependency('service-instance', 'service-manager');
139
-
140
- // add mtxs configmap
141
- await copyAndTrack(
142
- join(__dirname, 'files', `mtxs-configmap-${isJava ? 'java' : 'nodejs'}.yaml`),
143
- join('chart', 'templates', 'mtxs-configmap.yaml'),
144
- context,
145
- )
146
-
147
- // add saas registry secret
148
- await copyAndTrack(
149
- join(__dirname, 'files', 'saas-registry-secret.yaml'),
150
- join('chart', 'templates', 'saas-registry-secret.yaml'),
151
- context
152
- );
101
+ }
102
+ ]
103
+ }}).into('chart/values.yaml', { with: project })
153
104
 
154
- if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
105
+ await copy(join(__dirname, 'files', `mtxs-configmap-${isJava ? 'java' : 'nodejs'}.yaml`)).to('chart', 'templates', 'mtxs-configmap.yaml') // REVISIT: Move to build task
106
+ await copy(join(__dirname, 'files', 'saas-registry-secret.yaml')).to('chart', 'templates', 'saas-registry-secret.yaml') // REVISIT: Move to build task
155
107
  }
156
108
 
157
109
  if (hasXsuaa) {
158
- await mergeJSON('xs-security.json',join(__dirname, 'files', 'xs-security.json.hbs'), project, {
110
+ await merge(__dirname, 'files/xs-security.json.hbs').into('xs-security.json', {
111
+ project,
159
112
  additions: [{
160
113
  in: 'scopes',
161
- where: [{ property: 'name', isEqualTo: '$XSAPPNAME.mtcallback' }],
114
+ where: { name: '$XSAPPNAME.mtcallback' },
162
115
  }]
163
116
  })
164
- if (hasHelm) {
165
- await mergeYAML(join('chart', 'values.yaml'), { xsuaa: { parameters: { 'tenant-mode': 'shared' }}}, null, { forceOverwrite: true })
166
- if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
167
- }
168
117
  }
169
118
  }
170
119
  }
@@ -1,13 +1,14 @@
1
1
  const { join } = require('path')
2
2
  const cds = require('../../../cds')
3
3
  const { exists, mkdirp, path } = cds.utils
4
+ const { env4 } = require('../../projectReader')
4
5
  const { URLS, OPTIONS: { NODEJS, JAVA }, COMMAND_ADD } = require('../../constants')
5
6
  const term = require('../../../util/term')
6
- const { renderAndCopy } = require('../../util/template')
7
+ const { renderAndCopy } = require('../../template')
7
8
 
8
- module.exports = class NodejsTemplate extends require('../templateBase') {
9
+ module.exports = class NodejsTemplate extends require('../../plugin') {
9
10
 
10
- static hasFacet() {
11
+ static hasInProduction() {
11
12
  return !exists('pom.xml') && !cds.cli.options?.add?.has(JAVA)
12
13
  }
13
14
 
@@ -22,7 +23,7 @@ module.exports = class NodejsTemplate extends require('../templateBase') {
22
23
  }
23
24
 
24
25
  async run() {
25
- const { db, srv, app } = (await this.getEnv()).folders
26
+ const { db, srv, app } = env4('production').folders
26
27
  await renderAndCopy(join(__dirname, 'files'), cds.root, { projectName: path.basename(cds.root) })
27
28
  await Promise.all([db, srv, app].map(p => mkdirp(p)))
28
29
  }
@@ -1,6 +1,6 @@
1
1
  const term = require('../../../util/term');
2
2
 
3
- module.exports = class NotebookTemplate extends require('../templateBase') {
3
+ module.exports = class NotebookTemplate extends require('../../plugin') {
4
4
 
5
5
 
6
6
  async canRun() {
@@ -1,18 +1,21 @@
1
- const { join } = require('path')
2
- const { readProject } = require('../../util/projectReader')
3
- const { mergeJSON, mergeYAML } = require('../../util/merge')
1
+ const { readProject } = require('../../projectReader')
2
+ const { merge } = require('../../merge')
4
3
  const { DESTINATION } = require('../../constants').OPTIONS
5
4
 
6
- const { notificationTypesDeployer } = require('../_merging/registry-mta')
5
+ const { notificationTypesDeployer } = require('../../registries/mta')
7
6
 
8
- module.exports = class NotificationsTemplate extends require('../templateBase') {
7
+ module.exports = class NotificationsTemplate extends require('../../plugin') {
9
8
 
10
- static hasFacet(env) {
11
- return !!env.requires?.notifications;
9
+ requires() {
10
+ return [DESTINATION]
11
+ }
12
+
13
+ static hasInProduction(env) {
14
+ return !!env.requires?.notifications
12
15
  }
13
16
 
14
17
  async canRun() {
15
- const project = await readProject()
18
+ const project = readProject()
16
19
  const { isJava } = project
17
20
  if (isJava) {
18
21
  throw `'cds add notifications' is not available for Java yet`
@@ -20,24 +23,18 @@ module.exports = class NotificationsTemplate extends require('../templateBase')
20
23
  return true
21
24
  }
22
25
 
23
- getDependencies() {
24
- return [DESTINATION]
25
- }
26
-
27
26
  async run() {
28
- const project = await readProject()
27
+ const project = readProject()
29
28
  const { configFile } = project
30
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
29
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { project })
31
30
  }
32
31
 
33
- async runDependentMerging() {
34
- const project = await readProject()
32
+ async combine() {
33
+ const project = readProject()
35
34
  const { hasMta } = project
36
35
 
37
36
  if (hasMta) {
38
- await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, {
39
- additions: [notificationTypesDeployer]
40
- })
37
+ await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { project, additions: [notificationTypesDeployer] })
41
38
  }
42
39
  }
43
40
  }
@@ -3,7 +3,7 @@ const cds = require('../../../cds')
3
3
  const { exists, copy } = cds.utils
4
4
  const { URLS } = require('../../constants')
5
5
 
6
- module.exports = class PipelineTemplate extends require('../templateBase') {
6
+ module.exports = class PipelineTemplate extends require('../../plugin') {
7
7
 
8
8
  async canRun() {
9
9
  if (cds.cli.options.force) {
@@ -1,53 +1,47 @@
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, mergeYAML } = require('../../util/merge')
6
- const mvn = require('../../util/mvn')
7
- const { srvNode4, srvJava4, postgres, postgresDeployer } = require('../_merging/registry-mta')
3
+ const { readProject } = require('../../projectReader')
4
+ const { merge } = require('../../merge')
5
+ const mvn = require('../../mvn')
6
+ const { srv4, postgres, postgresDeployer } = require('../../registries/mta')
8
7
 
9
- module.exports = class PostgresTemplate extends require('../templateBase') {
8
+ module.exports = class PostgresTemplate extends require('../../plugin') {
10
9
 
11
10
  async canRun() {
12
- const { hasMta, hasHelm } = await readProject(this.options)
13
- if (hasHelm && !hasMta) throw `'cds add postgres' is not available for Kyma yet`
11
+ const { hasMta, hasHelm, hasHelmUnifiedRuntime } = readProject()
12
+ if ((hasHelm || hasHelmUnifiedRuntime) && !hasMta) throw `'cds add postgres' is not available for Kyma yet`
14
13
  return true
15
14
  }
16
15
 
17
- static hasFacet(env) {
16
+ static hasInProduction(env) {
18
17
  return env.requires?.db?.kind === 'postgres'
19
18
  }
20
19
 
21
20
  async run() {
22
- const project = await readProject(this.options)
21
+ const project = readProject()
23
22
  const { configFile, isJava } = project
24
23
  project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
25
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
24
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { project })
26
25
  if (isJava) await mvn.add('postgresql')
27
- await this.runDependentMerging()
28
26
  }
29
27
 
30
- async runDependentMerging() {
31
- const project = await readProject(this.options)
32
- const { hasMta, isNodejs, srvPath } = project
28
+ async combine() {
29
+ const project = readProject()
30
+ const { hasMta, srvPath } = project
33
31
 
34
32
  if (hasMta) {
35
- const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
36
- await mergeYAML(
37
- 'mta.yaml',
38
- join(__dirname, 'files', 'mta.yaml.hbs'),
39
- project,
40
- {
41
- additions: [srv, postgres, postgresDeployer],
42
- relationships: [{
43
- insert: [postgres, 'name'],
44
- into: [srv, 'requires', 'name']
45
- }, {
46
- insert: [postgres, 'name'],
47
- into: [postgresDeployer, 'requires', 'name']
48
- }]
49
- }
50
- )
33
+ const srv = srv4(srvPath)
34
+ await merge(__dirname, 'files/mta.yml.hbs').into('mta.yaml', {
35
+ project,
36
+ additions: [srv, postgres, postgresDeployer],
37
+ relationships: [{
38
+ insert: [postgres, 'name'],
39
+ into: [srv, 'requires', 'name']
40
+ }, {
41
+ insert: [postgres, 'name'],
42
+ into: [postgresDeployer, 'requires', 'name']
43
+ }]
44
+ })
51
45
  }
52
46
  }
53
47
  }
@@ -1,48 +1,44 @@
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, mergeYAML } = require('../../util/merge')
6
- const { srvNode4, srvJava4, redis } = require('../_merging/registry-mta')
3
+ const { readProject } = require('../../projectReader')
4
+ const { merge } = require('../../merge')
5
+ const { srv4, redis } = require('../../registries/mta')
7
6
 
8
- module.exports = class RedisMessagingTemplate extends require('../templateBase') {
7
+ module.exports = class RedisMessagingTemplate extends require('../../plugin') {
9
8
 
10
9
  async canRun() {
11
- const { hasMta, hasHelm, isJava } = await readProject()
12
- if (isJava) throw `'cds add redis-messaging' is not available for Java yet`
13
- if (hasHelm && !hasMta) throw `'cds add redis-messaging' is not available for Kyma yet`
10
+ const { hasMta, hasHelm, hasHelmUnifiedRuntime, isJava } = readProject()
11
+ const onlyHelm = !hasMta && (hasHelmUnifiedRuntime || hasHelm)
12
+ if (isJava) throw `'cds add redis-messaging' is not available for Java yet`
13
+ if (onlyHelm) throw `'cds add redis-messaging' is not available for Kyma yet`
14
14
  return true
15
15
  }
16
16
 
17
- static hasFacet(env) {
17
+ static hasInProduction(env) {
18
18
  return env.requires?.messaging?.kind === 'redis-messaging'
19
19
  }
20
20
 
21
21
  async run() {
22
- const project = await readProject()
22
+ const project = readProject()
23
23
  const { configFile } = project
24
24
  project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
25
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
25
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { project })
26
26
  }
27
27
 
28
- async runDependentMerging() {
29
- const project = await readProject()
30
- const { hasMta, isNodejs, srvPath } = project
28
+ async combine() {
29
+ const project = readProject()
30
+ const { hasMta, srvPath } = project
31
31
 
32
32
  if (hasMta) {
33
- const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
34
- await mergeYAML(
35
- 'mta.yaml',
36
- join(__dirname, 'files', 'mta.yaml.hbs'),
37
- project,
38
- {
39
- additions: [srv, redis],
40
- relationships: [{
41
- insert: [redis, 'name'],
42
- into: [srv, 'requires', 'name']
43
- }]
44
- }
45
- )
33
+ const srv = srv4(srvPath)
34
+ await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', {
35
+ project,
36
+ additions: [srv, redis],
37
+ relationships: [{
38
+ insert: [redis, 'name'],
39
+ into: [srv, 'requires', 'name']
40
+ }]
41
+ })
46
42
  }
47
43
  }
48
44
  }
@@ -1,17 +1,17 @@
1
1
  const { join } = require('path')
2
2
  const cds = require('../../../cds'), { exists, copy } = cds.utils
3
- const { readProject } = require('../../util/projectReader')
3
+ const { env4, readProject } = require('../../projectReader')
4
4
 
5
- module.exports = class SampleTemplate extends require('../templateBase') {
5
+ module.exports = class SampleTemplate extends require('../../plugin') {
6
6
 
7
7
  async canRun() {
8
- const { isJava } = await readProject()
8
+ const { isJava } = readProject()
9
9
  if (isJava) throw `'cds add sample' is not available for Java yet`
10
10
  return true
11
11
  }
12
12
 
13
13
  async run() {
14
- const { db, srv, app } = (await this.getEnv()).folders
14
+ const { db, srv, app } = env4('production').folders
15
15
  const language = exists('pom.xml') ? 'java' : 'nodejs'
16
16
  await Promise.all([
17
17
  copy(join(__dirname, 'files', 'db')).to(db),
@@ -1,8 +1,8 @@
1
1
  const term = require('../../../util/term')
2
2
  const { TINY_SAMPLE } = require('../../constants').OPTIONS
3
3
 
4
- module.exports = class SamplesTemplate extends require('../templateBase') {
5
- getDependencies() {
4
+ module.exports = class SamplesTemplate extends require('../../plugin') {
5
+ requires() {
6
6
  console.warn(term.warn(`'cds add samples' is deprecated and will be removed in future versions. Please use 'cds add tiny-sample' instead.\n`))
7
7
  return [TINY_SAMPLE]
8
8
  }
@@ -1,7 +1,5 @@
1
1
  {
2
- {{#isNodejs}}
3
2
  "devDependencies": {
4
3
  "@cap-js/sqlite": "^1"
5
4
  }
6
- {{/isNodejs}}
7
5
  }
@@ -1,18 +1,14 @@
1
- const { join } = require('path')
2
- const cds = require('../../../cds')
3
- const { read } = cds.utils
4
- const mvn = require('../../util/mvn')
5
- const { readProject } = require('../../util/projectReader')
6
- const { mergeJSON } = require('../../util/merge')
1
+ const mvn = require('../../mvn')
2
+ const { readProject } = require('../../projectReader')
3
+ const { merge } = require('../../merge')
7
4
 
8
- module.exports = class SQLiteTemplate extends require('../templateBase') {
5
+ module.exports = class SQLiteTemplate extends require('../../plugin') {
9
6
 
10
7
  async run() {
11
- const project = await readProject()
8
+ const project = readProject()
12
9
  const { isNodejs, isJava, configFile } = project
13
10
  if (isNodejs) {
14
- project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
15
- await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), project)
11
+ await merge(__dirname, 'files/package.json').into(configFile)
16
12
  } else if (isJava) {
17
13
  await mvn.add('sqlite')
18
14
  }
@@ -1,21 +1,21 @@
1
1
  const { join } = require('path')
2
2
  const cds = require('../../../../lib/cds'), { copy } = cds.utils
3
- const { renderAndCopy } = require('../../util/template')
4
- const mvn = require('../../util/mvn')
5
- const { readProject } = require('../../util/projectReader')
3
+ const { renderAndCopy } = require('../../template')
4
+ const mvn = require('../../mvn')
5
+ const { env4, readProject } = require('../../projectReader')
6
6
  const { JAVA } = require('../../constants')
7
7
 
8
- module.exports = class TinySampleTemplate extends require('../templateBase') {
8
+ module.exports = class TinySampleTemplate extends require('../../plugin') {
9
9
 
10
10
  async run() {
11
- const { isJava } = await readProject()
11
+ const { isJava } = readProject()
12
12
  if (isJava) {
13
13
  if (!cds.cli.options.add.has(JAVA)) {
14
14
  await mvn.execMvn(mvn.getAddSamplesCmdArgs())
15
15
  await mvn.execMvn(mvn.getAddTestsCmdArgs())
16
16
  }
17
17
  } else {
18
- const { db, srv } = (await this.getEnv()).folders
18
+ const { db, srv } = env4('production').folders
19
19
  await Promise.all([
20
20
  copy(join(__dirname, 'files', 'nodejs', 'db')).to(db),
21
21
  renderAndCopy(join(__dirname, 'files', 'nodejs', 'srv'), srv, { dbFolder: db.replace(/[\\/]+$/, '') })
@@ -1,17 +1,16 @@
1
- const { join } = require('path')
2
- const { readProject } = require('../../util/projectReader')
3
- const { mergeJSON, sort } = require('../../util/merge')
1
+ const { readProject } = require('../../projectReader')
2
+ const { merge, sort } = require('../../merge')
4
3
 
5
- module.exports = class TogglesTemplate extends require('../templateBase') {
4
+ module.exports = class TogglesTemplate extends require('../../plugin') {
6
5
 
7
- static hasFacet(env) {
6
+ static hasInProduction(env) {
8
7
  return !!env.requires?.toggles
9
8
  }
10
9
 
11
10
  async run() {
12
- const project = await readProject()
13
- const { isNodejs , configFile} = project
14
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
11
+ const project = readProject()
12
+ const { isNodejs, configFile } = project
13
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
15
14
  if (isNodejs) await sort('package.json', 'dependencies')
16
15
  }
17
16
  }
@@ -1,13 +1,13 @@
1
1
  const { join } = require('path')
2
- const { readProject } = require('../../util/projectReader')
3
- const { mergeJSON, mergeGitignore } = require('../../util/merge')
2
+ const { readProject } = require('../../projectReader')
3
+ const { merge, mergeGitignore } = require('../../merge')
4
4
  const { warn, secondary } = require('../../../util/term')
5
5
  const { TYPER } = require('../../constants').OPTIONS
6
6
  const { exists, read } = require('../../../cds').utils
7
7
 
8
- module.exports = class TyperTemplate extends require('../templateBase') {
8
+ module.exports = class TyperTemplate extends require('../../plugin') {
9
9
  async canRun() {
10
- const { isJava } = await readProject()
10
+ const { isJava } = readProject()
11
11
  if (isJava) {
12
12
  console.warn(warn(`This appears to be a Java project. 'cds add ${TYPER}' is intended to be used in Node.js projects. Proceeding anyway.\n`))
13
13
  }
@@ -23,11 +23,11 @@ module.exports = class TyperTemplate extends require('../templateBase') {
23
23
  source.compilerOptions.paths["#cds-models/*"][0] += '/index.ts'
24
24
  target = 'tsconfig.json'
25
25
  }
26
- await mergeJSON('package.json', template('package.json'))
26
+ await merge(template('package.json')).into('package.json')
27
27
  await mergeGitignore('.gitignore', template('gitignore'))
28
28
  console.log(secondary(` > Adding '@cds-models' to .gitignore to ignore generated types`)) // REVISIT: other facets are silent wrt. what they change
29
29
  try {
30
- await mergeJSON(target, source)
30
+ await merge(source).into(target)
31
31
  } catch (e) {
32
32
  throw e instanceof SyntaxError
33
33
  ? `SyntaxError in ${target}. This could indicate a JSON file with comments, which is not supported at this time. Remove all comments from ${target} and rerun or add the following entries manually:\n${JSON.stringify(source, null, 2)}`
@@ -6,13 +6,13 @@ modules:
6
6
  requires:
7
7
  - name: {{appName}}-auth
8
8
 
9
- {{#isMultitenant}}
9
+ {{#hasMultitenancy}}
10
10
  - name: {{appName}}-mtx
11
11
  type: nodejs
12
12
  path: {{#isNodejs}}gen/{{/isNodejs}}mtx/sidecar
13
13
  requires:
14
14
  - name: {{appName}}-auth
15
- {{/isMultitenant}}
15
+ {{/hasMultitenancy}}
16
16
 
17
17
  resources:
18
18
  - name: {{appName}}-auth
@@ -23,4 +23,4 @@ resources:
23
23
  path: ./xs-security.json
24
24
  config:
25
25
  xsappname: {{appName}}-${org}-${space}
26
- tenant-mode: {{#isMultitenant}}shared{{/isMultitenant}}{{^isMultitenant}}dedicated{{/isMultitenant}}
26
+ tenant-mode: {{#hasMultitenancy}}shared{{/hasMultitenancy}}{{^hasMultitenancy}}dedicated{{/hasMultitenancy}}
@@ -1,10 +1,10 @@
1
1
  ---
2
- {{#isMultitenant}}
2
+ {{#hasMultitenancy}}
3
3
  sidecar:
4
4
  bindings:
5
5
  auth:
6
6
  serviceInstanceName: xsuaa
7
- {{/isMultitenant}}
7
+ {{/hasMultitenancy}}
8
8
  {{#hasApprouter}}
9
9
  approuter:
10
10
  bindings:
@@ -20,7 +20,7 @@ xsuaa:
20
20
  servicePlanName: application
21
21
  parameters:
22
22
  xsappname: {{appName}}
23
- tenant-mode: {{#isMultitenant}}shared{{/isMultitenant}}{{^isMultitenant}}dedicated{{/isMultitenant}}
23
+ tenant-mode: {{#hasMultitenancy}}shared{{/hasMultitenancy}}{{^hasMultitenancy}}dedicated{{/hasMultitenancy}}
24
24
  {{#hasApprouter}}
25
25
  oauth2-configuration:
26
26
  redirect-uris: