@sap/cds-dk 7.1.1 → 7.3.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.
- package/bin/activate.js +2 -2
- package/bin/build.js +5 -2
- package/bin/compile/index.js +13 -5
- package/bin/env.js +0 -3
- package/bin/extend.js +25 -3
- package/bin/gen.js +27 -0
- package/bin/help.js +2 -1
- package/bin/import.js +7 -3
- package/bin/push.js +10 -6
- package/bin/watch.js +3 -4
- package/bin/watched.js +2 -3
- package/lib/bind/bindingUtil.js +1 -0
- package/lib/build/{buildTaskHandler.js → buildPlugin.js} +25 -30
- package/lib/build/buildTaskEngine.js +84 -89
- package/lib/build/buildTaskFactory.js +23 -44
- package/lib/build/buildTaskProvider.js +24 -19
- package/lib/build/buildTaskProviderFactory.js +176 -66
- package/lib/build/constants.js +6 -5
- package/lib/build/index.js +4 -3
- package/lib/build/provider/{buildTaskHandlerEdmx.js → edmxBuildPlugin.js} +6 -6
- package/lib/build/provider/{buildTaskHandlerFeatureToggles.js → featureToggleBuildPlugin.js} +3 -3
- package/lib/build/provider/fiori/index.js +5 -6
- package/lib/build/provider/hana/index.js +67 -36
- package/lib/build/provider/{buildTaskHandlerInternal.js → internalBuildPlugin.js} +11 -11
- package/lib/build/provider/{buildTaskProviderInternal.js → internalBuildTaskProvider.js} +42 -53
- package/lib/build/provider/java/index.js +24 -24
- package/lib/build/provider/mtx/index.js +4 -4
- package/lib/build/provider/mtx/resourcesTarBuilder.js +8 -8
- package/lib/build/provider/mtx-extension/index.js +17 -9
- package/lib/build/provider/mtx-sidecar/index.js +17 -11
- package/lib/build/provider/nodejs/index.js +63 -29
- package/lib/build/util.js +11 -19
- package/lib/client/auth_manager.js +6 -12
- package/lib/client/base_command.js +1 -1
- package/lib/client/download_legacy.js +48 -0
- package/lib/client/params.js +5 -0
- package/lib/client/push.js +41 -1
- package/lib/client/settings_manager.js +12 -3
- package/lib/compile/openapi/csdl2openapi.js +30 -21
- package/lib/compile/openapi/index.js +7 -3
- package/lib/env/schema.js +36 -0
- package/lib/env/schemas/cds-rc.json +101 -0
- package/lib/import/common.js +24 -11
- package/lib/import/importapi.js +2 -2
- package/lib/import/message.js +3 -1
- package/lib/import/odata/v4parser.js +23 -7
- package/lib/index.js +5 -0
- package/lib/init/constants.js +9 -12
- package/lib/init/index.js +86 -74
- package/lib/init/template/_merging/registry-mta.js +21 -12
- package/lib/init/template/approuter/files/mta.yaml.hbs +1 -1
- package/lib/init/template/approuter/index.js +3 -2
- package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +0 -5
- package/lib/init/template/cf-manifest/index.js +2 -2
- package/lib/init/template/connectivity/index.js +5 -4
- package/lib/init/template/destination/index.js +2 -5
- package/lib/init/template/h2/index.js +16 -0
- package/lib/init/template/hana/index.js +2 -3
- package/lib/init/template/helm/chart/values.root.schema.json +0 -5
- package/lib/init/template/helm/chart/values.schema.json +0 -4
- package/lib/init/template/helm/index.js +1 -1
- package/lib/init/template/html5-repo/index.js +27 -3
- package/lib/init/template/lint/index.js +3 -7
- package/lib/init/template/mta/index.js +9 -3
- package/lib/init/template/multitenancy/files/package.json.hbs +0 -3
- package/lib/init/template/multitenancy/index.js +2 -0
- package/lib/init/template/nodejs/index.js +3 -3
- package/lib/init/template/pipeline/index.js +2 -4
- package/lib/init/template/postgres/files/mta.yaml.hbs +27 -0
- package/lib/init/template/postgres/files/package.json.hbs +5 -0
- package/lib/init/template/postgres/index.js +52 -0
- package/lib/init/template/sample/index.js +5 -7
- package/lib/init/template/sqlite/index.js +8 -3
- package/lib/init/template/tiny-sample/index.js +16 -30
- package/lib/init/util/mvn.js +25 -1
- package/lib/init/util/projectReader.js +2 -7
- package/lib/init/util/template.js +7 -6
- package/lib/util/pruneAxiosErrors.js +22 -8
- package/lib/watch/node-watch.js +6 -1
- package/npm-shrinkwrap.json +2207 -384
- package/package.json +3 -3
- package/lib/init/template/auditlog/files/mta.yaml.hbs +0 -14
- package/lib/init/template/auditlog/files/package.json.hbs +0 -27
- package/lib/init/template/auditlog/index.js +0 -74
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const cds = require('../cds')
|
|
4
|
-
const { LOG_MODULE_NAMES, OUTPUT_MODE_FILESYSTEM } = require(
|
|
5
|
-
const
|
|
4
|
+
const { LOG_MODULE_NAMES, OUTPUT_MODE_FILESYSTEM } = require('./constants')
|
|
5
|
+
const InternalBuildTaskProvider = require('./provider/internalBuildTaskProvider')
|
|
6
6
|
const BuildTaskProvider = require('./buildTaskProvider')
|
|
7
|
+
const { BuildError } = require('./util')
|
|
8
|
+
const BuildPlugin = require('./buildPlugin')
|
|
7
9
|
|
|
8
10
|
class BuildTaskProviderFactory {
|
|
9
11
|
constructor(options = {}) {
|
|
12
|
+
// REVISIT: Logger is never passed to BuildTaskProviderFactory except for tests
|
|
13
|
+
// -> tests shouldn't pollute library coding
|
|
14
|
+
// see cds-dk/test/bin/eval.test.js for a non-invasive solution (intercepting console.log)
|
|
10
15
|
options.logger = options.logger || cds.log(LOG_MODULE_NAMES)
|
|
11
16
|
options.outputMode = options.outputMode || OUTPUT_MODE_FILESYSTEM
|
|
12
17
|
if (options.clean === undefined) {
|
|
13
18
|
options.clean = true
|
|
14
19
|
}
|
|
15
20
|
this._buildOptions = options
|
|
16
|
-
this._context = { options }
|
|
21
|
+
this._context = { options, tasks: [] } // resolved tasks
|
|
17
22
|
}
|
|
18
23
|
get logger() {
|
|
19
|
-
return this.
|
|
24
|
+
return this.options.logger
|
|
20
25
|
}
|
|
21
|
-
get
|
|
26
|
+
get options() {
|
|
22
27
|
return this._context.options
|
|
23
28
|
}
|
|
24
29
|
get context() {
|
|
@@ -31,22 +36,16 @@ class BuildTaskProviderFactory {
|
|
|
31
36
|
return this._providers
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
getTask(key) {
|
|
40
|
+
return this._getProvider(key).getTask(key)
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
async applyTaskDefaults(tasks) {
|
|
35
|
-
return Promise.all(tasks.map(async task => {
|
|
44
|
+
return Promise.all(tasks.map(async (task) => {
|
|
36
45
|
if (!task.for && !task.use) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
}
|
|
39
|
-
const provider = this.providers.find(provider => {
|
|
40
|
-
try {
|
|
41
|
-
return provider.canHandleTask(task)
|
|
42
|
-
} catch (e) {
|
|
43
|
-
this.logger.error(`Build task provider ${provider.constructor.name} returned error:\n` + e)
|
|
44
|
-
throw e
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
if (!provider) {
|
|
48
|
-
throw new Error(`No provider found for build task '${task.for || task.use}'`)
|
|
46
|
+
throw new Error(`Invalid build task definition - property 'for' and property 'use' missing`)
|
|
49
47
|
}
|
|
48
|
+
const provider = this._getProvider(task)
|
|
50
49
|
if (provider instanceof DefaultBuildTaskProvider) {
|
|
51
50
|
this.logger._debug && this.logger.debug(`No provider found for build task '${task.use}', using default provider`)
|
|
52
51
|
}
|
|
@@ -54,11 +53,11 @@ class BuildTaskProviderFactory {
|
|
|
54
53
|
}))
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
async lookupTasks(tasks = []) {
|
|
56
|
+
async lookupTasks(tasks = [], dependencies) {
|
|
58
57
|
for (let i = 0; i < this.providers.length; i++) {
|
|
59
58
|
const provider = this.providers[i]
|
|
60
59
|
const existingTasks = [...tasks]
|
|
61
|
-
await this._lookupTasks(provider, tasks)
|
|
60
|
+
await this._lookupTasks(provider, tasks, dependencies)
|
|
62
61
|
if (existingTasks.length < tasks.length) {
|
|
63
62
|
// apply defaults
|
|
64
63
|
const newTasks = tasks.filter(task => !existingTasks.includes(task))
|
|
@@ -70,45 +69,42 @@ class BuildTaskProviderFactory {
|
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
|
-
* Create a
|
|
72
|
+
* Create a BuildPlugin instance for the given build task.
|
|
74
73
|
* The implementation is loaded based on the build task's 'for' or 'use' option.
|
|
75
74
|
* @param {*} task
|
|
76
75
|
*/
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const resolvedTask = this.
|
|
80
|
-
this.logger._debug && this.logger.debug(`loaded build
|
|
76
|
+
createPlugin(task) {
|
|
77
|
+
const BuildPluginClass = this.loadPlugin(task)
|
|
78
|
+
const resolvedTask = this._resolveTask(task)
|
|
79
|
+
this.logger._debug && this.logger.debug(`loaded build plugin [${resolvedTask.use}]`)
|
|
81
80
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
81
|
+
const plugin = new BuildPluginClass()
|
|
82
|
+
plugin._task = resolvedTask
|
|
83
|
+
plugin._logger = this.logger
|
|
84
|
+
plugin._context = this.context
|
|
85
|
+
this.context.tasks.push(resolvedTask)
|
|
86
|
+
this.logger._debug && this.logger.debug(`created build plugin [${resolvedTask.use}]`)
|
|
87
|
+
return plugin
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* Loads the build
|
|
92
|
-
* 'for' defines an alias for built-in
|
|
93
|
-
* 'use' defines the fully qualified module name of
|
|
91
|
+
* Loads the build plugin implementation for the given build task.
|
|
92
|
+
* 'for' defines an alias for built-in plugins like 'hana', 'java', 'node', 'fiori' or 'mtx'.
|
|
93
|
+
* 'use' defines the fully qualified module name of custom build plugins implementations.
|
|
94
94
|
* @param {object} task
|
|
95
95
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (!provider) {
|
|
99
|
-
throw new Error(`No provider found for build task '${task.for || task.use}'`)
|
|
100
|
-
}
|
|
96
|
+
loadPlugin(task) {
|
|
97
|
+
const provider = this._getProvider(task)
|
|
101
98
|
try {
|
|
102
|
-
return provider.
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this.logger.error(`Provider failed to load handler class - provider: ${provider.constructor.name}, task: ${task.for || task.use} :\n` + e)
|
|
99
|
+
return provider.loadPlugin(task)
|
|
100
|
+
} catch (e) {
|
|
101
|
+
this.logger.error(`Provider failed to load build plugin class - provider: ${provider.constructor.name}, task: ${task.for || task.use} :\n` + e)
|
|
106
102
|
throw e
|
|
107
103
|
}
|
|
108
104
|
}
|
|
109
105
|
|
|
110
106
|
resolveTasks(tasks) {
|
|
111
|
-
return tasks.map(task => this.
|
|
107
|
+
return tasks.map(task => this._resolveTask(task))
|
|
112
108
|
}
|
|
113
109
|
|
|
114
110
|
/**
|
|
@@ -116,9 +112,9 @@ class BuildTaskProviderFactory {
|
|
|
116
112
|
* The task is validated in order to ensure that 'src' refers to a valid folder and 'for' or 'use' reference can be required.
|
|
117
113
|
* @param {*} task
|
|
118
114
|
*/
|
|
119
|
-
|
|
120
|
-
// first validate
|
|
121
|
-
this.
|
|
115
|
+
_resolveTask(task) {
|
|
116
|
+
// first validate plugin implementation
|
|
117
|
+
this.loadPlugin(task)
|
|
122
118
|
|
|
123
119
|
// second validate src path
|
|
124
120
|
const resolvedTask = JSON.parse(JSON.stringify(task))
|
|
@@ -138,8 +134,23 @@ class BuildTaskProviderFactory {
|
|
|
138
134
|
return resolvedTask
|
|
139
135
|
}
|
|
140
136
|
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
_getProvider(key) {
|
|
138
|
+
const provider = this.providers.find(provider => {
|
|
139
|
+
try {
|
|
140
|
+
return provider.providesTask(key)
|
|
141
|
+
} catch (e) {
|
|
142
|
+
this.logger.error(`Build task provider ${provider.constructor.name} returned an error:\n` + e)
|
|
143
|
+
throw e
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
if (!provider) {
|
|
147
|
+
throw new BuildError(`No provider found for build task '${key.for || key.use}'. Ensure that all required dependencies have been added and 'npm install' has been executed.`)
|
|
148
|
+
}
|
|
149
|
+
return provider
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async _lookupTasks(provider, tasks, dependencies) {
|
|
153
|
+
return provider.lookupTasks(tasks, dependencies)
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
async _applyTaskDefaults(provider, tasks) {
|
|
@@ -147,15 +158,12 @@ class BuildTaskProviderFactory {
|
|
|
147
158
|
}
|
|
148
159
|
|
|
149
160
|
_loadProviders() {
|
|
150
|
-
//
|
|
151
|
-
return [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
provider._logger = this.logger
|
|
157
|
-
provider._plugin = plugin
|
|
158
|
-
return provider
|
|
161
|
+
// DefaultBuildTaskProvider must be last entry
|
|
162
|
+
return [
|
|
163
|
+
new InternalBuildTaskProvider(this.logger),
|
|
164
|
+
new PluginBuildTaskProvider(this.logger),
|
|
165
|
+
new DefaultBuildTaskProvider(this.logger)
|
|
166
|
+
]
|
|
159
167
|
}
|
|
160
168
|
}
|
|
161
169
|
|
|
@@ -164,19 +172,121 @@ class BuildTaskProviderFactory {
|
|
|
164
172
|
* Has to be the last entry in the providers list.
|
|
165
173
|
*/
|
|
166
174
|
class DefaultBuildTaskProvider extends BuildTaskProvider {
|
|
167
|
-
|
|
168
|
-
|
|
175
|
+
constructor(logger) {
|
|
176
|
+
super()
|
|
177
|
+
this._logger = logger
|
|
169
178
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
|
|
180
|
+
providesTask(key) {
|
|
181
|
+
return !!key.use
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
loadPlugin(task) {
|
|
174
185
|
try {
|
|
175
186
|
return require(require.resolve(task.use, { paths: [cds.root] }))
|
|
176
|
-
}
|
|
177
|
-
catch (e) {
|
|
187
|
+
} catch (e) {
|
|
178
188
|
throw new Error(`Build task could not be resolved - module [${task.use}] cannot be loaded:\n` + e)
|
|
179
189
|
}
|
|
180
190
|
}
|
|
181
191
|
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Default provider implementation handling fully qualified custom build task declarations.
|
|
195
|
+
* Has to be the last entry in the providers list. // REVISIT: Above it says DefaultBuildTaskProvider should be last entry? -> clarify
|
|
196
|
+
*/
|
|
197
|
+
class PluginBuildTaskProvider extends BuildTaskProvider {
|
|
198
|
+
constructor(logger) {
|
|
199
|
+
super()
|
|
200
|
+
this._logger = logger
|
|
201
|
+
const plugins = new Map()
|
|
202
|
+
|
|
203
|
+
// REVISIT: Remove once fetch mechanism is removed
|
|
204
|
+
function _local (id) {
|
|
205
|
+
return require(require.resolve (id, {paths:[
|
|
206
|
+
process.cwd(), // project-local module is preferred
|
|
207
|
+
__dirname // otherwise from our own dependencies
|
|
208
|
+
]}))
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const cdsPlugins = _local('@sap/cds/lib/plugins').fetch?.() // REVISIT: Get rid of fetch mechanism
|
|
212
|
+
const buildPlugins = cds.env.build.plugins // REVISIT: Compat to old plugin mechanism, remove if possible
|
|
213
|
+
|
|
214
|
+
for (const [id, plugin] of Object.entries({ ...cdsPlugins, ...buildPlugins })) {
|
|
215
|
+
try {
|
|
216
|
+
const clazz = this._loadPlugin(id, plugin)
|
|
217
|
+
if (!clazz) continue
|
|
218
|
+
plugins.set(id, { id: id, impl: plugin.impl, class: clazz })
|
|
219
|
+
} catch (e) {
|
|
220
|
+
this._logger.error(`Skipping build plugin '${id}', it cannot be loaded.\n` + e + '\n') // REVISIT: why not throw? seems like an error one should fix, not exit with code 0
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
this._plugins = plugins
|
|
224
|
+
}
|
|
225
|
+
get plugins() {
|
|
226
|
+
return this._plugins
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
providesTask(key) {
|
|
230
|
+
return this.plugins.has(key.for)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
loadPlugin(task) {
|
|
234
|
+
return this._loadPlugin(task.for, this.plugins.get(task.for))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async lookupTasks(tasks, dependencies) {
|
|
238
|
+
if (!dependencies) {
|
|
239
|
+
this.plugins.forEach(plugin => {
|
|
240
|
+
if (plugin.class?.hasTask()) {
|
|
241
|
+
const task = this.getTask({ for: plugin.id })
|
|
242
|
+
if (!task) {
|
|
243
|
+
throw new Error(`Build task '${plugin.id}' required for custom plugin '${plugin.impl}'`)
|
|
244
|
+
}
|
|
245
|
+
task.for = plugin.id
|
|
246
|
+
tasks.push(task)
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async applyTaskDefaults(task) {
|
|
253
|
+
const defaultTask = this.getTask(task)
|
|
254
|
+
const names = Object.getOwnPropertyNames(defaultTask)
|
|
255
|
+
names.forEach(name => {
|
|
256
|
+
task[name] ??= defaultTask[name]
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
getTask(key) {
|
|
261
|
+
const task = this.plugins.get(key.for).class.getTaskDefaults() ?? key
|
|
262
|
+
task.src ??= '.'
|
|
263
|
+
if (task.src) {
|
|
264
|
+
task.src = task.src.replace(/\/$/, '')
|
|
265
|
+
}
|
|
266
|
+
task.for = key.for
|
|
267
|
+
return task
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
_loadPlugin(id, plugin) {
|
|
271
|
+
let pluginClass
|
|
272
|
+
try {
|
|
273
|
+
pluginClass = require(require.resolve(plugin.impl, { paths: [cds.root] }))
|
|
274
|
+
const inheritsFrom = (child, parent) => {
|
|
275
|
+
let proto = Object.getPrototypeOf(child)
|
|
276
|
+
while (proto) {
|
|
277
|
+
if (proto === parent) return true
|
|
278
|
+
proto = Object.getPrototypeOf(proto)
|
|
279
|
+
}
|
|
280
|
+
return false
|
|
281
|
+
}
|
|
282
|
+
if (!inheritsFrom(pluginClass, BuildPlugin)) return // REVISIT: better way to check if plugin is build-enabled than traversing prototype chain?
|
|
283
|
+
} catch (e) {
|
|
284
|
+
throw new Error(`Custom build plugin implementation '${plugin.impl}' for '${id}' cannot be loaded:\n` + e)
|
|
285
|
+
}
|
|
286
|
+
if (!pluginClass.hasTask || !pluginClass.getTaskDefaults) {
|
|
287
|
+
throw new Error(`Custom build plugin '${id}' must implement 'hasTask' and 'getTaskDefaults' methods`)
|
|
288
|
+
}
|
|
289
|
+
return pluginClass
|
|
290
|
+
}
|
|
291
|
+
}
|
|
182
292
|
module.exports = BuildTaskProviderFactory
|
package/lib/build/constants.js
CHANGED
|
@@ -19,9 +19,10 @@ exports.BUILD_TASKS = [this.BUILD_TASK_JAVA, this.BUILD_TASK_JAVA_CF, this.BUILD
|
|
|
19
19
|
exports.ODATA_VERSION_V2 = "v2"
|
|
20
20
|
exports.ODATA_VERSION_V4 = "v4"
|
|
21
21
|
|
|
22
|
-
exports.CONTENT_LANGUAGE_BUNDLES = "contentLanguageBundles" // create i18n.json language bundles
|
|
23
|
-
exports.CONTENT_DEFAULT_CSN = "contentDefaultCsn" // create default CSN format flavor: "inferred"
|
|
24
|
-
exports.
|
|
22
|
+
exports.CONTENT_LANGUAGE_BUNDLES = "contentLanguageBundles" // create i18n.json language bundles
|
|
23
|
+
exports.CONTENT_DEFAULT_CSN = "contentDefaultCsn" // create default CSN format flavor: "inferred"
|
|
24
|
+
exports.FLAVOR_LOCALIZED_EDMX = "flavorLocalizedEdmx" // create localized EDMX languages based on existing properties files
|
|
25
|
+
exports.CONTENT_EDMX = "contentEdmx" // create EDMX for required languages - ENABLED by default
|
|
25
26
|
exports.CONTENT_PACKAGE_JSON = "contentPackageJson" // create package.json file if not existing, or modify existing package.json - ENABLED by default
|
|
26
27
|
exports.CONTENT_PACKAGELOCK_JSON = "contentPackageLockJson" // copy package-lock.json file if existing into deployment folder - ENABLED by default
|
|
27
28
|
exports.CONTENT_HDBTABLEDATA = "contentHdbtabledata" // create .hdbtabledata files for .csv files if not existing - ENABLED by default
|
|
@@ -33,8 +34,9 @@ exports.CONTENT_DEFAULT_ENV_JSON = "contentDefaultEnvJson" // copy default-
|
|
|
33
34
|
|
|
34
35
|
exports.CSV_FILE_DETECTION = "csvFileDetection" // detect CSV files based on CDS model location - ENABLED by default
|
|
35
36
|
exports.EXTENSION_POINT_VALIDATION = "extensionPointValidation" // validate extension point restrictions defined by the extended SaaS app - ENABLED by default
|
|
36
|
-
exports.DEFAULT_BUILT_IN_MODELS = "defaultBuiltInModels" // add @sap/cds* built-in models to build tasks - ENABLED by default
|
|
37
37
|
exports.MTX_SIDECAR_DB_VALIDATION = "mtxSidecarDbValidation" // validate consistency of app and sidecar db configuration - ENABLED by default
|
|
38
|
+
exports.CONTINUE_UNRESOLVED_SCHEMA_CHANGES = "continueUnresolvedSchemaChanges" // build doesn't fail if unresolved HANA schema changes are detected
|
|
39
|
+
exports.IGNORE_DEFAULT_MODELS = "ignoreDefaultModels" // do not add default models (@sap/cds-*, fts/*) to existing build task model options
|
|
38
40
|
|
|
39
41
|
exports.FOLDER_GEN = "gen"
|
|
40
42
|
exports.FILE_EXT_CDS = ".cds"
|
|
@@ -55,4 +57,3 @@ exports.LOG_LEVEL_INFO = "info"
|
|
|
55
57
|
exports.LOG_LEVEL_DEBUG = "debug"
|
|
56
58
|
exports.LOG_LEVELS = [exports.LOG_LEVEL_ERROR, exports.LOG_LEVEL_WARN, exports.LOG_LEVEL_INFO, exports.LOG_LEVEL_DEBUG]
|
|
57
59
|
exports.LOG_MODULE_NAMES = "cds|build"
|
|
58
|
-
exports.OVERRIDE_METHOD_MSG = "Must override method"
|
package/lib/build/index.js
CHANGED
|
@@ -2,10 +2,10 @@ const fs = require('fs')
|
|
|
2
2
|
const cds = require('../cds')
|
|
3
3
|
const BuildTaskEngine = require('./buildTaskEngine')
|
|
4
4
|
const BuildTaskFactory = require('./buildTaskFactory')
|
|
5
|
-
const
|
|
5
|
+
const BuildPlugin = require('./buildPlugin')
|
|
6
6
|
const { BuildError } = require('./util')
|
|
7
7
|
|
|
8
|
-
module.exports = { build, BuildTaskFactory, BuildTaskEngine,
|
|
8
|
+
module.exports = { build, BuildTaskFactory, BuildTaskEngine, BuildPlugin, BuildError }
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Executes cds build in the directory defined by cds.root.
|
|
@@ -20,7 +20,8 @@ async function build(options = {}) {
|
|
|
20
20
|
return await new BuildTaskEngine(options).processTasks()
|
|
21
21
|
} catch (e) {
|
|
22
22
|
if (e instanceof BuildError || e.constructor.name === 'CompilationError') {
|
|
23
|
-
cds._log(e.messages.length ?
|
|
23
|
+
cds._log(e.messages.length ? e.messages : e.message, { 'log-level': options['log-level'] || cds.env['log-level'] })
|
|
24
|
+
console.log('')
|
|
24
25
|
// CompilationError.message also includes the detail messages - do not log twice
|
|
25
26
|
const message = e.constructor.name === 'CompilationError' ? 'CDS compilation failed' : e.messages.length ? e.message : 'CDS build failed'
|
|
26
27
|
throw message
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const cds = require('../../cds')
|
|
3
|
-
const
|
|
4
|
-
const { OUTPUT_MODE, OUTPUT_MODE_RESULT } = require('../constants')
|
|
3
|
+
const FeatureToggleBuildPlugin = require('./featureToggleBuildPlugin')
|
|
4
|
+
const { OUTPUT_MODE, OUTPUT_MODE_RESULT, FLAVOR_LOCALIZED_EDMX } = require('../constants')
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class EdmxBuildPlugin extends FeatureToggleBuildPlugin {
|
|
7
7
|
async compileToEdmx(model, edmxDest, compileOptions = {}) { // NOSONAR
|
|
8
8
|
const promises = []
|
|
9
9
|
|
|
@@ -24,12 +24,12 @@ class BuildTaskHandlerEdmx extends BuildTaskHandlerFeatureToggles {
|
|
|
24
24
|
const result = cds.compile.to.edmx(model, options)
|
|
25
25
|
|
|
26
26
|
if (result) {
|
|
27
|
-
let langs = this.task.options.lang || cds.env.i18n.languages
|
|
27
|
+
let langs = compileOptions[FLAVOR_LOCALIZED_EDMX] === false ? [] : this.task.options.lang || cds.env.i18n.languages
|
|
28
28
|
if (langs.split) { // string to array
|
|
29
29
|
langs = langs.split(',')
|
|
30
30
|
}
|
|
31
31
|
if (langs.length > 0 && langs[0] !== 'all' && langs.indexOf('') < 0) {
|
|
32
|
-
langs.push('') // make sure fallback language is in,
|
|
32
|
+
langs.push('') // make sure fallback language is in, runtime expects it
|
|
33
33
|
}
|
|
34
34
|
for (let [content, key] of result) {
|
|
35
35
|
const serviceName = key.file ? key.file : key.name
|
|
@@ -80,4 +80,4 @@ class BuildTaskHandlerEdmx extends BuildTaskHandlerFeatureToggles {
|
|
|
80
80
|
return Promise.resolve()
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
module.exports =
|
|
83
|
+
module.exports = EdmxBuildPlugin
|
package/lib/build/provider/{buildTaskHandlerFeatureToggles.js → featureToggleBuildPlugin.js}
RENAMED
|
@@ -2,10 +2,10 @@ const fs = require('fs')
|
|
|
2
2
|
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
|
-
const
|
|
5
|
+
const InternalBuildPlugin = require('./internalBuildPlugin')
|
|
6
6
|
const { getI18nDefaultFolder } = require('../util')
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class FeatureToggleBuildPlugin extends InternalBuildPlugin {
|
|
9
9
|
init() {
|
|
10
10
|
if (this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_RESULT)) {
|
|
11
11
|
this._result = {
|
|
@@ -130,4 +130,4 @@ class FeatureToggleBuilder extends BuildTaskHandlerInternal {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
module.exports =
|
|
133
|
+
module.exports = FeatureToggleBuildPlugin
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const cds = require('../../../cds')
|
|
3
|
-
const
|
|
3
|
+
const EdmxBuildPlugin = require('../edmxBuildPlugin')
|
|
4
4
|
const URL = require('url')
|
|
5
5
|
const { getProperty, relativePaths } = require('../../util')
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ const { OUTPUT_MODE, OUTPUT_MODE_RESULT, BUILD_TASK_FIORI, CDS_CONFIG_PATH_SEP,
|
|
|
11
11
|
* For SAP Web IDE Full-Stack compatibility a corresponding metadata.xml is still generated.
|
|
12
12
|
* Though, 'fiori' build tasks can still be configured for UI5 mock server usage - see https://github.wdf.sap.corp/cap/issues/issues/8673
|
|
13
13
|
*/
|
|
14
|
-
class
|
|
14
|
+
class FioriBuildPlugin extends EdmxBuildPlugin {
|
|
15
15
|
init() {
|
|
16
16
|
// enforce
|
|
17
17
|
this._result = {
|
|
@@ -26,7 +26,7 @@ class FioriAppModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
26
26
|
this.context.for = this.context.for || {}
|
|
27
27
|
this.context.for[BUILD_TASK_FIORI] = this.context.for[BUILD_TASK_FIORI] || {}
|
|
28
28
|
|
|
29
|
-
// cache for later use across multiple
|
|
29
|
+
// cache for later use across multiple FioriBuildPlugin instances
|
|
30
30
|
const fioriBuildOptions = this.context.for[BUILD_TASK_FIORI]
|
|
31
31
|
fioriBuildOptions.appModel = new Map()
|
|
32
32
|
fioriBuildOptions.appEdmx = new Map()
|
|
@@ -57,7 +57,6 @@ class FioriAppModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
57
57
|
this.context.options[OUTPUT_MODE] |= OUTPUT_MODE_RESULT
|
|
58
58
|
|
|
59
59
|
try {
|
|
60
|
-
const edmxOptions = { version: cds.env.odata?.version }
|
|
61
60
|
for (let [appFolder, appModelGroup] of appModelGroups.entries()) {
|
|
62
61
|
this.logger.debug(`building module [${appFolder}] using [${this.constructor.name}]`)
|
|
63
62
|
const modelPaths = cds.resolve(Array.from(appModelGroup.values()))
|
|
@@ -71,7 +70,7 @@ class FioriAppModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
71
70
|
const model = await cds.load(modelPaths, options)
|
|
72
71
|
fioriBuildOptions.appModel.set(appFolder, model)
|
|
73
72
|
|
|
74
|
-
await this.compileToEdmx(model
|
|
73
|
+
await this.compileToEdmx(model)
|
|
75
74
|
|
|
76
75
|
// cache edmx per fiori app root folder
|
|
77
76
|
fioriBuildOptions.appEdmx.set(appFolder, this._result.edmx)
|
|
@@ -165,4 +164,4 @@ class FioriAppModuleBuilder extends BuildTaskHandlerEdmx {
|
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
module.exports =
|
|
167
|
+
module.exports = FioriBuildPlugin
|