@sap/cds-dk 7.4.1 → 7.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/bin/activate.js +1 -1
  2. package/bin/add.js +6 -4
  3. package/bin/build.js +4 -6
  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 +2 -2
  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 +2 -1
  18. package/lib/bind/cfKeyProvider.js +2 -2
  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 +5 -4
  37. package/lib/build/provider/mtx-sidecar/index.js +2 -1
  38. package/lib/build/provider/nodejs/index.js +6 -5
  39. package/lib/compile/openapi/csdl2openapi.js +28 -14
  40. package/lib/compile/openapi/index.js +6 -6
  41. package/lib/deploy/to-hana/hana.js +2 -2
  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 +3 -1
  117. package/lib/{client → mtx}/pull.js +6 -4
  118. package/lib/{client → mtx}/push.js +10 -9
  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/axios.js +84 -0
  127. package/lib/util/fs.js +5 -1
  128. package/lib/util/write.js +1 -1
  129. package/npm-shrinkwrap.json +363 -157
  130. package/package.json +1 -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/util/pruneAxiosErrors.js +0 -39
  140. /package/lib/init/{util/indent.js → indent.js} +0 -0
  141. /package/lib/init/template/helm/{subcharts → files}/content-deployment/Chart.yaml +0 -0
  142. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/_helpers.tpl +0 -0
  143. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/job.yaml +0 -0
  144. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/secret.yaml +0 -0
  145. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/service-account.yaml +0 -0
  146. /package/lib/init/template/helm/{subcharts → files}/content-deployment/templates/service-binding.yaml +0 -0
  147. /package/lib/init/template/helm/{subcharts → files}/content-deployment/values.schema.json +0 -0
  148. /package/lib/init/template/helm/{subcharts → files}/content-deployment/values.yaml +0 -0
  149. /package/lib/init/template/helm/{subcharts → files}/service-instance/Chart.yaml +0 -0
  150. /package/lib/init/template/helm/{subcharts → files}/service-instance/templates/_helpers.tpl +0 -0
  151. /package/lib/init/template/helm/{subcharts → files}/service-instance/templates/serviceinstance.yaml +0 -0
  152. /package/lib/init/template/helm/{subcharts → files}/service-instance/values.schema.json +0 -0
  153. /package/lib/init/template/helm/{subcharts → files}/service-instance/values.yaml +0 -0
  154. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/NOTES.txt +0 -0
  155. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/_helpers.tpl +0 -0
  156. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/api-rule.yaml +0 -0
  157. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/deployment.yaml +0 -0
  158. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/network-policy.yaml +0 -0
  159. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/pod-disruption-budget.yaml +0 -0
  160. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/rbac.yaml +0 -0
  161. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/secret.yaml +0 -0
  162. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/service-account.yaml +0 -0
  163. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/service-binding.yaml +0 -0
  164. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/service.yaml +0 -0
  165. /package/lib/init/template/helm/{subcharts → files}/web-application/templates/virtual-service.yaml +0 -0
  166. /package/lib/init/template/helm/{subcharts → files}/web-application/values.schema.json +0 -0
  167. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/templates/NOTES.txt +0 -0
  168. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/templates/_deployment_helpers.tpl +0 -0
  169. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/templates/_helpers.tpl +0 -0
  170. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/values.root.schema.json +0 -0
  171. /package/lib/init/template/{helm/chart → helm-unified-runtime/files}/values.schema.json +0 -0
  172. /package/lib/init/template/postgres/files/{mta.yaml.hbs → mta.yml.hbs} +0 -0
  173. /package/lib/init/{util/xml.js → xml.js} +0 -0
  174. /package/lib/{client/helper/env_helper.js → mtx/util/env.js} +0 -0
  175. /package/lib/{client/helper/fs_helper.js → mtx/util/fs.js} +0 -0
  176. /package/lib/{client/helper → mtx/util}/logging.js +0 -0
  177. /package/lib/{client/helper → mtx/util}/question.js +0 -0
  178. /package/lib/{client/helper/string_helper.js → mtx/util/strings.js} +0 -0
  179. /package/lib/util/{cfUtil.js → cf.js} +0 -0
  180. /package/lib/util/{gitUtil.js → git.js} +0 -0
@@ -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:
@@ -1,87 +1,62 @@
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 { parseMd5File, writeMd5File } = require('../../util/md5')
7
- const { srvNode4, srvJava4, xsuaa, mtxSidecar4 } = require('../_merging/registry-mta')
3
+ const term = require('../../../util/term')
4
+ const { readProject } = require('../../projectReader')
5
+ const { merge } = require('../../merge')
6
+ const { srv4, xsuaa, mtxSidecar4 } = require('../../registries/mta')
8
7
 
