@sap/cds-dk 7.3.1 → 7.4.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 (52) hide show
  1. package/bin/add.js +2 -0
  2. package/bin/build.js +24 -14
  3. package/bin/cds.js +4 -4
  4. package/bin/compile/index.js +11 -0
  5. package/bin/init.js +1 -1
  6. package/bin/migrate.js +2 -2
  7. package/bin/repl.js +0 -2
  8. package/bin/subscribe.js +10 -5
  9. package/bin/unsubscribe.js +10 -5
  10. package/bin/upgrade.js +10 -5
  11. package/bin/watch.js +5 -0
  12. package/bin/watched.js +1 -1
  13. package/lib/build/buildTaskFactory.js +1 -1
  14. package/lib/build/constants.js +1 -0
  15. package/lib/build/provider/edmxBuildPlugin.js +7 -3
  16. package/lib/build/provider/featureToggleBuildPlugin.js +2 -3
  17. package/lib/build/provider/hana/2migration.js +4 -4
  18. package/lib/build/provider/hana/index.js +20 -10
  19. package/lib/build/provider/java/index.js +2 -2
  20. package/lib/build/provider/nodejs/index.js +77 -56
  21. package/lib/client/auth_manager.js +1 -1
  22. package/lib/client/base_command.js +8 -18
  23. package/lib/client/download_legacy.js +0 -3
  24. package/lib/client/params.js +5 -4
  25. package/lib/client/pull.js +9 -1
  26. package/lib/client/settings_manager.js +22 -21
  27. package/lib/compile/asyncapi/components/schemas/annotations.js +20 -0
  28. package/lib/compile/openapi/csdl2openapi.js +3 -3
  29. package/lib/deploy/to-hana/hana.js +53 -35
  30. package/lib/index.js +6 -4
  31. package/lib/init/constants.js +3 -4
  32. package/lib/init/index.js +9 -4
  33. package/lib/init/template/approuter/files/package.json +1 -1
  34. package/lib/init/template/enterprise-messaging/files/event-mesh.json.hbs +1 -1
  35. package/lib/init/template/enterprise-messaging/index.js +1 -1
  36. package/lib/init/template/enterprise-messaging-shared/files/event-mesh.json.hbs +1 -1
  37. package/lib/init/template/enterprise-messaging-shared/index.js +19 -5
  38. package/lib/init/template/hana/files/db/package.json +1 -1
  39. package/lib/init/template/helm/index.js +1 -1
  40. package/lib/init/template/local-messaging/files/package.json.hbs +15 -0
  41. package/lib/init/template/local-messaging/index.js +25 -0
  42. package/lib/init/template/multitenancy/index.js +3 -5
  43. package/lib/init/template/nodejs/files/.gitignore.hbs +3 -0
  44. package/lib/init/template/notifications/files/package.json.hbs +1 -10
  45. package/lib/init/template/notifications/index.js +7 -16
  46. package/lib/init/template/postgres/index.js +4 -3
  47. package/lib/init/template/templateBase.js +0 -13
  48. package/lib/init/template/typer/files/package.json +1 -1
  49. package/lib/init/util/projectReader.js +1 -0
  50. package/npm-shrinkwrap.json +377 -330
  51. package/package.json +1 -1
  52. package/lib/init/template/notifications/files/notificationtypes.json.hbs +0 -16
