@sap/cds-dk 7.0.0 → 7.0.2
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/bin/add.js +34 -38
- package/bin/build.js +4 -0
- package/bin/cds.js +13 -8
- package/bin/compile/index.js +3 -3
- package/bin/env.js +4 -1
- package/bin/help.js +2 -3
- package/lib/bind/bindingManager.js +1 -1
- package/lib/bind/bindingResolver.js +1 -1
- package/lib/bind/bindingUtil.js +1 -1
- package/lib/build/buildTaskEngine.js +1 -1
- package/lib/build/provider/buildTaskHandlerFeatureToggles.js +2 -1
- package/lib/build/provider/buildTaskHandlerInternal.js +1 -1
- package/lib/build/provider/java/index.js +2 -2
- package/lib/build/provider/mtx-sidecar/index.js +3 -4
- package/lib/build/provider/nodejs/index.js +6 -5
- package/lib/build/util.js +8 -0
- package/lib/cds.js +2 -2
- package/lib/import/asyncapi/parserContext.js +2 -2
- package/lib/index.js +6 -0
- package/lib/init/constants.js +4 -4
- package/lib/init/index.js +37 -38
- package/lib/init/template/_merging/registry-mta.js +2 -2
- package/lib/init/template/approuter/index.js +12 -8
- package/lib/init/template/auditlog/index.js +7 -7
- package/lib/init/template/cf-manifest/index.js +5 -5
- package/lib/init/template/connectivity/index.js +7 -7
- package/lib/init/template/data/index.js +1 -1
- package/lib/init/template/destination/index.js +6 -6
- package/lib/init/template/enterprise-messaging/index.js +10 -10
- package/lib/init/template/enterprise-messaging-shared/index.js +8 -8
- package/lib/init/template/extensibility/index.js +6 -6
- package/lib/init/template/file-based-messaging/index.js +4 -4
- package/lib/init/template/hana/index.js +11 -11
- package/lib/init/template/helm/index.js +5 -5
- package/lib/init/template/html5-repo/index.js +2 -2
- package/lib/init/template/java/index.js +20 -37
- package/lib/init/template/kibana/files/mta.yaml.hbs +29 -0
- package/lib/init/template/kibana/index.js +55 -0
- package/lib/init/template/multitenancy/files/package.json.hbs +0 -3
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
- package/lib/init/template/multitenancy/index.js +18 -12
- package/lib/init/template/nodejs/files/package.json.hbs +1 -1
- package/lib/init/template/nodejs/index.js +12 -19
- package/lib/init/template/pipeline/index.js +1 -1
- package/lib/init/template/redis-messaging/index.js +7 -7
- package/lib/init/template/sample/files/app/_i18n/i18n.properties +3 -32
- package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +2 -2
- package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +6 -7
- package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +3 -3
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +3 -11
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +117 -113
- package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +38 -0
- package/lib/init/template/sample/files/app/browse/fiori-service.cds +56 -0
- package/lib/init/template/sample/files/app/browse/webapp/Component.js +7 -0
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +4 -0
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +139 -0
- package/lib/init/template/sample/files/app/common.cds +78 -81
- package/lib/init/template/sample/files/app/services.cds +1 -0
- package/lib/init/template/samples/index.js +3 -3
- package/lib/init/template/sqlite/files/package.json.hbs +1 -21
- package/lib/init/template/sqlite/index.js +4 -4
- package/lib/init/template/templateBase.js +1 -1
- package/lib/init/template/{sample-tiny → tiny-sample}/files/nodejs/db/data-model.cds +1 -1
- package/lib/init/template/{sample-tiny → tiny-sample}/files/nodejs/srv/cat-service.cds.hbs +1 -1
- package/lib/init/template/{sample-tiny → tiny-sample}/index.js +2 -2
- package/lib/init/template/toggles/index.js +3 -3
- package/lib/init/template/typer/index.js +6 -5
- package/lib/init/template/xsuaa/index.js +9 -9
- package/lib/init/util/md5.js +2 -2
- package/lib/init/util/merge.js +9 -9
- package/lib/init/util/mvn.js +1 -1
- package/lib/init/util/projectReader.js +4 -4
- package/lib/util/fs.js +10 -10
- package/lib/util/term.js +2 -0
- package/npm-shrinkwrap.json +281 -334
- package/package.json +1 -1
- package/lib/init/template/kibana-logging/files/cds.package.json +0 -7
- package/lib/init/template/kibana-logging/files/mta.yaml.hbs +0 -14
- package/lib/init/template/kibana-logging/index.js +0 -45
- /package/lib/init/template/{kibana-logging → kibana}/files/package.json.hbs +0 -0
- /package/lib/init/template/{sample-tiny → tiny-sample}/files/nodejs/db/data/my.bookshop-Books.csv +0 -0
package/bin/add.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const term = require('../lib/util/term')
|
|
1
2
|
|
|
2
3
|
module.exports = Object.assign(add, {
|
|
3
4
|
options: ['--for', '--out', '--data:for'],
|
|
@@ -8,72 +9,68 @@ module.exports = Object.assign(add, {
|
|
|
8
9
|
|
|
9
10
|
*cds add* <feature | comma-separated list of features>
|
|
10
11
|
|
|
11
|
-
Adds one or more features to an existing project
|
|
12
|
-
folder - Grow-as-you-go scenario.
|
|
12
|
+
Adds one or more features to an existing project - grow as you go.
|
|
13
13
|
|
|
14
|
-
The following
|
|
14
|
+
The following features are supported so far:
|
|
15
15
|
|
|
16
|
-
*hana*
|
|
16
|
+
*hana* - add support for SAP HANA
|
|
17
17
|
|
|
18
|
-
*sqlite*
|
|
18
|
+
*sqlite* - add support for SQLite databases
|
|
19
19
|
|
|
20
|
-
*xsuaa*
|
|
20
|
+
*xsuaa* - add support for authentication via XSUAA
|
|
21
21
|
|
|
22
|
-
*multitenancy*
|
|
22
|
+
*multitenancy* - add support for multitenancy
|
|
23
23
|
|
|
24
|
-
*toggles*
|
|
24
|
+
*toggles* - add support for feature toggles
|
|
25
25
|
|
|
26
|
-
*extensibility*
|
|
26
|
+
*extensibility* - add support for extensibility
|
|
27
27
|
|
|
28
|
-
*
|
|
29
|
-
extensibility
|
|
28
|
+
*approuter* - add support for application routing
|
|
30
29
|
|
|
31
|
-
*
|
|
30
|
+
*file-based-messaging* - add support for file-based messaging
|
|
32
31
|
|
|
33
|
-
*
|
|
34
|
-
Technology Platform deployment
|
|
32
|
+
*enterprise-messaging* - add support for SAP Event Mesh
|
|
35
33
|
|
|
36
|
-
*
|
|
37
|
-
Cloud Foundry native deployment
|
|
34
|
+
*redis-messaging* - add support for Redis messaging
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
Plugin' that has to be installed separately using
|
|
41
|
-
_cf install-plugin Create-Service-Push_.
|
|
42
|
-
_cf create-service-push_ creates the service(s) and pushes
|
|
43
|
-
the application(s) to the SAP Business Technology
|
|
44
|
-
Platform.
|
|
36
|
+
*kibana-logging* - add support for Kibana formatting
|
|
45
37
|
|
|
46
|
-
*
|
|
38
|
+
*mta* - add support for MTA-based deployment
|
|
47
39
|
|
|
48
|
-
*
|
|
40
|
+
*cf-manifest* - add support for CF-native deployment
|
|
49
41
|
|
|
50
|
-
*
|
|
42
|
+
*helm* - add support for Helm-based Kyma deployment
|
|
51
43
|
|
|
52
|
-
*
|
|
44
|
+
*html5-repo* - add support for the HTML5 repository
|
|
53
45
|
|
|
54
|
-
*
|
|
55
|
-
deploy the application using Kyma.
|
|
46
|
+
*pipeline* - add files for CI/CD pipeline integration
|
|
56
47
|
|
|
57
|
-
*
|
|
58
|
-
|
|
48
|
+
*tiny-sample* - add minimal sample files
|
|
49
|
+
|
|
50
|
+
*sample* - add sample files including Fiori UI
|
|
51
|
+
|
|
52
|
+
*data* - add CSV headers for modeled entities
|
|
53
|
+
|
|
54
|
+
*typer* - add type generation for CDS models
|
|
55
|
+
|
|
56
|
+
*lint* - add support for CDS Lint
|
|
59
57
|
|
|
60
58
|
|
|
61
59
|
# OPTIONS
|
|
62
60
|
|
|
63
61
|
*--for* <profile>
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
\`"[production]": { "db": "hana" }\`
|
|
63
|
+
Write configuration data for the given profile.
|
|
67
64
|
|
|
68
65
|
*--data:for* <entity name or prefix>
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
Add data content for entities matching the given pattern. If it contains
|
|
71
68
|
meta characters like '^' or '*', it is treated like a regular expression,
|
|
72
69
|
otherwise as a prefix.
|
|
73
70
|
|
|
74
71
|
*-o* | *--out* <target folder>
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
Specify output target folder (applicable to ${term.bold('data')} feature only).
|
|
77
74
|
|
|
78
75
|
*--force*
|
|
79
76
|
|
|
@@ -81,11 +78,10 @@ module.exports = Object.assign(add, {
|
|
|
81
78
|
|
|
82
79
|
# EXAMPLES
|
|
83
80
|
|
|
84
|
-
*cds add*
|
|
85
|
-
*cds add* multitenancy
|
|
86
|
-
*cds add* hana,xsuaa --for production
|
|
87
|
-
*cds add* cf-manifest
|
|
81
|
+
*cds add* sample
|
|
82
|
+
*cds add* multitenancy,hana,xsuaa --for production
|
|
88
83
|
*cds add* data --data:for my.namespace.MyEntity
|
|
84
|
+
*cds add* mta
|
|
89
85
|
*cds add* helm
|
|
90
86
|
|
|
91
87
|
|
package/bin/build.js
CHANGED
|
@@ -101,6 +101,10 @@ async function build([project], options = {}) {
|
|
|
101
101
|
const { CliError } = require('../lib/client/helper/errors')
|
|
102
102
|
const { build } = require('../lib/build')
|
|
103
103
|
|
|
104
|
+
const [major] = cds.version.split('.')
|
|
105
|
+
if (Number(major) < 6) {
|
|
106
|
+
throw new CliError("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.")
|
|
107
|
+
}
|
|
104
108
|
if (options.clean === "false") {
|
|
105
109
|
throw new CliError("cds build option '--clean' is deprecated - build output folders are always cleaned before build")
|
|
106
110
|
}
|
package/bin/cds.js
CHANGED
|
@@ -54,9 +54,13 @@ const cli = { //NOSONAR
|
|
|
54
54
|
return await task.apply(this, args)
|
|
55
55
|
}
|
|
56
56
|
} catch (e) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
const { BuildError } = require('../lib/build')
|
|
58
|
+
const { CliError } = require('../lib/client/helper/errors')
|
|
59
|
+
process.exitCode ??= 1
|
|
60
|
+
if (e.messages?.length) return cds._log(e.messages, { 'log-level': cds.env.log.levels.cli })
|
|
61
|
+
else if (e instanceof CliError || e instanceof BuildError) return console.error(e.message)
|
|
62
|
+
if (cds.watched) throw e // bin/watched.js handles errors
|
|
63
|
+
else return console.error(e)
|
|
60
64
|
}
|
|
61
65
|
},
|
|
62
66
|
|
|
@@ -93,15 +97,16 @@ const cli = { //NOSONAR
|
|
|
93
97
|
|
|
94
98
|
function add (k,v) { options[k.slice(2)] = v || true }
|
|
95
99
|
function add_global (k,v='') {
|
|
96
|
-
if (k === '--production') process.env.CDS_ENV = [...process.env.CDS_ENV?.split(',') ?? [], 'production']
|
|
97
|
-
if (k === '--profile') process.env.CDS_ENV = [...process.env.CDS_ENV?.split(',') ?? [], ...v.split(',')]
|
|
100
|
+
if (k === '--production') return process.env.CDS_ENV = [...process.env.CDS_ENV?.split(',') ?? [], 'production']
|
|
101
|
+
if (k === '--profile') return process.env.CDS_ENV = [...process.env.CDS_ENV?.split(',') ?? [], ...v.split(',')]
|
|
98
102
|
if (k === '--odata') v = { flavor:v }
|
|
99
103
|
let e=env || (env={}), path = k.slice(2).split('-')
|
|
100
104
|
while (path.length > 1) { let p = path.shift(); e = e[p]||(e[p]={}) }
|
|
101
105
|
add (k, e[path[0]] = v)
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
if (env) require('../lib/cds').env.add (env)
|
|
108
|
+
// if (env) require('../lib/cds').env.add (env) //> avoid loading env
|
|
109
|
+
process.env.CDS_CONFIG = JSON.stringify(env)
|
|
105
110
|
return [ args, options ]
|
|
106
111
|
},
|
|
107
112
|
|
|
@@ -116,7 +121,7 @@ async function _resolveBindings(options) {
|
|
|
116
121
|
const bindingManager = new BindingManager(options)
|
|
117
122
|
const bindingEnv = await bindingManager.bindingEnv()
|
|
118
123
|
Object.assign(process.env, bindingEnv)
|
|
119
|
-
cds.env = cds.env.for('cds') // reload env
|
|
124
|
+
cds.env = cds.env.for('cds') // reload env // FIXME: This is too early!
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
function _local (id, _else) {
|
|
@@ -179,7 +184,7 @@ function _dieForUnknownCommand(cmd) {
|
|
|
179
184
|
`
|
|
180
185
|
console.error(msg)
|
|
181
186
|
|
|
182
|
-
process.
|
|
187
|
+
process.exit(1)
|
|
183
188
|
}
|
|
184
189
|
|
|
185
190
|
function _require (id,o) {
|
package/bin/compile/index.js
CHANGED
|
@@ -175,7 +175,7 @@ function compile (models, options={}) {
|
|
|
175
175
|
model = readModelFromStdin()
|
|
176
176
|
src = 'stdin'
|
|
177
177
|
} else { // no args, no stdin
|
|
178
|
-
throw
|
|
178
|
+
throw `You must specify a model to compile.\nRun 'cds c -?' to learn more.`
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
let chain = model.then (m => model=m)
|
|
@@ -189,7 +189,7 @@ function compile (models, options={}) {
|
|
|
189
189
|
if (typeof options.to === 'string') for (let each of options.to.split(',')) {
|
|
190
190
|
chain = chain.then (next (processor ('to', _suffix=each)))
|
|
191
191
|
} else if (options.to) {
|
|
192
|
-
|
|
192
|
+
throw `Specify a model processor`
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
// add processor for i18n
|
|
@@ -235,7 +235,7 @@ function compile (models, options={}) {
|
|
|
235
235
|
let p = cds.compile[kind]
|
|
236
236
|
for (let each of tail.split('.')) {
|
|
237
237
|
p = p[each]
|
|
238
|
-
if (!p) throw
|
|
238
|
+
if (!p) throw `Unknown model processor: cds.compile.${kind}.${tail}`
|
|
239
239
|
}
|
|
240
240
|
return p
|
|
241
241
|
}
|
package/bin/env.js
CHANGED
|
@@ -95,7 +95,7 @@ const commands = {
|
|
|
95
95
|
},
|
|
96
96
|
|
|
97
97
|
get (conf, key, val, options) {
|
|
98
|
-
let fmt =
|
|
98
|
+
let fmt = x => inspect (x, {depth:22,colors:true})
|
|
99
99
|
|
|
100
100
|
let obj = (
|
|
101
101
|
!key ? conf
|
|
@@ -104,6 +104,9 @@ const commands = {
|
|
|
104
104
|
: conf.get(key.replace(/^cds\./,''))
|
|
105
105
|
)
|
|
106
106
|
|
|
107
|
+
if (!process.stdout.isTTY) {
|
|
108
|
+
fmt = x => typeof x !== 'object' ? x : JSON.stringify(x,0,2)
|
|
109
|
+
}
|
|
107
110
|
if (options.json) {
|
|
108
111
|
fmt = x => JSON.stringify(x,0,2)
|
|
109
112
|
}
|
package/bin/help.js
CHANGED
|
@@ -39,9 +39,8 @@ module.exports = exports = Object.assign (help, {formatHelp, help:`
|
|
|
39
39
|
|
|
40
40
|
function help (topic) {
|
|
41
41
|
if (Array.isArray(topic)) topic = topic[0]
|
|
42
|
-
const task = !topic ? help : this.load
|
|
43
|
-
if (task
|
|
44
|
-
else throw new Error(`Didn't find a help topic for '${ topic.name || topic }'.`)
|
|
42
|
+
const task = !topic ? help : this.load?.(this.Shortcuts[topic] || topic)
|
|
43
|
+
if (task?.help) console.log (formatHelp (task.help))
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
function formatHelp (text) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const bindingResolver = require('./bindingResolver')
|
|
2
2
|
const { logger } = require('./bindingUtil')
|
|
3
3
|
const cds = require('../cds')
|
|
4
|
-
const DEBUG = cds.debug('cli')
|
|
4
|
+
const DEBUG = cds.debug('cli') // REVISIT: This loads cds.env too early!
|
|
5
5
|
|
|
6
6
|
class BindingManager {
|
|
7
7
|
constructor(options = {}) {
|
|
@@ -4,7 +4,7 @@ const { platformText, bindingText, logger } = require('./bindingUtil');
|
|
|
4
4
|
class BindingResolver {
|
|
5
5
|
getUnresolvedBindings({ cwd = process.cwd(), env } = {}) {
|
|
6
6
|
if (!env) {
|
|
7
|
-
env = cds.env.for('cds', cwd)
|
|
7
|
+
env = cds.env.for('cds', cwd) // REVISIT: This might load cds.env too early!
|
|
8
8
|
}
|
|
9
9
|
const bindings = {}
|
|
10
10
|
const requires = env.requires || {}
|
package/lib/bind/bindingUtil.js
CHANGED
|
@@ -54,7 +54,7 @@ class BindingUtil {
|
|
|
54
54
|
// Auto configure services based on VCAP_SERVICES
|
|
55
55
|
|
|
56
56
|
const cds = require('../cds');
|
|
57
|
-
const env = cds.env.for('cds', process.cwd());
|
|
57
|
+
const env = cds.env.for('cds', process.cwd()); // REVISIT: This might load cds.env too early!
|
|
58
58
|
|
|
59
59
|
if (!env._find_credentials_for_required_service) {
|
|
60
60
|
throw new Error(`Please provide a service kind or update @sap/cds version to use the kind detection.`);
|
|
@@ -30,7 +30,7 @@ class BuildTaskEngine {
|
|
|
30
30
|
const messages = []
|
|
31
31
|
|
|
32
32
|
this.logger.log(`building project [${cds.root}], clean [${this.buildOptions.clean}]`)
|
|
33
|
-
this.logger.log(`cds [${cds.version}], compiler [${cds.compiler.version()}], home [${cds.home}]\n`)
|
|
33
|
+
this.logger.log(`cds-dk [${require('../../package.json').version}], cds [${cds.version}], compiler [${cds.compiler.version()}], home [${cds.home}]\n`)
|
|
34
34
|
|
|
35
35
|
if (!tasks) {
|
|
36
36
|
const buildTaskFactory = new BuildTaskFactory(this.buildOptions)
|
|
@@ -3,6 +3,7 @@ const path = require('path')
|
|
|
3
3
|
const cds = require('../../cds')
|
|
4
4
|
const { DEFAULT_CSN_FILE_NAME, OUTPUT_MODE, OUTPUT_MODE_RESULT } = require('../constants')
|
|
5
5
|
const BuildTaskHandlerInternal = require('./buildTaskHandlerInternal')
|
|
6
|
+
const { getI18nDefaultFolder } = require('../util')
|
|
6
7
|
|
|
7
8
|
class FeatureToggleBuilder extends BuildTaskHandlerInternal {
|
|
8
9
|
init() {
|
|
@@ -46,7 +47,7 @@ class FeatureToggleBuilder extends BuildTaskHandlerInternal {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
async collectAllLanguageBundles(dictionary, paths, destBase, destFts) {
|
|
49
|
-
const i18nFolder =
|
|
50
|
+
const i18nFolder = getI18nDefaultFolder()
|
|
50
51
|
// create language bundle for base model
|
|
51
52
|
const i18n = await this.collectLanguageBundles(dictionary.base, path.join(destBase, i18nFolder))
|
|
52
53
|
if (i18n && this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_RESULT)) {
|
|
@@ -128,7 +128,7 @@ class BuildTaskHandlerInternal extends BuildTaskHandler {
|
|
|
128
128
|
// This ensures that the paths are relative to the cwd when executing cds run.
|
|
129
129
|
const jsonOptions = {
|
|
130
130
|
cwd: cds.root,
|
|
131
|
-
src: this.task.src
|
|
131
|
+
src: this.hasBuildOption('flatDeployLayout', true) || this.task.src === this.task.dest ? this.task.src : cds.root
|
|
132
132
|
}
|
|
133
133
|
const csnStr = cds.compile.to.json(model, jsonOptions)
|
|
134
134
|
await this.write(csnStr).to(csnFile)
|
|
@@ -3,6 +3,7 @@ const path = require('path')
|
|
|
3
3
|
const cds = require('../../../cds')
|
|
4
4
|
const BuildTaskHandlerEdmx = require('../buildTaskHandlerEdmx')
|
|
5
5
|
const { OUTPUT_MODE, OUTPUT_MODE_RESULT, FILE_EXT_CDS, CONTENT_LANGUAGE_BUNDLES, CONTENT_DEFAULT_CSN, DEFAULT_CSN_FILE_NAME } = require('../../constants')
|
|
6
|
+
const { getI18nDefaultFolder } = require('../../util')
|
|
6
7
|
const DEFAULT_COMPILE_DEST_FOLDER = path.normalize('src/main/resources/edmx')
|
|
7
8
|
|
|
8
9
|
class JavaModuleBuilder extends BuildTaskHandlerEdmx {
|
|
@@ -28,8 +29,7 @@ class JavaModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
28
29
|
|
|
29
30
|
if (this.hasBuildOption(CONTENT_LANGUAGE_BUNDLES, true)) {
|
|
30
31
|
// collect and write language bundles into single i18n.json file
|
|
31
|
-
const
|
|
32
|
-
const i18n = await this.collectLanguageBundles(model, path.join(this.task.dest, i18nFolder))
|
|
32
|
+
const i18n = await this.collectLanguageBundles(model, path.join(this.task.dest, getI18nDefaultFolder()))
|
|
33
33
|
if (i18n && this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_RESULT)) {
|
|
34
34
|
this._result.languageBundles = i18n.bundles
|
|
35
35
|
}
|
|
@@ -5,7 +5,7 @@ const { FOLDER_GEN, DEFAULT_CSN_FILE_NAME } = require('../../constants')
|
|
|
5
5
|
const NodeCfModuleBuilder = require('../nodejs')
|
|
6
6
|
const ResourcesTarProvider = require('../mtx/resourcesTarBuilder')
|
|
7
7
|
const { WARNING, ERROR } = NodeCfModuleBuilder
|
|
8
|
-
const { relativePaths, BuildError, resolveRequiredSapModels } = require('../../util')
|
|
8
|
+
const { relativePaths, BuildError, resolveRequiredSapModels, getI18nDefaultFolder } = require('../../util')
|
|
9
9
|
|
|
10
10
|
const DEFAULT_MAIN_FOLDER = "_main"
|
|
11
11
|
|
|
@@ -45,12 +45,11 @@ class MtxSidecarModuleBuilder extends NodeCfModuleBuilder {
|
|
|
45
45
|
async _buildNodeApp(sidecarEnv) {
|
|
46
46
|
const destSidecar = this.task.dest
|
|
47
47
|
const destSidecarSrc = path.join(destSidecar, cds.env.folders.srv)
|
|
48
|
-
const i18nFolder = cds.env.i18n.folders?.[0] || 'i18n'
|
|
49
48
|
const model = this._compileSidecarSync(sidecarEnv)
|
|
50
49
|
await this.compileToJson(model, path.join(destSidecarSrc, DEFAULT_CSN_FILE_NAME))
|
|
51
50
|
|
|
52
|
-
await this.collectLanguageBundles(model, path.join(destSidecarSrc,
|
|
53
|
-
await this.
|
|
51
|
+
await this.collectLanguageBundles(model, path.join(destSidecarSrc, getI18nDefaultFolder()))
|
|
52
|
+
await this.copySrvContent(this.task.src, destSidecar, destSidecar)
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
/**
|
|
@@ -51,7 +51,7 @@ class NodejsModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
51
51
|
|
|
52
52
|
if (this.isStagingBuild() && this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_FILESYSTEM)) {
|
|
53
53
|
const srcSrv = this.task.src === cds.root ? path.resolve(this.task.src, cds.env.folders.srv) : this.task.src
|
|
54
|
-
await this._copyNativeContent(cds.root, srcSrv, destRoot)
|
|
54
|
+
await this._copyNativeContent(cds.root, srcSrv, destRoot, destSrv)
|
|
55
55
|
await this._fixCapireSamplesDeps(destRoot)
|
|
56
56
|
}
|
|
57
57
|
return this._result
|
|
@@ -89,9 +89,9 @@ class NodejsModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
async _copyNativeContent(srcRoot, srcSrv, destRoot) {
|
|
92
|
+
async _copyNativeContent(srcRoot, srcSrv, destRoot, destSrv) {
|
|
93
93
|
// project/srv/** -> 'gen/srv/srv/**'
|
|
94
|
-
const filesFilter = await this.
|
|
94
|
+
const filesFilter = await this.copySrvContent(srcSrv, destRoot, this.hasBuildOption('flatDeployLayout', true)? destRoot : destSrv)
|
|
95
95
|
|
|
96
96
|
// project/* -> 'gen/srv/*'
|
|
97
97
|
await this.copyProjectRootContent(srcRoot, destRoot, (entry) => !filesFilter.includes(path.basename(entry)))
|
|
@@ -104,16 +104,17 @@ class NodejsModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
104
104
|
* are copied to <em>destSrv</em>.
|
|
105
105
|
* @param {*} src
|
|
106
106
|
* @param {*} destRoot - folder name representing the app root folder (e.g. gen/srv)
|
|
107
|
+
* @param {*} destSrv - folder name representing the app sub-folder (e.g. gen/srv/srv)
|
|
107
108
|
* @returns the list of files that have been copied
|
|
108
109
|
*/
|
|
109
|
-
async
|
|
110
|
+
async copySrvContent(src, destRoot, destSrv) {
|
|
110
111
|
const srvRootBlockList = RegExp('package\\.json$|package-lock\\.json$|\\.npmrc$|\\.cdsrc\\.json$')
|
|
111
112
|
const srvBlockList = RegExp('\\.cds$|csn\\.json$|\\.csn$|manifest\\.y.?ml$|\\.env($|\\..*$)|default-env\\.json$')
|
|
112
113
|
const srvRootFileNames = []
|
|
113
114
|
|
|
114
115
|
// 1. copy all files to 'destSrv' except those contained in the blocklist (including node_modules)
|
|
115
116
|
// project/srv -> 'gen/srv/srv'
|
|
116
|
-
await super.copyNativeContent(src,
|
|
117
|
+
await super.copyNativeContent(src, destSrv, (entry) => {
|
|
117
118
|
if (fs.statSync(entry).isDirectory()) {
|
|
118
119
|
// TODO shall not copy language bundles - return !/(\/|\\)(node_modules|_i18n)(\/|\\)?$/.test(entry)
|
|
119
120
|
return !/(\/|\\)node_modules(\/|\\)?$/.test(entry)
|
package/lib/build/util.js
CHANGED
|
@@ -170,6 +170,13 @@ async function copy(src, dest) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
function getI18nDefaultFolder() {
|
|
174
|
+
// keep '_i18n' as preferred folder for compatibility reasons
|
|
175
|
+
if (cds.env.i18n.folders.includes('_i18n')) return '_i18n'
|
|
176
|
+
if (cds.env.i18n.folders.includes('i18n')) return 'i18n'
|
|
177
|
+
return cds.env.i18n.folders[0] ?? 'i18n'
|
|
178
|
+
}
|
|
179
|
+
|
|
173
180
|
/**
|
|
174
181
|
* Return gnu-style error string for location `loc`:
|
|
175
182
|
* - 'File:Line:Col' without `loc.end`
|
|
@@ -258,6 +265,7 @@ module.exports = {
|
|
|
258
265
|
getDefaultModelOptions,
|
|
259
266
|
flatten,
|
|
260
267
|
copy,
|
|
268
|
+
getI18nDefaultFolder,
|
|
261
269
|
BuildMessage,
|
|
262
270
|
BuildError
|
|
263
271
|
}
|
package/lib/cds.js
CHANGED
|
@@ -3,8 +3,8 @@ const cds = _local ('@sap/cds')
|
|
|
3
3
|
|
|
4
4
|
module.exports = Object.defineProperties (cds, {
|
|
5
5
|
// for internal use in cds-dk only
|
|
6
|
-
_log: { value: _local ('../bin/util/log') },
|
|
7
|
-
_local: { value: _local },
|
|
6
|
+
_log: { value: _local ('../bin/util/log'), configurable: true },
|
|
7
|
+
_local: { value: _local, configurable: true },
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
function _local (id) {
|
|
@@ -71,8 +71,8 @@ module.exports = class ParserContext {
|
|
|
71
71
|
const eventAnnotations = this.getEventAnnotations(value);
|
|
72
72
|
|
|
73
73
|
// add topic annotation
|
|
74
|
-
if (this.topics[
|
|
75
|
-
eventAnnotations['@topic'] = this.topics[
|
|
74
|
+
if (this.topics[key]) {
|
|
75
|
+
eventAnnotations['@topic'] = this.topics[key];
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
let properties = {};
|
package/lib/index.js
CHANGED
|
@@ -12,3 +12,9 @@ cds.extend (cds.compile.to.constructor) .with (class {
|
|
|
12
12
|
'edmx-w4'(csn,o) { return cds.compile.to.edmx(csn,{...o,flavor:'w4'}) }
|
|
13
13
|
'edmx-x4'(csn,o) { return cds.compile.to.edmx(csn,{...o,flavor:'x4'}) }
|
|
14
14
|
})
|
|
15
|
+
|
|
16
|
+
// Compat to cds <=6. Esp. BAS tools need it, see cap/issues#13918
|
|
17
|
+
// TODO remove compat w/ cds-dk 8
|
|
18
|
+
if (cds.compile.to.constructor.name === 'Object') { // not a class as in cds 7
|
|
19
|
+
cds.compile.to.xsuaa = require('./compile/to-xsuaa')
|
|
20
|
+
}
|
package/lib/init/constants.js
CHANGED
|
@@ -15,6 +15,9 @@ const constants = {
|
|
|
15
15
|
JAVA_MVN: 'java:mvn',
|
|
16
16
|
JAVA_PACKAGE: 'java:package',
|
|
17
17
|
NODEJS: 'nodejs',
|
|
18
|
+
SAMPLES: 'samples', // deprecated
|
|
19
|
+
TINY_SAMPLE: 'tiny-sample',
|
|
20
|
+
SAMPLE: 'sample',
|
|
18
21
|
PIPELINE: 'pipeline',
|
|
19
22
|
MTA: 'mta',
|
|
20
23
|
CONNECTIVITY: 'connectivity',
|
|
@@ -33,11 +36,8 @@ const constants = {
|
|
|
33
36
|
REDIS_MESSAGING: 'redis-messaging',
|
|
34
37
|
APPROUTER: 'approuter',
|
|
35
38
|
DESTINATION: 'destination',
|
|
36
|
-
SAMPLES: 'samples', // deprecated
|
|
37
|
-
SAMPLE_TINY: 'sample-tiny',
|
|
38
|
-
SAMPLE: 'sample',
|
|
39
39
|
DATA: 'data',
|
|
40
|
-
|
|
40
|
+
KIBANA: 'kibana',
|
|
41
41
|
LINT: 'lint',
|
|
42
42
|
LINT_GLOBAL: 'lint:global',
|
|
43
43
|
LINT_DEV: 'lint:dev',
|