@sap/cds-dk 4.7.1 → 4.8.1
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/CHANGELOG.md +49 -0
- package/bin/activate.js +5 -1
- package/bin/add.js +2 -2
- package/lib/bind/bindingUtil.js +6 -1
- package/lib/client/activate.js +8 -3
- package/lib/client/base_command.js +5 -1
- package/lib/client/helper/cf_helper.js +5 -2
- package/lib/client/params.js +16 -2
- package/lib/client/settings_manager.js +15 -8
- package/lib/compile/openapi/csdl2openapi.js +6 -8
- package/lib/compile/to-xsuaa.js +0 -14
- package/lib/import/utils/MetadataConverter.js +6 -4
- package/lib/import/v2parser.js +59 -35
- package/lib/import/v4parser.js +70 -47
- package/lib/init/constants.js +10 -4
- package/lib/init/index.js +13 -7
- package/lib/init/template/_merging/existences.js +161 -0
- package/lib/init/template/approuter/files/default-env.json +9 -0
- package/lib/init/template/approuter/files/mta.yaml.hbs +48 -0
- package/lib/init/template/approuter/files/package.json +9 -0
- package/lib/init/template/approuter/files/xs-app.json +8 -0
- package/lib/init/template/approuter/index.js +66 -0
- package/lib/init/template/auditlog/files/dependencies.package.json +5 -0
- package/lib/init/template/auditlog/files/mta.yaml.hbs +13 -0
- package/lib/init/template/auditlog/index.js +38 -0
- package/lib/init/template/cf-manifest/index.js +1 -1
- package/lib/init/template/hana/files/mta.yaml.hbs +42 -0
- package/lib/init/template/hana/files/nodejs/dependencies.package.json +5 -0
- package/lib/init/template/hana/index.js +53 -24
- package/lib/init/template/java/index.js +1 -5
- package/lib/init/template/mta/files/mta.yaml.hbs +24 -220
- package/lib/init/template/mta/index.js +25 -17
- package/lib/init/template/mtx/files/cds.package.json +24 -0
- package/lib/init/template/mtx/files/dependencies.package.json +5 -0
- package/lib/init/template/mtx/files/mta.yaml.hbs +74 -0
- package/lib/init/template/mtx/files/xs-security.json.hbs +23 -9
- package/lib/init/template/mtx/index.js +126 -29
- package/lib/init/template/templateBase.js +14 -0
- package/lib/init/template/xsuaa/files/cds.package.json +9 -0
- package/lib/init/template/xsuaa/files/dependencies.package.json +6 -0
- package/lib/init/template/xsuaa/files/mta.yaml.hbs +17 -0
- package/lib/init/template/xsuaa/index.js +75 -0
- package/lib/init/util/fsUtil.js +17 -3
- package/lib/init/util/logger.js +3 -1
- package/lib/init/util/mvnArchetypeUtil.js +3 -1
- package/lib/init/{template/mta → util}/projectReader.js +26 -11
- package/lib/init/util/templateUtil.js +267 -3
- package/lib/lint/Linter.js +0 -1
- package/lib/lint/io.js +2 -2
- package/lib/util/exec.d.ts +54 -0
- package/lib/util/exec.js +210 -0
- package/lib/watch/livereload-server.js +43 -31
- package/lib/watch/open.js +1 -1
- package/npm-shrinkwrap.json +3819 -16606
- package/package.json +7 -8
- package/readme.md +1 -1
- package/lib/import/internalDoc/edm2cdsTypeMapping.md +0 -38
- package/lib/init/template/mtx/package/cds.package.json +0 -29
- package/lib/init/template/mtx/package/dependencies.package.json +0 -9
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
"xsappname": "{{cap.appName}}-${space}",
|
|
3
|
-
"tenant-mode": "shared",
|
|
4
2
|
"scopes": [
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
"$XSAPPNAME
|
|
11
|
-
|
|
3
|
+
{
|
|
4
|
+
"name": "$XSAPPNAME.ExtendCDS",
|
|
5
|
+
"description": "Extend CDS applications"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "$XSAPPNAME.ExtendCDSdelete",
|
|
9
|
+
"description": "Extend CDS applications with undeployments"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "$XSAPPNAME.MtxDiagnose",
|
|
13
|
+
"description": "Diagnose MTX"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "$XSAPPNAME.mtdeployment",
|
|
17
|
+
"description": "Deploy applications"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "$XSAPPNAME.mtcallback",
|
|
21
|
+
"description": "Subscribe to applications",
|
|
22
|
+
"grant-as-authority-to-apps": [
|
|
23
|
+
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
12
26
|
],
|
|
13
27
|
"authorities": [
|
|
14
28
|
"$XSAPPNAME.MtxDiagnose",
|
|
@@ -1,45 +1,142 @@
|
|
|
1
|
-
const TemplateBase = require('../templateBase')
|
|
2
|
-
const ProjectReader = require('
|
|
3
|
-
const {
|
|
4
|
-
|
|
1
|
+
const TemplateBase = require('../templateBase')
|
|
2
|
+
const ProjectReader = require('../../util/projectReader')
|
|
3
|
+
const { fse } = require('@sap/cds-foss')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const { OPTION_HANA, OPTION_XSUAA } = require('../../constants')
|
|
6
|
+
const { srvNode, srvJava, saasRegistry, mtxSidecar, mtxAPI, srvAPI, hdiContainer, xsuaa } = require('../_merging/existences');
|
|
5
7
|
|
|
6
8
|
module.exports = class MtxTemplate extends TemplateBase {
|
|
7
9
|
constructor(projectPath, generator) {
|
|
8
|
-
super(projectPath, generator, __dirname)
|
|
9
|
-
this.projectReader = new ProjectReader(this)
|
|
10
|
+
super(projectPath, generator, __dirname)
|
|
11
|
+
this.projectReader = new ProjectReader(this)
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
async getDependencies() {
|
|
13
|
-
return [OPTION_HANA]
|
|
15
|
+
return [OPTION_HANA, OPTION_XSUAA]
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
async
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
async runMTAMerging() {
|
|
19
|
+
const projectDescriptor = await this.projectReader.read()
|
|
20
|
+
|
|
21
|
+
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
|
|
22
|
+
if (!fse.existsSync(mtaYAMLPath)) {
|
|
23
|
+
console.warn(`There is no MTA file in your project. Run \`cds add mta\` to add an MTA file or create the MTX services yourself.`)
|
|
24
|
+
return;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
const mergingRules = projectDescriptor.cap.isNodejs ?
|
|
28
|
+
{
|
|
29
|
+
existences: [srvNode, saasRegistry, mtxAPI, xsuaa],
|
|
30
|
+
overwrites: [{
|
|
31
|
+
in: xsuaa.ref,
|
|
32
|
+
keyPath: ["parameters", "config", "tenant-mode"],
|
|
33
|
+
replacement: "shared"
|
|
34
|
+
}],
|
|
35
|
+
deletions: [hdiContainer],
|
|
36
|
+
relationships: [{
|
|
37
|
+
in: srvNode.ref,
|
|
38
|
+
inKeyPath: ["requires"],
|
|
39
|
+
into: "name",
|
|
40
|
+
existences: [saasRegistry.ref],
|
|
41
|
+
existenceKeyPath: ["name"],
|
|
42
|
+
}],
|
|
43
|
+
}
|
|
44
|
+
:
|
|
45
|
+
{
|
|
46
|
+
existences: [srvJava, srvAPI, mtxSidecar, saasRegistry],
|
|
47
|
+
relationships: [{
|
|
48
|
+
in: srvJava.ref,
|
|
49
|
+
inKeyPath: ["requires"],
|
|
50
|
+
into: "name",
|
|
51
|
+
existences: [saasRegistry.ref, mtxSidecar.ref],
|
|
52
|
+
existenceKeyPath: ["name"],
|
|
53
|
+
}],
|
|
54
|
+
}
|
|
23
55
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
56
|
+
await this.templateUtil.mergeYAML(
|
|
57
|
+
mtaYAMLPath,
|
|
58
|
+
path.join(__dirname, `files`, `mta.yaml.hbs`),
|
|
59
|
+
projectDescriptor,
|
|
60
|
+
mergingRules
|
|
61
|
+
)
|
|
28
62
|
}
|
|
29
63
|
|
|
30
|
-
async
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
async runXSSecurityMerging() {
|
|
65
|
+
const projectDescriptor = await this.projectReader.read()
|
|
66
|
+
const mtxPath = projectDescriptor.cap.isJava ? 'mtx-sidecar' : ''
|
|
67
|
+
await this.templateUtil.mergeJSON(
|
|
68
|
+
path.join(this.projectPath, mtxPath, 'xs-security.json'),
|
|
69
|
+
path.join(__dirname, 'files', 'xs-security.json.hbs'),
|
|
70
|
+
projectDescriptor,
|
|
71
|
+
{
|
|
72
|
+
existences: [{
|
|
73
|
+
ref: "scope-diagnose",
|
|
74
|
+
keyPath: ["scopes"],
|
|
75
|
+
constraints: [{
|
|
76
|
+
comparisonKeyPath: ["name"],
|
|
77
|
+
value: "$XSAPPNAME.MtxDiagnose"
|
|
78
|
+
}],
|
|
79
|
+
}, {
|
|
80
|
+
ref: "scope-subscription",
|
|
81
|
+
keyPath: ["scopes"],
|
|
82
|
+
constraints: [{
|
|
83
|
+
comparisonKeyPath: ["name"],
|
|
84
|
+
value: "$XSAPPNAME.mtcallback"
|
|
85
|
+
}],
|
|
86
|
+
}, {
|
|
87
|
+
ref: "scope-update",
|
|
88
|
+
keyPath: ["scopes"],
|
|
89
|
+
constraints: [{
|
|
90
|
+
comparisonKeyPath: ["name"],
|
|
91
|
+
value: "$XSAPPNAME.mtdeployment"
|
|
92
|
+
}],
|
|
93
|
+
}, {
|
|
94
|
+
ref: "scope-extend",
|
|
95
|
+
keyPath: ["scopes"],
|
|
96
|
+
constraints: [{
|
|
97
|
+
comparisonKeyPath: ["name"],
|
|
98
|
+
value: "$XSAPPNAME.ExtendCDS"
|
|
99
|
+
}],
|
|
100
|
+
}, {
|
|
101
|
+
ref: "scope-extend-delete",
|
|
102
|
+
keyPath: ["scopes"],
|
|
103
|
+
constraints: [{
|
|
104
|
+
comparisonKeyPath: ["name"],
|
|
105
|
+
value: "$XSAPPNAME.ExtendCDSdelete"
|
|
106
|
+
}],
|
|
107
|
+
}, {
|
|
108
|
+
ref: "template-mt-administrator",
|
|
109
|
+
keyPath: ["role-templates"],
|
|
110
|
+
constraints: [{
|
|
111
|
+
comparisonKeyPath: ["name"],
|
|
112
|
+
value: "MultitenancyAdministrator"
|
|
113
|
+
}],
|
|
114
|
+
}, {
|
|
115
|
+
ref: "template-extension-developer",
|
|
116
|
+
keyPath: ["role-templates"],
|
|
117
|
+
constraints: [{
|
|
118
|
+
comparisonKeyPath: ["name"],
|
|
119
|
+
value: "ExtensionDeveloper"
|
|
120
|
+
}],
|
|
121
|
+
}, {
|
|
122
|
+
ref: "template-extension-developer-undeploy",
|
|
123
|
+
keyPath: ["role-templates"],
|
|
124
|
+
constraints: [{
|
|
125
|
+
comparisonKeyPath: ["name"],
|
|
126
|
+
value: "ExtensionDeveloperUndeploy"
|
|
127
|
+
}],
|
|
128
|
+
}],
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
}
|
|
42
132
|
|
|
43
|
-
|
|
133
|
+
async run() {
|
|
134
|
+
const projectDescriptor = await this.projectReader.read()
|
|
135
|
+
const mtxPath = projectDescriptor.cap.isJava ? 'mtx-sidecar' : ''
|
|
136
|
+
const packageJsonPath = path.join(this.projectPath, mtxPath, 'package.json')
|
|
137
|
+
await this.templateUtil.mergeJSON(packageJsonPath, path.join(__dirname, 'files', 'cds.package.json'))
|
|
138
|
+
await this.templateUtil.mergeJSON(packageJsonPath, path.join(__dirname, 'files', 'dependencies.package.json'))
|
|
139
|
+
await this.runXSSecurityMerging()
|
|
140
|
+
await this.runMTAMerging()
|
|
44
141
|
}
|
|
45
142
|
}
|
|
@@ -57,6 +57,20 @@ module.exports = class TemplateBase {
|
|
|
57
57
|
return Config.for('cds', projectPath);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @abstract
|
|
62
|
+
* Executes the given template's merging steps.
|
|
63
|
+
* The separation from `run()` is necessary to preserve templating associativity,
|
|
64
|
+
* i.e. the order in which you apply them does not matter.
|
|
65
|
+
* Ex.: Assume `cds add hana` is called before `cds add mta`. We want `cds add mta`
|
|
66
|
+
* to create the base mta.yaml template and merge the hana mta.yaml in, but _don't_
|
|
67
|
+
* want any other steps from the hana template performed (e.g. creating the .hdiconfig).
|
|
68
|
+
* Separating the two let's us run this _only_ the merging part of the template.
|
|
69
|
+
*/
|
|
70
|
+
async runMTAMerging() {
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
60
74
|
/**
|
|
61
75
|
* @abstract
|
|
62
76
|
* Executes the given template.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
modules:
|
|
3
|
+
- name: {{cap.appName}}-srv
|
|
4
|
+
type: {{cap.pLanguage}}
|
|
5
|
+
requires:
|
|
6
|
+
- name: {{cap.appName}}-uaa
|
|
7
|
+
|
|
8
|
+
resources:
|
|
9
|
+
- name: {{cap.appName}}-uaa{{#cap.isMultitenant}}-mt{{/cap.isMultitenant}}
|
|
10
|
+
type: org.cloudfoundry.managed-service
|
|
11
|
+
parameters:
|
|
12
|
+
service: xsuaa
|
|
13
|
+
service-plan: application
|
|
14
|
+
path: ./xs-security.json
|
|
15
|
+
config:
|
|
16
|
+
xsappname: {{cap.appName}}-${org}-${space}
|
|
17
|
+
tenant-mode: {{#cap.isMultitenant}}shared{{/cap.isMultitenant}}{{^cap.isMultitenant}}dedicated{{/cap.isMultitenant}}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const TemplateBase = require('../templateBase')
|
|
2
|
+
const ProjectReader = require('../../util/projectReader')
|
|
3
|
+
const { fse } = require('@sap/cds-foss')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const { srvNode, srvJava, xsuaa } = require('../_merging/existences');
|
|
6
|
+
|
|
7
|
+
module.exports = class XsuaaTemplate extends TemplateBase {
|
|
8
|
+
constructor(projectPath, generator) {
|
|
9
|
+
super(projectPath, generator, __dirname)
|
|
10
|
+
this.projectReader = new ProjectReader(this)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async runMTAMerging() {
|
|
14
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
15
|
+
const {projectPath} = this
|
|
16
|
+
const mtaYAMLPath = path.join(projectPath, 'mta.yaml')
|
|
17
|
+
if (!fse.existsSync(mtaYAMLPath)) {
|
|
18
|
+
console.warn(`There is no MTA file in your project. Run \`cds add mta\` to add an MTA file or create the XSUAA services yourself.`)
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
const srv = projectDescriptor.cap.isNodejs ? srvNode : srvJava
|
|
22
|
+
await this.templateUtil.mergeYAML(
|
|
23
|
+
mtaYAMLPath,
|
|
24
|
+
`${__dirname}/files/mta.yaml.hbs`,
|
|
25
|
+
projectDescriptor,
|
|
26
|
+
{
|
|
27
|
+
existences: [srv, xsuaa],
|
|
28
|
+
relationships: [{
|
|
29
|
+
in: srv.ref,
|
|
30
|
+
inKeyPath: ["requires"],
|
|
31
|
+
into: "name",
|
|
32
|
+
existences: [xsuaa.ref],
|
|
33
|
+
existenceKeyPath: ["name"],
|
|
34
|
+
}],
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
// Re-applying the merging part of `cds add mtx` because cds.compile.to.xsuaa
|
|
39
|
+
// has overwritten the existing `xs-security.json`.
|
|
40
|
+
// TODO: Find a generic solution for situation like these.
|
|
41
|
+
if (projectDescriptor.cap.isMultitenant) {
|
|
42
|
+
const MtxTemplate = require(`../mtx`)
|
|
43
|
+
const mtxTemplate = new MtxTemplate(this.projectPath, this.generator)
|
|
44
|
+
await mtxTemplate.runMTAMerging()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async run() {
|
|
49
|
+
const {projectPath} = this
|
|
50
|
+
const templatePath = path.join(__dirname, 'files')
|
|
51
|
+
const packageJSONPath = path.join(projectPath, 'package.json')
|
|
52
|
+
await this.templateUtil.mergeJSON(packageJSONPath, `${templatePath}/cds.package.json`)
|
|
53
|
+
await this.templateUtil.mergeJSON(packageJSONPath, `${templatePath}/dependencies.package.json`)
|
|
54
|
+
const xsSecurityPath = path.join(projectPath, 'xs-security.json')
|
|
55
|
+
const cds = require('../../../../lib/compile')
|
|
56
|
+
const xsuaa = await (async () => { try {
|
|
57
|
+
const models = await cds.load(`${projectPath}/srv`)
|
|
58
|
+
return cds.compile.to.xsuaa(models)
|
|
59
|
+
} catch (error) { /* ignore */ }
|
|
60
|
+
})() || { scopes: [], attributes: [], 'role-templates': [] }
|
|
61
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
62
|
+
await this.fsUtil.writeJSON(xsSecurityPath, xsuaa)
|
|
63
|
+
|
|
64
|
+
// TODO: Get rid of this by auto-creating a merging definition from
|
|
65
|
+
// the current xs-security.json. This should also solve role-templates
|
|
66
|
+
// being thrown out
|
|
67
|
+
if (projectDescriptor.cap.isMultitenant) {
|
|
68
|
+
const MtxTemplate = require(`../mtx`)
|
|
69
|
+
const mtxTemplate = new MtxTemplate(this.projectPath, this.generator)
|
|
70
|
+
await mtxTemplate.runXSSecurityMerging()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await this.runMTAMerging()
|
|
74
|
+
}
|
|
75
|
+
}
|
package/lib/init/util/fsUtil.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
|
-
const {fse} = require('@sap/cds-foss')
|
|
3
|
+
const {fse, yaml} = require('@sap/cds-foss')
|
|
4
4
|
const JSONC = require('../../util/jsonc');
|
|
5
5
|
|
|
6
6
|
const UTF_8 = 'utf-8';
|
|
@@ -25,6 +25,10 @@ module.exports = class FsUtil {
|
|
|
25
25
|
await fse.outputJSON(filepath, object, options);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
async writeYAML(filepath, yaml, skipFileLog = false) {
|
|
29
|
+
await this.writeFile(filepath, String(yaml), skipFileLog);
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
async readFile(src) {
|
|
29
33
|
return await fse.readFile(src, UTF_8);
|
|
30
34
|
}
|
|
@@ -34,8 +38,18 @@ module.exports = class FsUtil {
|
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
async readJSONC(src) {
|
|
37
|
-
const
|
|
38
|
-
return JSONC.parse(
|
|
41
|
+
const fileContents = await this.readFile(src);
|
|
42
|
+
return JSONC.parse(fileContents);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async readYAML(src, projectDescriptor) {
|
|
46
|
+
const file = await this.readFile(src);
|
|
47
|
+
if (projectDescriptor) {
|
|
48
|
+
const Mustache = require('mustache');
|
|
49
|
+
const renderedFile = Mustache.render(file, projectDescriptor);
|
|
50
|
+
return yaml.parseDocument(renderedFile);
|
|
51
|
+
}
|
|
52
|
+
return yaml.parseDocument(file);
|
|
39
53
|
}
|
|
40
54
|
|
|
41
55
|
async copy(source, destination, options = {}, skipFileLog = false) {
|
package/lib/init/util/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
const { nullLogger } = require('
|
|
2
|
+
const { nullLogger } = require('../util/logger')
|
|
3
3
|
const { BuildTaskFactory } = require('@sap/cds/bin/build')
|
|
4
4
|
const P_LANGUAGE_JAVA = 'java'
|
|
5
5
|
const P_LANGUAGE_NODEJS = 'nodejs'
|
|
@@ -41,11 +41,11 @@ module.exports = class ProjectReader {
|
|
|
41
41
|
return this.template.projectPath
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
async read() {
|
|
44
|
+
async read(options) {
|
|
45
45
|
const env = await this.getEnv();
|
|
46
46
|
this.logger.isDebug && this.logger.debug(JSON.stringify(env, null, 1))
|
|
47
47
|
|
|
48
|
-
const capDescriptor = await this._getCapDescriptor(env)
|
|
48
|
+
const capDescriptor = await this._getCapDescriptor(env, options)
|
|
49
49
|
const uiDescriptor = await this._getUiDescriptor(env)
|
|
50
50
|
const projectDescriptor = {
|
|
51
51
|
cap: capDescriptor,
|
|
@@ -58,14 +58,14 @@ module.exports = class ProjectReader {
|
|
|
58
58
|
return projectDescriptor
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
async _getCapDescriptor(env) {
|
|
61
|
+
async _getCapDescriptor(env, options) {
|
|
62
62
|
let capDescriptor = {
|
|
63
63
|
pLanguage: DEFAULT_P_LANGUAGE,
|
|
64
64
|
srv: {},
|
|
65
65
|
db: [],
|
|
66
66
|
requires: [],
|
|
67
67
|
get isMultitenant() {
|
|
68
|
-
return env.requires.multitenancy || env.requires.db && env.requires.db.multiTenant || false
|
|
68
|
+
return options && options.add.has('mtx') || env.requires.multitenancy || env.requires.db && env.requires.db.multiTenant || false
|
|
69
69
|
},
|
|
70
70
|
get isNodejs() {
|
|
71
71
|
return this.pLanguage === P_LANGUAGE_NODEJS
|
|
@@ -79,10 +79,15 @@ module.exports = class ProjectReader {
|
|
|
79
79
|
get hasRequiresDb() {
|
|
80
80
|
return this.db.length > 0
|
|
81
81
|
},
|
|
82
|
-
get
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
get hasHana() {
|
|
83
|
+
return this.requires.some(({resource}) => resource.isHana)
|
|
84
|
+
},
|
|
85
|
+
get hasXsuaa() {
|
|
86
|
+
return this.requires.some(({resource}) => resource.isXsuaa)
|
|
85
87
|
},
|
|
88
|
+
get needsSidecar() {
|
|
89
|
+
return (options && options.add.has('hana') || this.db.length > 0) && (this.isJava || !this.isMultitenant)
|
|
90
|
+
}
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
// setting the effective env as it might have changed by already executed 'add' commands, e.g. cds init foo --add hana,mta
|
|
@@ -169,9 +174,19 @@ module.exports = class ProjectReader {
|
|
|
169
174
|
appPath: null
|
|
170
175
|
}
|
|
171
176
|
|
|
172
|
-
|
|
177
|
+
const absoluteAppPath = path.join(this.projectPath, env.folders.app)
|
|
178
|
+
if (await this.fsUtil.pathExists(absoluteAppPath)) {
|
|
173
179
|
uiDescriptor.appPath = env.folders.app
|
|
174
180
|
}
|
|
181
|
+
|
|
182
|
+
const packageJson = await (async () => { try {
|
|
183
|
+
return await this.fsUtil.readFile(absoluteAppPath+'package.json')
|
|
184
|
+
} catch(error) { /* ignore */ }
|
|
185
|
+
})()
|
|
186
|
+
|
|
187
|
+
if (packageJson && packageJson.dependencies) {
|
|
188
|
+
uiDescriptor.appRouterEnabled = packageJson.dependencies['@sap/approuter'] !== undefined
|
|
189
|
+
}
|
|
175
190
|
return uiDescriptor
|
|
176
191
|
}
|
|
177
192
|
|
|
@@ -366,7 +381,7 @@ module.exports = class ProjectReader {
|
|
|
366
381
|
// use different service name to avoid conflicts when switching from single tenant to multitenant
|
|
367
382
|
// otherwise we would enforce that users have to delete the db container first
|
|
368
383
|
if (resource.isMultitenant) {
|
|
369
|
-
resource.name += '-mt'
|
|
384
|
+
//resource.name += '-mt'
|
|
370
385
|
resource.service = 'service-manager'
|
|
371
386
|
resource.vcap.plan = 'container'
|
|
372
387
|
} else {
|
|
@@ -459,7 +474,7 @@ module.exports = class ProjectReader {
|
|
|
459
474
|
}))
|
|
460
475
|
}
|
|
461
476
|
} else {
|
|
462
|
-
this.logger.warn(`No SAP HANA service binding defined in the requires section of the project's package.json. Database module omitted`) //NOSONAR
|
|
477
|
+
//this.logger.warn(`No SAP HANA service binding defined in the requires section of the project's package.json. Database module omitted`) //NOSONAR
|
|
463
478
|
}
|
|
464
479
|
}
|
|
465
480
|
|