@sap/cds-dk 6.0.3 → 6.1.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/CHANGELOG.md +62 -0
- package/bin/add.js +29 -16
- package/bin/compile/index.js +7 -2
- package/bin/fix-redirects.js +4 -2
- package/bin/init.js +5 -0
- package/bin/login.js +20 -4
- package/bin/pull.js +58 -0
- package/bin/push.js +52 -0
- package/bin/subscribe.js +45 -0
- package/lib/bind/bindingUtil.js +1 -2
- package/lib/bind/cfKeyProvider.js +3 -3
- package/lib/cds.js +2 -3
- package/lib/client/activate.js +17 -16
- package/lib/client/auth_manager.js +10 -5
- package/lib/client/base_command.js +4 -6
- package/lib/client/extend.js +3 -2
- package/lib/client/helper/cf_helper.js +1 -0
- package/lib/client/helper/errors.js +11 -0
- package/lib/client/helper/logging.js +3 -10
- package/lib/client/helper/url_helper.js +7 -3
- package/lib/client/index.js +1 -1
- package/lib/client/params.js +9 -6
- package/lib/client/pull.js +48 -0
- package/lib/client/push.js +45 -0
- package/lib/client/settings_manager.js +81 -27
- package/lib/compile/openapi/csdl2openapi.js +135 -163
- package/lib/compile/openapi/index.js +0 -1
- package/lib/import/common.js +9 -1
- package/lib/import/odata/metadataconverter/MetadataConverter.js +17 -4
- package/lib/import/odata/v2parser.js +50 -26
- package/lib/import/odata/v4parser.js +110 -29
- package/lib/import/openapi/importOpenAPI.js +3 -3
- package/lib/init/constants.js +9 -3
- package/lib/init/template/_merging/registry-mta.js +284 -0
- package/lib/init/template/approuter/files/xs-app.json.hbs +7 -7
- package/lib/init/template/approuter/index.js +22 -32
- package/lib/init/template/auditlog/index.js +7 -9
- package/lib/init/template/data/index.js +2 -4
- package/lib/init/template/extensibility/files/cds.package.json +7 -0
- package/lib/init/template/extensibility/files/cds.package.json.hbs +9 -0
- package/lib/init/template/extensibility/files/xs-security.json.hbs +26 -0
- package/lib/init/template/extensibility/index.js +48 -0
- package/lib/init/template/hana/files/java/cdsrc.json.hbs +1 -1
- package/lib/init/template/hana/files/java/profile.cdsrc.json.hbs +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +10 -0
- package/lib/init/template/hana/files/nodejs/cds.package.json.hbs +1 -1
- package/lib/init/template/hana/files/nodejs/cds.profile.package.json.hbs +2 -2
- package/lib/init/template/hana/index.js +76 -63
- package/lib/init/template/kibana-logging/index.js +31 -37
- package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +14 -14
- package/lib/init/template/mta/files/mta.yaml.hbs +1 -1
- package/lib/init/template/mta/index.js +13 -7
- package/lib/init/template/mtx/index.js +2 -142
- package/lib/init/template/multitenancy/files/cds.package.json +7 -0
- package/lib/init/template/multitenancy/files/cds.package.json.hbs +9 -0
- package/lib/init/template/{mtx → multitenancy}/files/dependencies.package.json +1 -1
- package/lib/init/template/multitenancy/files/java/.cdsrc.json +19 -0
- package/lib/init/template/multitenancy/files/java/package.json +31 -0
- package/lib/init/template/{mtx → multitenancy}/files/mta.yaml.hbs +13 -6
- package/lib/init/template/multitenancy/files/xs-security.json.hbs +18 -0
- package/lib/init/template/multitenancy/index.js +109 -0
- package/lib/init/template/nodejs/files/package.json.hbs +3 -0
- package/lib/init/template/templateBase.js +2 -1
- package/lib/init/template/toggles/files/cds.package.json +7 -0
- package/lib/init/template/toggles/files/cds.package.json.hbs +9 -0
- package/lib/init/template/toggles/index.js +24 -0
- package/lib/init/template/xsuaa/files/mta.yaml.hbs +10 -0
- package/lib/init/template/xsuaa/index.js +44 -33
- package/lib/init/util/projectReader.js +12 -7
- package/lib/init/util/templateUtil.js +113 -111
- package/lib/k8s/ChartAdder.js +13 -3
- package/lib/k8s/ChartBuilder.js +6 -0
- package/lib/k8s/buildModel.js +1 -3
- package/lib/k8s/connectivity/index.js +5 -5
- package/lib/k8s/deployment/index.js +2 -4
- package/lib/k8s/deployment/subchart/Chart.yaml +1 -1
- package/lib/k8s/deployment/subchart/templates/_helpers.tpl +22 -11
- package/lib/k8s/deployment/subchart/templates/deployment.yaml +12 -5
- package/lib/k8s/deployment/subchart/templates/network-policy.yaml +3 -1
- package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +1 -1
- package/lib/k8s/deployment/subchart/values.md +812 -0
- package/lib/k8s/deployment/subchart/values.schema.json +125 -30
- package/lib/k8s/deployment/subchart/values.yaml +7 -3
- package/lib/k8s/hana-deployer/index.js +10 -0
- package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +8 -0
- package/lib/k8s/html5-apps-deployer/index.js +10 -0
- package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +8 -0
- package/lib/k8s/index.js +2 -2
- package/lib/k8s/resources/helm/chart/schemas/values.root.schema.json +11 -0
- package/lib/k8s/resources/helm/chart/schemas/values.schema.json +479 -0
- package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +1 -159
- package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +0 -33
- package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +1 -1
- package/lib/lint/Linter.js +155 -158
- package/lib/lint/io.js +12 -5
- package/npm-shrinkwrap.json +1052 -135
- package/package.json +5 -4
- package/lib/init/template/_merging/existences.js +0 -297
- package/lib/init/template/mtx/files/cds.package.json +0 -12
- package/lib/init/template/mtx/files/cds.package.json.hbs +0 -14
- package/lib/init/template/mtx/files/java/.cdsrc.json +0 -17
- package/lib/init/template/mtx/files/java/package.json +0 -43
- package/lib/init/template/mtx/files/java/server.js +0 -30
- package/lib/init/template/mtx/files/xs-security.json.hbs +0 -48
- package/lib/lint/.eslintrc.js +0 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
1
|
const { join } = require('path')
|
|
3
2
|
const TemplateBase = require('../templateBase')
|
|
4
3
|
const ProjectReader = require('../../util/projectReader')
|
|
@@ -9,7 +8,7 @@ const {
|
|
|
9
8
|
requiredMtxAPI, requiredJavaApprouterAPI, providedJavaApprouterAPI, // APIs
|
|
10
9
|
requiredAppAPI, providedAppAPI,
|
|
11
10
|
approuterExtensibility, approuterExtensibilityJava // xs-app.json config
|
|
12
|
-
} = require('../_merging/
|
|
11
|
+
} = require('../_merging/registry-mta')
|
|
13
12
|
|
|
14
13
|
module.exports = class ApprouterTemplate extends TemplateBase {
|
|
15
14
|
|
|
@@ -24,50 +23,41 @@ module.exports = class ApprouterTemplate extends TemplateBase {
|
|
|
24
23
|
|
|
25
24
|
async runDependentMerging() {
|
|
26
25
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (
|
|
26
|
+
const { isNodejs, isJava, isExtensible, isMultitenant, hasMtaDeployment } = projectDescriptor.cap
|
|
27
|
+
|
|
28
|
+
if (hasMtaDeployment) {
|
|
30
29
|
const srv = isNodejs ? srvNode : srvJava
|
|
31
30
|
const apis = isJava ? [requiredJavaApprouterAPI, providedJavaApprouterAPI] : []
|
|
32
31
|
if (isNodejs && isMultitenant) apis.push(requiredMtxAPI, requiredAppAPI, providedAppAPI)
|
|
33
32
|
if (isJava && isMultitenant) apis.push(requiredMtxAPI)
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
existenceKeyPath: ["name"],
|
|
47
|
-
}, {
|
|
48
|
-
in: approuter,
|
|
49
|
-
inKeyPath: ["requires"],
|
|
50
|
-
into: "name",
|
|
51
|
-
existences: [xsuaa],
|
|
52
|
-
existenceKeyPath: ["name"],
|
|
53
|
-
}],
|
|
54
|
-
}
|
|
55
|
-
)
|
|
33
|
+
const additions = [srv, approuter, xsuaa, ...apis]
|
|
34
|
+
const mtaYAMLPath = join(this.projectPath, 'mta.yaml')
|
|
35
|
+
await this.templateUtil.mergeYAML(mtaYAMLPath, `${__dirname}/files/mta.yaml.hbs`, projectDescriptor, {
|
|
36
|
+
additions,
|
|
37
|
+
relationships: [{
|
|
38
|
+
insert: [xsuaa, 'name'],
|
|
39
|
+
into: [srv, 'requires', 'name']
|
|
40
|
+
}, {
|
|
41
|
+
insert: [xsuaa, 'name'],
|
|
42
|
+
into: [approuter, 'requires', 'name']
|
|
43
|
+
}],
|
|
44
|
+
})
|
|
56
45
|
}
|
|
57
46
|
|
|
58
47
|
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
59
|
-
const
|
|
60
|
-
|
|
48
|
+
const additions = isExtensible && isJava ? [{ ...approuterExtensibilityJava, at: 0 }] :
|
|
49
|
+
isExtensible && isNodejs ? [{ ...approuterExtensibility, at: 0 }] : []
|
|
61
50
|
await this.templateUtil.mergeJSON(
|
|
62
51
|
`${appPath}/xs-app.json`,
|
|
63
52
|
`${__dirname}/files/xs-app.json.hbs`,
|
|
64
53
|
projectDescriptor,
|
|
65
|
-
{
|
|
54
|
+
{ additions }
|
|
66
55
|
)
|
|
67
56
|
}
|
|
68
57
|
|
|
69
58
|
async run() {
|
|
70
59
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
60
|
+
const { for: forProfile } = projectDescriptor.cap
|
|
71
61
|
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
72
62
|
const appPackageJSONPath = join(appPath, 'package.json')
|
|
73
63
|
|
|
@@ -83,14 +73,14 @@ module.exports = class ApprouterTemplate extends TemplateBase {
|
|
|
83
73
|
switch (projectType) {
|
|
84
74
|
case PROJECT_TYPE.java: {
|
|
85
75
|
const cdsrcJSONPath = join(this.projectPath, '.cdsrc.json')
|
|
86
|
-
const cdsTemplateFile =
|
|
76
|
+
const cdsTemplateFile = forProfile ? 'cds.cdsrc.json.hbs' : 'cds.cdsrc.json'
|
|
87
77
|
const cdsPackageJSONPath = join(__dirname, 'files', cdsTemplateFile)
|
|
88
78
|
await this.templateUtil.mergeJSON(cdsrcJSONPath, cdsPackageJSONPath, projectDescriptor)
|
|
89
79
|
break
|
|
90
80
|
}
|
|
91
81
|
case PROJECT_TYPE.nodejs: {
|
|
92
82
|
const packageJSONPath = join(this.projectPath, 'package.json')
|
|
93
|
-
const cdsTemplateFile =
|
|
83
|
+
const cdsTemplateFile = forProfile ? 'cds.package.json.hbs' : 'cds.package.json'
|
|
94
84
|
const cdsPackageJSONPath = join(__dirname, 'files', cdsTemplateFile)
|
|
95
85
|
await this.templateUtil.mergeJSON(packageJSONPath, cdsPackageJSONPath, projectDescriptor)
|
|
96
86
|
break
|
|
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const TemplateBase = require('../templateBase');
|
|
4
4
|
const ProjectReader = require('../../util/projectReader');
|
|
5
|
-
const { srvNode, srvJava, auditlog } = require('../_merging/
|
|
5
|
+
const { srvNode, srvJava, auditlog } = require('../_merging/registry-mta');
|
|
6
6
|
|
|
7
7
|
module.exports = class AuditlogTemplate extends TemplateBase {
|
|
8
8
|
constructor(projectPath, generator) {
|
|
@@ -12,22 +12,20 @@ module.exports = class AuditlogTemplate extends TemplateBase {
|
|
|
12
12
|
|
|
13
13
|
async runDependentMerging() {
|
|
14
14
|
const projectDescriptor = await this.projectReader.read(this.options);
|
|
15
|
+
const { isNodejs } = projectDescriptor.cap;
|
|
15
16
|
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
|
|
16
17
|
if (!fs.existsSync(mtaYAMLPath)) return;
|
|
17
|
-
const srv =
|
|
18
|
+
const srv = isNodejs ? srvNode : srvJava
|
|
18
19
|
await this.templateUtil.mergeYAML(
|
|
19
20
|
mtaYAMLPath,
|
|
20
21
|
`${__dirname}/files/mta.yaml.hbs`,
|
|
21
22
|
projectDescriptor,
|
|
22
23
|
{
|
|
23
|
-
|
|
24
|
+
additions: [srv, auditlog],
|
|
24
25
|
relationships: [{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
existences: [auditlog],
|
|
29
|
-
existenceKeyPath: ["name"],
|
|
30
|
-
}],
|
|
26
|
+
insert: [auditlog, 'name'],
|
|
27
|
+
into: [srv, 'requires', 'name']
|
|
28
|
+
}]
|
|
31
29
|
}
|
|
32
30
|
);
|
|
33
31
|
}
|
|
@@ -148,9 +148,8 @@ function getNamespace(csn, artifactName) {
|
|
|
148
148
|
|
|
149
149
|
// First step is not a namespace (we faked those in the CSN)
|
|
150
150
|
// No subsequent step can be a namespace then
|
|
151
|
-
if (art && art.kind !== 'namespace')
|
|
151
|
+
if (art && art.kind !== 'namespace' && art.kind !== 'context')
|
|
152
152
|
return null;
|
|
153
|
-
}
|
|
154
153
|
|
|
155
154
|
|
|
156
155
|
for (let i = 1; i < parts.length; i++) {
|
|
@@ -159,9 +158,8 @@ function getNamespace(csn, artifactName) {
|
|
|
159
158
|
seen = `${seen}.${parts[i]}`;
|
|
160
159
|
// This might not be - if it isn't, return the result.
|
|
161
160
|
const currentArtifact = csn.definitions[seen];
|
|
162
|
-
if (currentArtifact && currentArtifact.kind !== 'namespace')
|
|
161
|
+
if (currentArtifact && currentArtifact.kind !== 'namespace' && currentArtifact.kind !== 'context')
|
|
163
162
|
return previousArtifactName;
|
|
164
|
-
}
|
|
165
163
|
}
|
|
166
164
|
// We came till here - so the full artifactName is a namespace
|
|
167
165
|
return artifactName;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scopes": [
|
|
3
|
+
{
|
|
4
|
+
"name": "$XSAPPNAME.cds.ExtensionDeveloper",
|
|
5
|
+
"description": "Extend CAP applications via extension projects"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "$XSAPPNAME.cds.UIFlexDeveloper",
|
|
9
|
+
"description": "Extend CAP applications via UIFlex extensibility"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"role-templates": [
|
|
13
|
+
{
|
|
14
|
+
"name": "ExtensionDeveloper",
|
|
15
|
+
"description": "Extension development including UIFlex extensibility",
|
|
16
|
+
"scope-references": [
|
|
17
|
+
"$XSAPPNAME.cds.ExtensionDeveloper",
|
|
18
|
+
"$XSAPPNAME.cds.UIFlexDeveloper"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"authorities": [
|
|
23
|
+
"$XSAPPNAME.cds.ExtensionDeveloper",
|
|
24
|
+
"$XSAPPNAME.cds.UIFlexDeveloper"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const cds = require('../../../cds'), { path } = cds.utils
|
|
2
|
+
const TemplateBase = require('../templateBase')
|
|
3
|
+
const ProjectReader = require('../../util/projectReader')
|
|
4
|
+
|
|
5
|
+
module.exports = class ExtensibilityTemplate extends TemplateBase {
|
|
6
|
+
constructor(projectPath, generator) {
|
|
7
|
+
super(projectPath, generator, __dirname)
|
|
8
|
+
this.projectReader = new ProjectReader(this)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async runDependentMerging() {
|
|
12
|
+
const projectDescriptor = await this.projectReader.read()
|
|
13
|
+
const { hasXsuaa } = projectDescriptor.cap
|
|
14
|
+
if (hasXsuaa) {
|
|
15
|
+
await this.templateUtil.mergeJSON(
|
|
16
|
+
path.join(this.projectPath, 'xs-security.json'),
|
|
17
|
+
path.join(__dirname, 'files', 'xs-security.json.hbs'),
|
|
18
|
+
projectDescriptor,
|
|
19
|
+
{
|
|
20
|
+
additions: [{
|
|
21
|
+
ref: 'scope-extension-developer',
|
|
22
|
+
in: 'scopes',
|
|
23
|
+
where: [{ property: 'name', isEqualTo: '$XSAPPNAME.cds.ExtensionDeveloper' }],
|
|
24
|
+
}, {
|
|
25
|
+
ref: 'scope-uiflex',
|
|
26
|
+
in: 'scopes',
|
|
27
|
+
where: [{ property: 'name', isEqualTo: '$XSAPPNAME.cds.UIFlexDeveloper' }],
|
|
28
|
+
}, {
|
|
29
|
+
ref: 'template-extension-developer',
|
|
30
|
+
in: 'role-templates',
|
|
31
|
+
where: [{ property: 'name', isEqualTo: 'ExtensionDeveloper' }],
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async run() {
|
|
39
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
40
|
+
const { for: forProfile, isJava } = projectDescriptor.cap
|
|
41
|
+
const basePath = isJava ? path.join(this.projectPath, 'mtx', 'sidecar') : this.projectPath
|
|
42
|
+
const packageJSONPath = path.join(basePath, 'package.json')
|
|
43
|
+
const cdsTemplateFile = forProfile ? 'cds.package.json.hbs' : 'cds.package.json'
|
|
44
|
+
await this.templateUtil.mergeJSON(packageJSONPath, path.join(__dirname, 'files', cdsTemplateFile), projectDescriptor)
|
|
45
|
+
await this.templateUtil.sortDependencies(packageJSONPath)
|
|
46
|
+
await this.runDependentMerging()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"requires": {
|
|
3
3
|
"db": {
|
|
4
|
-
"kind":
|
|
4
|
+
"kind": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"requires": {
|
|
3
3
|
"[{{cap.for}}]": {
|
|
4
4
|
"db": {
|
|
5
|
-
"kind":
|
|
5
|
+
"kind": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
|
|
6
6
|
}
|
|
7
7
|
},
|
|
8
8
|
"db": {
|
|
9
|
-
"kind": "sql"
|
|
9
|
+
"kind": "{{#cap.isMultitenant}}sqlite{{/cap.isMultitenant}}{{^cap.isMultitenant}}sql{{/cap.isMultitenant}}"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -15,6 +15,16 @@ modules:
|
|
|
15
15
|
- name: {{cap.appName}}-db
|
|
16
16
|
{{/cap.isMultitenant}}
|
|
17
17
|
|
|
18
|
+
{{#cap.isJava}}
|
|
19
|
+
{{#cap.isMultitenant}}
|
|
20
|
+
- name: {{cap.appName}}-mtx-sidecar
|
|
21
|
+
type: nodejs
|
|
22
|
+
path: mtx/sidecar
|
|
23
|
+
requires:
|
|
24
|
+
- name: {{cap.appName}}-db
|
|
25
|
+
{{/cap.isMultitenant}}
|
|
26
|
+
{{/cap.isJava}}
|
|
27
|
+
|
|
18
28
|
resources:
|
|
19
29
|
- name: {{cap.appName}}-db
|
|
20
30
|
{{^cap.isMultitenant}}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"cds": {
|
|
3
3
|
"requires": {
|
|
4
4
|
"db": {
|
|
5
|
-
"kind":
|
|
5
|
+
"kind": "{{#cap.isMultitenant}}sql-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"requires": {
|
|
4
4
|
"[{{cap.for}}]": {
|
|
5
5
|
"db": {
|
|
6
|
-
"kind":
|
|
6
|
+
"kind": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
|
|
7
7
|
}
|
|
8
8
|
},
|
|
9
9
|
"db": {
|
|
10
|
-
"kind": "sql"
|
|
10
|
+
"kind": "{{#cap.isMultitenant}}sqlite{{/cap.isMultitenant}}{{^cap.isMultitenant}}sql{{/cap.isMultitenant}}"
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -7,10 +7,11 @@ const term = require('../../../util/term');
|
|
|
7
7
|
const ProjectReader = require('../../util/projectReader');
|
|
8
8
|
|
|
9
9
|
const TemplateBase = require('../templateBase');
|
|
10
|
+
const versionCompare = require('../../util/versionCompare');
|
|
10
11
|
|
|
11
12
|
const { PROJECT_TYPE, OPTION_JAVA, URLS, OPTION_HELM_UPDATE } = require('../../constants');
|
|
12
13
|
const { nullLogger } = require('../../util/logger');
|
|
13
|
-
const { srvNode, srvJava, hdbDeployer, serviceManager, hdiContainer } = require('../_merging/
|
|
14
|
+
const { srvNode, srvJava, hdbDeployer, serviceManager, hdiContainer, mtxSidecar } = require('../_merging/registry-mta');
|
|
14
15
|
|
|
15
16
|
module.exports = class HanaTemplate extends TemplateBase {
|
|
16
17
|
constructor(projectPath, generator) {
|
|
@@ -34,66 +35,70 @@ module.exports = class HanaTemplate extends TemplateBase {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
async checkEnabled() {
|
|
37
|
-
const { lt } = require('semver')
|
|
38
38
|
const cds = require('../../../cds')
|
|
39
|
-
if (
|
|
39
|
+
if (versionCompare(cds.version, '5.9.0') < 0) {
|
|
40
40
|
cds.error('The added configuration requires @sap/cds 5.9.0 or higher. Please update @sap/cds to the latest version and run \x1b[1mcds add hana\x1b[0m again.')
|
|
41
41
|
}
|
|
42
42
|
return true
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
async runDependentMerging() {
|
|
46
|
-
const projectDescriptor = await this.projectReader.read(this.options)
|
|
46
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
47
|
+
const { hasMtaDeployment, isNodejs, isJava, isMultitenant, hasHana } = projectDescriptor.cap
|
|
48
|
+
|
|
49
|
+
if (isNodejs && isMultitenant) {
|
|
50
|
+
await this._updateCdsConfiguration()
|
|
51
|
+
} else if (isJava && isMultitenant) {
|
|
52
|
+
await this._updateCdsrcJson()
|
|
53
|
+
}
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
if (hasMtaDeployment) {
|
|
56
|
+
const srv = isNodejs ? srvNode : srvJava
|
|
57
|
+
const db = isMultitenant ? serviceManager : hdiContainer
|
|
58
|
+
const deletions = isMultitenant ? [{
|
|
59
|
+
item: hdbDeployer,
|
|
60
|
+
relationships: [{
|
|
61
|
+
removeProperty: 'name',
|
|
62
|
+
allWithin: ['modules', 'requires', 'name'],
|
|
63
|
+
}]
|
|
64
|
+
}, {
|
|
65
|
+
item: hdiContainer,
|
|
66
|
+
relationships: [{
|
|
67
|
+
removeProperty: 'name',
|
|
68
|
+
allWithin: ['modules', 'requires', 'name'],
|
|
69
|
+
}]
|
|
70
|
+
}] : []
|
|
49
71
|
|
|
50
|
-
|
|
72
|
+
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
|
|
51
73
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const deletions = projectDescriptor.cap.isMultitenant ? [{
|
|
56
|
-
existence: hdbDeployer,
|
|
57
|
-
relationships: [{
|
|
58
|
-
allWithinKeyPath: ["modules"],
|
|
59
|
-
inKeyPath: ["requires"],
|
|
60
|
-
into: "name",
|
|
61
|
-
existenceKeyPath: ["name"],
|
|
62
|
-
}]
|
|
63
|
-
}, {
|
|
64
|
-
existence: hdiContainer,
|
|
65
|
-
relationships: [{
|
|
66
|
-
allWithinKeyPath: ["modules"],
|
|
67
|
-
inKeyPath: ["requires"],
|
|
68
|
-
into: "name",
|
|
69
|
-
existenceKeyPath: ["name"],
|
|
74
|
+
const relationships = [{
|
|
75
|
+
insert: [db, 'name'],
|
|
76
|
+
into: [srv, 'requires', 'name']
|
|
70
77
|
}]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
into:
|
|
83
|
-
|
|
84
|
-
existenceKeyPath: ["name"],
|
|
85
|
-
},
|
|
86
|
-
!projectDescriptor.cap.isMultitenant && projectDescriptor.cap.isNodejs ?
|
|
87
|
-
{
|
|
88
|
-
in: deployer,
|
|
89
|
-
inKeyPath: ["requires"],
|
|
90
|
-
into: "name",
|
|
91
|
-
existences: [db],
|
|
92
|
-
existenceKeyPath: ["name"],
|
|
93
|
-
} : null],
|
|
94
|
-
deletions
|
|
78
|
+
|
|
79
|
+
if (!isMultitenant) {
|
|
80
|
+
relationships.push({
|
|
81
|
+
insert: [hdiContainer, 'name'],
|
|
82
|
+
into: [hdbDeployer, 'requires', 'name']
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (isJava && isMultitenant) {
|
|
87
|
+
relationships.push({
|
|
88
|
+
insert: [serviceManager, 'name'],
|
|
89
|
+
into: [mtxSidecar, 'requires', 'name']
|
|
90
|
+
})
|
|
95
91
|
}
|
|
96
|
-
|
|
92
|
+
|
|
93
|
+
const modules = !isMultitenant ? [srv, hdbDeployer] : [srv]
|
|
94
|
+
|
|
95
|
+
await this.templateUtil.mergeYAML(
|
|
96
|
+
mtaYAMLPath,
|
|
97
|
+
`${__dirname}/files/mta.yaml.hbs`,
|
|
98
|
+
projectDescriptor,
|
|
99
|
+
{ additions: [...modules, db].filter(a => a), deletions, relationships }
|
|
100
|
+
)
|
|
101
|
+
}
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
async run() {
|
|
@@ -112,14 +117,13 @@ module.exports = class HanaTemplate extends TemplateBase {
|
|
|
112
117
|
case PROJECT_TYPE.java: {
|
|
113
118
|
await this.templateUtil.copyFiles(path.join('java', 'db'), path.join(this.projectPath, env.folders.db), {}, this.options.force);
|
|
114
119
|
await this._updatePomXml();
|
|
115
|
-
|
|
116
|
-
await this._updateCdsrcJson(cdsrcJsonPath, env.folders.db, env);
|
|
120
|
+
await this._updateCdsrcJson();
|
|
117
121
|
break;
|
|
118
122
|
}
|
|
119
|
-
case PROJECT_TYPE.nodejs:
|
|
120
|
-
await this._updatePackageJson(
|
|
123
|
+
case PROJECT_TYPE.nodejs: {
|
|
124
|
+
await this._updatePackageJson()
|
|
121
125
|
break;
|
|
122
|
-
|
|
126
|
+
}
|
|
123
127
|
default: break;
|
|
124
128
|
}
|
|
125
129
|
await this.runDependentMerging()
|
|
@@ -142,29 +146,38 @@ module.exports = class HanaTemplate extends TemplateBase {
|
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
async _updatePackageJson(
|
|
146
|
-
const
|
|
149
|
+
async _updatePackageJson() {
|
|
150
|
+
const packageJsonPath = path.join(this.projectPath, 'package.json')
|
|
147
151
|
const dependenciesTemplatePath = path.join(__dirname, 'files', 'nodejs', 'dependencies.package.json');
|
|
148
152
|
await this.templateUtil.mergeJSON(packageJsonPath, dependenciesTemplatePath);
|
|
149
153
|
|
|
150
|
-
const cdsTemplateFile = projectDescriptor.cap.for ? 'cds.profile.package.json.hbs' : 'cds.package.json.hbs';
|
|
151
|
-
const cdsTemplatePath = path.join(__dirname, 'files', 'nodejs', cdsTemplateFile);
|
|
152
|
-
await this.templateUtil.mergeJSON(packageJsonPath, cdsTemplatePath, projectDescriptor);
|
|
153
|
-
|
|
154
154
|
const packageJson = await this.fsUtil.readJSON(packageJsonPath);
|
|
155
155
|
if (packageJson.dependencies['@sap/hana-client']) {
|
|
156
156
|
delete packageJson.dependencies['@sap/hana-client'];
|
|
157
157
|
await this.fsUtil.writeJSON(packageJsonPath, packageJson);
|
|
158
158
|
}
|
|
159
|
+
|
|
160
|
+
await this._updateCdsConfiguration(packageJsonPath)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async _updateCdsConfiguration() {
|
|
164
|
+
const packageJsonPath = path.join(this.projectPath, 'package.json')
|
|
165
|
+
const projectDescriptor = await this.projectReader.read(this.options);
|
|
166
|
+
const { for: forProfile } = projectDescriptor.cap;
|
|
167
|
+
const cdsTemplateFile = forProfile ? 'cds.profile.package.json.hbs' : 'cds.package.json.hbs';
|
|
168
|
+
const cdsTemplatePath = path.join(__dirname, 'files', 'nodejs', cdsTemplateFile);
|
|
169
|
+
await this.templateUtil.mergeJSON(packageJsonPath, cdsTemplatePath, projectDescriptor, { forceOverwrite: true })
|
|
159
170
|
}
|
|
160
171
|
|
|
161
|
-
async _updateCdsrcJson(
|
|
172
|
+
async _updateCdsrcJson() {
|
|
173
|
+
const cdsrcJsonPath = path.join(this.projectPath, '.cdsrc.json');
|
|
162
174
|
const projectDescriptor = await this.projectReader.read(this.options);
|
|
163
|
-
const
|
|
175
|
+
const { for: forProfile } = projectDescriptor.cap;
|
|
176
|
+
const cdsTemplateFile = forProfile ? 'profile.cdsrc.json.hbs' : 'cdsrc.json.hbs';
|
|
164
177
|
const cdsTemplatePath = path.join(__dirname, 'files', 'java', cdsTemplateFile);
|
|
165
178
|
if (!fs.existsSync(cdsrcJsonPath)) {
|
|
166
179
|
this.fsUtil.writeJSON(cdsrcJsonPath, {})
|
|
167
180
|
}
|
|
168
|
-
await this.templateUtil.mergeJSON(cdsrcJsonPath, cdsTemplatePath, projectDescriptor);
|
|
181
|
+
await this.templateUtil.mergeJSON(cdsrcJsonPath, cdsTemplatePath, projectDescriptor, { forceOverwrite: true });
|
|
169
182
|
}
|
|
170
183
|
}
|
|
@@ -1,59 +1,53 @@
|
|
|
1
1
|
const cds = require('../../../cds')
|
|
2
|
-
const
|
|
3
|
-
const path = require('path');
|
|
2
|
+
const path = require('path')
|
|
4
3
|
|
|
5
|
-
const ProjectReader = require('../../util/projectReader')
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const { PROJECT_TYPE, } = require('../../constants');
|
|
10
|
-
const { srvNode, srvJava, kibanaLogging } = require('../_merging/existences');
|
|
4
|
+
const ProjectReader = require('../../util/projectReader')
|
|
5
|
+
const TemplateBase = require('../templateBase')
|
|
6
|
+
const { PROJECT_TYPE, } = require('../../constants')
|
|
7
|
+
const { srvNode, srvJava, kibanaLogging } = require('../_merging/registry-mta')
|
|
11
8
|
|
|
12
9
|
module.exports = class KibanaTemplate extends TemplateBase {
|
|
13
10
|
constructor(projectPath, generator) {
|
|
14
|
-
super(projectPath, generator, __dirname)
|
|
15
|
-
this.projectReader = new ProjectReader(this)
|
|
11
|
+
super(projectPath, generator, __dirname)
|
|
12
|
+
this.projectReader = new ProjectReader(this)
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
async runDependentMerging() {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
17
|
+
const { hasMtaDeployment, isNodejs } = projectDescriptor.cap
|
|
18
|
+
|
|
19
|
+
if (hasMtaDeployment) {
|
|
20
|
+
const srv = isNodejs ? srvNode : srvJava
|
|
21
|
+
|
|
22
|
+
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
|
|
23
|
+
await this.templateUtil.mergeYAML(
|
|
24
|
+
mtaYAMLPath,
|
|
25
|
+
`${__dirname}/files/mta.yaml.hbs`,
|
|
26
|
+
projectDescriptor,
|
|
27
|
+
{
|
|
28
|
+
additions: [srv, kibanaLogging],
|
|
29
|
+
relationships: [{
|
|
30
|
+
insert: [kibanaLogging, 'name'],
|
|
31
|
+
into: [srv, 'requires', 'name']
|
|
32
|
+
}],
|
|
33
|
+
}
|
|
34
|
+
)
|
|
23
35
|
}
|
|
24
|
-
|
|
25
|
-
const projectDescriptor = await this.projectReader.read(this.options);
|
|
26
|
-
const srv = projectDescriptor.cap.isNodejs ? srvNode : srvJava
|
|
27
|
-
|
|
28
|
-
await this.templateUtil.mergeYAML(
|
|
29
|
-
mtaYAMLPath,
|
|
30
|
-
`${__dirname}/files/mta.yaml.hbs`,
|
|
31
|
-
projectDescriptor,
|
|
32
|
-
{
|
|
33
|
-
existences: [srv, kibanaLogging],
|
|
34
|
-
relationships: [{
|
|
35
|
-
in: srv,
|
|
36
|
-
inKeyPath: ["requires"],
|
|
37
|
-
into: "name",
|
|
38
|
-
existences: [kibanaLogging],
|
|
39
|
-
existenceKeyPath: ["name"],
|
|
40
|
-
}],
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
36
|
}
|
|
44
37
|
|
|
45
38
|
async run() {
|
|
46
|
-
const projectType = await this.getProjectType()
|
|
39
|
+
const projectType = await this.getProjectType()
|
|
47
40
|
|
|
48
41
|
switch (projectType) {
|
|
49
42
|
case PROJECT_TYPE.java:
|
|
50
43
|
default:
|
|
51
|
-
cds.error(`kibana-logging is not implemented for project type '${projectType}' yet`)
|
|
44
|
+
cds.error(`kibana-logging is not implemented for project type '${projectType}' yet`)
|
|
52
45
|
// TODO: implement
|
|
53
|
-
break
|
|
46
|
+
break
|
|
54
47
|
case PROJECT_TYPE.nodejs: {
|
|
55
48
|
const projectDescriptor = await this.projectReader.read(this.options);
|
|
56
|
-
const
|
|
49
|
+
const { for: forProfile } = projectDescriptor.cap
|
|
50
|
+
const cdsTemplateFile = forProfile ? 'cds.profile.package.json.hbs' : 'cds.package.json'
|
|
57
51
|
const cdsTemplatePath = path.join(__dirname, 'files', cdsTemplateFile)
|
|
58
52
|
await this.templateUtil.mergeJSON(path.join(this.projectPath, 'package.json'), cdsTemplatePath, projectDescriptor)
|
|
59
53
|
}
|