@sap/cds-dk 8.9.5 → 9.0.5

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 (109) hide show
  1. package/CHANGELOG.md +101 -2012
  2. package/LICENSE +15 -21
  3. package/bin/bind.js +1 -1
  4. package/bin/build.js +35 -37
  5. package/bin/cds.js +13 -30
  6. package/bin/compile/index.js +2 -2
  7. package/bin/debug.js +27 -7
  8. package/bin/deploy/index.js +6 -23
  9. package/bin/deploy/to-hana.js +4 -2
  10. package/bin/help.js +5 -3
  11. package/bin/init.js +1 -1
  12. package/bin/up.js +45 -12
  13. package/bin/watch.js +45 -63
  14. package/lib/bind/cf.js +2 -1
  15. package/lib/bind/k8s.js +2 -2
  16. package/lib/bind/plugin.js +1 -1
  17. package/lib/bind/shared.js +16 -25
  18. package/lib/build/buildTaskEngine.js +26 -10
  19. package/lib/build/buildTaskFactory.js +3 -2
  20. package/lib/build/buildTaskProvider.js +18 -7
  21. package/lib/build/buildTaskProviderFactory.js +35 -13
  22. package/lib/build/constants.js +4 -0
  23. package/lib/build/index.js +1 -1
  24. package/lib/build/plugin.js +89 -54
  25. package/lib/build/plugins/helm/files/subcharts/web-application/Chart.yaml +3 -1
  26. package/lib/build/plugins/helm/files/subcharts/web-application/templates/_helpers.tpl +4 -2
  27. package/lib/build/plugins/helm/files/subcharts/web-application/templates/api-rule.yaml +4 -2
  28. package/lib/build/plugins/helm/files/subcharts/web-application/templates/deployment.yaml +18 -1
  29. package/lib/build/plugins/helm/files/subcharts/web-application/templates/service-binding.yaml +0 -1
  30. package/lib/build/plugins/helm/files/subcharts/web-application/values.schema.json +34 -2
  31. package/lib/build/plugins/helm/files/subcharts/web-application/values.yaml +9 -2
  32. package/lib/build/plugins/helm/index.js +2 -1
  33. package/lib/build/plugins.js +24 -10
  34. package/lib/build/provider/edmxBuildPlugin.js +1 -11
  35. package/lib/build/provider/fiori/index.js +4 -4
  36. package/lib/build/provider/hana/index.js +12 -5
  37. package/lib/build/provider/hana/template/package.json +1 -1
  38. package/lib/build/provider/internalBuildPlugin.js +1 -1
  39. package/lib/build/provider/internalBuildTaskProvider.js +3 -24
  40. package/lib/build/provider/java/index.js +1 -1
  41. package/lib/build/provider/mtx-extension/index.js +15 -8
  42. package/lib/build/provider/nodejs/index.js +28 -6
  43. package/lib/build/util.js +186 -125
  44. package/lib/deploy/index.js +5 -0
  45. package/lib/deploy/to-hana/hana.js +27 -33
  46. package/lib/deploy/to-hana/hdiDeployUtil.js +2 -2
  47. package/lib/import/odata/v2parser.js +34 -3
  48. package/lib/import/openapi/importOpenAPI.js +4 -0
  49. package/lib/index.js +2 -11
  50. package/lib/init/constants.js +1 -2
  51. package/lib/init/merge.js +101 -77
  52. package/lib/init/mvn.js +3 -3
  53. package/lib/init/projectReader.js +1 -1
  54. package/lib/init/template/ams/files/mta.yaml.hbs +6 -1
  55. package/lib/init/template/ams/files/package.json.hbs +1 -1
  56. package/lib/init/template/approuter/files/mta.yaml.hbs +5 -0
  57. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +1 -1
  58. package/lib/init/template/cloud-logging/files/package.json.hbs +3 -3
  59. package/lib/init/template/data/as-json.js +3 -3
  60. package/lib/init/template/dynatrace/files/mta.yaml.hbs +1 -1
  61. package/lib/init/template/dynatrace/files/package.json.hbs +2 -2
  62. package/lib/init/template/dynatrace/index.js +2 -1
  63. package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +6 -0
  64. package/lib/init/template/enterprise-messaging/index.js +5 -1
  65. package/lib/init/template/extensibility/files/package.json.hbs +1 -1
  66. package/lib/init/template/hana/files/db/package.json +1 -1
  67. package/lib/init/template/hana/files/package.json.hbs +2 -4
  68. package/lib/init/template/hana/index.js +2 -2
  69. package/lib/init/template/handler/index.js +16 -12
  70. package/lib/init/template/helm/index.js +13 -22
  71. package/lib/init/template/helm-unified-runtime/index.js +2 -1
  72. package/lib/init/template/html5-repo/files/values.yaml.hbs +12 -1
  73. package/lib/init/template/html5-repo/index.js +10 -5
  74. package/lib/init/template/http/index.js +1 -1
  75. package/lib/init/template/ias/files/mta.yaml.hbs +1 -1
  76. package/lib/init/template/ias/files/sidecar.package.json.hbs +0 -7
  77. package/lib/init/template/ias/index.js +5 -4
  78. package/lib/init/template/lint/files/package.json +6 -0
  79. package/lib/init/template/lint/index.js +61 -204
  80. package/lib/init/template/mta/files/package.json +1 -1
  81. package/lib/init/template/multitenancy/files/mta.yaml.hbs +2 -2
  82. package/lib/init/template/multitenancy/files/package.json.hbs +1 -1
  83. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +7 -4
  84. package/lib/init/template/multitenancy/index.js +3 -0
  85. package/lib/init/template/nodejs/files/package.json.hbs +6 -3
  86. package/lib/init/template/postgres/files/package.json.hbs +1 -1
  87. package/lib/init/template/redis/files/package.json.hbs +1 -1
  88. package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +6 -0
  89. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +1 -0
  90. package/lib/init/template/sample/files/app/browse/fiori-service.cds +3 -2
  91. package/lib/init/template/sample/files/app/common.cds +0 -11
  92. package/lib/init/template/sqlite/files/package.json +1 -1
  93. package/lib/init/template/toggles/files/package.json.hbs +1 -1
  94. package/lib/init/template/typescript/files/package.json +2 -4
  95. package/lib/init/template/workzone-standard/index.js +2 -0
  96. package/lib/init/template/xsuaa/index.js +2 -6
  97. package/lib/lint/Linter.js +203 -331
  98. package/lib/lint/generators.js +52 -46
  99. package/lib/lint/io.js +77 -289
  100. package/lib/util/fs.js +2 -1
  101. package/lib/util/git.js +1 -1
  102. package/lib/util/glob.js +77 -0
  103. package/lib/watch/livereload-server.js +3 -4
  104. package/lib/watch/node-watch.js +3 -4
  105. package/lib/watch/watched.js +1 -1
  106. package/npm-shrinkwrap.json +200 -858
  107. package/package.json +6 -8
  108. package/readme.md +1 -1
  109. package/lib/lint/checks.js +0 -135
