@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,18 +1,14 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
3
  const cds = require('../cds')
4
- const { LOG_MODULE_NAMES, OUTPUT_MODE_FILESYSTEM, DEFAULT_SRC_FOLDER } = require('./constants')
4
+ const { OUTPUT_MODE_FILESYSTEM, DEFAULT_SRC_FOLDER } = require('./constants')
5
5
  const InternalBuildTaskProvider = require('./provider/internalBuildTaskProvider')
6
6
  const BuildTaskProvider = require('./buildTaskProvider')
7
7
  const { BuildError } = require('./util')
8
- const BuildPlugin = require('./buildPlugin')
8
+ const DEBUG = cds.debug('cli|build')
9
9
 
10
10
  class BuildTaskProviderFactory {
11
11
  constructor(options = {}) {
12
- // REVISIT: Logger is never passed to BuildTaskProviderFactory except for tests
13
- // -> tests shouldn't pollute library coding
14
- // see cds-dk/test/bin/eval.test.js for a non-invasive solution (intercepting console.log)
15
- options.logger = options.logger || cds.log(LOG_MODULE_NAMES)
16
12
  options.outputMode = options.outputMode || OUTPUT_MODE_FILESYSTEM
17
13
  if (options.clean === undefined) {
18
14
  options.clean = true
@@ -20,9 +16,6 @@ class BuildTaskProviderFactory {
20
16
  this._buildOptions = options
21
17
  this._context = { options, tasks: [] } // resolved tasks
22
18
  }
23
- get logger() {
24
- return this.options.logger
25
- }
26
19
  get options() {
27
20
  return this._context.options
28
21
  }
@@ -47,7 +40,7 @@ class BuildTaskProviderFactory {
47
40
  }
48
41
  const provider = this._getProvider(task)
49
42
  if (provider instanceof DefaultBuildTaskProvider) {
50
- this.logger._debug && this.logger.debug(`No provider found for build task '${task.use}', using default provider`)
43
+ DEBUG?.(`No provider found for build task '${task.use}', using default provider`)
51
44
  }
52
45
  return this._applyTaskDefaults(provider, [task])
53
46
  }))
@@ -62,7 +55,7 @@ class BuildTaskProviderFactory {
62
55
  // apply defaults
63
56
  const newTasks = tasks.filter(task => !existingTasks.includes(task))
64
57
  await this._applyTaskDefaults(provider, newTasks)
65
- this.logger._debug && this.logger.debug(`Build task provider ${provider.constructor.name} returned build tasks ${JSON.stringify(newTasks)}`)
58
+ DEBUG?.(`Build task provider ${provider.constructor.name} returned build tasks ${JSON.stringify(newTasks)}`)
66
59
  }
67
60
  }
68
61
  return tasks
