@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.
- package/CHANGELOG.md +101 -2012
- package/LICENSE +15 -21
- package/bin/bind.js +1 -1
- package/bin/build.js +35 -37
- package/bin/cds.js +13 -30
- package/bin/compile/index.js +2 -2
- package/bin/debug.js +27 -7
- package/bin/deploy/index.js +6 -23
- package/bin/deploy/to-hana.js +4 -2
- package/bin/help.js +5 -3
- package/bin/init.js +1 -1
- package/bin/up.js +45 -12
- package/bin/watch.js +45 -63
- package/lib/bind/cf.js +2 -1
- package/lib/bind/k8s.js +2 -2
- package/lib/bind/plugin.js +1 -1
- package/lib/bind/shared.js +16 -25
- package/lib/build/buildTaskEngine.js +26 -10
- package/lib/build/buildTaskFactory.js +3 -2
- package/lib/build/buildTaskProvider.js +18 -7
- package/lib/build/buildTaskProviderFactory.js +35 -13
- package/lib/build/constants.js +4 -0
- package/lib/build/index.js +1 -1
- package/lib/build/plugin.js +89 -54
- package/lib/build/plugins/helm/files/subcharts/web-application/Chart.yaml +3 -1
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/_helpers.tpl +4 -2
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/api-rule.yaml +4 -2
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/deployment.yaml +18 -1
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/service-binding.yaml +0 -1
- package/lib/build/plugins/helm/files/subcharts/web-application/values.schema.json +34 -2
- package/lib/build/plugins/helm/files/subcharts/web-application/values.yaml +9 -2
- package/lib/build/plugins/helm/index.js +2 -1
- package/lib/build/plugins.js +24 -10
- package/lib/build/provider/edmxBuildPlugin.js +1 -11
- package/lib/build/provider/fiori/index.js +4 -4
- package/lib/build/provider/hana/index.js +12 -5
- package/lib/build/provider/hana/template/package.json +1 -1
- package/lib/build/provider/internalBuildPlugin.js +1 -1
- package/lib/build/provider/internalBuildTaskProvider.js +3 -24
- package/lib/build/provider/java/index.js +1 -1
- package/lib/build/provider/mtx-extension/index.js +15 -8
- package/lib/build/provider/nodejs/index.js +28 -6
- package/lib/build/util.js +186 -125
- package/lib/deploy/index.js +5 -0
- package/lib/deploy/to-hana/hana.js +27 -33
- package/lib/deploy/to-hana/hdiDeployUtil.js +2 -2
- package/lib/import/odata/v2parser.js +34 -3
- package/lib/import/openapi/importOpenAPI.js +4 -0
- package/lib/index.js +2 -11
- package/lib/init/constants.js +1 -2
- package/lib/init/merge.js +101 -77
- package/lib/init/mvn.js +3 -3
- package/lib/init/projectReader.js +1 -1
- package/lib/init/template/ams/files/mta.yaml.hbs +6 -1
- package/lib/init/template/ams/files/package.json.hbs +1 -1
- package/lib/init/template/approuter/files/mta.yaml.hbs +5 -0
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +1 -1
- package/lib/init/template/cloud-logging/files/package.json.hbs +3 -3
- package/lib/init/template/data/as-json.js +3 -3
- package/lib/init/template/dynatrace/files/mta.yaml.hbs +1 -1
- package/lib/init/template/dynatrace/files/package.json.hbs +2 -2
- package/lib/init/template/dynatrace/index.js +2 -1
- package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +6 -0
- package/lib/init/template/enterprise-messaging/index.js +5 -1
- package/lib/init/template/extensibility/files/package.json.hbs +1 -1
- package/lib/init/template/hana/files/db/package.json +1 -1
- package/lib/init/template/hana/files/package.json.hbs +2 -4
- package/lib/init/template/hana/index.js +2 -2
- package/lib/init/template/handler/index.js +16 -12
- package/lib/init/template/helm/index.js +13 -22
- package/lib/init/template/helm-unified-runtime/index.js +2 -1
- package/lib/init/template/html5-repo/files/values.yaml.hbs +12 -1
- package/lib/init/template/html5-repo/index.js +10 -5
- package/lib/init/template/http/index.js +1 -1
- package/lib/init/template/ias/files/mta.yaml.hbs +1 -1
- package/lib/init/template/ias/files/sidecar.package.json.hbs +0 -7
- package/lib/init/template/ias/index.js +5 -4
- package/lib/init/template/lint/files/package.json +6 -0
- package/lib/init/template/lint/index.js +61 -204
- package/lib/init/template/mta/files/package.json +1 -1
- package/lib/init/template/multitenancy/files/mta.yaml.hbs +2 -2
- package/lib/init/template/multitenancy/files/package.json.hbs +1 -1
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +7 -4
- package/lib/init/template/multitenancy/index.js +3 -0
- package/lib/init/template/nodejs/files/package.json.hbs +6 -3
- package/lib/init/template/postgres/files/package.json.hbs +1 -1
- package/lib/init/template/redis/files/package.json.hbs +1 -1
- package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +6 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +1 -0
- package/lib/init/template/sample/files/app/browse/fiori-service.cds +3 -2
- package/lib/init/template/sample/files/app/common.cds +0 -11
- package/lib/init/template/sqlite/files/package.json +1 -1
- package/lib/init/template/toggles/files/package.json.hbs +1 -1
- package/lib/init/template/typescript/files/package.json +2 -4
- package/lib/init/template/workzone-standard/index.js +2 -0
- package/lib/init/template/xsuaa/index.js +2 -6
- package/lib/lint/Linter.js +203 -331
- package/lib/lint/generators.js +52 -46
- package/lib/lint/io.js +77 -289
- package/lib/util/fs.js +2 -1
- package/lib/util/git.js +1 -1
- package/lib/util/glob.js +77 -0
- package/lib/watch/livereload-server.js +3 -4
- package/lib/watch/node-watch.js +3 -4
- package/lib/watch/watched.js +1 -1
- package/npm-shrinkwrap.json +200 -858
- package/package.json +6 -8
- package/readme.md +1 -1
- package/lib/lint/checks.js +0 -135
package/lib/util/glob.js
ADDED
|
@@ -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
|
|
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 (
|
|
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 (
|
|
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))
|
package/lib/watch/node-watch.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
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 (
|
|
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 (
|
|
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
|
package/lib/watch/watched.js
CHANGED