9
- module.exports = class XsuaaTemplate extends require('../templateBase') {
8
+ module.exports = class XsuaaTemplate extends require('../../plugin') {
10
9
 
11
- static hasFacet(env) {
10
+ static hasInProduction(env) {
12
11
  return env.requires?.auth?.kind === 'xsuaa'
13
12
  }
14
13
 
15
- getRelatedFacets() {
16
- return ['multitenancy', 'extensibility', 'enterprise-messaging']
17
- }
18
-
19
14
  async run() {
20
- const project = await readProject()
15
+ const project = readProject()
21
16
  const { configFile } = project
22
17
  project.shortcut = !(await read(configFile)).cds?.requires?.auth?.kind
23
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project, { forceOverwrite: true })
18
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { project, forceOverwrite: true })
24
19
  }
25
20
 
26
- async runDependentMerging( context = {}) {
27
- const project = await readProject()
28
- const { isMultitenant, hasMta, hasHelm, isJava, srvPath } = project
21
+ async combine() {
22
+ const project = readProject()
23
+ const { hasMultitenancy, hasMta, hasHelm, hasHelmUnifiedRuntime, isJava, srvPath } = project
29
24
 
30
25
  const cds = require('../../../../lib')
31
26
  const xsSecurity = await (async () => { try {
32
27
  const models = await cds.load(cds.env.folders.srv)
33
28
  return cds.compile.to.xsuaa(models)
34
- } catch (error) { /* ignore */ }
35
- })() || { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
36
- const mergingSemantics = { additions: xsSecurity.scopes.map(scope => ({
37
- in: 'scopes',
38
- where: [{
39
- property: 'name',
40
- isEqualTo: scope.name
41
- }],
42
- }))}
43
- await mergeJSON('xs-security.json', xsSecurity, project, mergingSemantics)
29
+ } catch (error) { /* ignore */ }})() ?? { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
30
+
31
+ const additions = xsSecurity.scopes.map(scope => ({ in: 'scopes', where: { name: scope.name } }))
32
+ await merge(xsSecurity).into('xs-security.json', { project, additions })
44
33
 
45
34
  if (hasMta) {
46
- const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
35
+ const srv = srv4(srvPath)
47
36
  const additions = [srv, xsuaa]
48
37
  const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar')
49
- if (isMultitenant && isJava) additions.push(mtxSidecar)
38
+ if (hasMultitenancy && isJava) additions.push(mtxSidecar)
50
39
 
51
40
  const relationships = [{
52
41
  insert: [xsuaa, 'name'],
53
42
  into: [srv, 'requires', 'name']
54
43
  }]
55
- if (isMultitenant) relationships.push({
44
+ if (hasMultitenancy) relationships.push({
56
45
  insert: [xsuaa, 'name'],
57
46
  into: [mtxSidecar, 'requires', 'name']
58
47
  })
59
-
60
- await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, { additions, relationships })
48
+ await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { project, additions, relationships })
61
49
  }
62
50
 
63
- if (hasHelm) {
64
- //in case facet is being added to the already exisiting charts folder
65
- let isIndependentCommand = false;
66
- if(Object.keys(context).length == 0){
67
- isIndependentCommand = true;
68
- context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'));
69
- }
70
-
71
- // copy service-instance chart
72
- const HelmTemplate = require(`../helm`);
73
- const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
74
- isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
75
-
76
- // add dependency entry in chart.yaml
77
- await helmTemplate.addDependency('service-instance', 'xsuaa');
51
+ if (hasHelm || hasHelmUnifiedRuntime) {
52
+ await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project })
53
+ }
54
+ }
78
55
 
79
- await mergeYAML(
80
- join('chart', 'values.yaml'),
81
- join(__dirname, 'files', 'values.yaml.hbs'),
82
- project
83
- )
84
- if(isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
56
+ finalize() {
57
+ const { hasUI, hasApprouter } = readProject()
58
+ if (hasUI && !hasApprouter) {
59
+ console.log(`\nAlso run ${term.bold('cds add approuter --for production')} to route and authenticate the paths accessed via the UI.`)
85
60
  }
86
61
  }
87
62
  }
@@ -1,5 +1,5 @@
1
1
  const Mustache = require('mustache')
2
- const cds = require('../../cds')
2
+ const cds = require('../cds')
3
3
  const { copy, read, write, exists, readdir, path, isdir } = cds.utils
4
4
 
