@sap/cds-dk 9.7.2 → 9.8.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 (105) hide show
  1. package/CHANGELOG.md +42 -2
  2. package/bin/bind.js +7 -2
  3. package/bin/build.js +14 -4
  4. package/bin/cds.js +2 -2
  5. package/bin/completion/completionFs.js +1 -1
  6. package/bin/completion/index.js +2 -2
  7. package/bin/data-products/get-csn-via-dp-cli.js +1 -1
  8. package/bin/debug.js +1 -1
  9. package/bin/deploy/index.js +3 -2
  10. package/bin/gen.js +1 -1
  11. package/bin/help.js +1 -1
  12. package/bin/import.js +3 -0
  13. package/bin/minify.js +1 -1
  14. package/bin/mock.js +1 -1
  15. package/bin/repl.js +212 -39
  16. package/bin/test.js +0 -2
  17. package/bin/up.js +27 -3
  18. package/bin/util/containerize.js +1 -3
  19. package/bin/version.js +30 -9
  20. package/bin/watch.js +20 -4
  21. package/lib/bind/cf.js +2 -2
  22. package/lib/bind/k8s.js +0 -1
  23. package/lib/bind/plugin.js +2 -0
  24. package/lib/bind/shared.js +6 -1
  25. package/lib/build/constants.js +0 -8
  26. package/lib/build/index.js +569 -25
  27. package/lib/build/{provider/edmxBuildPlugin.js → plugins/edmx.js} +6 -15
  28. package/lib/build/{provider/featureToggleBuildPlugin.js → plugins/featureToggles.js} +8 -27
  29. package/lib/build/{provider → plugins}/fiori/index.js +27 -40
  30. package/lib/build/{provider → plugins}/hana/index.js +67 -85
  31. package/lib/build/{provider → plugins}/hana/migrationtable.js +4 -3
  32. package/lib/build/plugins/helm/index.js +6 -6
  33. package/lib/build/{provider/internalBuildPlugin.js → plugins/internal.js} +7 -31
  34. package/lib/build/{provider → plugins}/java/index.js +18 -26
  35. package/lib/build/plugins/mtx/index.js +41 -0
  36. package/lib/build/plugins/mtx/resourcesTarBuilder.js +41 -0
  37. package/lib/build/{provider → plugins}/mtx-extension/extensionCompilation.js +1 -1
  38. package/lib/build/{provider → plugins}/mtx-extension/index.js +35 -44
  39. package/lib/build/{provider → plugins}/mtx-sidecar/index.js +17 -3
  40. package/lib/build/{provider → plugins}/nodejs/index.js +29 -28
  41. package/lib/build/{plugin.js → plugins/plugin.js} +57 -60
  42. package/lib/build/plugins.js +11 -8
  43. package/lib/build/util.js +0 -8
  44. package/lib/compile/to-xsuaa.js +2 -2
  45. package/lib/deploy/to-hana/hana.js +64 -56
  46. package/lib/import/common.js +1 -1
  47. package/lib/import/odata/metadataconverter/MetadataConverter.js +4 -3
  48. package/lib/import/odata/v2parser.js +28 -28
  49. package/lib/import/odata/v4parser.js +37 -2
  50. package/lib/import/openapi/index.js +1 -1
  51. package/lib/init/constants.js +1 -2
  52. package/lib/init/template/app-frontend/index.js +1 -1
  53. package/lib/init/template/approuter/files/package.json +1 -1
  54. package/lib/init/template/completion/completionSetup.js +1 -1
  55. package/lib/init/template/data/as-csv.js +1 -1
  56. package/lib/init/template/github-actions/index.js +1 -1
  57. package/lib/init/template/handler/index.js +1 -1
  58. package/lib/init/template/helm/index.js +4 -4
  59. package/lib/init/template/kyma/index.js +3 -3
  60. package/lib/init/template/lint/index.js +7 -21
  61. package/lib/init/template/multitenancy/files/package.json.hbs +0 -5
  62. package/lib/init/template/postgres/files/containerize.yaml.hbs +15 -0
  63. package/lib/init/template/postgres/files/package.json.hbs +35 -0
  64. package/lib/init/template/postgres/files/values.yaml.hbs +23 -0
  65. package/lib/init/template/postgres/index.js +34 -9
  66. package/lib/init/template/test/files/package.json +1 -1
  67. package/lib/init/template/typescript/files/package.json +1 -1
  68. package/lib/init/template/workzone-standard/files/mta.yaml.hbs +1 -0
  69. package/lib/lint/eslintHelp.json +1 -1
  70. package/lib/lint/io.js +9 -13
  71. package/lib/mtx/pull.js +1 -1
  72. package/lib/mtx/settings_manager.js +11 -5
  73. package/lib/mtx/tenant_action.js +1 -1
  74. package/lib/mtx/util/fs.js +2 -2
  75. package/lib/util/fs.js +3 -3
  76. package/lib/util/git.js +1 -1
  77. package/lib/util/glob.js +1 -1
  78. package/lib/watch/hot-reload.js +202 -0
  79. package/lib/watch/livereload-server.js +6 -4
  80. package/lib/watch/node-watch.js +5 -1
  81. package/lib/watch/watched.js +7 -3
  82. package/lib/watch/watcher.js +41 -3
  83. package/npm-shrinkwrap.json +46 -31
  84. package/package.json +1 -1
  85. package/lib/build/buildTaskEngine.js +0 -377
  86. package/lib/build/buildTaskFactory.js +0 -198
  87. package/lib/build/buildTaskProvider.js +0 -38
  88. package/lib/build/buildTaskProviderFactory.js +0 -233
  89. package/lib/build/provider/internalBuildTaskProvider.js +0 -227
  90. package/lib/build/provider/java-cf/index.js +0 -1
  91. package/lib/build/provider/mtx/index.js +0 -36
  92. package/lib/build/provider/mtx/resourcesTarBuilder.js +0 -102
  93. package/lib/build/provider/node-cf/index.js +0 -1
  94. package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +0 -40
  95. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/fixed/schema.cds +0 -4
  96. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/invalid/schema.cds +0 -4
  97. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/rule.test.js +0 -15
  98. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/valid/schema.cds +0 -6
  99. package/lib/init/types.d.ts +0 -23
  100. /package/lib/build/{provider → plugins}/hana/2migration.js +0 -0
  101. /package/lib/build/{provider → plugins}/hana/template/.hdiconfig-all +0 -0
  102. /package/lib/build/{provider → plugins}/hana/template/.hdiconfig-cloud +0 -0
  103. /package/lib/build/{provider → plugins}/hana/template/.hdinamespace +0 -0
  104. /package/lib/build/{provider → plugins}/hana/template/package.json +0 -0
  105. /package/lib/build/{provider → plugins}/hana/template/undeploy.json +0 -0
