@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
package/bin/activate.js CHANGED
@@ -69,7 +69,7 @@ async function activate ([projectFolder], options = {}) {
69
69
 
70
70
  Object.assign(options, { projectFolder })
71
71
 
72
- await require('../lib/client/activate').run(injection, options);
72
+ await require('../lib/mtx/activate').run(injection, options);
73
73
  }
74
74
 
75
75
 
package/bin/add.js CHANGED
@@ -1,3 +1,4 @@
1
+ const cds = require('../lib/cds')
1
2
  const term = require('../lib/util/term')
2
3
 
3
4
  module.exports = Object.assign(add, {
@@ -91,10 +92,11 @@ module.exports = Object.assign(add, {
91
92
 
92
93
  *cds init*
93
94
 
94
- `});
95
+ `})
95
96
 
96
97
  async function add(args) {
97
- const CDSGenerator = require('../lib/init');
98
- const generator = new CDSGenerator();
99
- await generator.addCmd(args[0]);
98
+ await cds.plugins
99
+ const CDSGenerator = require('../lib/init')
100
+ const generator = new CDSGenerator()
101
+ await generator.addCmd(args[0])
100
102
  }
package/bin/build.js CHANGED
@@ -80,7 +80,6 @@ module.exports = Object.assign(build, {
80
80
  a tarball will be created in folder 'gen/srv'. Dependencies in package.json
81
81
  will be adapted to point to the correct tarball file URL.
82
82
  Contents is packaged based on the rules of the 'npm pack' command.
83
- See 'npm workspaces' and 'npm pack' for further details.
84
83
 
85
84
  # EXAMPLES
86
85
 
@@ -94,6 +93,9 @@ module.exports = Object.assign(build, {
94
93
  async function build([project], options = {}) {
95
94
  const path = require('path')
96
95
 
96
+ // ensure that cds build plugins defined as devDependencies are loaded
97
+ if (process.env.NODE_ENV === 'production') delete process.env.NODE_ENV
98
+
97
99
  const cds = require('../lib/cds')
98
100
 
99
101
  // plugins are loaded based on cds.root path
@@ -105,11 +107,6 @@ async function build([project], options = {}) {
105
107
  cds.env = cds.env.for('cds', cds.root);
106
108
  delete options.project // avoid that relative project paths are resolved twice
107
109
 
108
- const { build } = require('../lib/build')
109
- const [major] = cds.version.split('.')
110
- if (Number(major) < 6) {
111
- throw "This application uses @sap/cds version < 6, which is not compatible with the installed @sap/cds-dk version >= 7. Update @sap/cds to version >= 6."
112
- }
113
110
  if (typeof options["options-model"] === "string") {
114
111
  options.opts = "model=[" + options["options-model"].split(",").map((entry) => entry.trim()) + "]"
115
112
  delete options["options-model"]
@@ -122,5 +119,6 @@ async function build([project], options = {}) {
122
119
  delete options["no-clean"]
123
120
  }
124
121
 
122
+ const { build } = require('../lib/build')
125
123
  await build(options)
126
124
  }
package/bin/cds.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
 
4
- const cli = { //NOSONAR
4
+ const cli = {
5
5
 
6
6
  Shortcuts: {
7
7
  i: 'init',
@@ -90,6 +90,9 @@ const cli = { //NOSONAR
90
90
  else if (_global.test(a)) add_global(a, _flags[a] || argv[++i])
91
91
  else throw 'Invalid option: '+ a
92
92
  }
93
+ // consistent production setting for NODE_ENV and CDS_ENV
94
+ if (process.env.NODE_ENV !== 'production') process.env.NODE_ENV = process.env.CDS_ENV?.split(',').find(p => p === 'production') || process.env.NODE_ENV
95
+ else process.env.CDS_ENV = Array.from(new Set([...process.env.CDS_ENV?.split(',') ?? [], 'production']))
93
96
 
94
97
  function add (k,v) { options[k.slice(2)] = v || true }
95
98
  function add_global (k,v='') {
@@ -88,8 +88,6 @@ module.exports = Object.assign(deploy, {
88
88
 
89
89
  `})
90
90
 
91
- const cds = require('../../lib/cds')
92
-
93
91
  async function deploy(_model, options) { // NOSONAR
94
92
 
95
93
  if (process.stdout.isTTY && options['no-save']) {
@@ -98,6 +96,11 @@ async function deploy(_model, options) { // NOSONAR
98
96
 
99
97
  if (_model && _model.length === 0) _model = undefined // empty array (no model args) means default models
100
98
 
99
+ // ensure that cds build plugins defined as devDependencies are loaded
100
+ if (process.env.NODE_ENV === 'production') delete process.env.NODE_ENV
101
+
102
+ const cds = require('../../lib/cds')
103
+
101
104
  // IMPORTANT: call plugins before subsequent access to cds.env
102
105
  await cds.plugins
103
106
 
package/bin/eval.js CHANGED
@@ -23,7 +23,7 @@ function run ([code]) {
23
23
  // eslint-disable-next-line no-unused-vars
24
24
  const cds = require('../lib/cds')
25
25
  if (code[0] === '.') code = 'cds' + code
26
- const outcome = eval(code) //NOSONAR
26
+ const outcome = eval(code)
27
27
  console.log (outcome)
28
28
  }
29
29
 
package/bin/extend.js CHANGED
@@ -81,7 +81,7 @@ async function extend ([url], options = {}) {
81
81
  const [username, password] = options.username?.split(':') ?? [];
82
82
  delete options.user;
83
83
 
84
- await require('../lib/client/download_legacy').run({
84
+ await require('../lib/mtx/download_legacy').run({
85
85
  ...options,
86
86
  url,
87
87
  username,
@@ -91,14 +91,14 @@ async function extend ([url], options = {}) {
91
91
  }
92
92
 
93
93
  if (options.force) {
94
- if (! await require('../lib/client/helper/question').askBooleanQuestion('Using option --force will overwrite existing files. Continue (yN)? ', false, false)) {
94
+ if (! await require('../lib/mtx/util/question').askBooleanQuestion('Using option --force will overwrite existing files. Continue (yN)? ', false, false)) {
95
95
  console.log('Extend cancelled')
96
96
  return
97
97
  }
98
98
  }
99
99
 
100
100
  Object.assign(options, { url })
101
- await require('../lib/client/extend').run(options);
101
+ await require('../lib/mtx/extend').run(options);
102
102
  }
103
103
 
104
104
 
package/bin/login.js CHANGED
@@ -3,7 +3,7 @@ module.exports = Object.assign(login, {
3
3
  shortcuts: ['-s', '-d', '-p', '-u', '-c', '-m'],
4
4
  flags: ['--plain'],
5
5
  get help() {
6
- const config = require('../lib/client/settings_manager').SettingsManager.config
6
+ const config = require('../lib/mtx/settings_manager').SettingsManager.config
7
7
  return `
8
8
  # SYNOPSIS
9
9
 
@@ -169,7 +169,7 @@ async function login ([url], options = {}) {
169
169
  });
170
170
  delete options.plain;
171
171
 
172
- await require('../lib/client/auth_manager').login(options);
172
+ await require('../lib/mtx/auth_manager').login(options);
173
173
  }
174
174
 
175
175
 
package/bin/logout.js CHANGED
@@ -54,7 +54,7 @@ module.exports = Object.assign(logout, {
54
54
  async function logout ([projectFolder], options = {}) {
55
55
  Object.assign(options, { projectFolder })
56
56
 
57
- await require('../lib/client/auth_manager').logout(options)
57
+ await require('../lib/mtx/auth_manager').logout(options)
58
58
  }
59
59
 
60
60
 
package/bin/pull.js CHANGED
@@ -59,7 +59,7 @@ async function pull([url], options = {}) {
59
59
  if (options.from) url = options.from;
60
60
  delete options.from;
61
61
 
62
- await require('../lib/client/pull').run({
62
+ await require('../lib/mtx/pull').run({
63
63
  ...options,
64
64
  url,
65
65
  username,
package/bin/push.js CHANGED
@@ -25,7 +25,7 @@ module.exports = Object.assign(push, {
25
25
 
26
26
  # OPTIONS
27
27
 
28
- *--to* <url>
28
+ *-2* | *--to* <url>
29
29
 
30
30
  Specify the URL of the extensible SaaS app. Determined from the current
31
31
  user's active
@@ -100,5 +100,5 @@ async function push([projectFolder], options = {}) {
100
100
  args.push({ extArchive });
101
101
  }
102
102
 
103
- await require('../lib/client/push').run(...args);
103
+ await require('../lib/mtx/push').run(...args);
104
104
  }
package/bin/subscribe.js CHANGED
@@ -1,5 +1,5 @@
1
1
  module.exports = Object.assign(subscribe, {
2
- init: cmd => new (require('../lib/client/tenant_action'))(cmd),
2
+ init: cmd => new (require('../lib/mtx/tenant_action'))(cmd),
3
3
  options: ['--to', '--user'],
4
4
  flags: ['--local', '--resolve-bindings'],
5
5
  shortcuts: ['-2', '-u', '-l', '-b'],
@@ -50,7 +50,7 @@ module.exports = Object.assign(subscribe, {
50
50
 
51
51
 
52
52
  async function subscribe([tenant], options = {}) {
53
- const { getMessage } = require('../lib/client/helper/logging');
53
+ const { getMessage } = require('../lib/mtx/util/logging');
54
54
  if (!tenant) {
55
55
  throw getMessage('Tenant not given.', { command: 'subscribe' });
56
56
  }
@@ -1,5 +1,5 @@
1
1
  module.exports = Object.assign(unsubscribe, {
2
- init: cmd => new (require('../lib/client/tenant_action'))(cmd),
2
+ init: cmd => new (require('../lib/mtx/tenant_action'))(cmd),
3
3
  options: ['--from', '--user'],
4
4
  flags: ['--local', '--resolve-bindings'],
5
5
  shortcuts: ['-f', '-u', '-l', '-b'],
@@ -51,7 +51,7 @@ module.exports = Object.assign(unsubscribe, {
51
51
 
52
52
 
53
53
  async function unsubscribe([tenant], options = {}) {
54
- const { getMessage } = require('../lib/client/helper/logging');
54
+ const { getMessage } = require('../lib/mtx/util/logging');
55
55
  if (!tenant) {
56
56
  throw getMessage('Tenant not given.', { command: 'unsubscribe' });
57
57
  }
package/bin/upgrade.js CHANGED
@@ -1,5 +1,5 @@
1
1
  module.exports = Object.assign(upgrade, {
2
- init: cmd => new (require('../lib/client/tenant_action'))(cmd),
2
+ init: cmd => new (require('../lib/mtx/tenant_action'))(cmd),
3
3
  options: ['--at', '--user'],
4
4
  flags: ['--local', '--resolve-bindings'],
5
5
  shortcuts: ['-a', '-u', '-l', '-b'],
@@ -51,7 +51,7 @@ module.exports = Object.assign(upgrade, {
51
51
 
52
52
 
53
53
  async function upgrade([tenant], options = {}) {
54
- const { getMessage } = require('../lib/client/helper/logging');
54
+ const { getMessage } = require('../lib/mtx/util/logging');
55
55
  if (!tenant) {
56
56
  throw getMessage('Tenant not given.', { command: 'upgrade' });
57
57
  }
package/bin/version.js CHANGED
@@ -34,7 +34,7 @@ module.exports = Object.assign(list_versions, {
34
34
 
35
35
  const MISSING = '-- missing --'
36
36
 
37
- function list_versions(args, options) { //NOSONAR
37
+ function list_versions(args, options) {
38
38
  if (options['npm-list'] || options['npm-tree']) {
39
39
  let [pattern] = args, re = pattern ? RegExp(pattern) : /@sap\/cd[rs]|@sap\/eslint-plugin-cds/
40
40
  let cmd = 'npm ls --depth ' + (options['npm-tree'] ? 11 : 0)
@@ -93,7 +93,7 @@ function _markdown (versions) {
93
93
  const pkg = { name:'', repository:'', version:'' }; try {
94
94
  Object.assign (pkg, require (resolve('package.json')))
95
95
  } catch (e) {/* ignored */}
96
- console.log ('|', pkg.name, '|', pkg.repository.url || pkg.repository, '|')
96
+ console.log ('|', pkg.name, '|', pkg.repository.url || pkg.repository || 'https://github.com/<your/repo>', '|')
97
97
  console.log ('|:---------------------- | ----------- |')
98
98
  if (require('../lib').env['project-nature'] === 'nodejs') {
99
99
  console.log ('|', v('Node.js'), '|')
package/bin/watch.js CHANGED
@@ -64,7 +64,7 @@ const t = module.exports.codes = {
64
64
  orange: colors ? '\x1b[38;2;255;140;0m' : '' // darker orange, works with bright and dark background
65
65
  }
66
66
  const extDefaults = 'cds,csn,csv,ts,mjs,cjs,js,json,properties,edmx,xml,env'
67
- const ignore = RegExp(`(node_modules\\${sep}|@cds-models\\${sep}|@types\\${sep}|app(\\${sep}.+)?\\${sep}((webapp|dist|target)\\${sep}|\\.cds-services\\.json$|tsconfig\\.json$|.*\\.tsbuildinfo$))`)
67
+ const ignore = RegExp(`(_out\\${sep}|node_modules\\${sep}|@cds-models\\${sep}|@types\\${sep}|app(\\${sep}.+)?\\${sep}((webapp|dist|target)\\${sep}|\\.cds-services\\.json$|tsconfig\\.json$|.*\\.tsbuildinfo$))`)
68
68
 
69
69
  async function watch ([cwd], {
70
70
  args = ['serve', 'all'],
@@ -9,7 +9,8 @@ const KindToRequiresNameMap = {
9
9
  'sql-mt': 'db', // For compatibility only
10
10
  destinations: 'destinations',
11
11
  connectivity: 'connectivity',
12
- 'audit-log': 'audit-log',
12
+ 'audit-log': 'auditlog',
13
+ 'audit-log-to-restv2': 'auditlog',
13
14
  'enterprise-messaging': 'messaging',
14
15
  'enterprise-messaging-amqp': 'messaging',
15
16
  'enterprise-messaging-http': 'messaging',
@@ -1,10 +1,10 @@
1
1
  const cds = require('../cds');
2
2
  const DEBUG = cds.debug('cli')
3
3
 
4
- const cfUtil = require('../util/cfUtil');
4
+ const cfUtil = require('../util/cf');
5
5
 
6
6
  const axios = require('axios');
7
- require('../util/pruneAxiosErrors');
7
+ require('../util/axios').pruneErrors();
8
8
  const { URL } = require('url');
9
9
  const { bold, highlight } = require('../util/term');
10
10
 
@@ -6,7 +6,7 @@ const fs = require('fs').promises;
6
6
  const { highlight } = require('../util/term');
7
7
  const { logger } = require('./bindingUtil');
8
8
 
9
- const gitUtil = require('../util/gitUtil');
9
+ const gitUtil = require('../util/git');
10
10
 
11
11
  const CDSRC_FILENAME = '.cdsrc-private.json';
12
12
 
@@ -1,9 +1,9 @@
1
1
  const path = require('path')
2
2
  const fs = require('fs').promises
3
3
  const cds = require('../cds')
4
-
5
4
  const { OUTPUT_MODE, OUTPUT_MODE_FILESYSTEM, SEVERITY_INFO, SEVERITY_WARNING, SEVERITY_ERROR } = require('./constants')
6
5
  const { hasOptionValue, getProperty, relativePaths, BuildMessage, pathExists } = require('./util')
6
+ const DEBUG = cds.debug('cli|build')
7
7
 
8
8
  /**
9
9
  * The build plugin creates the build output for a dedicated build task. It is uniquely identified
@@ -30,15 +30,9 @@ class BuildPlugin {
30
30
  static hasTask() {
31
31
  return true
32
32
  }
33
- static get INFO() {
34
- return SEVERITY_INFO
35
- }
36
- static get WARNING() {
37
- return SEVERITY_WARNING
38
- }
39
- static get ERROR() {
40
- return SEVERITY_ERROR
41
- }
33
+ static INFO = SEVERITY_INFO
34
+ static WARNING = SEVERITY_WARNING
35
+ static ERROR = SEVERITY_ERROR
42
36
  /**
43
37
  * Returns the build context
44
38
  * @returns {object}
@@ -194,10 +188,10 @@ class BuildPlugin {
194
188
  async model() {
195
189
  const files = this._resolveModel()
196
190
  if (!files || files.length === 0) {
197
- this._logger.log(`no CDS model found for [${this.task.for}] build task [${this.task.src}] - nothing to be done`)
191
+ console.log(`no CDS model found for [${this.task.for}] build task [${this.task.src}] - nothing to be done`)
198
192
  return null
199
193
  }
200
- this._logger._debug && this._logger.debug(`model: ${relativePaths(cds.root, files).join(", ")}`)
194
+ DEBUG?.(`model: ${relativePaths(cds.root, files).join(", ")}`)
201
195
  // $location paths are relative to current working dir by default - make sure a given project root folder is taken
202
196
  const options = { ...this.options(), cwd: cds.root }
203
197
 
@@ -2,13 +2,13 @@ const fs = require('fs')
2
2
  const path = require('path')
3
3
  const cds = require('../cds'), { _log: log } = cds
4
4
  const { sortMessagesSeverityAware, deduplicateMessages, CompilationError } = cds.compiler
5
- const { relativePaths, BuildError, resolveRequiredSapModels } = require('./util')
5
+ const { relativePaths, BuildError, resolveRequiredSapModels, redactCredentials } = require('./util')
6
6
  const { SEVERITIES, LOG_LEVELS } = require('./constants')
7
7
  const BuildTaskFactory = require('./buildTaskFactory')
8
8
  const InternalBuildPlugin = require('./provider/internalBuildPlugin')
9
-
10
9
  const COMPILATION_ERROR = 'CompilationError'
11
10
  const COMPILE_MESSAGE = 'CompileMessage'
11
+ const DEBUG = cds.debug('cli|build')
12
12
 
13
13
  class BuildTaskEngine {
14
14
  constructor(options) {
@@ -17,9 +17,6 @@ class BuildTaskEngine {
17
17
  get taskFactory() {
18
18
  return this._taskFactory
19
19
  }
20
- get logger() {
21
- return this.taskFactory.logger
22
- }
23
20
  get options() {
24
21
  return this.taskFactory.options
25
22
  }
@@ -27,8 +24,12 @@ class BuildTaskEngine {
27
24
  async processTasks(tasks) {
28
25
  const startTime = Date.now()
29
26
 
30
- this.logger.log(`building project [${cds.root}], clean [${this.options.clean}]`)
31
- this.logger.log(`cds-dk [${require('../../package.json').version}], cds [${cds.version}], compiler [${cds.compiler.version()}], home [${cds.home}]\n`)
27
+ console.log(`building project [${cds.root}], clean [${this.options.clean}]`)
28
+
29
+ DEBUG?.("cds configuration settings:")
30
+ DEBUG?.(redactCredentials(cds.env))
31
+
32
+ console.log(`cds-dk [${require('../../package.json').version}], cds [${cds.version}], compiler [${cds.compiler.version()}], home [${cds.home}]\n`)
32
33
 
33
34
  if (!tasks) {
34
35
  tasks = await this.taskFactory.getTasks()
@@ -98,7 +99,7 @@ class BuildTaskEngine {
98
99
  for (let plugin of pluginGroup) {
99
100
  // prepare has been deprecated
100
101
  if (plugin instanceof InternalBuildPlugin) {
101
- this.logger._debug && this.logger.debug(`preparing, plugin [${plugin.constructor.name}], src [${relativePaths(cds.root, plugin.task.src)}]`)
102
+ DEBUG?.(`preparing, plugin [${plugin.constructor.name}], src [${relativePaths(cds.root, plugin.task.src)}]`)
102
103
  const result = await plugin.prepare()
103
104
  if (result === false) {
104
105
  break
@@ -112,12 +113,12 @@ class BuildTaskEngine {
112
113
  // clean entire build staging folder once
113
114
  if (cds.env.build.target !== '.') {
114
115
  const target = path.resolve(cds.root, cds.env.build.target)
115
- this.logger._debug && this.logger.debug(`cleaning staging folder ${target}`)
116
+ DEBUG?.(`cleaning staging folder ${target}`)
116
117
  await fs.promises.rm(target, { force: true, recursive: true })
117
118
  }
118
119
 
119
120
  const results = await Promise.allSettled(plugins.map((plugin) => {
120
- this.logger._debug && this.logger.debug(`cleaning, plugin [${plugin.constructor.name}], src [${relativePaths(cds.root, plugin.task.src)}]`)
121
+ DEBUG?.(`cleaning, plugin [${plugin.constructor.name}], src [${relativePaths(cds.root, plugin.task.src)}]`)
121
122
  return plugin.clean()
122
123
  }))
123
124
  // check for errors and throw exception
@@ -155,7 +156,7 @@ class BuildTaskEngine {
155
156
  let allResults = []
156
157
  for (const group of pipeline) {
157
158
  const results = await Promise.allSettled(group.map((plugin) => {
158
- this.logger._debug && this.logger.debug(`building, plugin [${plugin.constructor.name}], src [${relativePaths(cds.root, plugin.task.src)}]`)
159
+ DEBUG?.(`building, plugin [${plugin.constructor.name}], src [${relativePaths(cds.root, plugin.task.src)}]`)
159
160
  return plugin.build()
160
161
  .then(pluginResult => {
161
162
  return Promise.resolve({
@@ -220,7 +221,11 @@ class BuildTaskEngine {
220
221
  const files = BuildTaskEngine._getOutput(plugins)
221
222
  if (files.length > 0) {
222
223
  const term = require('../util/term')
223
- this.logger.log(`done > wrote output to:\n ${term.secondary(files.join("\n "))}\n`)
224
+ if (!process.env.DEBUG && files.length > 20) {
225
+ files.length = 20
226
+ files.push('...')
227
+ }
228
+ console.log(`done > wrote output to:\n ${term.secondary(files.join("\n "))}\n`)
224
229
  }
225
230
  }
226
231
 
@@ -228,13 +233,13 @@ class BuildTaskEngine {
228
233
  const outputFile = cds.env.build.outputfile || process.env.GENERATION_LOG
229
234
  if (outputFile) {
230
235
  const files = BuildTaskEngine._getOutput(plugins)
231
- this.logger.log(`writing generation log to [${outputFile}]\n`)
236
+ console.log(`writing generation log to [${outputFile}]\n`)
232
237
  try {
233
238
  await fs.promises.mkdir(path.dirname(outputFile), { recursive: true })
234
239
  await fs.promises.writeFile(outputFile, files.join('\n'))
235
240
  } catch (error) {
236
- this.logger.error(`failed to write generation log`)
237
- this.logger.error(error.stack || error)
241
+ console.error(`failed to write generation log`)
242
+ console.error(error.stack || error)
238
243
  }
239
244
  }
240
245
  }
@@ -250,18 +255,18 @@ class BuildTaskEngine {
250
255
  }
251
256
 
252
257
  _logTimer(start, end) {
253
- this.logger.log(`build completed in ${end - start} ms\n`)
258
+ console.log(`build completed in ${end - start} ms\n`)
254
259
  }
255
260
 
256
261
  _logTaskHandler(plugin) {
257
- this.logger._debug && this.logger.debug(`plugin ${plugin.constructor.name}`)
258
- this.logger._debug && this.logger.debug(`details src [${relativePaths(cds.root, plugin.task.src)}], dest [${relativePaths(cds.root, plugin.task.dest)}], use [${plugin.task.use}], options [${JSON.stringify(plugin.task.options)}]`) //NOSONAR
262
+ DEBUG?.(`plugin ${plugin.constructor.name}`)
263
+ DEBUG?.(`details src [${relativePaths(cds.root, plugin.task.src)}], dest [${relativePaths(cds.root, plugin.task.dest)}], use [${plugin.task.use}], options [${JSON.stringify(plugin.task.options)}]`)
259
264
  }
260
265
 
261
266
  _logMessages(messages) {
262
267
  if (messages.length > 0) {
263
268
  const options = {
264
- log: this.logger.log,
269
+ log: console.log,
265
270
  "log-level": this._getLogLevel() // ensures that for tests the correct cds.env is used
266
271
  }
267
272
  deduplicateMessages(messages)
@@ -2,9 +2,10 @@ const fs = require('fs')
2
2
  const path = require('path')
3
3
  const cds = require('../cds')
4
4
  const BuildTaskProviderFactory = require('./buildTaskProviderFactory')
5
- const { hasJavaNature, getProperty, redactCredentials, flatten, getDefaultModelOptions } = require('./util')
5
+ const { hasJavaNature, getProperty, flatten, getDefaultModelOptions } = require('./util')
6
6
  const { FILE_EXT_CDS, BUILD_TASK_JAVA_CF, BUILD_TASK_JAVA } = require("./constants")
7
7
  const term = require('../util/term')
8
+ const DEBUG = cds.debug('cli|build')
8
9
 
9
10
  class BuildTaskFactory {
10
11
  constructor(options) {
@@ -13,9 +14,6 @@ class BuildTaskFactory {
13
14
  get providerFactory() {
14
15
  return this._providerFactory
15
16
  }
16
- get logger() {
17
- return this.providerFactory.logger
18
- }
19
17
  get options() {
20
18
  return this.providerFactory.options
21
19
  }
@@ -33,11 +31,7 @@ class BuildTaskFactory {
33
31
  tasksOutput += " " + BuildTaskFactory._stringifyTask(tasks[i]) + (i + 1 < tasks.length ? ",\n" : "\n")
34
32
  }
35
33
  tasksOutput += " ]\n }\n}\n"
36
- this.logger.log(tasksOutput)
37
-
38
- // for testing purposes
39
- this.logger.debug("cds.env used for build:")
40
- this.logger._debug && this.logger.debug(redactCredentials(cds.env))
34
+ console.log(tasksOutput)
41
35
 
42
36
  // always resolve tasks for input validation
43
37
  const resolvedTasks = this.providerFactory.resolveTasks(tasks)
@@ -52,7 +46,7 @@ class BuildTaskFactory {
52
46
  }
53
47
 
54
48
  async _createTasks() {
55
- this.logger.debug(`determining build tasks for project [${cds.root}].`)
49
+ DEBUG?.(`determining build tasks for project [${cds.root}].`)
56
50
 
57
51
  // clearing model cache (details https://github.tools.sap/cap/cds/pull/181) is no longer required
58
52
  // because of changes https://github.tools.sap/cap/cds/pull/1121
@@ -118,7 +112,7 @@ class BuildTaskFactory {
118
112
 
119
113
  // Java projects use "." as the default build target folder
120
114
  if (hasJavaNature([path.join(cds.root, srv), cds.root]) && BuildTaskFactory._adaptBuildTargetSettingForJava()) {
121
- this.logger.debug("using inplace build for java project instead of default staging build")
115
+ DEBUG?.("using inplace build for java project instead of default staging build")
122
116
  }
123
117
  }
124
118
 
@@ -201,31 +195,31 @@ class BuildTaskFactory {
201
195
  return keys.reduce((acc, key, i) => {
202
196
  const prefix = acc !== '{' ? ', ' : (i === 0 ? ' ' : '')
203
197
  if (!key.startsWith('_')) {
204
- // render either "for" OR "use" value
205
- if (key in { src: 1, for: 1 } || (!task.for && key === 'use')) {
206
- return `${acc}${prefix}${key}: ${term.info(`'${task[key]}'`)}`
207
- } else if (key === 'options') {
208
- const options = Object.entries(task.options)
209
- .map(([key, value]) => {
210
- if (Array.isArray(value)) {
211
- return `${key}: [${value.map(v => term.info(`'${v}'`)).join(', ')}]`
212
- } else if (typeof value === 'object') {
213
- const nested = Object.entries(value)
214
- .map(([key, value]) => `${key}: ${term.info(`'${value}'`)}`)
198
+ // render either "for" OR "use" value
199
+ if (key in { src: 1, for: 1 } || (!task.for && key === 'use')) {
200
+ return `${acc}${prefix}${key}: ${term.info(`'${task[key]}'`)}`
201
+ } else if (key === 'options') {
202
+ const options = Object.entries(task.options)
203
+ .map(([key, value]) => {
204
+ if (Array.isArray(value)) {
205
+ return `${key}: [${value.map(v => term.info(`'${v}'`)).join(', ')}]`
206
+ } else if (typeof value === 'object') {
207
+ const nested = Object.entries(value)
208
+ .map(([key, value]) => `${key}: ${term.info(`'${value}'`)}`)
209
+ .join(', ')
210
+ return `${key}: { ${nested} }`
211
+ } else {
212
+ return `${key}: ${term.info(`'${value}'`)}`
213
+ }
214
+ })
215
215
  .join(', ')
216
- return `${key}: { ${nested} }`
217
- } else {
218
- return `${key}: ${term.info(`'${value}'`)}`
219
- }
220
- })
221
- .join(', ')
222
- return `${acc}${prefix}${key}: { ${options} }`
223
- } else if (key !== 'use') {
224
- return `${acc}${prefix}${key}: ${term.info(`'${task[key]}'`)}`
225
- }
216
+ return `${acc}${prefix}${key}: { ${options} }`
217
+ } else if (key !== 'use') {
218
+ return `${acc}${prefix}${key}: ${term.info(`'${task[key]}'`)}`
219
+ }
226
220
  }
227
221
  return acc
228
- }, '{') + '}'
222
+ }, '{') + '}'
229
223
  }
230
224
 
231
225
  static _scanTaskOptionParams(optsParams) {
@@ -14,7 +14,7 @@ module.exports = class BuildTaskProvider {
14
14
  /**
15
15
  * @param {object} task
16
16
  */
17
- getPluginClass(task) { }
17
+ getPlugin(task) { }
18
18
  /**
19
19
  * @param {Array} tasks
20
20
  * @param {boolean} dependencies