5
5
  async function renderAndCopy(from, into, replacements, overwrite = cds.cli.options.force) {
@@ -3,12 +3,16 @@ const path = require('path');
3
3
  const axios = require('axios');
4
4
 
5
5
  const cds = require('../cds');
6
- const DEBUG = cds.debug('cli');
7
- const { collectFileContent, collectFiles, toUnixPath } = require('./helper/fs_helper');
8
- const { getMessage } = require('./helper/logging');
9
-
10
6
  const AuthManager = require('./auth_manager');
11
- const BaseCommand = require('./base_command');
7
+
8
+ require('../util/axios').pruneErrors().setReqTimeout();
9
+ const { collectFileContent, collectFiles, toUnixPath } = require('./util/fs');
10
+ const { getMessage } = require('./util/logging');
11
+ const { handleHttpError } = require('./util/errors');
12
+ const { concatUrls } = require('./util/urls');
13
+ const { checkProject, getMtxApiUrl } = require('./util/legacy_ext');
14
+
15
+ const DEBUG = cds.debug('cli');
12
16
 
13
17
  const COMMAND_URL_SUFFIX = 'asyncActivate';
14
18
  const COMMAND_URL_SUFFIX_SYNC = 'activate';
@@ -37,7 +41,7 @@ async function checkFinished(jobId, statusUrl, params, finisher) {
37
41
  }
38
42
  }
39
43
 
40
- module.exports = class Activate extends BaseCommand {
44
+ module.exports = class Activate {
41
45
 
42
46
  static get COMMAND_URL_SUFFIX() { return COMMAND_URL_SUFFIX; }
43
47
  static get COMMAND_URL_SUFFIX_SYNC() { return COMMAND_URL_SUFFIX_SYNC; }
@@ -57,7 +61,7 @@ module.exports = class Activate extends BaseCommand {
57
61
  console.log('Activating extension located at', params.get('projectFolder'), 'to URL', params.get('appUrl'));
58
62
  }
59
63
 
60
- if (!await this.checkProject(params.get('projectFolder'))) {
64
+ if (!await checkProject(params.get('projectFolder'))) {
61
65
  throw params.get('projectFolder') + ' is not a valid extension project';
62
66
  }
63
67
 
@@ -67,7 +71,7 @@ module.exports = class Activate extends BaseCommand {
67
71
  await this.runCustomFileUpload(params);
68
72
  }
69
73
  } catch (error) {
70
- this.handleHttpError(error, params, { command: 'activate' });
74
+ handleHttpError(error, params, { command: 'activate' });
71
75
  }
72
76
  }
73
77
 
@@ -163,7 +167,7 @@ module.exports = class Activate extends BaseCommand {
163
167
  console.log('Activating extension...');
164
168
 
165
169
  const urlSuffix = isSync ? this.COMMAND_URL_SUFFIX_SYNC : this.COMMAND_URL_SUFFIX;
166
- activationUrl = this.getMtxApiUrl(params.get('appUrl'), urlSuffix);
170
+ activationUrl = getMtxApiUrl(params.get('appUrl'), urlSuffix);
167
171
  const requestOptions = Object.assign({
168
172
  headers: {}
169
173
  }, params.get('reqAuth'));
@@ -192,7 +196,7 @@ module.exports = class Activate extends BaseCommand {
192
196
  DEBUG?.(`Job ID: ${jobId}`);
193
197
 
194
198
  return new Promise((resolve, reject) => {
195
- const statusUrl = this.concatUrls(params.get('appUrl'), statusPath);
199
+ const statusUrl = concatUrls(params.get('appUrl'), statusPath);
196
200
  const finisher = {
197
201
  resolve,
198
202
  reject,
@@ -218,7 +222,7 @@ module.exports = class Activate extends BaseCommand {
218
222
  });
219
223
  });
220
224
 
221
- const customFileUrl = this.getMtxApiUrl(params.get('appUrl'), this.UPDATE_CUSTOM_FILE_URL_SUFFIX);
225
+ const customFileUrl = getMtxApiUrl(params.get('appUrl'), this.UPDATE_CUSTOM_FILE_URL_SUFFIX);
222
226
  const requestOptions = Object.assign({
223
227
  headers: {},
224
228
  }, params.get('reqAuth'));
@@ -1,12 +1,13 @@
1
1
  const axios = require('axios');
2
2
 
3
- require('../util/pruneAxiosErrors');
4
-
5
3
  const cds = require('../cds');
6
- const DEBUG = cds.debug('cli');
7
4
  const { SettingsManager } = require('./settings_manager');
8
5
  const { ParamCollection } = require('./params');
9
- const { getMessage } = require('./helper/logging');
6
+
7
+ require('../util/axios').pruneErrors().setReqTimeout();
8
+ const { getMessage } = require('./util/logging');
9
+
10
+ const DEBUG = cds.debug('cli');
10
11
 
11
12
  function addTokenInfo(params, authData) {
12
13
  params.set('token', authData.access_token);