@sap/cds-dk 6.1.5 → 6.2.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 +36 -2
- package/bin/cds.js +7 -5
- package/bin/deploy/index.js +3 -2
- package/bin/deploy/to-sqlite.js +4 -3
- package/bin/help.js +4 -0
- package/bin/init.js +2 -1
- package/bin/login.js +23 -9
- package/bin/mock.js +1 -0
- package/bin/pull.js +24 -19
- package/bin/push.js +20 -9
- package/bin/subscribe.js +40 -10
- package/bin/watch.js +15 -10
- package/lib/bind/kubernetesCredentialsProvider.js +1 -0
- package/lib/client/activate.js +42 -51
- package/lib/client/auth_manager.js +7 -8
- package/lib/client/base_command.js +5 -2
- package/lib/client/extend.js +33 -38
- package/lib/client/helper/cf_helper.js +11 -11
- package/lib/client/helper/dependency_helper.js +2 -2
- package/lib/client/helper/errors.js +4 -3
- package/lib/client/helper/logging.js +17 -23
- package/lib/client/params.js +5 -5
- package/lib/client/pull.js +19 -21
- package/lib/client/push.js +16 -15
- package/lib/client/settings_manager.js +54 -55
- package/lib/compile/openapi/csdl2openapi.js +18 -12
- package/lib/import/message.js +1 -1
- package/lib/import/odata/metadataconverter/MetadataConverter.js +23 -17
- package/lib/import/odata/v2parser.js +43 -17
- package/lib/import/odata/v4parser.js +77 -22
- package/lib/init/constants.js +5 -2
- package/lib/init/index.js +16 -4
- package/lib/init/template/_merging/registry-mta.js +13 -0
- package/lib/init/template/approuter/index.js +9 -0
- package/lib/{k8s/connectivity/templates/connectivity.yaml → init/template/auditlog/files/auditlog.yaml} +0 -0
- package/lib/init/template/auditlog/index.js +46 -27
- package/lib/{k8s/connectivity/templates → init/template/connectivity/files}/connectivity-binding.yaml +0 -0
- package/lib/{k8s/connectivity/templates → init/template/connectivity/files}/connectivity-proxy-info.yaml +1 -1
- package/lib/init/template/connectivity/files/connectivity.yaml +1 -0
- package/lib/init/template/connectivity/files/values.yaml.hbs +26 -0
- package/lib/init/template/connectivity/index.js +41 -0
- package/lib/init/template/data/index.js +8 -8
- package/lib/init/template/destinations/files/destination.yaml +1 -0
- package/lib/init/template/destinations/index.js +44 -0
- package/lib/init/template/enterprise-messaging/files/cds.package.json +10 -0
- package/lib/init/template/enterprise-messaging/files/cds.profile.package.json.hbs +12 -0
- package/lib/init/template/enterprise-messaging/files/cdsrc.json +8 -0
- package/lib/init/template/enterprise-messaging/files/cdsrc.json.hbs +10 -0
- package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +1 -0
- package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +13 -0
- package/lib/init/template/enterprise-messaging/files/values.yaml +8 -0
- package/lib/init/template/enterprise-messaging/index.js +56 -0
- package/lib/init/template/extensibility/files/cdsrc.json +5 -0
- package/lib/init/template/extensibility/files/cdsrc.json.hbs +7 -0
- package/lib/init/template/extensibility/index.js +18 -13
- package/lib/{k8s/hana-deployer/templates → init/template/hana/files}/hana-deployer-job.yaml +0 -0
- package/lib/init/template/hana/files/java/{cdsrc.json.hbs → cds.json.hbs} +0 -0
- package/lib/init/template/hana/files/java/{profile.cdsrc.json.hbs → cds.profile.json.hbs} +0 -0
- package/lib/init/template/hana/files/java/cds.shortcut.json.hbs +5 -0
- package/lib/init/template/hana/files/java/cds.shortcut.profile.json.hbs +8 -0
- package/lib/init/template/hana/files/java/db/package.json +2 -1
- package/lib/init/template/hana/files/mta.yaml.hbs +6 -0
- package/lib/init/template/hana/files/nodejs/{cds.package.json.hbs → cds.json.hbs} +0 -0
- package/lib/init/template/hana/files/nodejs/{cds.profile.package.json.hbs → cds.profile.json.hbs} +0 -0
- package/lib/init/template/hana/files/nodejs/cds.shortcut.json.hbs +7 -0
- package/lib/init/template/hana/files/nodejs/cds.shortcut.profile.json.hbs +10 -0
- package/lib/init/template/hana/files/values.yaml.hbs +19 -0
- package/lib/init/template/hana/index.js +29 -29
- package/lib/{k8s → init/template/helm}/Model.d.ts +0 -0
- package/lib/{k8s/resources → init/template}/helm/chart/templates/NOTES.txt +0 -0
- package/lib/{k8s/resources → init/template}/helm/chart/templates/_deployment_helpers.tpl +0 -0
- package/lib/{k8s/resources → init/template}/helm/chart/templates/_helpers.tpl +4 -5
- package/lib/{k8s/resources → init/template}/helm/chart/templates/_sapcp_helpers.tpl +0 -0
- package/lib/{k8s/resources/helm/chart/schemas → init/template/helm/chart}/values.root.schema.json +0 -0
- package/lib/{k8s/resources/helm/chart/schemas → init/template/helm/chart}/values.schema.json +0 -0
- package/lib/init/template/helm/files/Chart.yaml.hbs +13 -0
- package/lib/init/template/helm/files/values.yaml.hbs +26 -0
- package/lib/init/template/helm/index.js +74 -14
- package/lib/{k8s/deployment → init/template/helm}/subchart/Chart.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/_helpers.tpl +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/api-rule.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/deployment.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/network-policy.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/pod-disruption-budget.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/secret.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/service-binding.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/templates/service.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/values-lint.yaml +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/values.md +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/values.schema.json +0 -0
- package/lib/{k8s/deployment → init/template/helm}/subchart/values.yaml +0 -0
- package/lib/{k8s/html5-apps-deployer/templates → init/template/html5-repo/files}/_html5_deployment_helpers.tpl +0 -0
- package/lib/{k8s/html5-apps-deployer/templates → init/template/html5-repo/files}/html5-apps-deployer-job.yaml +1 -1
- package/lib/{k8s/html5-apps-repo-host/templates → init/template/html5-repo/files}/html5-apps-repo-host.yaml +0 -0
- package/lib/init/template/html5-repo/index.js +59 -0
- package/lib/init/template/kibana-logging/index.js +8 -0
- package/lib/init/template/lint/index.js +1 -4
- package/lib/init/template/mta/files/mta.yaml.hbs +3 -2
- package/lib/init/template/mta/index.js +6 -1
- package/lib/init/template/multitenancy/files/java/.cdsrc.json +3 -0
- package/lib/init/template/multitenancy/files/java/package.json +2 -6
- package/lib/{k8s/multitenancy/templates → init/template/multitenancy/files}/saas-registry.yaml +3 -3
- package/lib/init/template/multitenancy/files/xsuaa.yaml +1 -0
- package/lib/init/template/multitenancy/index.js +53 -26
- package/lib/init/template/nodejs/files/.gitignore.hbs +1 -0
- package/lib/init/template/templateBase.js +1 -1
- package/lib/init/template/xsuaa/files/values.yaml.hbs +10 -0
- package/lib/init/template/xsuaa/files/xsuaa.yaml +1 -0
- package/lib/init/template/xsuaa/index.js +34 -22
- package/lib/init/util/fsUtil.js +11 -5
- package/lib/init/util/projectReader.js +24 -32
- package/lib/init/util/templateUtil.js +17 -5
- package/lib/lint/Linter.js +9 -17
- package/lib/lint/checks.js +0 -1
- package/lib/lint/generators.js +2 -192
- package/lib/lint/io.js +1 -3
- package/lib/watch/node-watch.js +2 -2
- package/npm-shrinkwrap.json +1666 -873
- package/package.json +5 -4
- package/lib/init/template/helm/update/index.js +0 -28
- package/lib/k8s/ChartAdder.js +0 -75
- package/lib/k8s/ChartBuilder.js +0 -192
- package/lib/k8s/Context.js +0 -71
- package/lib/k8s/ImageUtil.js +0 -21
- package/lib/k8s/auditlog/index.js +0 -29
- package/lib/k8s/auditlog/templates/auditlog.yaml +0 -1
- package/lib/k8s/buildModel.js +0 -68
- package/lib/k8s/connectivity/index.js +0 -80
- package/lib/k8s/deployment/index.js +0 -79
- package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +0 -81
- package/lib/k8s/destinations/index.js +0 -40
- package/lib/k8s/destinations/lib.js +0 -16
- package/lib/k8s/destinations/templates/destinations.yaml +0 -1
- package/lib/k8s/docker/push.js +0 -8
- package/lib/k8s/event-mesh/index.js +0 -53
- package/lib/k8s/event-mesh/lib.js +0 -9
- package/lib/k8s/event-mesh/templates/event-mesh.yaml +0 -1
- package/lib/k8s/hana-deployer/index.js +0 -48
- package/lib/k8s/helm/Release.js +0 -80
- package/lib/k8s/html5-apps-deployer/index.js +0 -53
- package/lib/k8s/html5-apps-repo-host/index.js +0 -26
- package/lib/k8s/html5-apps-repo-host/lib.js +0 -16
- package/lib/k8s/index.js +0 -153
- package/lib/k8s/modules.js +0 -36
- package/lib/k8s/multitenancy/index.js +0 -24
- package/lib/k8s/multitenancy/lib.js +0 -25
- package/lib/k8s/readProject.js +0 -14
- package/lib/k8s/util.js +0 -186
- package/lib/k8s/wrapFeature.js +0 -55
- package/lib/k8s/xsuaa/index.js +0 -64
- package/lib/k8s/xsuaa/lib.js +0 -17
- package/lib/k8s/xsuaa/templates/xsuaa.yaml +0 -1
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const TemplateBase = require('../templateBase');
|
|
5
5
|
const ProjectReader = require('../../util/projectReader');
|
|
6
|
-
const {
|
|
7
|
-
const {
|
|
8
|
-
|
|
6
|
+
const { fs, rimraf } = require('../../../cds').utils;
|
|
7
|
+
const { yaml } = require('@sap/cds-foss')
|
|
8
|
+
|
|
9
9
|
module.exports = class HelmTemplate extends TemplateBase {
|
|
10
10
|
constructor(projectPath, generator) {
|
|
11
11
|
super(projectPath, generator, __dirname);
|
|
@@ -13,27 +13,87 @@ module.exports = class HelmTemplate extends TemplateBase {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async checkEnabled() {
|
|
16
|
-
|
|
17
16
|
if (this.options.force) {
|
|
18
|
-
await rimraf(this.chartPath
|
|
17
|
+
await rimraf(this.chartPath)
|
|
19
18
|
return true;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
return true;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
chartPath() {
|
|
23
|
+
get chartPath() {
|
|
26
24
|
return path.join(this.projectPath, 'chart');
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
async run() {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
29
|
+
const { appName, appDescription, appVersion, isJava } = projectDescriptor.cap
|
|
30
|
+
|
|
31
|
+
await fs.copy(
|
|
32
|
+
path.join(__dirname, 'subchart'),
|
|
33
|
+
path.join(this.projectPath, 'chart', 'charts', 'web-application'),
|
|
34
|
+
)
|
|
35
|
+
await fs.copy(
|
|
36
|
+
path.join(__dirname, 'chart'),
|
|
37
|
+
path.join(this.chartPath),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const webApplicationChartPath = process.env.WEB_APPLICATION_CHART || path.join(__dirname, 'subchart')
|
|
41
|
+
const chartFilePath = path.join(webApplicationChartPath, 'Chart.yaml')
|
|
42
|
+
const chartFile = await fs.promises.readFile(chartFilePath, { encoding: 'utf-8' })
|
|
43
|
+
const { version } = yaml.parse(chartFile)
|
|
44
|
+
|
|
45
|
+
await this.templateUtil.mergeYAML(
|
|
46
|
+
path.join(this.projectPath, 'chart', 'Chart.yaml'),
|
|
47
|
+
path.join(__dirname, 'files', 'Chart.yaml.hbs'),
|
|
48
|
+
projectDescriptor, { forceOverwrite: true }
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
await this.templateUtil.mergeYAML(
|
|
52
|
+
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
53
|
+
path.join(__dirname, 'files', 'values.yaml.hbs'),
|
|
54
|
+
projectDescriptor, { forceOverwrite: true }
|
|
55
|
+
)
|
|
56
|
+
await this.runDependentMerging();
|
|
57
|
+
}
|
|
35
58
|
|
|
36
|
-
|
|
37
|
-
await
|
|
59
|
+
async runDependentMerging() {
|
|
60
|
+
const projectDescriptor = await this.projectReader.read()
|
|
61
|
+
const { hasHana, hasXsuaa, isMultitenant, isExtensible, hasMessaging, hasAuditlog, hasDestination } = projectDescriptor.cap
|
|
62
|
+
|
|
63
|
+
if (hasHana) {
|
|
64
|
+
const HanaTemplate = require(`../hana`)
|
|
65
|
+
const template = new HanaTemplate(this.projectPath, this.generator)
|
|
66
|
+
await template.runDependentMerging()
|
|
67
|
+
}
|
|
68
|
+
if (hasAuditlog) {
|
|
69
|
+
const AuditlogTemplate = require(`../auditlog`)
|
|
70
|
+
const template = new AuditlogTemplate(this.projectPath, this.generator)
|
|
71
|
+
await template.runDependentMerging()
|
|
72
|
+
}
|
|
73
|
+
if (hasMessaging) {
|
|
74
|
+
const EnterpriseMessagingTemplate = require(`../enterprise-messaging`)
|
|
75
|
+
const template = new EnterpriseMessagingTemplate(this.projectPath, this.generator)
|
|
76
|
+
await template.runDependentMerging()
|
|
77
|
+
}
|
|
78
|
+
if (hasDestination) {
|
|
79
|
+
const DestinationsTemplate = require(`../destinations`)
|
|
80
|
+
const template = new DestinationsTemplate(this.projectPath, this.generator)
|
|
81
|
+
await template.runDependentMerging()
|
|
82
|
+
}
|
|
83
|
+
if (hasXsuaa) {
|
|
84
|
+
const XsuaaTemplate = require(`../xsuaa`)
|
|
85
|
+
const template = new XsuaaTemplate(this.projectPath, this.generator)
|
|
86
|
+
await template.runDependentMerging()
|
|
87
|
+
}
|
|
88
|
+
if (isMultitenant) {
|
|
89
|
+
const MultitenancyTemplate = require(`../multitenancy`)
|
|
90
|
+
const template = new MultitenancyTemplate(this.projectPath, this.generator)
|
|
91
|
+
await template.runDependentMerging()
|
|
92
|
+
}
|
|
93
|
+
if (isExtensible) {
|
|
94
|
+
const ExtensibilityTemplate = require(`../extensibility`)
|
|
95
|
+
const template = new ExtensibilityTemplate(this.projectPath, this.generator)
|
|
96
|
+
await template.runDependentMerging()
|
|
97
|
+
}
|
|
38
98
|
}
|
|
39
99
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/{k8s/deployment → init/template/helm}/subchart/templates/pod-disruption-budget.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
{{- $ := merge (dict "root" . "name" "html5-apps-deployer") .Values.html5_apps_deployer . }}
|
|
5
5
|
{{- if $.backendDestinations }}
|
|
6
|
-
{{- if not (.Values.
|
|
6
|
+
{{- if not (.Values.destination.parameters.HTML5Runtime_enabled) }}
|
|
7
7
|
{{- fail "destinations.parameters.HTML5Runtime_enabled must be set to true for use with Launchpad Service" }}
|
|
8
8
|
{{- end }}
|
|
9
9
|
{{- end }}
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const TemplateBase = require('../templateBase')
|
|
3
|
+
const ProjectReader = require('../../util/projectReader')
|
|
4
|
+
const { srvNode, srvJava, auditlog } = require('../_merging/registry-mta')
|
|
5
|
+
const { OPTION_DESTINATIONS } = require('../../constants')
|
|
6
|
+
const cds = require('../../../cds'), { fs } = cds.utils
|
|
7
|
+
|
|
8
|
+
module.exports = class Html5RepoTemplate extends TemplateBase {
|
|
9
|
+
constructor(projectPath, generator) {
|
|
10
|
+
super(projectPath, generator, __dirname)
|
|
11
|
+
this.projectReader = new ProjectReader(this)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async getDependencies() {
|
|
15
|
+
return [OPTION_DESTINATIONS]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async run() {
|
|
19
|
+
await this.runDependentMerging()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async runDependentMerging() {
|
|
23
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
24
|
+
const { appName, hasHelmDeployment } = projectDescriptor.cap
|
|
25
|
+
|
|
26
|
+
if (hasHelmDeployment) {
|
|
27
|
+
await this.templateUtil.mergeYAML(
|
|
28
|
+
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
29
|
+
{
|
|
30
|
+
html5_apps_repo_host: {
|
|
31
|
+
serviceOfferingName: 'html5-apps-repo',
|
|
32
|
+
servicePlanName: 'app-host'
|
|
33
|
+
},
|
|
34
|
+
html5_apps_deployer: {
|
|
35
|
+
cloudService: null,
|
|
36
|
+
backendDestinations: {},
|
|
37
|
+
image: {
|
|
38
|
+
repository: `<your-container-registry>/${appName}-html5-deployer`,
|
|
39
|
+
tag: 'latest'
|
|
40
|
+
},
|
|
41
|
+
bindings: {
|
|
42
|
+
xsuaa: { serviceInstanceName: 'xsuaa' },
|
|
43
|
+
destination: { serviceInstanceName: 'destination' },
|
|
44
|
+
html5_apps_repo: { serviceInstanceName: 'html5-apps-repo-host' }
|
|
45
|
+
},
|
|
46
|
+
resources: {
|
|
47
|
+
limits: { cpu: '2000m', memory: '1G' },
|
|
48
|
+
requests: { cpu: '1000m', memory: '1G' }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
null, { forceOverwrite: true }
|
|
53
|
+
)
|
|
54
|
+
await fs.copy(path.join(__dirname, 'files', '_html5_deployment_helpers.tpl'), path.join(this.projectPath, 'chart', 'templates', '_html5_deployment_helpers.tpl'))
|
|
55
|
+
await fs.copy(path.join(__dirname, 'files', 'html5-apps-deployer-job.yaml'), path.join(this.projectPath, 'chart', 'templates', 'html5-apps-deployer-job.yaml'))
|
|
56
|
+
await fs.copy(path.join(__dirname, 'files', 'html5-apps-repo-host.yaml'), path.join(this.projectPath, 'chart', 'templates', 'html5-apps-repo-host.yaml'))
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -12,6 +12,14 @@ module.exports = class KibanaTemplate extends TemplateBase {
|
|
|
12
12
|
this.projectReader = new ProjectReader(this)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
async checkEnabled() {
|
|
16
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
17
|
+
const { hasMtaDeployment, hasHelmDeployment } = projectDescriptor.cap
|
|
18
|
+
if (hasHelmDeployment && !hasMtaDeployment) {
|
|
19
|
+
throw `'cds add kibana-logging' is not available for Kyma yet`
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
async runDependentMerging() {
|
|
16
24
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
17
25
|
const { hasMtaDeployment, isNodejs } = projectDescriptor.cap
|
|
@@ -8,9 +8,8 @@ const io = require("../../../lint/io");
|
|
|
8
8
|
const readline = require("readline");
|
|
9
9
|
|
|
10
10
|
const { OPTION_LINT_DEV, OPTION_LINT_GLOBAL } = require("../../constants");
|
|
11
|
-
const { mkdirp, fs } = require("
|
|
11
|
+
const { mkdirp, fs } = require("../../../cds").utils;
|
|
12
12
|
const { getConfigPath, getFileExtensions } = require("@sap/eslint-plugin-cds/lib/api");
|
|
13
|
-
const generators = require("../../../lint/generators");
|
|
14
13
|
|
|
15
14
|
const IS_WIN = os.platform() === "win32";
|
|
16
15
|
const ALLOWED_FILE_EXTENSIONS = getFileExtensions();
|
|
@@ -68,8 +67,6 @@ module.exports = class LintTemplate extends TemplateBase {
|
|
|
68
67
|
if (!fs.existsSync(".eslint/tests/no-entity-moo.test.js")) {
|
|
69
68
|
await this._copyFromTemplate(".eslint/tests", this.testsPath);
|
|
70
69
|
}
|
|
71
|
-
// Generate custom lint rules docs
|
|
72
|
-
await generators.genDocs(this.projectPath);
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
// Generate VS Code extension settings
|
|
@@ -5,12 +5,13 @@ version: {{cap.appVersion}}
|
|
|
5
5
|
description: "{{cap.appDescription}}"
|
|
6
6
|
parameters:
|
|
7
7
|
enable-parallel-deployments: true
|
|
8
|
+
{{#cap.isNodejs}}
|
|
8
9
|
build-parameters:
|
|
9
10
|
before-all:
|
|
10
11
|
- builder: custom
|
|
11
12
|
commands:
|
|
12
|
-
- npx -p @sap/cds-dk
|
|
13
|
-
|
|
13
|
+
- npx -p @sap/cds-dk cds build --production
|
|
14
|
+
{{/cap.isNodejs}}
|
|
14
15
|
modules:
|
|
15
16
|
- name: {{cap.appName}}-srv
|
|
16
17
|
type: {{cap.pLanguage}}
|
|
@@ -11,7 +11,7 @@ module.exports = class MtaTemplate extends TemplateBase {
|
|
|
11
11
|
|
|
12
12
|
async run() {
|
|
13
13
|
const projectDescriptor = await this.projectReader.read();
|
|
14
|
-
const { hasApprouter, hasHana, hasXsuaa, isMultitenant, isExtensible } = projectDescriptor.cap;
|
|
14
|
+
const { hasApprouter, hasHana, hasXsuaa, isMultitenant, isExtensible, hasMessaging } = projectDescriptor.cap;
|
|
15
15
|
if (!existsSync(join(this.projectPath, 'mta.yaml'))) {
|
|
16
16
|
await this.templateUtil.copyFiles('.', this.projectPath, projectDescriptor);
|
|
17
17
|
}
|
|
@@ -44,5 +44,10 @@ module.exports = class MtaTemplate extends TemplateBase {
|
|
|
44
44
|
const template = new ExtensibilityTemplate(this.projectPath, this.generator)
|
|
45
45
|
await template.runDependentMerging()
|
|
46
46
|
}
|
|
47
|
+
if (hasMessaging) {
|
|
48
|
+
const EnterpriseMessagingTemplate = require(`../enterprise-messaging`)
|
|
49
|
+
const template = new EnterpriseMessagingTemplate(this.projectPath, this.generator)
|
|
50
|
+
await template.runDependentMerging()
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -18,13 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"cds": {
|
|
20
20
|
"requires": {
|
|
21
|
-
"db":
|
|
22
|
-
"kind": "sqlite",
|
|
23
|
-
"[production]": {
|
|
24
|
-
"kind": "hana-mt"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
21
|
+
"db": "sql-mt",
|
|
27
22
|
"cds.xt.ModelProviderService": "in-sidecar",
|
|
23
|
+
"cds.xt.DeploymentService": true,
|
|
28
24
|
"cds.xt.SaasProvisioningService": true
|
|
29
25
|
}
|
|
30
26
|
}
|
package/lib/{k8s/multitenancy/templates → init/template/multitenancy/files}/saas-registry.yaml
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{{- if (default dict .Values.multitenancy).enabled }}
|
|
2
2
|
{{- $srvHostFull := include "cap.deploymentHostFull" (merge (dict "name" "srv" "deployment" .Values.srv) . ) }}
|
|
3
3
|
{{- $defaultAppUrls := dict
|
|
4
|
-
"getDependencies" (print "https://" $srvHostFull "/
|
|
5
|
-
"onSubscription" (print "https://" $srvHostFull "/
|
|
4
|
+
"getDependencies" (print "https://" $srvHostFull "/-/cds/saas-provisioning/dependencies")
|
|
5
|
+
"onSubscription" (print "https://" $srvHostFull "/-/cds/saas-provisioning/tenant/{tenantId}")
|
|
6
6
|
"onSubscriptionAsync" false
|
|
7
7
|
"onUnSubscriptionAsync" false
|
|
8
8
|
"callbackTimeoutMillis" 300000
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
"appUrls" $defaultAppUrls
|
|
17
17
|
}}
|
|
18
18
|
{{- include "cap.service-instance" (merge (dict "defaultParameters" $defaultParameters . )) }}
|
|
19
|
-
{{ end }}
|
|
19
|
+
{{ end }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{- include "cap.service-instance" . }}
|
|
@@ -15,9 +15,26 @@ module.exports = class MultitenancyTemplate extends TemplateBase {
|
|
|
15
15
|
this.projectReader = new ProjectReader(this)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
async run() {
|
|
19
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
20
|
+
const { for: forProfile, isNodejs, isJava } = projectDescriptor.cap
|
|
21
|
+
if (isNodejs) {
|
|
22
|
+
const packageJSONPath = path.join(this.projectPath, 'package.json')
|
|
23
|
+
const cdsTemplateFile = forProfile ? 'cds.package.json.hbs' : 'cds.package.json'
|
|
24
|
+
await this.templateUtil.mergeJSON(packageJSONPath, path.join(__dirname, 'files', cdsTemplateFile), projectDescriptor)
|
|
25
|
+
await this.templateUtil.mergeJSON(packageJSONPath, path.join(__dirname, 'files', 'dependencies.package.json'))
|
|
26
|
+
await this.templateUtil.sortDependencies(packageJSONPath)
|
|
27
|
+
} else if (isJava) {
|
|
28
|
+
const cdsrcJSONPath = path.join(this.projectPath, '.cdsrc.json')
|
|
29
|
+
await this.templateUtil.mergeJSON(cdsrcJSONPath, path.join(__dirname, 'files', 'java', '.cdsrc.json'))
|
|
30
|
+
await fs.copy(path.join(__dirname, 'files', 'java', 'package.json'), path.join(this.projectPath, 'mtx', 'sidecar', 'package.json'))
|
|
31
|
+
}
|
|
32
|
+
await this.runDependentMerging()
|
|
33
|
+
}
|
|
34
|
+
|
|
18
35
|
async runDependentMerging() {
|
|
19
36
|
const projectDescriptor = await this.projectReader.read()
|
|
20
|
-
const { isNodejs, isJava, hasMtaDeployment, hasApprouter, hasXsuaa, hasHana } = projectDescriptor.cap
|
|
37
|
+
const { isNodejs, isJava, hasMtaDeployment, hasHelmDeployment, hasApprouter, hasXsuaa, hasHana } = projectDescriptor.cap
|
|
21
38
|
|
|
22
39
|
if (hasMtaDeployment) {
|
|
23
40
|
const modules = isNodejs ? [srvNode] : [srvJava, mtxSidecar]
|
|
@@ -25,11 +42,14 @@ module.exports = class MultitenancyTemplate extends TemplateBase {
|
|
|
25
42
|
const services = [saasRegistry]
|
|
26
43
|
if (hasXsuaa) services.push(xsuaa)
|
|
27
44
|
const apis = isNodejs ? [providedMtxAPI] : [srvAPI, providedMtxAPI, providedMtxSidecarAPI, requiredMtxSidecarAPI]
|
|
45
|
+
const additions = [...modules, ...services, ...apis]
|
|
46
|
+
|
|
47
|
+
const overwrites = hasXsuaa ? [{ item: [xsuaa, 'parameters.config.tenant-mode'], withValue: 'shared'}] : []
|
|
48
|
+
|
|
28
49
|
const relationships = [{
|
|
29
50
|
insert: [saasRegistry, 'name'],
|
|
30
51
|
into: [srv, 'requires', 'name']
|
|
31
52
|
}]
|
|
32
|
-
|
|
33
53
|
if (isJava) {
|
|
34
54
|
if (hasXsuaa) {
|
|
35
55
|
relationships.push({
|
|
@@ -45,19 +65,35 @@ module.exports = class MultitenancyTemplate extends TemplateBase {
|
|
|
45
65
|
}
|
|
46
66
|
}
|
|
47
67
|
|
|
48
|
-
const mergingRules = {
|
|
49
|
-
additions: [...modules, ...services, ...apis],
|
|
50
|
-
overwrites: hasXsuaa ? [{ // TODO: the hasXsuaa should not be necessary
|
|
51
|
-
item: [xsuaa, 'parameters.config.tenant-mode'],
|
|
52
|
-
withValue: 'shared'
|
|
53
|
-
}] : undefined,
|
|
54
|
-
relationships,
|
|
55
|
-
}
|
|
56
|
-
const mtaPath = path.join(this.projectPath, 'mta.yaml')
|
|
57
68
|
const templateMtaPath = path.join(__dirname, `files`, `mta.yaml.hbs`)
|
|
69
|
+
const mtaPath = path.join(this.projectPath, 'mta.yaml')
|
|
70
|
+
const mergingRules = { additions, overwrites, relationships }
|
|
58
71
|
await this.templateUtil.mergeYAML(mtaPath, templateMtaPath, projectDescriptor, mergingRules)
|
|
59
72
|
}
|
|
60
73
|
|
|
74
|
+
if (hasHelmDeployment) {
|
|
75
|
+
await this.templateUtil.mergeYAML(
|
|
76
|
+
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
77
|
+
{
|
|
78
|
+
xsuaa: {
|
|
79
|
+
serviceOfferingName: 'saas-registry',
|
|
80
|
+
servicePlanName: 'application'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
null, { forceOverwrite: true }
|
|
84
|
+
)
|
|
85
|
+
//if (hasXsuaa) { // REVISIT: Can we get rid of this dependency?
|
|
86
|
+
await fs.copy(
|
|
87
|
+
path.join(__dirname, 'files', 'xsuaa.yaml'),
|
|
88
|
+
path.join(this.projectPath, 'chart', 'templates', 'xsuaa.yaml')
|
|
89
|
+
)
|
|
90
|
+
//}
|
|
91
|
+
await fs.copy(
|
|
92
|
+
path.join(__dirname, 'files', 'saas-registry.yaml'),
|
|
93
|
+
path.join(this.projectPath, 'chart', 'templates', 'saas-registry.yaml')
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
61
97
|
if (hasApprouter) {
|
|
62
98
|
const ApprouterTemplate = require(`../approuter`)
|
|
63
99
|
const template = new ApprouterTemplate(this.projectPath, this.generator)
|
|
@@ -88,22 +124,13 @@ module.exports = class MultitenancyTemplate extends TemplateBase {
|
|
|
88
124
|
}
|
|
89
125
|
)
|
|
90
126
|
}
|
|
91
|
-
}
|
|
92
127
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
await this.templateUtil.mergeJSON(packageJSONPath, path.join(__dirname, 'files', cdsTemplateFile), projectDescriptor)
|
|
100
|
-
await this.templateUtil.mergeJSON(packageJSONPath, path.join(__dirname, 'files', 'dependencies.package.json'))
|
|
101
|
-
await this.templateUtil.sortDependencies(packageJSONPath)
|
|
102
|
-
} else if (isJava) {
|
|
103
|
-
const cdsrcJSONPath = path.join(this.projectPath, '.cdsrc.json')
|
|
104
|
-
await this.templateUtil.mergeJSON(cdsrcJSONPath, path.join(__dirname, 'files', 'java', '.cdsrc.json'))
|
|
105
|
-
await fs.copy(path.join(__dirname, 'files', 'java', 'package.json'), path.join(this.projectPath, 'mtx', 'sidecar', 'package.json'))
|
|
128
|
+
if (hasXsuaa && hasHelmDeployment) {
|
|
129
|
+
// REVISIT: Shared xs-security.json location for Helm and MTA?
|
|
130
|
+
await fs.copy(
|
|
131
|
+
path.join(this.projectPath, 'xs-security.json'),
|
|
132
|
+
path.join(this.projectPath, 'chart', 'xs-security.json')
|
|
133
|
+
)
|
|
106
134
|
}
|
|
107
|
-
await this.runDependentMerging()
|
|
108
135
|
}
|
|
109
136
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{- include "cap.service-instance" . }}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
+
const cds = require('../../../cds'), { fs } = cds.utils
|
|
2
3
|
const TemplateBase = require('../templateBase')
|
|
3
4
|
const ProjectReader = require('../../util/projectReader')
|
|
4
5
|
const { srvNode, srvJava, xsuaa, mtxSidecar } = require('../_merging/registry-mta')
|
|
5
|
-
const { PROJECT_TYPE
|
|
6
|
+
const { PROJECT_TYPE } = require('../../constants')
|
|
6
7
|
|
|
7
8
|
module.exports = class XsuaaTemplate extends TemplateBase {
|
|
8
9
|
constructor(projectPath, generator) {
|
|
@@ -12,7 +13,24 @@ module.exports = class XsuaaTemplate extends TemplateBase {
|
|
|
12
13
|
|
|
13
14
|
async runDependentMerging() {
|
|
14
15
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
15
|
-
const { isMultitenant, isExtensible, hasMtaDeployment, isNodejs, isJava } = projectDescriptor.cap
|
|
16
|
+
const { isMultitenant, isExtensible, hasMtaDeployment, hasHelmDeployment, isNodejs, isJava } = projectDescriptor.cap
|
|
17
|
+
|
|
18
|
+
const cds = require('../../../../lib/compile')
|
|
19
|
+
const xsSecurity = await (async () => { try {
|
|
20
|
+
const models = await cds.load(path.join(this.projectPath, cds.env.folders.srv))
|
|
21
|
+
return cds.compile.to.xsuaa(models)
|
|
22
|
+
} catch (error) { /* ignore */ }
|
|
23
|
+
})() || { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
|
|
24
|
+
const mergingSemantics = { additions: xsSecurity.scopes.map(scope => ({
|
|
25
|
+
ref: scope.name,
|
|
26
|
+
in: 'scopes',
|
|
27
|
+
where: [{
|
|
28
|
+
property: 'name',
|
|
29
|
+
isEqualTo: scope.name
|
|
30
|
+
}],
|
|
31
|
+
}))}
|
|
32
|
+
const xsSecurityPath = path.join(this.projectPath, 'xs-security.json')
|
|
33
|
+
await this.templateUtil.mergeJSON(xsSecurityPath, xsSecurity, projectDescriptor, mergingSemantics)
|
|
16
34
|
|
|
17
35
|
if (hasMtaDeployment) {
|
|
18
36
|
const srv = isNodejs ? srvNode : srvJava
|
|
@@ -40,6 +58,20 @@ module.exports = class XsuaaTemplate extends TemplateBase {
|
|
|
40
58
|
)
|
|
41
59
|
}
|
|
42
60
|
|
|
61
|
+
if (hasHelmDeployment) {
|
|
62
|
+
await fs.copy(path.join(__dirname, 'files', 'xsuaa.yaml'), path.join(this.projectPath, 'chart', 'templates', 'xsuaa.yaml'))
|
|
63
|
+
await this.templateUtil.mergeYAML(
|
|
64
|
+
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
65
|
+
path.join(__dirname, 'files', 'values.yaml.hbs'),
|
|
66
|
+
projectDescriptor, { forceOverwrite: true }
|
|
67
|
+
)
|
|
68
|
+
// REVISIT: Shared xs-security.json location for Helm and MTA?
|
|
69
|
+
await fs.copy(
|
|
70
|
+
path.join(this.projectPath, 'xs-security.json'),
|
|
71
|
+
path.join(this.projectPath, 'chart', 'xs-security.json')
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
43
75
|
// Re-applying the merging part of `cds add mtx` because cds.compile.to.xsuaa
|
|
44
76
|
// has overwritten the existing `xs-security.json`.
|
|
45
77
|
// TODO: Find a generic solution for situation like these.
|
|
@@ -80,27 +112,7 @@ module.exports = class XsuaaTemplate extends TemplateBase {
|
|
|
80
112
|
break
|
|
81
113
|
}
|
|
82
114
|
}
|
|
83
|
-
const cds = require('../../../../lib/compile')
|
|
84
|
-
const xsuaa = await (async () => { try {
|
|
85
|
-
const models = await cds.load(path.join(projectPath, cds.env.folders.srv))
|
|
86
|
-
return cds.compile.to.xsuaa(models)
|
|
87
|
-
} catch (error) { /* ignore */ }
|
|
88
|
-
})() || { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
|
|
89
115
|
|
|
90
|
-
const mergingSemantics = { additions: xsuaa.scopes.map(scope => ({
|
|
91
|
-
ref: scope.name,
|
|
92
|
-
in: 'scopes',
|
|
93
|
-
where: [{
|
|
94
|
-
property: 'name',
|
|
95
|
-
isEqualTo: scope.name
|
|
96
|
-
}],
|
|
97
|
-
}))}
|
|
98
|
-
const xsSecurityPath = path.join(projectPath, 'xs-security.json')
|
|
99
|
-
await this.templateUtil.mergeJSON(xsSecurityPath, xsuaa, projectDescriptor, mergingSemantics)
|
|
100
116
|
await this.runDependentMerging()
|
|
101
117
|
}
|
|
102
|
-
|
|
103
|
-
async getDependencies() {
|
|
104
|
-
return [OPTION_HELM_UPDATE];
|
|
105
|
-
}
|
|
106
118
|
}
|
package/lib/init/util/fsUtil.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs').promises;
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const {yaml} = require('@sap/cds-foss')
|
|
4
|
+
const {yaml:YAML} = require('@sap/cds-foss')
|
|
5
5
|
const JSONC = require('../../util/jsonc');
|
|
6
6
|
|
|
7
7
|
const UTF_8 = 'utf-8';
|
|
@@ -30,7 +30,7 @@ module.exports = class FsUtil {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async writeYAML(filepath, yaml, skipFileLog = false) {
|
|
33
|
-
await this.writeFile(filepath,
|
|
33
|
+
await this.writeFile(filepath, YAML.stringify(yaml, { collectionStyle: 'block' }), skipFileLog);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
async readFile(src) {
|
|
@@ -53,13 +53,19 @@ module.exports = class FsUtil {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
async readYAML(src, projectDescriptor) {
|
|
56
|
-
|
|
56
|
+
let file;
|
|
57
|
+
try {
|
|
58
|
+
file = await this.readFile(src);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
if (e.code === 'ENOENT') return undefined;
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
57
63
|
if (projectDescriptor) {
|
|
58
64
|
const Mustache = require('mustache');
|
|
59
65
|
const renderedFile = Mustache.render(file, projectDescriptor);
|
|
60
|
-
return
|
|
66
|
+
return YAML.parseDocument(renderedFile);
|
|
61
67
|
}
|
|
62
|
-
return
|
|
68
|
+
return YAML.parseDocument(file);
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
// eslint-disable-next-line no-unused-vars
|