@@ -0,0 +1,77 @@
1
+ const path = require('node:path');
2
+ const { join } = path;
3
+ const { existsSync } = require('node:fs');
4
+ const { readdir } = require('node:fs').promises;
5
+
6
+ /**
7
+ * Returns an AsyncIterator of those (recursive) subdirectories that match the glob pattern.
8
+ * @param pattern - The glob pattern to match against.
9
+ * @param cwd - The current working directory to start the search from.
10
+ * @returns {AsyncIterator<string>} - An array of relative paths that match the glob pattern.
11
+ */
12
+ async function* glob(pattern, { cwd } = { cwd: process.cwd() }) {
13
+ if (/\{.*}/.test(pattern)) {
14
+ // We rely on the native Node.js glob support for brace expansion.
15
+ const { glob: globNative } = require('node:fs/promises');
16
+ if (!globNative) {
17
+ throw `Glob pattern '${pattern} requires native Node.js glob support to resolve, which is available in Node.js version 22, but project uses ${process.version}.`
18
+ }
19
+ return globNative(pattern, { cwd });
20
+ }
21
+ yield* (await globArray(pattern, { cwd }));
22
+ }
23
+
24
+ /**
25
+ * Returns those subdirectories, recursively, that match the glob pattern.
26
+ * @param pattern - The glob pattern to match against.
27
+ * @param cwd - The current working directory to start the search from.
28
+ * @returns {Promise<string[]>} - An array of relative paths that match the glob pattern.
29
+ */
30
+ async function globArray(pattern, { cwd }) {
31
+ const regex = globToRegex(pattern);
32
+ return (await subdirs(cwd))
33
+ .map(fullPath => path.relative(cwd, fullPath))
34
+ .filter(relativePath => regex.test(relativePath));
35
+ }
36
+
37
+ /**
38
+ * Recursively returns all subdirectories of a given directory.
39
+ * Returns only non-hidden directories (those not starting with a dot).
40
+ * @param {import('fs').PathLike} dir - The directory to search in.
41
+ * @returns {Promise<String[]>} - An array of paths to subdirectories.
42
+ */
43
+ async function subdirs(dir) {
44
+ if (!existsSync(dir)) return [];
45
+ const children = (await readdir(dir, { withFileTypes: true }))
46
+ .filter(child => child.isDirectory() && !child.name.startsWith('.'));
47
+ return (await Promise.all(
48
+ children.map(async child => {
49
+ const childPath = join(dir, child.name);
50
+ const descendants = await subdirs(childPath);
51
+ return [childPath, ...descendants];
52
+ })
53
+ )).flat();
54
+ }
55
+
56
+ /**
57
+ * Converts a glob pattern to a regular expression.
58
+ * Supports the following wildcards: `? * ** [...] [!...]`.
59
+ * Patterns such as `./foo` are normalized to `foo`.
60
+ * @param {string} glob - The glob pattern to convert.
61
+ * @returns {RegExp} - The regular expression that matches the glob pattern.
62
+ */
63
+ function globToRegex(glob) {
64
+ const regex = glob
65
+ .replace(/^\.\//, '')
66
+ .replaceAll('**', '|')
67
+ .replaceAll(/\[!([^\]]+)]/g, '[^$1]')
68
+ .replaceAll('?', '[^/]')
69
+ .replaceAll('*', '[^/]*')
70
+ .replaceAll('|', '.*');
71
+
72
+ return new RegExp(`^${regex}$`);
73
+ }
74
+
75
+ module.exports = {
76
+ glob
77
+ };
@@ -1,5 +1,4 @@
1
- const cds = require('../cds')
2
- const LOG = cds.log('cli|watch|livereload'), DEBUG = cds.debug('cli|watch|livereload')
1
+ const DEBUG = /\b(y|all|cli|watch|livereload)\b/.test (process.env.DEBUG) ? ((..._) => console.debug ('[cli] -', ..._)) : undefined
3
2
 