package/bin/add.js CHANGED
@@ -27,6 +27,8 @@ module.exports = Object.assign(add, {
27
27
 
28
28
  *approuter* - add support for application routing
29
29
 
30
+ *local-messaging* - add support for local messaging
31
+
30
32
  *file-based-messaging* - add support for file-based messaging
31
33
 
32
34
  *enterprise-messaging* - add support for SAP Event Mesh
package/bin/build.js CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = Object.assign(build, {
2
2
  options: ['--project', '--src', '--dest', '--for', '--use', '--opts', '--log-level', '--options-model'],
3
3
  shortcuts: ['-in', '-s', '-o', '-4'],
4
- flags: ['--ws', '--clean'],
4
+ flags: ['--clean', '--no-clean', '--ws'], // REVISIT: --clean is deprecated, backward compatibility
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
@@ -16,7 +16,6 @@ module.exports = Object.assign(build, {
16
16
  # OPTIONS
17
17
 
18
18
  *-4 | --for* hana | java | nodejs | mtx | mtx-sidecar | mtx-extension
19
-
20
19
  Name of the build task that is applied to the source folder, either
21
20
  explicitly configured in the build task list or generated out of the
22
21
  project setup
@@ -25,7 +24,6 @@ module.exports = Object.assign(build, {
25
24
  otherwise.
26
25
 
27
26
  *-s | --src* <folder>
28
-
29
27
  The module folder to build using the build task defined by option
30
28
  '--for'.
31
29
  This option is only supported when building an individual module of the
@@ -36,7 +34,6 @@ module.exports = Object.assign(build, {
36
34
  *hana* build task, 'srv' for *nodejs* or *java* build task.
37
35
 
38
36
  *-o | --dest* <folder>
39
-
40
37
  Output folder of the build task. The type of build task is defined by
41
38
  option '--for'.
42
39
  The folder is resolved based on '<project>/<cds.env.build.target>'.
@@ -49,14 +46,12 @@ module.exports = Object.assign(build, {
49
46
  '<project>/*<dest>*/*'.
50
47
 
51
48
  *--opts* <build task specific options>
52
-
53
49
  Add a comma-separated list of build task specific options in the format
54
50
  <opt1>=[value1,value2],<opt2>=value.
55
51
  For example, --opts model=[db,srv,schema.cds] loads and compiles the CDS
56
52
  model based on the given sources.
57
53
 
58
54
  *--profile* <profile,...>
59
-
60
55
  Loads the configuration data for the specified profile(s) and executes
61
56
  'cds build' based on this profile settings.
62
57
  E.g. you may want to create the HANA deployment artefacts only if the
@@ -64,18 +59,28 @@ module.exports = Object.assign(build, {
64
59
  The *development* profile is used by default.
65
60
 
66
61
  *--production*
67
-
68
62
  Shortcut for '--profile production'
69
63
 
70
64
  *--log-level* <debug | info | warn | error>
71
-
72
65
  Choose which level of cds build messages to log, default is *warn*.
73
66
 
74
67
  *-in | --project* [<project>]
75
-
76
68
  Runs 'cds build' for the specified project, default is current working
77
69
  directory.
78
-
70
+
71
+ *--no-clean* (beta)
72
+ Skips cleaning the build output folder before running the actual build
73
+ operation. Clients need to clean the output folder upfront to ensure
74
+ consistent build results.
75
+
76
+ *--ws* (beta)
77
+ Enable tarball based packaging of npm workspace dependencies for Node.js apps.
78
+ This feature can be used to package npm workspace dependencies as part of your
79
+ mono or multi-repo deployment.
80
+ Tarball files are created for all 'dependencies' and 'devDependencies'
81
+ of your project for which a npm workspace exists. The '*' dependency is replaced
82
+ by the correct tarball file URL.
83
+ See 'npm workspaces' for further details.
79
84
 
80
85
  # EXAMPLES
81
86
 
@@ -88,8 +93,9 @@ module.exports = Object.assign(build, {
88
93
 
89
94
  async function build([project], options = {}) {
90
95
  const path = require('path')
96
+
91
97
  const cds = require('../lib/cds')
92
-
98
+
93
99
  // plugins are loaded based on cds.root path
94
100
  cds.root = path.resolve(process.cwd(), project || options.project || '.')
95
101
 
@@ -104,13 +110,17 @@ async function build([project], options = {}) {
104
110
  if (Number(major) < 6) {
105
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."
106
112
  }
107
- if (options.clean === "false") {
108
- throw "cds build option '--clean' is deprecated - build output folders are always cleaned before build"
109
- }
110
113
  if (typeof options["options-model"] === "string") {
111
114
  options.opts = "model=[" + options["options-model"].split(",").map((entry) => entry.trim()) + "]"
112
115
  delete options["options-model"]
113
116
  }
117
+ if (options["no-clean"]) {
118
+ // mapping to the existing 'clean' option
119
+ if (options["no-clean"] === "true" || options["no-clean"] === true) {
120
+ options.clean = false
121
+ }
122
+ delete options["no-clean"]
123
+ }
114
124
 
115
125
  await build(options)
116
126
  }
package/bin/cds.js CHANGED
@@ -30,7 +30,7 @@ const cli = { //NOSONAR
30
30
  if (cmd in this.Shortcuts) cmd = process.argv[2] = this.Shortcuts[cmd]
31
31
  if (argv.some(a => this.Shortcuts[a]==='help')) return this.help (cmd)
32
32
 
33
- const cds = require('../lib/cds')
33
+ const cds = require('../lib') // make sure to load cds-dk API for plugins
34
34
  DEBUG?.(`[cds] - @sap/cds ${cds.version} loaded: ${cds.home}`)
35
35
 
36
36
  try {
@@ -93,8 +93,8 @@ const cli = { //NOSONAR
93
93
 
94
94
  function add (k,v) { options[k.slice(2)] = v || true }
95
95
  function add_global (k,v='') {
96
- if (k === '--production') return process.env.CDS_ENV = [...process.env.CDS_ENV?.split(',') ?? [], 'production']
97
- if (k === '--profile') return process.env.CDS_ENV = [...process.env.CDS_ENV?.split(',') ?? [], ...v.split(',')]
96
+ if (k === '--production') return process.env.CDS_ENV = Array.from(new Set([...process.env.CDS_ENV?.split(',') ?? [], 'production']))
97
+ if (k === '--profile') return process.env.CDS_ENV = Array.from(new Set([...process.env.CDS_ENV?.split(',') ?? [], ...v.split(',')]))
98
98
  if (k === '--odata') v = { flavor:v }
99
99
  let e=env || (env={}), path = k.slice(2).split('-')
100
100
  while (path.length > 1) { let p = path.shift(); e = e[p]||(e[p]={}) }
@@ -103,7 +103,7 @@ const cli = { //NOSONAR
103
103
 
104
104
  // if (env) require('../lib/cds').env.add (env) //> avoid loading env
105
105
  // unless it has already explicitly been set by the user
106
- process.env.CDS_CONFIG ??= JSON.stringify(env)
106
+ if (env) process.env.CDS_CONFIG ??= JSON.stringify(env)
107
107
  return [ args, options ]
108
108
  },
109
109
 
@@ -53,6 +53,17 @@ module.exports = Object.assign ( compile, {
53
53
 
54
54
  - odata
55
55
  - sql
56
+
57
+ *--dialect* <dialect>
58
+
59
+ Needs option *--to*.
60
+ Specify the dialect in combination with *--to sql*.
61
+ Currently supported:
62
+
63
+ - sqlite
64
+ - h2
65
+ - postgres
66
+ - hana
56
67
 
57
68
  *-s* | *--service* <name> | all
58
69
 
package/bin/init.js CHANGED
@@ -40,7 +40,7 @@ module.exports = Object.assign(init, {
40
40
 
41
41
  *approuter* - add support for application routing
42
42
 
43
- *file-based-messaging* - add support for file-based messaging
43
+ *local-messaging* - add support for local messaging
44
44
 
45
45
  *enterprise-messaging* - add support for SAP Event Mesh
46
46
 
package/bin/migrate.js CHANGED
@@ -43,11 +43,11 @@ module.exports = Object.assign(migrate, {
43
43
  Skip verification step. Does not check for potential deployment
44
44
  differences.
45
45
 
46
- *--cleanup* (beta)
46
+ *--cleanup*
47
47
 
48
48
  Removes all metadata containers created by @sap/cds-mtx.
49
49
 
50
- *--resolve-bindings* (beta)
50
+ *--resolve-bindings*
51
51
 
52
52
  Resolve remote service bindings configured via *cds bind*.
53
53
 
package/bin/repl.js CHANGED
@@ -17,8 +17,6 @@ async function repl (_, options={}) {
17
17
  const cds = require('../lib/cds')
18
18
  console.log('\x1b[32m\x1b[1m'+'Welcome to cds repl v', cds.version, '\x1b[0m')
19
19
 
20
- await cds.plugins
21
-
22
20
  const { inspect } = require('util')
23
21
  inspect.defaultOptions.colors = true
24
22
  inspect.defaultOptions.depth = 11
package/bin/subscribe.js CHANGED
@@ -1,8 +1,8 @@
1
1
  module.exports = Object.assign(subscribe, {
2
2
  init: cmd => new (require('../lib/client/tenant_action'))(cmd),
3
3
  options: ['--to', '--user'],
4
- flags: ['--local'],
5
- shortcuts: ['-2', '-u', '-l'],
4
+ flags: ['--local', '--resolve-bindings'],
5
+ shortcuts: ['-2', '-u', '-l', '-b'],
6
6
  help: `
7
7
  # SYNOPSIS
8
8
 
@@ -24,10 +24,10 @@ module.exports = Object.assign(subscribe, {
24
24
 
25
25
  Username and optionally password for authentication with Basic Auth in
26
26
  test scenarios.
27
-
27
+
28
28
  Only relevant if <url> is given. May be omitted in case of dummy
29
29
  authentication.
30
-
30
+
31
31
  Tokens saved with *cds login* are not used for this command.
32
32
 
33
33
  *-l* | *--local*
@@ -35,11 +35,15 @@ module.exports = Object.assign(subscribe, {
35
35
  Run a locally-installed @sap/cds-mtxs and connect to it instead of a
36
36
  URL. Ignore settings saved with *cds login*.
37
37
 
38
+ *-b* | *--resolve-bindings*
39
+
40
+ Resolve remote service bindings configured via *cds bind*.
41
+
38
42
 
39
43
  # SEE ALSO
40
44
 
41
45
  *cds login* for more information on authentication options.
42
-
46
+
43
47
  *cds login* to save project settings and Basic-Auth data, simplifying multiple runs of this command.
44
48
 
45
49
  `});
@@ -63,6 +67,7 @@ async function subscribe([tenant], options = {}) {
63
67
  }
64
68
  const [username, password] = options.user?.split(':') ?? [];
65
69
  delete options.user;
70
+ delete options['resolve-bindings'];
66
71
 
67
72
  await subscribe.init('subscribe').run({
68
73
  ...options,
@@ -1,8 +1,8 @@
1
1
  module.exports = Object.assign(unsubscribe, {
2
2
  init: cmd => new (require('../lib/client/tenant_action'))(cmd),
3
3
  options: ['--from', '--user'],
4
- flags: ['--local'],
5
- shortcuts: ['-f', '-u', '-l'],
4
+ flags: ['--local', '--resolve-bindings'],
5
+ shortcuts: ['-f', '-u', '-l', '-b'],
6
6
  help: `
7
7
  # SYNOPSIS
8
8
 
@@ -25,10 +25,10 @@ module.exports = Object.assign(unsubscribe, {
25
25
 
26
26
  Username and optionally password for authentication with Basic Auth in
27
27
  test scenarios.
28
-
28
+
29
29
  Only relevant if <url> is given. May be omitted in case of dummy
30
30
  authentication.
31
-
31
+
32
32
  Tokens saved with *cds login* are not used for this command.
33
33
 
34
34
  *-l* | *--local*
@@ -36,11 +36,15 @@ module.exports = Object.assign(unsubscribe, {
36
36
  Run a locally-installed @sap/cds-mtxs and connect to it instead of a
37
37
  URL. Ignore settings saved with *cds login*.
38
38
 
39
+ *-b* | *--resolve-bindings*
40
+
41
+ Resolve remote service bindings configured via *cds bind*.
42
+
39
43
 
40
44
  # SEE ALSO
41
45
 
42
46
  *cds login* for more information on authentication options.
43
-
47
+
44
48
  *cds login* to save project settings and Basic-Auth data, simplifying multiple runs of this command.
45
49
 
46
50
  `});
@@ -64,6 +68,7 @@ async function unsubscribe([tenant], options = {}) {
64
68
  }
65
69
  const [username, password] = options.user?.split(':') ?? [];
66
70
  delete options.user;
71
+ delete options['resolve-bindings'];
67
72
 
68
73
  await unsubscribe.init('unsubscribe').run({
69
74
  ...options,
package/bin/upgrade.js CHANGED
@@ -1,8 +1,8 @@
1
1
  module.exports = Object.assign(upgrade, {
2
2
  init: cmd => new (require('../lib/client/tenant_action'))(cmd),
3
3
  options: ['--at', '--user'],
4
- flags: ['--local'],
5
- shortcuts: ['-a', '-u', '-l'],
4
+ flags: ['--local', '--resolve-bindings'],
5
+ shortcuts: ['-a', '-u', '-l', '-b'],
6
6
  help: `
7
7
  # SYNOPSIS
8
8
 
@@ -25,10 +25,10 @@ module.exports = Object.assign(upgrade, {
25
25
 
26
26
  Username and optionally password for authentication with Basic Auth in
27
27
  test scenarios.
28
-
28
+
29
29
  Only relevant if <url> is given. May be omitted in case of dummy
30
30
  authentication.
31
-
31
+
32
32
  Tokens saved with *cds login* are not used for this command.
33
33
 
34
34
  *-l* | *--local*
@@ -36,11 +36,15 @@ module.exports = Object.assign(upgrade, {
36
36
  Run a locally-installed @sap/cds-mtxs and connect to it instead of a
37
37
  URL. Ignore settings saved with *cds login*.
38
38
 
39
+ *-b* | *--resolve-bindings*
40
+
41
+ Resolve remote service bindings configured via *cds bind*.
42
+
39
43
 
40
44
  # SEE ALSO
41
45
 
42
46
  *cds login* for more information on authentication options.
43
-
47
+
44
48
  *cds login* to save project settings and Basic-Auth data, simplifying multiple runs of this command.
45
49
 
46
50
  `});
@@ -64,6 +68,7 @@ async function upgrade([tenant], options = {}) {
64
68
  }
65
69
  const [username, password] = options.user?.split(':') ?? [];
66
70
  delete options.user;
71
+ delete options['resolve-bindings'];
67
72
 
68
73
  await upgrade.init('upgrade').run({
69
74
  ...options,
package/bin/watch.js CHANGED
@@ -37,6 +37,11 @@ module.exports = Object.assign ( watch, {
37
37
  Open the given URL (suffix) in the browser after starting.
38
38
  If none is given, the default application URL will be opened.
39
39
 
40
+ *--profile* <profile,...>
41
+
42
+ Specify from which profile(s) the binding information is taken.
43
+ *Example:* cds w --profile hybrid,production
44
+
40
45
  # SEE ALSO
41
46
 
42
47
  *cds serve --help* for the different start options.
package/bin/watched.js CHANGED
@@ -7,8 +7,8 @@
7
7
 
8
8
  // run through cli in order to use its error handling
9
9
  const args = JSON.parse(process.env._args)
10
+ const cds = require('../lib/cds'); cds.watched = true
10
11
  const bootstrap = require('./cds')(...args)
11
- const {cds} = global; cds.watched = true
12
12
 
13
13
  cds.once('listening', ({server}) => {
14
14
  process.send ({ code:'listening', port: server.address().port })
@@ -230,7 +230,7 @@ class BuildTaskFactory {
230
230
 
231
231
  static _scanTaskOptionParams(optsParams) {
232
232
  // need to create new regex every call since a constant would keep the match state
233
- const quoteRegex = /([\w-]+)=([\w/.]+|\[([\w/,.]+)\])/g
233
+ const quoteRegex = /([\w-]+)=([\w/.-]+|\[([\w/,.-]+)\])/g
234
234
 
235
235
  // captures a=1 => a:1
236
236
  // a=[x,y,z] => a:[x,y,z]
@@ -34,6 +34,7 @@ exports.CONTENT_NODE_MODULES = "contentNodeModules" // copy node_mod
34
34
  exports.CONTENT_ENV = "contentEnv" // copy .env file if existing into deployment folder - DISABLED by default
35
35
  exports.CONTENT_DEFAULT_ENV_JSON = "contentDefaultEnvJson" // copy default-env.json file if existing into deployment folder - DISABLED by default
36
36
 
37
+ exports.CSV_FILE_TARGET = "csvFileTarget" // target folder when copying CSV files to the deployment target folder ./db/src/gen/*, default is 'data'
37
38
  exports.CSV_FILE_DETECTION = "csvFileDetection" // detect CSV files based on CDS model location - ENABLED by default
38
39
  exports.EXTENSION_POINT_VALIDATION = "extensionPointValidation" // validate extension point restrictions defined by the extended SaaS app - ENABLED by default
39
40
  exports.MTX_SIDECAR_DB_VALIDATION = "mtxSidecarDbValidation" // validate consistency of app and sidecar db configuration - ENABLED by default
@@ -51,9 +51,13 @@ class EdmxBuildPlugin extends FeatureToggleBuildPlugin {
51
51
  }
52
52
 
53
53
  _isOdataProtocol(srv) {
54
- let protocols = cds.service.protocols.protocol4(srv)
55
- if (typeof protocols === "string") {
56
- protocols = [protocols]
54
+ let protocols = cds.service.protocols4?.(srv)
55
+ if (!protocols) {
56
+ // compatibility with @sap/cds < 7.3.0
57
+ protocols = cds.service.protocols.protocol4(srv)
58
+ if (typeof protocols === "string") {
59
+ protocols = [protocols]
60
+ }
57
61
  }
58
62
  return protocols.some(p => p && p.startsWith('odata'))
59
63
  }
@@ -124,9 +124,8 @@ class FeatureToggleBuildPlugin extends InternalBuildPlugin {
124
124
 
125
125
  _validateFeature(ftCsn, baseCsn) {
126
126
  // features must not have other dependencies than base model dependencies - cross feature dependencies are not supported
127
- // do not pass options.messages in order to avoid duplicate compiler messages
128
- // version 2.13.9 of compileSources does not read the 'requires' definition of parsed CSNs
129
- cds.compiler.compileSources({ [ftCsn.requires[0]]: baseCsn, 'feature.csn': ftCsn }, this.options())
127
+ // assuming only core compiler options are relevant for validation scenario
128
+ cds.compiler.compileSources({ [ftCsn.requires[0]]: baseCsn, 'feature.csn': ftCsn }, { ...super.options(), ...cds.env.cdsc ?? {}})
130
129
  }
131
130
  }
132
131
 
@@ -13,8 +13,7 @@ module.exports = async (model, lastDevVersion, srcPath, options = {}) => {
13
13
  logger = options.logger
14
14
  }
15
15
 
16
- const journalFileNames = _getJournalFileNames(model)
17
- const { definitions, deletions, migrations, afterImage } = _toHdiMigration(model, lastDevVersion, journalFileNames, options)
16
+ const { definitions, deletions, migrations, afterImage, journalFileNames } = _toHdiMigration(model, lastDevVersion, options)
18
17
  const definitionResult = []
19
18
 
20
19
  for (const { name, suffix, sql } of definitions) {
@@ -33,8 +32,9 @@ module.exports = async (model, lastDevVersion, srcPath, options = {}) => {
33
32
  return { definitions: definitionResult, deletions, afterImage: _filterJournalArtifacts(afterImage) }
34
33
  }
35
34
 
36
- function _toHdiMigration(model, lastDevVersion, journalFileNames, options) {
35
+ function _toHdiMigration(model, lastDevVersion, options) {
37
36
  const result = cdsc.to.hdi.migration(cds.minify(model), options, lastDevVersion);
37
+ const journalFileNames = _getJournalFileNames(result.afterImage);
38
38
  if (logger._debug) {
39
39
  logger.debug('cdsc.to.hdi.migration returned')
40
40
  for (const { name, suffix, sql } of result.definitions) {
@@ -50,7 +50,7 @@ ${migration ? migration.changeset.map(change => change.sql).join('\n') : 'Empty
50
50
  }
51
51
  }
52
52
  }
53
- return result
53
+ return { ...result, journalFileNames };
54
54
  }
55
55
 
56
56
  /**
@@ -6,7 +6,7 @@ const InternalBuildPlugin = require('../internalBuildPlugin')
6
6
  const { BuildError, relativePaths, BuildMessage } = require('../../util')
7
7
 
8
8
  const { OUTPUT_MODE_NONE, OUTPUT_MODE, CONTENT_PACKAGE_JSON, CONTENT_HDBTABLEDATA, CSV_FILE_DETECTION,
9
- CONTENT_ENV, CONTENT_DEFAULT_ENV_JSON, CONTENT_NODE_MODULES, OUTPUT_MODE_RESULT, CONTINUE_UNRESOLVED_SCHEMA_CHANGES } = require('../../constants')
9
+ CONTENT_ENV, CONTENT_DEFAULT_ENV_JSON, CONTENT_NODE_MODULES, OUTPUT_MODE_RESULT, CONTINUE_UNRESOLVED_SCHEMA_CHANGES, CSV_FILE_TARGET } = require('../../constants')
10
10
  const { WARNING } = InternalBuildPlugin
11
11
 
12
12
  const DEFAULT_COMPILE_DEST_FOLDER = path.normalize("src/gen")
@@ -90,18 +90,28 @@ class HanaBuildPlugin extends InternalBuildPlugin {
90
90
  */
91
91
  async _copyResourcesExt(src, dest, model) {
92
92
  const resources = Object.keys(await cds.deploy.resources(model)).reverse() // reverse to get reuse resources first and app resources last
93
- const csvPath = path.join(src, "data")
94
- // determine subfolder name used by the application for backward compatibility
95
- const csvFolder = resources.some(res => res && res.startsWith(csvPath)) ? "data" : "csv"
93
+ const dbSrc = path.join(src, 'src')
96
94
 
97
95
  // 1. copy csv files into 'src/gen/data' or 'src/gen/csv' subfolder
98
- const dbSrc = path.join(src, 'src')
96
+ if (resources.length) {
97
+ // determine the CSV folder from the location of the CSVs defined in this build task db folder, use subfolder data by default
98
+ const dbCSVs = resources.filter(res => res.startsWith(src) && !res.startsWith(dbSrc))
99
+ let csvFolder = this.getBuildOption(CSV_FILE_TARGET)
100
+ if (csvFolder && !["data", "csv"].includes(csvFolder)) {
101
+ throw new BuildError("Invalid value for option 'csvFileTarget'. Valid values are 'data' or 'csv'.")
102
+ }
103
+ if (!csvFolder) {
104
+ const csvPath = path.join(src, "data")
105
+ // determine subfolder name used by the application for backward compatibility
106
+ csvFolder = !dbCSVs.length || dbCSVs.some(res => res && res.startsWith(csvPath)) ? "data" : "csv"
107
+ }
99
108
 
100
- // await each copy as order is important - reuse resources first and app resources last
101
- for (const res of resources) {
102
- // do not duplicate resources that are already contained in db/src/**
103
- if (res && /\.csv$/.test(res) && !res.startsWith(dbSrc)) {
104
- await this.copy(res).to(path.join(this.task.options.compileDest, csvFolder, path.basename(res)))
109
+ // await each copy as order is important - reuse resources first and app resources last
110
+ for (const res of resources) {
111
+ // do not duplicate resources that are already contained in db/src/**
112
+ if (res && /\.csv$/.test(res) && !res.startsWith(dbSrc)) {
113
+ await this.copy(res).to(path.join(this.task.options.compileDest, csvFolder, path.basename(res)))
114
+ }
105
115
  }
106
116
  }
107
117
 
@@ -24,12 +24,12 @@ class JavaBuildPlugin extends EdmxBuildPlugin {
24
24
 
25
25
  if (!this.hasBuildOption(CONTENT_EDMX, false)) {
26
26
  // generate edmx files containing all features
27
- // localized edmx for backward compatibility
27
+ // REVISIT: localized edmx for backward compatibility
28
28
  if (!this.hasBuildOption(CONTENT_LOCALIZED_EDMX, false)) {
29
29
  await this.compileToEdmx(odata, compileDest, { [FLAVOR_LOCALIZED_EDMX]: true })
30
30
  }
31
31
  // non-localized edmx
32
- await this.compileToEdmx(odata, path.join(compileDest, 'odata', cds.env.odata.version), { [FLAVOR_LOCALIZED_EDMX]: false })
32
+ await this.compileToEdmx(odata, path.join(compileDest, 'odata', cds.env.odata.version), { [FLAVOR_LOCALIZED_EDMX]: this.hasBuildOption(FLAVOR_LOCALIZED_EDMX, true) })
33
33
  }
34
34
 
35
35
  if (!this.hasBuildOption(CONTENT_LANGUAGE_BUNDLES, false)) {