package/bin/version.js CHANGED
@@ -7,13 +7,15 @@ module.exports = exports = async function cds_version (pattern, options) {
7
7
  java_versions(o),
8
8
  ])
9
9
  print_versions (all.flat(),o)
10
- if (o.info) console.log ('\n','> Project:', project_info (o))
11
- if (o._elsp) console.log ('\n', `${RED}ELSPROBLEMS${RESET} reported by ${BOLD}npm ls${RESET}. Run ${BOLD}npm install${RESET} to fix dependency problems, then rerun ${BOLD}cds version${RESET}.`)
10
+ if (!o.json) {
11
+ if (o.info) console.log ('\n','> Project:', project_info (o))
12
+ if (o._elsp) console.log ('\n', `${RED}ELSPROBLEMS${RESET} reported by ${BOLD}npm ls${RESET}. Run ${BOLD}npm install${RESET} to fix dependency problems, then rerun ${BOLD}cds version${RESET}.`)
13
+ }
12
14
  console.log()
13
15
  }
14
16
 
15
17
  exports.options = [ '--depth', '--omit' ]
16
- exports.flags = [ '--info', '--markdown', '--abs', '--all' ]
18
+ exports.flags = [ '--info', '--markdown', '--abs', '--all', '--json' ]
17
19
  exports.shortcuts = [ '-d', '-o', '-i', '-m', '-a' ]