4
3
  const axios = require('axios')
5
4
  const ws = require('ws')
@@ -70,7 +69,7 @@ module.exports = class LiveReload {
70
69
  }
71
70
  })
72
71
  })
73
- if (LOG._debug) {
72
+ if (DEBUG) {
74
73
  server.on('close', () => DEBUG('⚡️','cds watch - livereload closed'))
75
74
  this.wsServer.on('close', () => DEBUG('⚡️','cds watch - web socket closed'))
76
75
  this.wsServer.on('error', (e) => DEBUG(e))
@@ -92,7 +91,7 @@ module.exports = class LiveReload {
92
91
  return isIn
93
92
  }
94
93
  const watcher = watch (cwd||process.cwd(),{ recursive:true, filter, delay:0 })
95
- if (LOG._debug) watcher.on('close', ()=> DEBUG('⚡️', 'cds watch - livereload file watcher closed'))
94
+ if (DEBUG) watcher.on('close', ()=> DEBUG('⚡️', 'cds watch - livereload file watcher closed'))
96
95
  watcher.on('change', _coalesceEvents(delay, (files) => {
97
96
  DEBUG?. (`livereload for: ${files.map(f => f.name)}`)
98
97
  this.markPending(files.map(f => f.name))
@@ -1,5 +1,4 @@
1
- const cds = require ('../cds')
2
- const LOG = cds.log('cli|watch'), DEBUG = cds.debug('cli|watch')
1
+ const DEBUG = /\b(y|all|cli|watch)\b/.test (process.env.DEBUG) ? ((..._) => console.debug ('[cli] -', ..._)) : undefined
3
2
  const { relative } = require('path')
4
3
 
5
4
  module.exports = ({ cwd = process.cwd(), script, ext, ignore=RegExp(), watched, env={}, delay=200, options={} })=>{
@@ -59,7 +58,7 @@ module.exports = ({ cwd = process.cwd(), script, ext, ignore=RegExp(), watched,
59
58
  return isIn
60
59
  }
61
60
  const watcher = watch (watched,{ recursive:true, filter, delay:0 })
62
- if (LOG._debug) watcher.on('close', ()=> DEBUG('⚡️', 'cds watch - file watcher closed'))
61
+ if (DEBUG) watcher.on('close', ()=> DEBUG('⚡️', 'cds watch - file watcher closed'))
63
62
  watcher.on('change', restart)
64
63
  process.on('shutdown', ()=> watcher.close())
65
64
 
@@ -74,7 +73,7 @@ module.exports = ({ cwd = process.cwd(), script, ext, ignore=RegExp(), watched,
74
73
  else if (input === 'bye' || input.match(/^n$/i)) { _kill (child) }
75
74
  else console.log ('?\n')
76
75
  })
77
- if (LOG._debug) readline.on('close', ()=> DEBUG('⚡️', 'cds watch - readline closed'))
76
+ if (DEBUG) readline.on('close', ()=> DEBUG('⚡️', 'cds watch - readline closed'))
78
77
  process.on('shutdown', ()=> readline.close())
79
78
 
80
79
  emitter.restart = restart
@@ -26,7 +26,7 @@
26
26
  }}
27
27
 
28
28
  function _no_models_found(e) { console.log (`
29
- No models found in ${cds.resolve(e.model||'*',false)}.
29
+ No models found in ${e.locations||cds.resolve(e.model||'*',false)}.
30
30
  Waiting for some to arrive...
31
31
  `)}
32
32