@@ -74,19 +67,18 @@ class BuildTaskProviderFactory {
74
67
  * @param {*} task
75
68
  */
76
69
  createPlugin(task) {
77
- const BuildPluginClass = this.getPluginClass(task)
70
+ const BuildPlugin = this.getPlugin(task)
78
71
  const resolvedTask = this._resolveTask(task)
79
- this.logger._debug && this.logger.debug(`loaded build plugin [${resolvedTask.use}]`)
72
+ DEBUG?.(`loaded build plugin [${resolvedTask.use}]`)
80
73
 
81
- const plugin = new BuildPluginClass()
74
+ const plugin = new BuildPlugin()
82
75
  if (!(plugin instanceof BuildPlugin)) {
83
76
  throw new Error(`Invalid Build plugin type ${task.for}`)
84
77
  }
85
78
  plugin._task = resolvedTask
86
- plugin._logger = this.logger
87
79
  plugin._context = this.context
88
80
  this.context.tasks.push(resolvedTask)
89
- this.logger._debug && this.logger.debug(`created build plugin [${resolvedTask.use}]`)
81
+ DEBUG?.(`created build plugin [${resolvedTask.use}]`)
90
82
  return plugin
91
83
  }
92
84
 
@@ -96,12 +88,12 @@ class BuildTaskProviderFactory {
96
88
  * 'use' defines the fully qualified module name of custom build plugins implementations.
97
89
  * @param {object} task
98
90
  */
99
- getPluginClass(task) {
91
+ getPlugin(task) {
100
92
  const provider = this._getProvider(task)
101
93
  try {
102
- return provider.getPluginClass(task)
94
+ return provider.getPlugin(task)
103
95
  } catch (e) {
104
- this.logger.error(`Provider failed to load build plugin class - provider: ${provider.constructor.name}, task: ${task.for || task.use} :\n` + e)
96
+ console.error(`Provider failed to load build plugin class - provider: ${provider.constructor.name}, task: ${task.for || task.use} :\n` + e)
105
97
  throw e
106
98
  }
107
99
  }
@@ -139,7 +131,7 @@ class BuildTaskProviderFactory {
139
131
  try {
140
132
  return provider.providesTask(key)
141
133
  } catch (e) {
142
- this.logger.error(`Build task provider ${provider.constructor.name} returned an error:\n` + e)
134
+ console.error(`Build task provider ${provider.constructor.name} returned an error:\n` + e)
143
135
  throw e
144
136
  }
145
137
  })
@@ -160,9 +152,9 @@ class BuildTaskProviderFactory {
160
152
  _loadProviders() {
161
153
  // DefaultBuildTaskProvider must be last entry
162
154
  return [
163
- new InternalBuildTaskProvider(this.logger),
164
- new PluginBuildTaskProvider(this.logger),
165
- new DefaultBuildTaskProvider(this.logger)
155
+ new InternalBuildTaskProvider(),
156
+ new PluginBuildTaskProvider(),
157
+ new DefaultBuildTaskProvider()
166
158
  ]
167
159
  }
168
160
  }
@@ -172,16 +164,15 @@ class BuildTaskProviderFactory {
172
164
  * Has to be the last entry in the providers list.
173
165
  */
174
166
  class DefaultBuildTaskProvider extends BuildTaskProvider {
175
- constructor(logger) {
167
+ constructor() {
176
168
  super()
177
- this._logger = logger
178
169
  }
179
170
 
180
171
  providesTask(key) {
181
172
  return !!key.use
182
173
  }
183
174
 
184
- getPluginClass(task) {
175
+ getPlugin(task) {
185
176
  try {
186
177
  return require(require.resolve(task.use, { paths: [cds.root] }))
187
178
  } catch (e) {
@@ -194,10 +185,9 @@ class DefaultBuildTaskProvider extends BuildTaskProvider {
194
185
  * Default provider implementation handling fully qualified custom build task declarations.
195
186
  */
196
187
  class PluginBuildTaskProvider extends BuildTaskProvider {
197
- constructor(logger) {
188
+ constructor() {
198
189
  super()
199
- this._logger = logger
200
- this._plugins = require('./plugins').getPlugins()
190
+ this._plugins = require('./plugins').plugins
201
191
  }
202
192
 
203
193
  get plugins() {
@@ -208,22 +198,17 @@ class PluginBuildTaskProvider extends BuildTaskProvider {
208
198
  return this.plugins.has(key.for)
209
199
  }
210
200
 
211
- getPluginClass(task) {
212
- return this.plugins.get(task.for).class
201
+ getPlugin(task) {
202
+ return this.plugins.get(task.for)
213
203
  }
214
204
 
215
205
  async lookupTasks(tasks, dependencies) {
216
206
  if (!dependencies) {
217
- this.plugins.forEach(plugin => {
218
- if (plugin.class?.hasTask()) {
219
- const task = this.getTask({ for: plugin.id })
220
- if (!task) {
221
- throw new Error(`Build task '${plugin.id}' required for custom plugin '${plugin.impl}'`)
222
- }
223
- task.for = plugin.id
224
- tasks.push(task)
207
+ for (const [id, plugin] of this.plugins) {
208
+ if (plugin.hasTask()) {
209
+ tasks.push(this.getTask({ for: id }))
225
210
  }
226
- })
211
+ }
227
212
  }
228
213
  }
229
214
 
@@ -236,7 +221,7 @@ class PluginBuildTaskProvider extends BuildTaskProvider {
236
221
  }
237
222
 
238
223
  getTask(key) {
239
- const task = this.plugins.get(key.for).taskDefaults
224
+ const task = this.plugins.get(key.for).taskDefaults ?? {}
240
225
  task.for = key.for
241
226
  task.src ??= DEFAULT_SRC_FOLDER
242
227
  task.src = task.src.replace(/\/$/, '')
@@ -59,4 +59,3 @@ exports.LOG_LEVEL_WARN = "warn"
59
59
  exports.LOG_LEVEL_INFO = "info"
60
60
  exports.LOG_LEVEL_DEBUG = "debug"
61
61
  exports.LOG_LEVELS = [exports.LOG_LEVEL_ERROR, exports.LOG_LEVEL_WARN, exports.LOG_LEVEL_INFO, exports.LOG_LEVEL_DEBUG]
62
- exports.LOG_MODULE_NAMES = "cds|build"
@@ -4,7 +4,7 @@ const BuildTaskEngine = require('./buildTaskEngine')
4
4
  const BuildPlugin = require('./buildPlugin')
5
5
  const { BuildError } = require('./util')
6
6
 
7
- module.exports = { build, register, BuildPlugin }
7
+ module.exports = { build, register, Plugin: BuildPlugin, BuildError, BuildPlugin }
8
8
 
9
9
  /**
10
10
  * Executes cds build in the directory defined by cds.root.
@@ -29,6 +29,6 @@ async function build(options = {}) {
29
29
  }
30
30
  }
31
31
 
32
- function register(id, options) {
33
- return require('./plugins').register(id, options)
32
+ function register(id, plugin) {
33
+ return require('./plugins').register(id, plugin)
34
34
  }
@@ -1,33 +1,33 @@
1
1
  const cds = require('../cds')
2
+ const DEBUG = cds.debug('cli|build')
2
3
 
3
- module.exports = new (class BuildPlugins {
4
+ module.exports = new (class Plugins {
4
5
  constructor() {
5
6
  this._plugins = new Map()
6
7
  }
7
- getPlugins() {
8
+ get plugins() {
8
9
  return this._plugins
9
10
  }
10
- getPlugin(id) {
11
- return this._plugins.get(id)
12
- }
13
- register(id, options) {
14
- if (!id || !options?.impl) {
15
- throw Error("Invalid build plugin parameter")
11
+ register(id, plugin) {
12
+ if (!id || !plugin) {
13
+ throw Error("Invalid parameter")
14
+ }
15
+ if (plugin.impl) {
16
+ // REVISIT: remove compat mode - latest cds-dk@8
17
+ const taskDefaults = plugin.taskDefaults
18
+ plugin = this._loadPlugin(id, plugin.impl)
19
+ plugin.taskDefaults = taskDefaults
16
20
  }
17
21
  if (this._plugins.has(id)) {
18
22
  throw Error(`Build plugin ${id} already registered`)
19
23
  }
20
- this._plugins.set(id, {
21
- id,
22
- class: this._loadPlugin(id, options.impl),
23
- description: options.description,
24
- taskDefaults: options.taskDefaults ?? {}
25
- })
24
+ DEBUG?.(`Registering build plugin ${id}`)
25
+ this._plugins.set(id, plugin)
26
26
  }
27
27
  _loadPlugin(id, impl) {
28
28
  try {
29
29
  // project-local module is preferred - otherwise from our own dependencies
30
- return require(require.resolve(impl, { paths: [cds.root, __dirname] }))
30
+ return require(require.resolve(impl, { paths: [cds.root, __dirname] }))
31
31
  } catch (e) {
32
32
  throw new Error(`Custom build plugin implementation '${impl}' for '${id}' cannot be loaded:\n` + e)
33
33
  }
@@ -2,6 +2,7 @@ const path = require('path')
2
2
  const cds = require('../../cds')
3
3
  const FeatureToggleBuildPlugin = require('./featureToggleBuildPlugin')
4
4
  const { OUTPUT_MODE, OUTPUT_MODE_RESULT, FLAVOR_LOCALIZED_EDMX } = require('../constants')
5
+ const DEBUG = cds.debug('cli|build')
5
6
 
6
7
  class EdmxBuildPlugin extends FeatureToggleBuildPlugin {
7
8
  async compileToEdmx(model, edmxDest, compileOptions = {}) { // NOSONAR
@@ -19,7 +20,7 @@ class EdmxBuildPlugin extends FeatureToggleBuildPlugin {
19
20
  ...compileOptions,
20
21
  serviceNames
21
22
  }
22
- this.logger._debug && this.logger.debug(`compiling edmx files using OData version ${options.version}`)
23
+ DEBUG?.(`compiling edmx files using OData version ${options.version}`)
23
24
 
24
25
  const result = cds.compile.to.edmx(model, options)
25
26
 
@@ -51,13 +52,11 @@ class EdmxBuildPlugin extends FeatureToggleBuildPlugin {
51
52
  }
52
53
 
53
54
  _isOdataProtocol(srv) {
54
- let protocols = cds.service.protocols4?.(srv)
55
- if (!protocols) {
56
- // compatibility with @sap/cds < 7.3.0
55
+ if ('_serves_odata' in srv) return srv._serves_odata // >= cds 7.4.0
56
+ let protocols = cds.service.protocols4?.(srv) // >= cds 7.4.0
57
+ if (!protocols) { // @sap/cds < 7.3.0
57
58
  protocols = cds.service.protocols.protocol4(srv)
58
- if (typeof protocols === "string") {
59
- protocols = [protocols]
60
- }
59
+ if (typeof protocols === "string") return protocols.startsWith('odata')
61
60
  }
62
61
  return protocols.some(p => p && p.startsWith('odata'))
63
62
  }
@@ -3,8 +3,8 @@ const cds = require('../../../cds')
3
3
  const EdmxBuildPlugin = require('../edmxBuildPlugin')
4
4
  const URL = require('url')
5
5
  const { getProperty, relativePaths } = require('../../util')
6
-
7
6
  const { OUTPUT_MODE, OUTPUT_MODE_RESULT, BUILD_TASK_FIORI, CDS_CONFIG_PATH_SEP, OUTPUT_MODE_FILESYSTEM } = require('../../constants')
7
+ const DEBUG = cds.debug('cli|build')
8
8
 
9
9
  /**
10
10
  * With cds 4 service metadata for the UI service binding is no longer created by default.
@@ -58,12 +58,12 @@ class FioriBuildPlugin extends EdmxBuildPlugin {
58
58
 
59
59
  try {
60
60
  for (let [appFolder, appModelGroup] of appModelGroups.entries()) {
61
- this.logger.debug(`building module [${appFolder}] using [${this.constructor.name}]`)
61
+ DEBUG?.(`building module [${appFolder}] using [${this.constructor.name}]`)
62
62
  const modelPaths = cds.resolve(Array.from(appModelGroup.values()))
63
63
  if (!modelPaths || modelPaths.length === 0) {
64
64
  continue
65
65
  }
66
- this.logger._debug && this.logger.debug(`model: ${relativePaths(cds.root, modelPaths).join(", ")}`)
66
+ DEBUG?.(`model: ${relativePaths(cds.root, modelPaths).join(", ")}`)
67
67
 
68
68
  //cache model per fiori app root folder
69
69
  const options = this.options()
@@ -102,14 +102,14 @@ class FioriBuildPlugin extends EdmxBuildPlugin {
102
102
  try {
103
103
  manifest = require(manifestPath)
104
104
  } catch (error) {
105
- this.logger.log(`UI module does not contain a manifest.json [${relativePaths(cds.root, manifestPath)}], skipping build`)
105
+ console.log(`UI module does not contain a manifest.json [${relativePaths(cds.root, manifestPath)}], skipping build`)
106
106
  return
107
107
  }
108
108
 
109
109
  const mainService = getProperty(manifest, ['sap.app', 'dataSources', 'mainService'])
110
110
  if (!mainService) {
111
111
  // no mainService defined - not supported
112
- this.logger._debug && this.logger.debug(`UI module does not have a datasource [mainService], [${relativePaths(cds.root, manifestPath)}], skipping build`)
112
+ DEBUG?.(`UI module does not have a datasource [mainService], [${relativePaths(cds.root, manifestPath)}], skipping build`)
113
113
  return
114
114
  }
115
115
 
@@ -117,20 +117,20 @@ class FioriBuildPlugin extends EdmxBuildPlugin {
117
117
  const uri = mainService.uri
118
118
 
119
119
  if (!localUri || !uri) {
120
- this.logger._debug && this.logger.warn(`local uri setting missing for data source [mainService], [${relativePaths(cds.root, manifestPath)}]`)
120
+ DEBUG?.(`local uri setting missing for data source [mainService], [${relativePaths(cds.root, manifestPath)}]`)
121
121
  return
122
122
  }
123
123
 
124
124
  const appFolder = path.relative(cds.root, src).split(CDS_CONFIG_PATH_SEP)[0]
125
125
  const model = this.context.for[BUILD_TASK_FIORI].appModel.get(appFolder)
126
126
  if (!model) {
127
- this.logger.error(`failed to load model for service uri ${uri}, data source [mainService]`)
127
+ console.error(`failed to load model for service uri ${uri}, data source [mainService]`)
128
128
  return
129
129
  }
130
130
 
131
131
  const edmx = this._getEdmxForUri(model, appFolder, uri)
132
132
  if (!edmx) {
133
- this.logger.error(`failed to resolve service definition for service uri ${uri}, data source [mainService]`)
133
+ console.error(`failed to resolve service definition for service uri ${uri}, data source [mainService]`)
134
134
  return
135
135
  }
136
136
 
@@ -1,18 +1,14 @@
1
1
  const path = require('path')
2
2
  const parser = require('./migrationtable')
3
- const { BuildError, hasOptionValue } = require('../../util')
4
- const { LOG_MODULE_NAMES } = require('../../constants')
3
+ const { BuildError, hasOptionValue, BuildMessage } = require('../../util')
4
+ const { SEVERITY_WARNING } = require('../../constants')
5
5
  const cds = require('../../../cds'), { compiler: cdsc } = cds
6
6
  const cdscVersion = `-- generated by cds-compiler version ${cdsc.version()}`
7
7
  const { getArtifactCdsPersistenceName } = cdsc
8
- let logger = cds.log(LOG_MODULE_NAMES)
9
8
  const ANNO_PERSISTENCE_JOURNAL = '@cds.persistence.journal'
9
+ const DEBUG = cds.debug('cli|build')
10
10
 
11
11
  module.exports = async (model, lastDevVersion, srcPath, options = {}) => {
12
- if (options.logger) {
13
- logger = options.logger
14
- }
15
-
16
12
  const { definitions, deletions, migrations, afterImage, journalFileNames } = _toHdiMigration(model, lastDevVersion, options)
17
13
  const definitionResult = []
18
14
 
@@ -34,14 +30,14 @@ module.exports = async (model, lastDevVersion, srcPath, options = {}) => {
34
30
 
35
31
  function _toHdiMigration(model, lastDevVersion, options) {
36
32
  const result = cdsc.to.hdi.migration(cds.minify(model), options, lastDevVersion);
37
- const journalFileNames = _getJournalFileNames(result.afterImage);
38
- if (logger._debug) {
39
- logger.debug('cdsc.to.hdi.migration returned')
33
+ const journalFileNames = _getJournalFileNames(result.afterImage, options);
34
+ if (DEBUG) {
35
+ DEBUG('cdsc.to.hdi.migration returned')
40
36
  for (const { name, suffix, sql } of result.definitions) {
41
37
  if (suffix === '.hdbtable' || suffix === '.hdbmigrationtable') {
42
38
  if (journalFileNames.has(name)) {
43
39
  const migration = result.migrations.find(migration => migration.name === name)
44
- logger.debug(`
40
+ DEBUG(`
45
41
  File ${name + '.hdbmigrationtable'} - ${migration ? migration.changeset.length : 0} new changes
46
42
  ${sql}
47
43
  ${migration ? migration.changeset.map(change => change.sql).join('\n') : 'Empty changeset'}
@@ -50,7 +46,7 @@ ${migration ? migration.changeset.map(change => change.sql).join('\n') : 'Empty
50
46
  }
51
47
  }
52
48
  }
53
- return { ...result, journalFileNames };
49
+ return { ...result, journalFileNames }
54
50
  }
55
51
 
56
52
  /**
@@ -136,19 +132,19 @@ function _emptyMigration(name) {
136
132
  return { name, suffix: ".hdbmigrationtable", changeset: [] }
137
133
  }
138
134
 
139
- function _getJournalFileNames(model) {
135
+ function _getJournalFileNames(model, options) {
140
136
  const journalNames = new Set(cds.reflect(model).all(item => {
141
137
  if (item.kind === 'entity' && item[ANNO_PERSISTENCE_JOURNAL] === true) {
142
138
  if (item['@cds.persistence.skip'] === true || item['@cds.persistence.exists'] === true) {
143
- logger.warn(`[hdbmigrationtable] annotation @cds.persistence.journal skipped for entity '${item.name}' as persistence exists`)
139
+ options.messages?.push(new BuildMessage(`[hdbmigrationtable] annotation @cds.persistence.journal skipped for entity '${item.name}' as persistence exists`, SEVERITY_WARNING))
144
140
  }
145
141
  return true
146
142
  }
147
143
  return false
148
144
  }).map(entity => getArtifactCdsPersistenceName(entity.name, 'quoted', model, 'hana')))
149
145
 
150
- logger._debug && logger.debug(`\n[hdbmigrationtable] found ${journalNames.size} model entities annotated with '@cds.persistence.journal`)
151
- logger._debug && logger.debug(`[hdbmigrationtable] ${[...journalNames].join(', ')}\n`)
146
+ DEBUG?.(`\n[hdbmigrationtable] found ${journalNames.size} model entities annotated with '@cds.persistence.journal`)
147
+ DEBUG?.(`[hdbmigrationtable] ${[...journalNames].join(', ')}\n`)
152
148
 
153
149
  return journalNames
154
150
  }
@@ -4,13 +4,10 @@ const cds = require('../../../cds')
4
4
  const to_hdbmigration = require('./2migration')
5
5
  const InternalBuildPlugin = require('../internalBuildPlugin')
6
6
  const { BuildError, relativePaths, BuildMessage } = require('../../util')
7
-
8
7
  const { OUTPUT_MODE_NONE, OUTPUT_MODE, CONTENT_PACKAGE_JSON, CONTENT_HDBTABLEDATA, CSV_FILE_DETECTION,
9
8
  CONTENT_ENV, CONTENT_DEFAULT_ENV_JSON, CONTENT_NODE_MODULES, OUTPUT_MODE_RESULT, CONTINUE_UNRESOLVED_SCHEMA_CHANGES, CSV_FILE_TARGET } = require('../../constants')
10
9
  const { WARNING } = InternalBuildPlugin
11
-
12
10
  const DEFAULT_COMPILE_DEST_FOLDER = path.normalize("src/gen")
13
-
14
11
  const FILE_EXT_CSV = ".csv"
15
12
  const FILE_EXT_HDBTABLEDATA = ".hdbtabledata"
16
13
  const FILE_EXT_HDBTABLE = ".hdbtable"
@@ -21,6 +18,7 @@ const FILE_NAME_PACKAGE_JSON = "package.json"
21
18
  const PATH_LAST_DEV_CSN = "last-dev/csn.json"
22
19
  const FILE_NAME_UNDEPLOY_JSON = "undeploy.json"
23
20
  const DEPLOY_FORMAT = "deploy-format"
21
+ const DEBUG = cds.debug('cli|build')
24
22
 
25
23
  class HanaBuildPlugin extends InternalBuildPlugin {
26
24
  init() {
@@ -215,7 +213,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
215
213
 
216
214
  const promises = []
217
215
  const relDest = path.relative(this.task.dest, this.task.options.compileDest)
218
- const options = { ...this.options(), logger: this.logger, dirs: csvDirs, baseDir: this.task.options.compileDest }
216
+ const options = { ...this.options(), messages: this.messages, dirs: csvDirs, baseDir: this.task.options.compileDest }
219
217
 
220
218
  const toHdbtabledata = cds.compile.to.hdbtabledata ?? require(path.join(cds.home, 'bin/build/provider/hana/2tabledata')) // cds@6 compatibility
221
219
  const tableDataResult = await toHdbtabledata(model, options)
@@ -314,7 +312,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
314
312
  lastDev = JSON.parse((await fs.promises.readFile(lastDevCsnDir, 'utf-8')).toString())
315
313
  }
316
314
  // enforces sqlNames option for compiler in tests, pass options from cds env, ensures that the correct format is taken
317
- const options = { ...this.options(), logger: this.logger, sql_mapping: cds.env.sql.names, "deploy-format": format }
315
+ const options = { ...this.options(), messages: this.messages, sql_mapping: cds.env.sql.names, "deploy-format": format }
318
316
 
319
317
  const compilationResult = await to_hdbmigration(model, lastDev, dbSrcDir, options)
320
318
  const definitions = compilationResult.definitions
@@ -332,7 +330,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
332
330
  }
333
331
  promises.push(this.write(content).to(path.join(dbSrcDir, file)))
334
332
  } else {
335
- this.logger._debug && this.logger.debug(`no change, keep existing ${file}`)
333
+ DEBUG?.(`no change, keep existing ${file}`)
336
334
  }
337
335
  } else {
338
336
  if (this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_RESULT)) {
@@ -384,7 +382,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
384
382
  const exists = fs.existsSync(packageJson)
385
383
 
386
384
  if (exists) {
387
- this.logger._debug && this.logger.debug(`skip create [${relativePaths(cds.root, packageJson)}], already existing`)
385
+ DEBUG?.(`skip create [${relativePaths(cds.root, packageJson)}], already existing`)
388
386
  }
389
387
  if (this.isStagingBuild() && !exists) {
390
388
  const content = await HanaBuildPlugin._readTemplateAsJson(FILE_NAME_PACKAGE_JSON)
@@ -4,7 +4,7 @@
4
4
  "@sap/hdi-deploy": "^4"
5
5
  },
6
6
  "engines": {
7
- "node": "^14 || ^16 || ^18"
7
+ "node": "^16 || ^18 || ^20"
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node node_modules/@sap/hdi-deploy/deploy.js"
@@ -6,14 +6,6 @@ const { hasOptionValue } = require('../util')
6
6
  const { FOLDER_GEN } = require('../constants')
7
7
 
8
8
  class InternalBuildPlugin extends BuildPlugin {
9
- /**
10
- * Returns the logger that has been passed the build task engine.
11
- * @returns {object}
12
- */
13
- get logger() {
14
- //injected by framework
15
- return this._logger;
16
- }
17
9
  /**
18
10
  * Custom build plugins are executed before internal build plugins in order
19
11
  * ensure and content cannot be overwritten by mistake.
@@ -3,24 +3,20 @@ const path = require('path')
3
3
  const cds = require('../../cds')
4
4
  const { hasJavaNature, getDefaultModelOptions, BuildError, hasOptionValue, isClassicMtx, normalizePath } = require('../util')
5
5
  const BuildTaskProvider = require('../buildTaskProvider')
6
-
7
6
  const { FILE_EXT_CDS, BUILD_TASK_HANA, BUILD_TASK_FIORI, BUILD_TASK_JAVA, BUILD_TASK_JAVA_CF, BUILD_TASK_NODEJS, BUILD_TASK_NODE_CF, BUILD_TASK_MTX,
8
7
  BUILD_TASK_PREFIX, BUILD_TASKS, BUILD_TASK_MTX_SIDECAR, MTX_SIDECAR_FOLDER, BUILD_TASK_MTX_EXTENSION, NODEJS_MODEL_EXCLUDE_LIST,
9
8
  IGNORE_DEFAULT_MODELS } = require("../constants")
9
+ const DEBUG = cds.debug('cli|build')
10
10
 
11
11
  class InternalBuildTaskProvider extends BuildTaskProvider {
12
- constructor(logger) {
12
+ constructor() {
13
13
  super()
14
- this._logger = logger
15
14
  // ensure that classic mtx is not used in combination with cds-dk@7
16
15
  if (isClassicMtx()) {
17
16
  throw new BuildError(`@sap/cds-mtx is deprecated and not supported by @sap/cds-dk >= 7.
18
17
  Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/docs/guides/multitenancy/old-mtx-migration or install @sap/cds-dk version 6 instead.`)
19
18
  }
20
19
  }
21
- get logger() {
22
- return this._logger
23
- }
24
20
 
25
21
  providesTask(key) {
26
22
  return BUILD_TASKS.includes(key.for) || key.use && key.use.startsWith(BUILD_TASK_PREFIX)
@@ -43,7 +39,7 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
43
39
  InternalBuildTaskProvider._setDefaultModel(task)
44
40
  }
45
41
 
46
- getPluginClass(task) {
42
+ getPlugin(task) {
47
43
  return require(`./${InternalBuildTaskProvider._getForValueFromTask(task)}`)
48
44
  }
49
45
 
@@ -60,13 +56,13 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
60
56
  if (Array.isArray(db) && db.length > 0) {
61
57
  db = InternalBuildTaskProvider._getModuleFolder(db) || null
62
58
  if (!db && !dependencies) { // log once
63
- this.logger.debug("No database module found")
59
+ DEBUG?.("No database module found")
64
60
  }
65
61
  }
66
62
  if (Array.isArray(srv) && srv.length > 0) {
67
63
  srv = InternalBuildTaskProvider._getModuleFolder(srv) || null
68
64
  if (!srv && !dependencies) { // log once
69
- this.logger.debug("No service module found")
65
+ DEBUG?.("No service module found")
70
66
  }
71
67
  }
72
68
 
@@ -99,8 +95,8 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
99
95
  }
100
96
  }
101
97
  } else {
102
- !db && this.logger._debug && this.logger.debug(`project doesn't have a database module '${cds.env.folders.db}'`)
103
- !srv && this.logger._debug && this.logger.debug(`project doesn't have a service module '${cds.env.folders.srv}'`)
98
+ !db && DEBUG?.(`project doesn't have a database module '${cds.env.folders.db}'`)
99
+ !srv && DEBUG?.(`project doesn't have a service module '${cds.env.folders.srv}'`)
104
100
 
105
101
  // create hana build task
106
102
  const dbTask = this._createDbTask(db, dbOptions)
@@ -122,13 +118,13 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
122
118
  }
123
119
 
124
120
  _createDbTask(src, taskOptions) {
125
- this.logger.debug("determining database kind")
121
+ DEBUG?.("determining database kind")
126
122
  if (!src || InternalBuildTaskProvider._isMtxExtension()) {
127
123
  return null
128
124
  }
129
125
  let task = null
130
126
  if (this._useHana()) {
131
- this.logger.debug("found HANA database")
127
+ DEBUG?.("found HANA database")
132
128
  // legacy build supports dest property
133
129
  const compileDest = cds.env.data?.dest
134
130
  if (compileDest) {
@@ -142,7 +138,7 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
142
138
  options: taskOptions
143
139
  }
144
140
  } else {
145
- this.logger.debug("found sqlite database - skipping HANA build task")
141
+ DEBUG?.("found sqlite database - skipping HANA build task")
146
142
  }
147
143
  return task
148
144
  }
@@ -162,11 +158,11 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
162
158
  }
163
159
 
164
160
  _createMtxTask(src) {
165
- this.logger.debug("determining MTX architecture")
161
+ DEBUG?.("determining MTX architecture")
166
162
 
167
163
  // preserve order of creation
168
164
  if (InternalBuildTaskProvider._isMtxExtension()) {
169
- this.logger.debug("MTX extension app")
165
+ DEBUG?.("MTX extension app")
170
166
  return { for: BUILD_TASK_MTX_EXTENSION }
171
167
  }
172
168
 
@@ -180,7 +176,7 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
180
176
  cds.env.profiles?.includes('with-mtx-sidecar') || // new presets
181
177
  cds.env.requires["cds.xt.ModelProviderService"]?.external // for compatibility with former mtxs presets
182
178
  ) {
183
- this.logger.debug("MTX app with sidecar")
179
+ DEBUG?.("MTX app with sidecar")
184
180
  if (!sidecarEnv) {
185
181
  throw new BuildError(`MTX sidecar directory '${sidecarPath}' not existing. Custom build task configuration required if the folder is named differently.`)
186
182
  }
@@ -204,7 +200,7 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
204
200
 
205
201
  // mtxs nodejs app without sidecar
206
202
  if (!InternalBuildTaskProvider._hasJavaNature(src)) {
207
- this.logger.debug("MTX Nodejs app without sidecar")
203
+ DEBUG?.("MTX Nodejs app without sidecar")
208
204
  return {
209
205
  for: BUILD_TASK_MTX,
210
206
  src
@@ -214,7 +210,7 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
214
210
  }
215
211
 
216
212
  _createSrvTask(src, taskOptions) {
217
- this.logger.debug("determining implementation technology")
213
+ DEBUG?.("determining implementation technology")
218
214
  if (!src || InternalBuildTaskProvider._isMtxExtension()) {
219
215
  return null
220
216
  }
@@ -228,7 +224,7 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
228
224
  }
229
225
 
230
226
  _createJavaTask(src, taskOptions) {
231
- this.logger.debug("found implementation technology Java")
227
+ DEBUG?.("found implementation technology Java")
232
228
  // legacy build supports dest property
233
229
  const compileDest = cds.env.service?.dest
234
230
  if (compileDest) {
@@ -243,7 +239,7 @@ Upgrade to @sap/cds-mtxs following the migration guide https://cap.cloud.sap/doc
243
239
  }
244
240
 
245
241
  _createNodeTask(src, taskOptions) {
246
- this.logger.debug("found implementation technology Nodejs")
242
+ DEBUG?.("found implementation technology Nodejs")
247
243
  return {
248
244
  src: src,
249
245
  for: BUILD_TASK_NODEJS,