18
20
  exports.help = `
19
21
  # SYNOPSIS
@@ -89,7 +91,7 @@ const $npm_ls = (cmd,..._) => {
89
91
 
90
92
  const cds = require('../lib')
91
93
  const home = require('os').homedir()
92
- const cap_packages = /@sap\/cds|@cap-js\//
94
+ const cap_packages = /@sap\/[\w-]*\bcds\b|@cap-js\//
93
95
  const { GREEN, YELLOW, RED, DIMMED, BOLD, RESET } = cds.utils.colors
94
96
  const { join, dirname } = require ('node:path')
95
97
 
@@ -98,6 +100,7 @@ function canonic_options4 ([pattern], options) {
98
100
  const o = {
99
101
  root: cds.root,
100
102
  depth: options.all ? 11 : 1,
103
+ java: cds.env['project-nature'] === 'java',
101
104
  ...options,
102
105
  }
103
106
  if (pattern) o.pattern = pattern
@@ -126,7 +129,7 @@ async function node_versions(o) {
126
129
  const _pkg = o.pattern ? RegExp(o.pattern) : cap_packages
127
130
  const deps = lines.map (line => {
128
131
  let [, path, name, version, location = path ] = _line.exec(line) || []
129
- if (!location || location.includes('EXTRANEOUS')) return
132
+ if (!location || (location.includes('EXTRANEOUS') && !o.java)) return
130
133
  if (name.match(_pkg)) return [ name, version, location ]
131
134
  }) .filter (x => x)
132
135
 
@@ -172,9 +175,9 @@ async function node_versions(o) {
172
175
 
173
176
 
174
177
  function java_versions (o) {
175
- const javaInfo = !cds.env.cli?.version?.skipjava && cds.env['project-nature'] === 'java'
178
+ const javaInfo = !cds.env.cli?.version?.skipjava && o.java
176
179
  if (!javaInfo) return []
177
- else if (process.stderr.isTTY) console.warn (DIMMED, 'This takes a while. Collecting Java versions...', RESET)
180
+ else if (process.stderr.isTTY && !o.json) console.warn (DIMMED, 'This takes a while. Collecting Java versions...', RESET)
178
181
  const { MAVEN_ARCHETYPE_VERSION:mav } = require ('../lib/init/constants')
179
182
  const cmd = `mvn com.sap.cds:cds-maven-plugin:${mav}:version -B -ntp -Dcds.version.excludeCds -Dcds.version.json`
180
183
  try {
@@ -199,17 +202,26 @@ function project_info (o) {
199
202
 
200
203
 
201
204
  function print_versions (rows, o, cwd = o.root+'/') {
205
+ if (o.json) {
206
+ const json = rows?.reduce((acc, [name, version, location]) => {
207
+ acc[name] = {}
208
+ if (version) acc[name].version = version
209
+ if (location) acc[name].location = location
210
+ return acc
211
+ }, {})
212
+ return console.log(JSON.stringify(json||{}, null, 2))
213
+ }
202
214
 
203
215
  if (!rows || rows.length === 0) return console.error (YELLOW, ' No CAP packages found.', RESET)
204
- const local = o.abs ? p => p : p => !p ? '' : p.startsWith(cwd) ? p.replace(cwd,'./') : p.replace(home,'~')
205
216
 
206
217
  // cds10: remove and offer --json option instead
207
- if (cds.env['project-nature'] === 'java' || process.env.WS_BASE_URL) {
218
+ if (process.env.WS_BASE_URL || o.java || findPom(cwd)) {
208
219
  console.log(rows.map(([name,version,location]) => `${GREEN}${name === 'cds.home'?'home':name}:${RESET} ${version??location}`).join('\n'))
209
220
  return
210
221
  }
211
222
 
212
223
  // compute column widths for tabular printing
224
+ const local = o.abs ? p => p : p => !p ? '' : p.startsWith(cwd) ? p.replace(cwd,'./') : p.replace(home,'~')
213
225
  const header = o.markdown && [ 'Package', 'Version', 'Location' ]
214
226
  const all = Object.values(rows); if (header) all.push (header)
215
227
  const w1 = Math.max (...all.map(s => s[0]?.length || 0))
@@ -236,3 +248,12 @@ function print_versions (rows, o, cwd = o.root+'/') {
236
248
  const colored = [ GREEN, YELLOW, DIMMED ]
237
249
  for (let each of rows) print (each, colored)
238
250
  }
251
+
252
+ const { existsSync } = require('fs')
253
+ function findPom (dir) {
254
+ if (!dir || dir === '/' || dir === '.') return false
255
+ if (existsSync(join(dir,'pom.xml'))) return true
256
+ const parent = dirname(dir)
257
+ if (parent === dir) return false // reached filesystem root
258
+ return findPom(parent)
259
+ }
package/bin/watch.js CHANGED
@@ -1,4 +1,4 @@
1
- const watchOnlyOptions = ['--ext', '--livereload', '--open', '--debug', '--inspect', '--inspect-brk', '--include', '--exclude']
1
+ const watchOnlyOptions = ['--ext', '--livereload', '--experimental-hot-reload', '--open', '--debug', '--inspect', '--inspect-brk', '--include', '--exclude']
2
2
 
3
3
  module.exports = Object.assign ( watch, {
4
4
  flags: [ '--in-memory', '--in-memory?', '--with-mocks', '--with-mtx' ],
@@ -41,6 +41,11 @@ module.exports = Object.assign ( watch, {
41
41
  Specify the port for the livereload server. Defaults to '35729'.
42
42
  Disable it with value _false_.
43
43
 
44
+ *--experimental-hot-reload* <true | false>
45
+
46
+ Specify if the experimental hot reload should be used. Changes to the CDS model
47
+ in most scenarios no longer restart the server
48
+
44
49
  *--open* <url>
45
50
 
46
51
  Open the given URL (suffix) in the browser after starting.
@@ -85,7 +90,8 @@ const ignoreDefaults = [
85
90
  /_out/,
86
91
  /@types/,
87
92
  /@cds-models/,
88
- new RegExp(`app${escapedSep}.+?${escapedSep}webapp${escapedSep}`),
93
+ new RegExp(`app${escapedSep}.+?${escapedSep}webapp`),
94
+ new RegExp(`app${escapedSep}.+?${escapedSep}.*\\.json`),
89
95
  new RegExp(`app${escapedSep}.+?${escapedSep}dist${escapedSep}`),
90
96
  new RegExp(`app${escapedSep}.+?${escapedSep}target${escapedSep}`),
91
97
  new RegExp(`app${escapedSep}.+?${escapedSep}tsconfig\\.json$`),
@@ -119,12 +125,15 @@ async function watch ([cwd], {
119
125
  if (fs.existsSync(cwd)) cwd = resolve (cwd)
120
126
  else try { // try module name like `@capire/bookshop`
121
127
  cwd = require.resolve (cwd+'/package.json', {paths:[ ocwd ]}).slice(0,-13)
122
- } catch (err) { throw `Error: No such folder or package: '${cwd}'` }
128
+ } catch { throw `Error: No such folder or package: '${cwd}'` }
123
129
  log (`cd ${relative(ocwd,cwd)}`)
124
130
  }
125
131
  else cwd = cds.root
126
132
 
127
- if (isJava) options.livereload = false
133
+ if (isJava) {
134
+ options.livereload = false
135
+ options['experimental-hot-reload'] = false
136
+ }
128
137
  if (!isJava) log (`\n${t.bold}cds ${args.join(' ')}`)
129
138
 
130
139
  const env = Object.assign (process.env, {
@@ -198,6 +207,13 @@ async function watch ([cwd], {
198
207
  delete options.open
199
208
  break
200
209
  case 'EADDRINUSE': env.PORT = 0; _addr_in_use(msg); break
210
+ case 'model-refreshed':
211
+ case 'refreshModel':
212
+ liveReload?.reload()
213
+ break;
214
+ case 'restart':
215
+ watcher.restart()
216
+ break;
201
217
  default: console.error (msg)
202
218
  }})
203
219
 
package/lib/bind/cf.js CHANGED
@@ -74,8 +74,8 @@ module.exports = new class CFBind extends require('./plugin') {
74
74
  orgGuid = sharedFromOrgObj.guid;
75
75
  }
76
76
  }
77
- } catch (error) {
78
- throw `service instance ${bold(instance)} not found.`;
77
+ } catch {
78
+ throw `service instance ${bold(instance)} not found in the currently targeted Cloud Foundry space`
79
79
  }
80
80
  switch (instanceObj.type) {
81
81
  case 'managed':
package/lib/bind/k8s.js CHANGED
@@ -81,7 +81,6 @@ module.exports = new class K8SBind extends require('./plugin') {
81
81
  )
82
82
 
83
83
  // REVISIT: Proper API
84
- // eslint-disable-next-line cds-dk/use-relative-require, cds-dk/use-api-require
85
84
  const serviceBinding = require('@sap/cds/lib/env/serviceBindings').parseBinding('/', name, properties)
86
85
  const { credentials } = serviceBinding
87
86
  const vcap = { ...serviceBinding, credentials: undefined }
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-unused-vars */
2
+
1
3
  module.exports = class BindPlugin {
2
4
 
3
5
  /**
@@ -3,6 +3,7 @@ const cds = require('../cds')
3
3
  const { exists, read, fs, path } = cds.utils
4
4
  const git = require('../util/git')
5
5
  const { bold } = require('../util/term')
6
+ const { readProject } = require('../init/projectReader')
6
7
 
7
8
  // REVISIT: We should get rid of this...
8
9
  const KindToRequiresNameMap = {
@@ -36,7 +37,11 @@ const PreferredKinds = {
36
37
  'saas-registry': 1
37
38
  }
38
39
 
39
- async function bind(options = { on: 'cf' }) {
40
+ async function bind(options = {}) {
41
+ const { hasKyma, hasMta } = readProject()
42
+ const onKyma = cds.cli.options.on === 'k8s' || (hasKyma && !hasMta && cds.cli.options.on !== 'cf')
43
+ options.on = onKyma ? 'k8s' : 'cf'
44
+
40
45
  let on
41
46
  switch (options.on) {
42
47
  case 'k8s':
@@ -1,8 +1,3 @@
1
- exports.OUTPUT_MODE = "outputMode"
2
- exports.OUTPUT_MODE_NONE = 0x0
3
- exports.OUTPUT_MODE_FILESYSTEM = 0x1
4
- exports.OUTPUT_MODE_RESULT = 0x2
5
-
6
1
  exports.DEFAULT_SRC_FOLDER = '.'
7
2
  exports.BUILD_TASK_JAVA = "java"
8
3
  exports.BUILD_TASK_JAVA_CF = "java-cf"
@@ -13,9 +8,6 @@ exports.BUILD_TASK_FIORI = "fiori"
13
8
  exports.BUILD_TASK_MTX = "mtx"
14
9
  exports.BUILD_TASK_MTX_SIDECAR = "mtx-sidecar"
15
10
  exports.BUILD_TASK_MTX_EXTENSION = "mtx-extension"
16
- exports.BUILD_TASKS = [this.BUILD_TASK_JAVA, this.BUILD_TASK_JAVA_CF, this.BUILD_TASK_NODEJS, this.BUILD_TASK_NODE_CF, this.BUILD_TASK_HANA, this.BUILD_TASK_FIORI, this.BUILD_TASK_MTX, this.BUILD_TASK_MTX_SIDECAR, this.BUILD_TASK_MTX_EXTENSION]
17
- exports.DEFAULT_BUILTIN_PRIORITY_MIN = 0
18
- exports.DEFAULT_BUILTIN_PRIORITY_MAX = 524
19
11
 
20
12
  exports.ODATA_VERSION_V2 = "v2"
21
13
  exports.ODATA_VERSION_V4 = "v4"