@sap/cds-dk 7.2.0 → 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 +6 -3
- package/bin/compile/index.js +9 -5
- package/bin/env.js +0 -3
- package/bin/extend.js +25 -3
- package/bin/import.js +7 -3
- package/bin/push.js +10 -6
- package/bin/watch.js +1 -1
- package/lib/build/{buildTaskHandler.js → buildPlugin.js} +23 -25
- package/lib/build/buildTaskEngine.js +73 -73
- package/lib/build/buildTaskFactory.js +6 -23
- package/lib/build/buildTaskProvider.js +24 -19
- package/lib/build/buildTaskProviderFactory.js +170 -57
- package/lib/build/constants.js +4 -4
- package/lib/build/index.js +3 -2
- 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 +54 -30
- package/lib/build/provider/{buildTaskHandlerInternal.js → internalBuildPlugin.js} +10 -10
- package/lib/build/provider/{buildTaskProviderInternal.js → internalBuildTaskProvider.js} +27 -28
- 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 +14 -13
- 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/env/schema.js +36 -0
- package/lib/env/schemas/cds-rc.json +101 -0
- package/lib/import/common.js +23 -10
- 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 +4 -2
- package/lib/init/index.js +2 -3
- package/lib/init/template/_merging/registry-mta.js +21 -0
- package/lib/init/template/approuter/files/mta.yaml.hbs +1 -1
- package/lib/init/template/approuter/index.js +9 -9
- package/lib/init/template/connectivity/index.js +5 -4
- package/lib/init/template/destination/index.js +2 -5
- package/lib/init/template/html5-repo/index.js +27 -3
- package/lib/init/template/mta/index.js +9 -3
- 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/util/projectReader.js +0 -1
- package/lib/util/pruneAxiosErrors.js +22 -8
- package/npm-shrinkwrap.json +1829 -23
- package/package.json +1 -1
|
@@ -1,12 +1,17 @@
|
|
|
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) {
|
|
@@ -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,46 +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
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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}]`)
|
|
80
|
+
|
|
81
|
+
const plugin = new BuildPluginClass()
|
|
82
|
+
plugin._task = resolvedTask
|
|
83
|
+
plugin._logger = this.logger
|
|
84
|
+
plugin._context = this.context
|
|
86
85
|
this.context.tasks.push(resolvedTask)
|
|
87
|
-
this.logger._debug && this.logger.debug(`created
|
|
88
|
-
return
|
|
86
|
+
this.logger._debug && this.logger.debug(`created build plugin [${resolvedTask.use}]`)
|
|
87
|
+
return plugin
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
/**
|
|
92
|
-
* Loads the build
|
|
93
|
-
* 'for' defines an alias for built-in
|
|
94
|
-
* '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.
|
|
95
94
|
* @param {object} task
|
|
96
95
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (!provider) {
|
|
100
|
-
throw new Error(`No provider found for build task '${task.for || task.use}'`)
|
|
101
|
-
}
|
|
96
|
+
loadPlugin(task) {
|
|
97
|
+
const provider = this._getProvider(task)
|
|
102
98
|
try {
|
|
103
|
-
return provider.
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
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)
|
|
107
102
|
throw e
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
resolveTasks(tasks) {
|
|
112
|
-
return tasks.map(task => this.
|
|
107
|
+
return tasks.map(task => this._resolveTask(task))
|
|
113
108
|
}
|
|
114
109
|
|
|
115
110
|
/**
|
|
@@ -117,9 +112,9 @@ class BuildTaskProviderFactory {
|
|
|
117
112
|
* The task is validated in order to ensure that 'src' refers to a valid folder and 'for' or 'use' reference can be required.
|
|
118
113
|
* @param {*} task
|
|
119
114
|
*/
|
|
120
|
-
|
|
121
|
-
// first validate
|
|
122
|
-
this.
|
|
115
|
+
_resolveTask(task) {
|
|
116
|
+
// first validate plugin implementation
|
|
117
|
+
this.loadPlugin(task)
|
|
123
118
|
|
|
124
119
|
// second validate src path
|
|
125
120
|
const resolvedTask = JSON.parse(JSON.stringify(task))
|
|
@@ -139,8 +134,23 @@ class BuildTaskProviderFactory {
|
|
|
139
134
|
return resolvedTask
|
|
140
135
|
}
|
|
141
136
|
|
|
142
|
-
|
|
143
|
-
|
|
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)
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
async _applyTaskDefaults(provider, tasks) {
|
|
@@ -150,8 +160,9 @@ class BuildTaskProviderFactory {
|
|
|
150
160
|
_loadProviders() {
|
|
151
161
|
// DefaultBuildTaskProvider must be last entry
|
|
152
162
|
return [
|
|
153
|
-
new
|
|
154
|
-
new
|
|
163
|
+
new InternalBuildTaskProvider(this.logger),
|
|
164
|
+
new PluginBuildTaskProvider(this.logger),
|
|
165
|
+
new DefaultBuildTaskProvider(this.logger)
|
|
155
166
|
]
|
|
156
167
|
}
|
|
157
168
|
}
|
|
@@ -161,19 +172,121 @@ class BuildTaskProviderFactory {
|
|
|
161
172
|
* Has to be the last entry in the providers list.
|
|
162
173
|
*/
|
|
163
174
|
class DefaultBuildTaskProvider extends BuildTaskProvider {
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
constructor(logger) {
|
|
176
|
+
super()
|
|
177
|
+
this._logger = logger
|
|
166
178
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
179
|
+
|
|
180
|
+
providesTask(key) {
|
|
181
|
+
return !!key.use
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
loadPlugin(task) {
|
|
171
185
|
try {
|
|
172
186
|
return require(require.resolve(task.use, { paths: [cds.root] }))
|
|
173
|
-
}
|
|
174
|
-
catch (e) {
|
|
187
|
+
} catch (e) {
|
|
175
188
|
throw new Error(`Build task could not be resolved - module [${task.use}] cannot be loaded:\n` + e)
|
|
176
189
|
}
|
|
177
190
|
}
|
|
178
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
|
+
}
|
|
179
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
|
|
@@ -56,4 +57,3 @@ exports.LOG_LEVEL_INFO = "info"
|
|
|
56
57
|
exports.LOG_LEVEL_DEBUG = "debug"
|
|
57
58
|
exports.LOG_LEVELS = [exports.LOG_LEVEL_ERROR, exports.LOG_LEVEL_WARN, exports.LOG_LEVEL_INFO, exports.LOG_LEVEL_DEBUG]
|
|
58
59
|
exports.LOG_MODULE_NAMES = "cds|build"
|
|
59
|
-
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.
|
|
@@ -21,6 +21,7 @@ async function build(options = {}) {
|
|
|
21
21
|
} catch (e) {
|
|
22
22
|
if (e instanceof BuildError || e.constructor.name === 'CompilationError') {
|
|
23
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
|