@sap/cds-dk 7.0.1 → 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 +8 -4
- package/bin/compile/index.js +3 -3
- package/bin/help.js +2 -3
- package/lib/build/buildTaskEngine.js +1 -1
- package/lib/build/provider/buildTaskHandlerFeatureToggles.js +2 -1
- package/lib/build/provider/java/index.js +2 -2
- package/lib/build/provider/mtx-sidecar/index.js +2 -3
- package/lib/build/util.js +8 -0
- package/lib/cds.js +2 -2
- package/lib/init/constants.js +4 -4
- package/lib/init/index.js +15 -15
- package/lib/init/template/_merging/registry-mta.js +2 -2
- package/lib/init/template/approuter/index.js +7 -3
- package/lib/init/template/cf-manifest/index.js +4 -4
- package/lib/init/template/data/index.js +1 -1
- package/lib/init/template/hana/index.js +1 -1
- package/lib/init/template/java/index.js +3 -3
- 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/index.js +9 -3
- package/lib/init/template/nodejs/index.js +2 -2
- package/lib/init/template/pipeline/index.js +1 -1
- 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/templateBase.js +1 -1
- package/lib/init/template/tiny-sample/index.js +1 -1
- package/lib/init/util/mvn.js +1 -1
- package/lib/init/util/projectReader.js +2 -2
- package/npm-shrinkwrap.json +14 -25
- 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/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
|
|
|
@@ -180,7 +184,7 @@ function _dieForUnknownCommand(cmd) {
|
|
|
180
184
|
`
|
|
181
185
|
console.error(msg)
|
|
182
186
|
|
|
183
|
-
process.
|
|
187
|
+
process.exit(1)
|
|
184
188
|
}
|
|
185
189
|
|
|
186
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/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) {
|
|
@@ -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)) {
|
|
@@ -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,11 +45,10 @@ 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,
|
|
51
|
+
await this.collectLanguageBundles(model, path.join(destSidecarSrc, getI18nDefaultFolder()))
|
|
53
52
|
await this.copySrvContent(this.task.src, destSidecar, destSidecar)
|
|
54
53
|
}
|
|
55
54
|
|
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) {
|
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
|
-
TINY_SAMPLE: 'tiny-sample',
|
|
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',
|
package/lib/init/index.js
CHANGED
|
@@ -100,7 +100,7 @@ module.exports = class CDSGenerator {
|
|
|
100
100
|
this._greetings(options._cmd);
|
|
101
101
|
|
|
102
102
|
if (!PROJECT_FILES.find(exists)) {
|
|
103
|
-
throw
|
|
103
|
+
throw `The current folder doesn't seem to contain a project. None of the following files found: ${PROJECT_FILES.join(', ')}.`
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
await this._process(options);
|
|
@@ -176,8 +176,6 @@ module.exports = class CDSGenerator {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
async _createTemplate(filename) {
|
|
179
|
-
// Compat
|
|
180
|
-
if (filename === 'sample-tiny') filename = 'tiny-sample'
|
|
181
179
|
|
|
182
180
|
try {
|
|
183
181
|
const TemplateClass = require(`./template/${filename}`);
|
|
@@ -202,26 +200,28 @@ module.exports = class CDSGenerator {
|
|
|
202
200
|
|
|
203
201
|
async _fillTemplateList() {
|
|
204
202
|
const templates = new Map();
|
|
205
|
-
for (
|
|
203
|
+
for (let option of this.options.add) {
|
|
204
|
+
// Compat
|
|
205
|
+
if (option === 'sample-tiny') option = 'tiny-sample'
|
|
206
|
+
if (option === 'kibana-logging') option = 'kibana'
|
|
207
|
+
|
|
206
208
|
if (!templates.has(option)) {
|
|
207
209
|
const template = await this._createTemplate(option);
|
|
208
|
-
|
|
209
210
|
if (await template.canRun()) {
|
|
210
211
|
DEBUG?.(`Adding feature '${template.name}'`);
|
|
211
|
-
|
|
212
212
|
templates.set(option, template);
|
|
213
213
|
const deps = await template.getDependencies();
|
|
214
214
|
if (deps) {
|
|
215
|
-
deps.forEach(this.options.add.add, this.options.add)
|
|
215
|
+
deps.forEach(this.options.add.add, this.options.add) // REVISIT: Ugly add.add
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
const cmds = Object.values(OPTIONS)
|
|
222
|
-
this.templateList = Array.from(templates.entries())
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
const cmds = Object.values(OPTIONS)
|
|
222
|
+
this.templateList = Array.from(templates.entries())
|
|
223
|
+
.sort(([a], [b]) => cmds.indexOf(a) - cmds.indexOf(b))
|
|
224
|
+
.map((entry) => entry[1])
|
|
225
225
|
|
|
226
226
|
// check debug to avoid lengthy computation when not in debug mode
|
|
227
227
|
DEBUG?.(`Features: ${this.templateList.map(({name}) => name).join(', ')}`);
|
|
@@ -293,7 +293,7 @@ module.exports = class CDSGenerator {
|
|
|
293
293
|
|
|
294
294
|
async _validateProjectName(projectName) {
|
|
295
295
|
if (!projectName) {
|
|
296
|
-
throw
|
|
296
|
+
throw 'Specify a project name.'
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
// remove duplicates by using a set
|
|
@@ -302,9 +302,9 @@ module.exports = class CDSGenerator {
|
|
|
302
302
|
case 0:
|
|
303
303
|
break;
|
|
304
304
|
case 1:
|
|
305
|
-
throw
|
|
305
|
+
throw `Project name ${projectName} contains an invalid character (${[...invalidChars].join(', ')}). Specify a different project name.`
|
|
306
306
|
default:
|
|
307
|
-
throw
|
|
307
|
+
throw `Project name ${projectName} contains invalid characters (${[...invalidChars].join(', ')}). Specify a different project name.`
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
@@ -317,7 +317,7 @@ module.exports = class CDSGenerator {
|
|
|
317
317
|
} else {
|
|
318
318
|
message = `You seem to be trying to initialize an existing project. Use a different project name instead.`;
|
|
319
319
|
}
|
|
320
|
-
throw
|
|
320
|
+
throw `${message}\nDetails: File '${existingProjectFile}' exists in the project folder which indicates an existing project. Use ${term.bold('cds add')} to add more features.`
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
}
|
|
@@ -93,7 +93,7 @@ const enterpriseMessaging = {
|
|
|
93
93
|
}]
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
const
|
|
96
|
+
const kibana = {
|
|
97
97
|
in: 'resources',
|
|
98
98
|
where: [{
|
|
99
99
|
property: 'type',
|
|
@@ -278,6 +278,6 @@ module.exports = {
|
|
|
278
278
|
requiredAppApi4,
|
|
279
279
|
providedJavaApprouterApi4,
|
|
280
280
|
providedJavaApprouterApi,
|
|
281
|
-
|
|
281
|
+
kibana,
|
|
282
282
|
approuterExtensibility
|
|
283
283
|
}
|
|
@@ -3,7 +3,7 @@ const { exists } = cds.utils
|
|
|
3
3
|
const { join } = require('path')
|
|
4
4
|
const { readProject } = require('../../util/projectReader')
|
|
5
5
|
const { mergeJSON, mergeYAML, sort } = require('../../util/merge')
|
|
6
|
-
const { XSUAA } = require('../../constants').OPTIONS
|
|
6
|
+
const { XSUAA, KIBANA } = require('../../constants').OPTIONS
|
|
7
7
|
const {
|
|
8
8
|
srvNode4, srvJava4, mtxSidecar4, approuter, // Modules
|
|
9
9
|
xsuaa, // BTP Services
|
|
@@ -23,6 +23,10 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
23
23
|
return [XSUAA]
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
getRelatedFacets() {
|
|
27
|
+
return [KIBANA]
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
async run() {
|
|
27
31
|
const { appPath = 'app' } = await readProject(this.options)
|
|
28
32
|
const appPackageJSONPath = join(appPath, 'package.json')
|
|
@@ -34,7 +38,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
34
38
|
|
|
35
39
|
async runDependentMerging(context = {}) {
|
|
36
40
|
const project = await readProject(this.options)
|
|
37
|
-
const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath } = project
|
|
41
|
+
const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath, appPath } = project
|
|
38
42
|
|
|
39
43
|
if (hasMta) {
|
|
40
44
|
const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
|
|
@@ -113,7 +117,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
113
117
|
if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
const xsAppPath = join(
|
|
120
|
+
const xsAppPath = join(appPath, 'xs-app.json')
|
|
117
121
|
const additions = isExtensible ? [{ ...approuterExtensibility, at: 0 }] : []
|
|
118
122
|
await mergeJSON(xsAppPath, join(__dirname, 'files', 'xs-app.json.hbs'), project, { additions })
|
|
119
123
|
}
|
|
@@ -10,16 +10,16 @@ module.exports = class CfManifestTemplate extends require('../templateBase') {
|
|
|
10
10
|
|
|
11
11
|
async canRun() {
|
|
12
12
|
if (this.options.force) {
|
|
13
|
-
return true
|
|
13
|
+
return true
|
|
14
14
|
}
|
|
15
15
|
if (exists(MANIFEST_FILE) || exists(SERVICES_MANIFEST_FILE)) {
|
|
16
|
-
throw
|
|
16
|
+
throw `File ${MANIFEST_FILE} or ${SERVICES_MANIFEST_FILE} already exist in current folder. Use --force to overwrite.`
|
|
17
17
|
}
|
|
18
|
-
return true
|
|
18
|
+
return true
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async run() {
|
|
22
22
|
const project = await readProject()
|
|
23
|
-
await copyFiles(join(__dirname, 'files'), cds.root, project, this.options.force)
|
|
23
|
+
await copyFiles(join(__dirname, 'files'), cds.root, project, this.options.force)
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -204,7 +204,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
|
|
|
204
204
|
} catch (err) {
|
|
205
205
|
// REVISIT: This should not have to be checked and tested in a facet implementation, move to Maven util
|
|
206
206
|
if (err.code === 'ENOENT' && err.path === 'mvn') {
|
|
207
|
-
throw
|
|
207
|
+
throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
|
|
208
208
|
}
|
|
209
209
|
throw err;
|
|
210
210
|
}
|
|
@@ -14,10 +14,10 @@ module.exports = class JavaTemplate extends require('../templateBase') {
|
|
|
14
14
|
|
|
15
15
|
async canRun() {
|
|
16
16
|
if (cds.cli.command === COMMAND_ADD) {
|
|
17
|
-
throw
|
|
17
|
+
throw `You can't change the runtime of an existing project.`
|
|
18
18
|
}
|
|
19
19
|
if (cds.cli.options.add?.has(NODEJS)) {
|
|
20
|
-
throw
|
|
20
|
+
throw `Only one runtime per project is supported. Specify either ${term.bold(JAVA)} or ${term.bold(NODEJS)}.`
|
|
21
21
|
}
|
|
22
22
|
return true
|
|
23
23
|
}
|
|
@@ -32,7 +32,7 @@ module.exports = class JavaTemplate extends require('../templateBase') {
|
|
|
32
32
|
await copy(join(temp, artifactId), this.projectPath);
|
|
33
33
|
} catch (err) {
|
|
34
34
|
if (err.code === 'ENOENT' && err.path === 'mvn') {
|
|
35
|
-
throw
|
|
35
|
+
throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
|
|
36
36
|
}
|
|
37
37
|
throw err;
|
|
38
38
|
} finally {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
modules:
|
|
3
|
+
- name: {{appName}}-srv
|
|
4
|
+
type: {{language}}
|
|
5
|
+
path: {{& srvPath}}
|
|
6
|
+
requires:
|
|
7
|
+
- name: {{appName}}-logging
|
|
8
|
+
|
|
9
|
+
{{#isMultitenant}}
|
|
10
|
+
- name: {{appName}}-mtx
|
|
11
|
+
type: nodejs
|
|
12
|
+
path: {{#isNodejs}}gen/{{/isNodejs}}mtx/sidecar
|
|
13
|
+
requires:
|
|
14
|
+
- name: {{appName}}-logging
|
|
15
|
+
{{/isMultitenant}}
|
|
16
|
+
|
|
17
|
+
{{#hasApprouter}}
|
|
18
|
+
- name: {{appName}}
|
|
19
|
+
type: approuter.nodejs
|
|
20
|
+
requires:
|
|
21
|
+
- name: {{appName}}-logging
|
|
22
|
+
{{/hasApprouter}}
|
|
23
|
+
|
|
24
|
+
resources:
|
|
25
|
+
- name: {{appName}}-logging
|
|
26
|
+
type: org.cloudfoundry.managed-service
|
|
27
|
+
parameters:
|
|
28
|
+
service: application-logs
|
|
29
|
+
service-plan: lite
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const { join } = require('path')
|
|
2
|
+
const { readProject } = require('../../util/projectReader')
|
|
3
|
+
const { mergeJSON, mergeYAML } = require('../../util/merge')
|
|
4
|
+
const { srvNode4, srvJava4, mtxSidecar4, kibana, approuter } = require('../_merging/registry-mta')
|
|
5
|
+
|
|
6
|
+
module.exports = class KibanaTemplate extends require('../templateBase') {
|
|
7
|
+
|
|
8
|
+
static hasFacet(env) {
|
|
9
|
+
return env.features.kibana_formatter
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async canRun() {
|
|
13
|
+
const { hasMta, hasHelm, isJava } = await readProject(this.options)
|
|
14
|
+
if (hasHelm && !hasMta) throw `'cds add kibana' is not available for Kyma yet`
|
|
15
|
+
if (isJava) throw `'cds add kibana' is not available for Java yet`
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async run() {
|
|
20
|
+
const project = await readProject(this.options)
|
|
21
|
+
const { configFile } = project
|
|
22
|
+
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
23
|
+
await this.runDependentMerging()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async runDependentMerging() {
|
|
27
|
+
const project = await readProject(this.options)
|
|
28
|
+
const { hasMta, hasApprouter, isJava, isMultitenant, srvPath } = project
|
|
29
|
+
|
|
30
|
+
if (hasMta) {
|
|
31
|
+
const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
|
|
32
|
+
const additions = [srv, kibana]
|
|
33
|
+
const relationships = [{
|
|
34
|
+
insert: [kibana, 'name'],
|
|
35
|
+
into: [srv, 'requires', 'name']
|
|
36
|
+
}]
|
|
37
|
+
if (isMultitenant) {
|
|
38
|
+
const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar')
|
|
39
|
+
additions.push(mtxSidecar)
|
|
40
|
+
relationships.push({
|
|
41
|
+
insert: [kibana, 'name'],
|
|
42
|
+
into: [mtxSidecar, 'requires', 'name']
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
if (hasApprouter) {
|
|
46
|
+
additions.push(approuter)
|
|
47
|
+
relationships.push({
|
|
48
|
+
insert: [kibana, 'name'],
|
|
49
|
+
into: [approuter, 'requires', 'name']
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, { additions, relationships })
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|