@sap/cds-dk 4.9.7 → 6.0.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 +56 -0
- package/bin/activate.js +4 -4
- package/bin/add.js +11 -5
- package/bin/bind.js +16 -28
- package/bin/build/all.js +2 -2
- package/bin/build/index.js +12 -19
- package/bin/cds.js +16 -17
- package/bin/compile/index.js +12 -3
- package/bin/deploy/index.js +14 -14
- package/bin/deploy/to-hana.js +4 -4
- package/bin/deploy/to-sqlite.js +1 -1
- package/bin/env.js +13 -4
- package/bin/eval.js +1 -1
- package/bin/fix-redirects.js +1 -1
- package/bin/import.js +44 -179
- package/bin/repl.js +1 -1
- package/bin/watch.js +10 -15
- package/lib/bind/BindingManager.js +87 -0
- package/lib/bind/bindingResolver.js +14 -85
- package/lib/bind/bindingUtil.js +18 -11
- package/lib/bind/cfKeyProvider.js +58 -29
- package/lib/bind/kubernetesCredentialsProvider.js +44 -21
- package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
- package/lib/cds.js +13 -0
- package/lib/client/base_command.js +3 -2
- package/lib/client/extend.js +6 -7
- package/lib/client/helper/fs_helper.js +7 -8
- package/lib/client/settings_manager.js +14 -10
- package/lib/compile/index.js +9 -10
- package/lib/compile/openapi/csdl2openapi.js +151 -43
- package/lib/compile/openapi/index.js +2 -2
- package/lib/compile/to-xsuaa.js +3 -2
- package/lib/import/common.js +342 -27
- package/lib/import/importapi.js +81 -13
- package/lib/import/message.js +4 -4
- package/lib/import/odata/index.js +141 -0
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverter.js +2 -2
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverterFactory.js +1 -1
- package/lib/import/{utils → odata/util}/MultiMap.js +0 -0
- package/lib/import/{v2parser.js → odata/v2parser.js} +405 -468
- package/lib/import/{v4parser.js → odata/v4parser.js} +311 -322
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Aggregation.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Authorization.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Capabilities.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Core.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Measures.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Validation.V1.json +0 -0
- package/lib/import/openapi/importOpenAPI.js +521 -0
- package/lib/import/openapi/index.js +19 -0
- package/lib/import/openapi/utilities.js +38 -0
- package/lib/index.js +1 -1
- package/lib/init/constants.js +7 -2
- package/lib/init/index.js +10 -3
- package/lib/init/template/_merging/existences.js +79 -19
- package/lib/init/template/approuter/files/mta.yaml.hbs +25 -11
- package/lib/init/template/approuter/files/package.json +1 -1
- package/lib/init/template/approuter/files/xs-app.json.hbs +7 -0
- package/lib/init/template/approuter/index.js +61 -54
- package/lib/init/template/auditlog/index.js +2 -2
- package/lib/init/template/data/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +17 -17
- package/lib/init/template/hana/index.js +8 -4
- package/lib/init/template/helm/index.js +39 -0
- package/lib/init/template/helm/update/index.js +28 -0
- package/lib/init/template/java/index.js +7 -9
- package/lib/init/template/kibana-logging/index.js +5 -6
- package/lib/init/template/mta/index.js +4 -4
- package/lib/init/template/mtx/files/java/package.json +9 -9
- package/lib/init/template/mtx/files/mta.yaml.hbs +0 -7
- package/lib/init/template/mtx/files/xs-security.json.hbs +11 -20
- package/lib/init/template/mtx/index.js +50 -57
- package/lib/init/template/nodejs/files/package.json.hbs +2 -2
- package/lib/init/template/notebook/index.js +2 -0
- package/lib/init/template/templateBase.js +6 -4
- package/lib/init/template/xsuaa/index.js +9 -5
- package/lib/init/util/fsUtil.js +25 -10
- package/lib/init/util/logger.js +1 -1
- package/lib/init/util/mvnArchetypeUtil.js +4 -10
- package/lib/init/util/projectReader.js +16 -8
- package/lib/init/util/templateUtil.js +30 -34
- package/lib/k8s/ChartAdder.js +65 -0
- package/lib/k8s/ChartBuilder.js +186 -0
- package/lib/k8s/Context.js +71 -0
- package/lib/k8s/ImageUtil.js +21 -0
- package/lib/k8s/Model.d.ts +53 -0
- package/lib/k8s/auditlog/index.js +29 -0
- package/lib/k8s/auditlog/templates/auditlog.yaml +1 -0
- package/lib/k8s/buildModel.js +70 -0
- package/lib/k8s/connectivity/index.js +74 -0
- package/lib/k8s/connectivity/templates/connectivity-binding.yaml +9 -0
- package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +16 -0
- package/lib/k8s/connectivity/templates/connectivity.yaml +1 -0
- package/lib/k8s/deployment/index.js +81 -0
- package/lib/k8s/deployment/subchart/Chart.yaml +6 -0
- package/lib/k8s/deployment/subchart/templates/_helpers.tpl +156 -0
- package/lib/k8s/deployment/subchart/templates/api-rule.yaml +24 -0
- package/lib/k8s/deployment/subchart/templates/deployment.yaml +110 -0
- package/lib/k8s/deployment/subchart/templates/network-policy.yaml +16 -0
- package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +11 -0
- package/lib/k8s/deployment/subchart/templates/secret.yaml +10 -0
- package/lib/k8s/deployment/subchart/templates/service-binding.yaml +27 -0
- package/lib/k8s/deployment/subchart/templates/service.yaml +11 -0
- package/lib/k8s/deployment/subchart/values-lint.yaml +8 -0
- package/lib/k8s/deployment/subchart/values.schema.json +449 -0
- package/lib/k8s/deployment/subchart/values.yaml +76 -0
- package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +81 -0
- package/lib/k8s/destinations/index.js +40 -0
- package/lib/k8s/destinations/lib.js +16 -0
- package/lib/k8s/destinations/templates/destinations.yaml +1 -0
- package/lib/k8s/docker/push.js +8 -0
- package/lib/k8s/event-mesh/index.js +53 -0
- package/lib/k8s/event-mesh/lib.js +9 -0
- package/lib/k8s/event-mesh/templates/event-mesh.yaml +1 -0
- package/lib/k8s/hana-deployer/index.js +38 -0
- package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +41 -0
- package/lib/k8s/helm/Release.js +80 -0
- package/lib/k8s/html5-apps-deployer/index.js +43 -0
- package/lib/k8s/html5-apps-deployer/templates/_html5_deployment_helpers.tpl +16 -0
- package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +53 -0
- package/lib/k8s/html5-apps-repo-host/index.js +26 -0
- package/lib/k8s/html5-apps-repo-host/lib.js +16 -0
- package/lib/k8s/html5-apps-repo-host/templates/html5-apps-repo-host.yaml +1 -0
- package/lib/k8s/index.js +153 -0
- package/lib/k8s/modules.js +36 -0
- package/lib/k8s/multitenancy/index.js +24 -0
- package/lib/k8s/multitenancy/lib.js +25 -0
- package/lib/k8s/multitenancy/templates/saas-registry.yaml +19 -0
- package/lib/k8s/readProject.js +14 -0
- package/lib/k8s/resources/helm/chart/templates/NOTES.txt +11 -0
- package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +221 -0
- package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +167 -0
- package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +103 -0
- package/lib/k8s/util.js +186 -0
- package/lib/k8s/wrapFeature.js +55 -0
- package/lib/k8s/xsuaa/index.js +64 -0
- package/lib/k8s/xsuaa/lib.js +14 -0
- package/lib/k8s/xsuaa/templates/xsuaa.yaml +1 -0
- package/lib/util/exec.js +1 -1
- package/lib/util/write.js +1 -1
- package/lib/watch/node-watch.js +43 -14
- package/npm-shrinkwrap.json +1221 -2743
- package/package.json +5 -5
- package/lib/import/index.js +0 -235
|
@@ -21,22 +21,22 @@ module.exports = class MtaTemplate extends TemplateBase {
|
|
|
21
21
|
if (projectDescriptor.cap.hasApprouter) {
|
|
22
22
|
const ApprouterTemplate = require(`../approuter`)
|
|
23
23
|
const template = new ApprouterTemplate(this.projectPath, this.generator)
|
|
24
|
-
await template.
|
|
24
|
+
await template.runDependentMerging()
|
|
25
25
|
}
|
|
26
26
|
if (projectDescriptor.cap.hasHana) {
|
|
27
27
|
const HanaTemplate = require(`../hana`)
|
|
28
28
|
const template = new HanaTemplate(this.projectPath, this.generator)
|
|
29
|
-
await template.
|
|
29
|
+
await template.runDependentMerging()
|
|
30
30
|
}
|
|
31
31
|
if (projectDescriptor.cap.hasXsuaa) {
|
|
32
32
|
const XsuaaTemplate = require(`../xsuaa`)
|
|
33
33
|
const template = new XsuaaTemplate(this.projectPath, this.generator)
|
|
34
|
-
await template.
|
|
34
|
+
await template.runDependentMerging()
|
|
35
35
|
}
|
|
36
36
|
if (projectDescriptor.cap.isMultitenant) {
|
|
37
37
|
const MtxTemplate = require(`../mtx`)
|
|
38
38
|
const template = new MtxTemplate(this.projectPath, this.generator)
|
|
39
|
-
await template.
|
|
39
|
+
await template.runDependentMerging()
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cap-mtx-sidecar",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@sap/cds": "^
|
|
5
|
-
"@sap/cds-mtx": "^2.
|
|
6
|
-
"@sap/hdi-deploy": "^4.3.
|
|
7
|
-
"@sap/instance-manager": "^3.
|
|
8
|
-
"@sap/xssec": "^3",
|
|
9
|
-
"@sap/hana-client": "^2.
|
|
10
|
-
"express": "^4.
|
|
11
|
-
"passport": "^0.
|
|
4
|
+
"@sap/cds": "^6.0.0",
|
|
5
|
+
"@sap/cds-mtx": "^2.5.6",
|
|
6
|
+
"@sap/hdi-deploy": "^4.3.3",
|
|
7
|
+
"@sap/instance-manager": "^3.3.3",
|
|
8
|
+
"@sap/xssec": "^3.2.13",
|
|
9
|
+
"@sap/hana-client": "^2.12.25",
|
|
10
|
+
"express": "^4.18.1",
|
|
11
|
+
"passport": "^0.6.0"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"start": "node server.js"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": "
|
|
17
|
+
"node": "^16.15.0"
|
|
18
18
|
},
|
|
19
19
|
"cds": {
|
|
20
20
|
"features": {
|
|
@@ -3,11 +3,6 @@ modules:
|
|
|
3
3
|
- name: {{cap.appName}}-srv
|
|
4
4
|
type: {{cap.pLanguage}}
|
|
5
5
|
path: {{& cap.srv.path}}
|
|
6
|
-
{{#cap.isNodejs}}
|
|
7
|
-
properties:
|
|
8
|
-
SUBSCRIPTION_URL: ${protocol}://\${tenant_subdomain}-${default-uri}
|
|
9
|
-
SUBSCRIPTION_URL_REPLACEMENT_RULES: [['-srv', '']]
|
|
10
|
-
{{/cap.isNodejs}}
|
|
11
6
|
requires:
|
|
12
7
|
- name: {{cap.appName}}-registry
|
|
13
8
|
{{#cap.isJava}}
|
|
@@ -19,11 +14,9 @@ modules:
|
|
|
19
14
|
- name: srv-api # required by consumers of CAP services (e.g. approuter)
|
|
20
15
|
properties:
|
|
21
16
|
srv-url: ${default-url}
|
|
22
|
-
{{#cap.isNodejs}}
|
|
23
17
|
- name: mtx-api # potentially required by approuter
|
|
24
18
|
properties:
|
|
25
19
|
mtx-url: ${default-url}
|
|
26
|
-
{{/cap.isNodejs}}
|
|
27
20
|
|
|
28
21
|
{{#cap.isJava}}
|
|
29
22
|
- name: {{cap.appName}}-mtx-sidecar
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"scopes": [
|
|
3
3
|
{
|
|
4
|
-
"name": "$XSAPPNAME.
|
|
5
|
-
"description": "
|
|
4
|
+
"name": "$XSAPPNAME.mtcallback",
|
|
5
|
+
"description": "Subscribe to applications",
|
|
6
|
+
"grant-as-authority-to-apps": [
|
|
7
|
+
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
|
|
8
|
+
]
|
|
6
9
|
},
|
|
7
10
|
{
|
|
8
|
-
"name": "$XSAPPNAME.
|
|
9
|
-
"description": "
|
|
11
|
+
"name": "$XSAPPNAME.mtdeployment",
|
|
12
|
+
"description": "Deploy applications"
|
|
10
13
|
},
|
|
11
14
|
{
|
|
12
15
|
"name": "$XSAPPNAME.MtxDiagnose",
|
|
13
16
|
"description": "Diagnose MTX"
|
|
14
17
|
},
|
|
15
18
|
{
|
|
16
|
-
"name": "$XSAPPNAME.
|
|
17
|
-
"description": "
|
|
19
|
+
"name": "$XSAPPNAME.ExtendCDS",
|
|
20
|
+
"description": "Extend CDS applications"
|
|
18
21
|
},
|
|
19
22
|
{
|
|
20
|
-
"name": "$XSAPPNAME.
|
|
21
|
-
"description": "
|
|
22
|
-
"grant-as-authority-to-apps": [
|
|
23
|
-
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
|
|
24
|
-
]
|
|
23
|
+
"name": "$XSAPPNAME.ExtendCDSdelete",
|
|
24
|
+
"description": "Extend CDS applications with undeployments"
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
27
|
"authorities": [
|
|
@@ -30,15 +30,6 @@
|
|
|
30
30
|
"$XSAPPNAME.mtcallback"
|
|
31
31
|
],
|
|
32
32
|
"role-templates": [
|
|
33
|
-
{
|
|
34
|
-
"name": "MultitenancyAdministrator",
|
|
35
|
-
"description": "Administrate multitenant applications",
|
|
36
|
-
"scope-references": [
|
|
37
|
-
"$XSAPPNAME.MtxDiagnose",
|
|
38
|
-
"$XSAPPNAME.mtdeployment",
|
|
39
|
-
"$XSAPPNAME.mtcallback"
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
33
|
{
|
|
43
34
|
"name": "ExtensionDeveloper",
|
|
44
35
|
"description": "Extend application",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const cds = require
|
|
1
|
+
const cds = require('../../../cds'), { fs, path } = cds.utils
|
|
2
2
|
const TemplateBase = require('../templateBase')
|
|
3
3
|
const ProjectReader = require('../../util/projectReader')
|
|
4
4
|
const { OPTION_HANA, OPTION_XSUAA } = require('../../constants')
|
|
@@ -20,57 +20,57 @@ module.exports = class MtxTemplate extends TemplateBase {
|
|
|
20
20
|
return [OPTION_HANA, OPTION_XSUAA]
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async
|
|
23
|
+
async runDependentMerging() {
|
|
24
24
|
const projectDescriptor = await this.projectReader.read()
|
|
25
25
|
|
|
26
|
-
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
|
|
26
|
+
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (fs.existsSync(mtaYAMLPath)) {
|
|
29
|
+
const mergingRules = projectDescriptor.cap.isNodejs ?
|
|
30
|
+
{
|
|
31
|
+
existences: [srvNode, saasRegistry, providedMtxAPI, xsuaa],
|
|
32
|
+
overwrites: [{
|
|
33
|
+
in: xsuaa,
|
|
34
|
+
keyPath: ["parameters", "config", "tenant-mode"],
|
|
35
|
+
replacement: "shared"
|
|
36
|
+
}],
|
|
37
|
+
relationships: [{
|
|
38
|
+
in: srvNode,
|
|
39
|
+
inKeyPath: ["requires"],
|
|
40
|
+
into: "name",
|
|
41
|
+
existences: [saasRegistry],
|
|
42
|
+
existenceKeyPath: ["name"],
|
|
43
|
+
}],
|
|
44
|
+
}
|
|
45
|
+
:
|
|
46
|
+
{
|
|
47
|
+
existences: [srvJava, srvAPI, mtxSidecar, xsuaa, saasRegistry, providedMtxAPI, providedMtxSidecarAPI, requiredMtxSidecarAPI],
|
|
48
|
+
overwrites: [{
|
|
49
|
+
in: xsuaa,
|
|
50
|
+
keyPath: ["parameters", "config", "tenant-mode"],
|
|
51
|
+
replacement: "shared"
|
|
52
|
+
}],
|
|
53
|
+
relationships: [{
|
|
54
|
+
in: srvJava,
|
|
55
|
+
inKeyPath: ["requires"],
|
|
56
|
+
into: "name",
|
|
57
|
+
existences: [saasRegistry],
|
|
58
|
+
existenceKeyPath: ["name"],
|
|
59
|
+
}],
|
|
60
|
+
}
|
|
29
61
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
replacement: "shared"
|
|
37
|
-
}],
|
|
38
|
-
relationships: [{
|
|
39
|
-
in: srvNode,
|
|
40
|
-
inKeyPath: ["requires"],
|
|
41
|
-
into: "name",
|
|
42
|
-
existences: [saasRegistry],
|
|
43
|
-
existenceKeyPath: ["name"],
|
|
44
|
-
}],
|
|
45
|
-
}
|
|
46
|
-
:
|
|
47
|
-
{
|
|
48
|
-
existences: [srvJava, srvAPI, mtxSidecar, xsuaa, saasRegistry, providedMtxSidecarAPI, requiredMtxSidecarAPI],
|
|
49
|
-
overwrites: [{
|
|
50
|
-
in: xsuaa,
|
|
51
|
-
keyPath: ["parameters", "config", "tenant-mode"],
|
|
52
|
-
replacement: "shared"
|
|
53
|
-
}],
|
|
54
|
-
relationships: [{
|
|
55
|
-
in: srvJava,
|
|
56
|
-
inKeyPath: ["requires"],
|
|
57
|
-
into: "name",
|
|
58
|
-
existences: [saasRegistry],
|
|
59
|
-
existenceKeyPath: ["name"],
|
|
60
|
-
}],
|
|
62
|
+
await this.templateUtil.mergeYAML(
|
|
63
|
+
mtaYAMLPath,
|
|
64
|
+
path.join(__dirname, `files`, `mta.yaml.hbs`),
|
|
65
|
+
projectDescriptor,
|
|
66
|
+
mergingRules
|
|
67
|
+
)
|
|
61
68
|
}
|
|
62
69
|
|
|
63
|
-
await this.templateUtil.mergeYAML(
|
|
64
|
-
mtaYAMLPath,
|
|
65
|
-
path.join(__dirname, `files`, `mta.yaml.hbs`),
|
|
66
|
-
projectDescriptor,
|
|
67
|
-
mergingRules
|
|
68
|
-
)
|
|
69
|
-
|
|
70
70
|
if (projectDescriptor.cap.hasApprouter) {
|
|
71
71
|
const ApprouterTemplate = require(`../approuter`)
|
|
72
72
|
const template = new ApprouterTemplate(this.projectPath, this.generator)
|
|
73
|
-
await template.
|
|
73
|
+
await template.runDependentMerging()
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -82,25 +82,25 @@ module.exports = class MtxTemplate extends TemplateBase {
|
|
|
82
82
|
projectDescriptor,
|
|
83
83
|
{
|
|
84
84
|
existences: [{
|
|
85
|
-
ref: "scope-
|
|
85
|
+
ref: "scope-subscription",
|
|
86
86
|
keyPath: ["scopes"],
|
|
87
87
|
constraints: [{
|
|
88
88
|
comparisonKeyPath: ["name"],
|
|
89
|
-
value: "$XSAPPNAME.
|
|
89
|
+
value: "$XSAPPNAME.mtcallback"
|
|
90
90
|
}],
|
|
91
91
|
}, {
|
|
92
|
-
ref: "scope-
|
|
92
|
+
ref: "scope-update",
|
|
93
93
|
keyPath: ["scopes"],
|
|
94
94
|
constraints: [{
|
|
95
95
|
comparisonKeyPath: ["name"],
|
|
96
|
-
value: "$XSAPPNAME.
|
|
96
|
+
value: "$XSAPPNAME.mtdeployment"
|
|
97
97
|
}],
|
|
98
98
|
}, {
|
|
99
|
-
ref: "scope-
|
|
99
|
+
ref: "scope-diagnose",
|
|
100
100
|
keyPath: ["scopes"],
|
|
101
101
|
constraints: [{
|
|
102
102
|
comparisonKeyPath: ["name"],
|
|
103
|
-
value: "$XSAPPNAME.
|
|
103
|
+
value: "$XSAPPNAME.MtxDiagnose"
|
|
104
104
|
}],
|
|
105
105
|
}, {
|
|
106
106
|
ref: "scope-extend",
|
|
@@ -116,13 +116,6 @@ module.exports = class MtxTemplate extends TemplateBase {
|
|
|
116
116
|
comparisonKeyPath: ["name"],
|
|
117
117
|
value: "$XSAPPNAME.ExtendCDSdelete"
|
|
118
118
|
}],
|
|
119
|
-
}, {
|
|
120
|
-
ref: "template-mt-administrator",
|
|
121
|
-
keyPath: ["role-templates"],
|
|
122
|
-
constraints: [{
|
|
123
|
-
comparisonKeyPath: ["name"],
|
|
124
|
-
value: "MultitenancyAdministrator"
|
|
125
|
-
}],
|
|
126
119
|
}, {
|
|
127
120
|
ref: "template-extension-developer",
|
|
128
121
|
keyPath: ["role-templates"],
|
|
@@ -156,6 +149,6 @@ module.exports = class MtxTemplate extends TemplateBase {
|
|
|
156
149
|
await fs.copy(path.join(__dirname, 'files', 'java'), path.join(this.projectPath, 'mtx-sidecar'))
|
|
157
150
|
}
|
|
158
151
|
await this.runXSSecurityMerging()
|
|
159
|
-
await this.
|
|
152
|
+
await this.runDependentMerging()
|
|
160
153
|
}
|
|
161
154
|
}
|
|
@@ -358,6 +358,8 @@ module.exports = class NotebookTemplate extends TemplateBase {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
async checkEnabled() {
|
|
361
|
+
this.logger.warn('There is a new generation of notebooks. Find out more about the new VS Code based CAP Notebooks on https://cap.cloud.sap/docs/releases/jun22#vs-code-cap-notebooks.');
|
|
362
|
+
this.logger.log();
|
|
361
363
|
return true;
|
|
362
364
|
}
|
|
363
365
|
|
|
@@ -10,10 +10,11 @@ module.exports = class TemplateBase {
|
|
|
10
10
|
/**
|
|
11
11
|
* @constructor
|
|
12
12
|
*/
|
|
13
|
-
constructor(projectPath, generator, dirName) {
|
|
13
|
+
constructor(projectPath, generator, dirName, dontAnnounce) {
|
|
14
14
|
if (generator.options && generator.options.for && typeof generator.options.for !== 'string') {
|
|
15
15
|
throw new Error('The --for argument must not be empty.')
|
|
16
16
|
}
|
|
17
|
+
this.projectPath = path.resolve(projectPath);
|
|
17
18
|
this.options = generator.options || {};
|
|
18
19
|
this.projectPath = path.resolve(projectPath);
|
|
19
20
|
this.fsUtil = generator.fsUtil;
|
|
@@ -21,7 +22,8 @@ module.exports = class TemplateBase {
|
|
|
21
22
|
this.generator = generator;
|
|
22
23
|
|
|
23
24
|
this.cwd = this.options.cwd || process.cwd();
|
|
24
|
-
this.name = this.constructor.name.replace(/template/i, '').toLowerCase();
|
|
25
|
+
this.name = (dirName ? path.basename(dirName) : this.constructor.name.replace(/template/i, '').toLowerCase());
|
|
26
|
+
this.dontAnnounce = dontAnnounce;
|
|
25
27
|
|
|
26
28
|
this.projectName = path.basename(this.projectPath);
|
|
27
29
|
this.templateUtil = new TemplateUtil(path.join(dirName, 'files'), this.fsUtil);
|
|
@@ -70,9 +72,9 @@ module.exports = class TemplateBase {
|
|
|
70
72
|
* want any other steps from the hana template performed (e.g. creating the .hdiconfig).
|
|
71
73
|
* Separating the two let's us run this _only_ the merging part of the template.
|
|
72
74
|
*/
|
|
73
|
-
|
|
75
|
+
async runDependentMerging() {
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
}
|
|
76
78
|
|
|
77
79
|
/**
|
|
78
80
|
* @abstract
|
|
@@ -3,7 +3,7 @@ const path = require('path')
|
|
|
3
3
|
const TemplateBase = require('../templateBase')
|
|
4
4
|
const ProjectReader = require('../../util/projectReader')
|
|
5
5
|
const { srvNode, srvJava, xsuaa } = require('../_merging/existences')
|
|
6
|
-
const { PROJECT_TYPE } = require('../../constants');
|
|
6
|
+
const { PROJECT_TYPE, OPTION_HELM_UPDATE } = require('../../constants');
|
|
7
7
|
|
|
8
8
|
module.exports = class XsuaaTemplate extends TemplateBase {
|
|
9
9
|
constructor(projectPath, generator) {
|
|
@@ -11,7 +11,7 @@ module.exports = class XsuaaTemplate extends TemplateBase {
|
|
|
11
11
|
this.projectReader = new ProjectReader(this)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
async
|
|
14
|
+
async runDependentMerging() {
|
|
15
15
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
16
16
|
const { projectPath } = this
|
|
17
17
|
|
|
@@ -41,7 +41,7 @@ module.exports = class XsuaaTemplate extends TemplateBase {
|
|
|
41
41
|
if (projectDescriptor.cap.isMultitenant) {
|
|
42
42
|
const MtxTemplate = require(`../mtx`)
|
|
43
43
|
const mtxTemplate = new MtxTemplate(this.projectPath, this.generator)
|
|
44
|
-
await mtxTemplate.
|
|
44
|
+
await mtxTemplate.runDependentMerging()
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -74,7 +74,7 @@ module.exports = class XsuaaTemplate extends TemplateBase {
|
|
|
74
74
|
const models = await cds.load(path.join(projectPath, cds.env.folders.srv))
|
|
75
75
|
return cds.compile.to.xsuaa(models)
|
|
76
76
|
} catch (error) { /* ignore */ }
|
|
77
|
-
})() || { scopes: [], attributes: [], 'role-templates': [] }
|
|
77
|
+
})() || { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
|
|
78
78
|
|
|
79
79
|
const mergingSemantics = { existences: xsuaa.scopes.map(scope => ({
|
|
80
80
|
ref: scope.name,
|
|
@@ -86,6 +86,10 @@ module.exports = class XsuaaTemplate extends TemplateBase {
|
|
|
86
86
|
}))}
|
|
87
87
|
const xsSecurityPath = path.join(projectPath, 'xs-security.json')
|
|
88
88
|
await this.templateUtil.mergeJSON(xsSecurityPath, xsuaa, projectDescriptor, mergingSemantics)
|
|
89
|
-
await this.
|
|
89
|
+
await this.runDependentMerging()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async getDependencies() {
|
|
93
|
+
return [OPTION_HELM_UPDATE];
|
|
90
94
|
}
|
|
91
95
|
}
|
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 {
|
|
4
|
+
const {yaml} = require('@sap/cds-foss')
|
|
5
5
|
const JSONC = require('../../util/jsonc');
|
|
6
6
|
|
|
7
7
|
const UTF_8 = 'utf-8';
|
|
@@ -20,14 +20,13 @@ module.exports = class FsUtil {
|
|
|
20
20
|
if (!skipFileLog) {
|
|
21
21
|
this._addTouchedFile(filepath);
|
|
22
22
|
}
|
|
23
|
-
await
|
|
23
|
+
await fs.mkdir(path.dirname(filepath), { recursive: true })
|
|
24
|
+
await fs.writeFile(filepath, content, UTF_8);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
async writeJSON(filepath, object, options = { spaces: 2 }, skipFileLog = false) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
await fse.outputJSON(filepath, object, options);
|
|
28
|
+
const content = JSON.stringify(object, null, options.spaces)
|
|
29
|
+
await this.writeFile(filepath, content, skipFileLog)
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
async writeYAML(filepath, yaml, skipFileLog = false) {
|
|
@@ -45,7 +44,7 @@ module.exports = class FsUtil {
|
|
|
45
44
|
const renderedFile = Mustache.render(file, projectDescriptor);
|
|
46
45
|
return JSON.parse(renderedFile);
|
|
47
46
|
}
|
|
48
|
-
return
|
|
47
|
+
return JSON.parse(file)
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
async readJSONC(src) {
|
|
@@ -63,15 +62,20 @@ module.exports = class FsUtil {
|
|
|
63
62
|
return yaml.parseDocument(file);
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
// eslint-disable-next-line no-unused-vars
|
|
66
66
|
async copy(source, destination, options = {}, skipFileLog = false) {
|
|
67
67
|
if (!skipFileLog) {
|
|
68
68
|
this._addTouchedFile(destination);
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
if (fs.cp) { // Node.js >= 16.7
|
|
71
|
+
await fs.cp(source, destination, { recursive: true })
|
|
72
|
+
} else {
|
|
73
|
+
await _copy(source, destination);
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
async pathExists(filePath) {
|
|
74
|
-
return
|
|
78
|
+
return fs.access(filePath).then(() => true).catch(() => false)
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
async readdir(filePath) {
|
|
@@ -83,7 +87,7 @@ module.exports = class FsUtil {
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
async mkdirp(folderPath) {
|
|
86
|
-
await
|
|
90
|
+
await fs.mkdir(folderPath, { recursive: true });
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
async stat(filePath) {
|
|
@@ -104,3 +108,14 @@ module.exports = class FsUtil {
|
|
|
104
108
|
this.touchedFiles.add(relativeFilepath);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
111
|
+
|
|
112
|
+
// Polyfill for Node.14: asynchronously copies the entire content from src to dest.
|
|
113
|
+
async function _copy(src, dest) {
|
|
114
|
+
if ((await fs.stat(src)).isDirectory()) {
|
|
115
|
+
const entries = await fs.readdir(src)
|
|
116
|
+
return Promise.all(entries.map(async each => _copy(path.join(src, each), path.join(dest, each))))
|
|
117
|
+
} else {
|
|
118
|
+
await fs.mkdir(path.dirname(dest), { recursive: true })
|
|
119
|
+
return fs.copyFile(src, dest)
|
|
120
|
+
}
|
|
121
|
+
}
|
package/lib/init/util/logger.js
CHANGED
|
@@ -12,7 +12,7 @@ class MvnArchetypeUtil {
|
|
|
12
12
|
// need to create new regex every call since a constant
|
|
13
13
|
// would keep the match state
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const quoteRegex = /([\w\-.]+)=([\w\-.]+|\[([\w.\-,]+)\])/g;
|
|
16
16
|
// captures a=1 => a:1
|
|
17
17
|
// -Da=[x,y,z] => -Da:x,y,z (Maven specific)
|
|
18
18
|
// a=[x,y,z] => a:x,y,z
|
|
@@ -35,14 +35,7 @@ class MvnArchetypeUtil {
|
|
|
35
35
|
params.set('-X'); params.set('-e');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
return Array.from(params, (
|
|
39
|
-
let result = e[0];
|
|
40
|
-
// ignore if null/undefined but write "false" and "0"
|
|
41
|
-
if (e[1] != undefined) {
|
|
42
|
-
result = result + `=${e[1]}`;
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
});
|
|
38
|
+
return Array.from(params, ([arg, val]) => val !== null && val !== undefined ? `${arg}=${val}` : arg)
|
|
46
39
|
}
|
|
47
40
|
|
|
48
41
|
getAddSamplesCmdArgs(options) {
|
|
@@ -129,7 +122,7 @@ class MvnArchetypeUtil {
|
|
|
129
122
|
|
|
130
123
|
const packageFromParam = params.get(`-Dpackage`);
|
|
131
124
|
if (packageFromParam) {
|
|
132
|
-
//
|
|
125
|
+
// explicitly specified, so do not modify
|
|
133
126
|
if (!options.force && !packageFromParam.match(REGEX_JAVA_PACKAGE)) {
|
|
134
127
|
throw new Error(`Package '${packageFromParam}' is an invalid Java package name. Use --force to use it anyway.`);
|
|
135
128
|
}
|
|
@@ -147,6 +140,7 @@ class MvnArchetypeUtil {
|
|
|
147
140
|
|
|
148
141
|
return {
|
|
149
142
|
cmdLine: this._finalize(params),
|
|
143
|
+
archetypeVersion: params.get('-DarchetypeVersion'),
|
|
150
144
|
artifactId
|
|
151
145
|
};
|
|
152
146
|
}
|
|
@@ -5,11 +5,14 @@ const { fs } = require('@sap/cds/lib/utils')
|
|
|
5
5
|
const P_LANGUAGE_JAVA = 'java'
|
|
6
6
|
const P_LANGUAGE_NODEJS = 'nodejs'
|
|
7
7
|
const DEFAULT_P_LANGUAGE = P_LANGUAGE_NODEJS
|
|
8
|
-
const BUILD_TASK_JAVA = "java
|
|
9
|
-
const
|
|
8
|
+
const BUILD_TASK_JAVA = "java"
|
|
9
|
+
const BUILD_TASK_JAVA_CF = "java-cf"
|
|
10
|
+
const BUILD_TASK_NODEJS = "nodejs"
|
|
11
|
+
const BUILD_TASK_NODE_CF = "node-cf"
|
|
10
12
|
const BUILD_TASK_HANA = "hana"
|
|
11
13
|
const BUILD_TASK_FIORI = "fiori"
|
|
12
14
|
const BUILD_TASK_MTX = "mtx"
|
|
15
|
+
const BUILD_TASK_MTX_SIDECAR = "mtx-sidecar"
|
|
13
16
|
|
|
14
17
|
module.exports = class ProjectReader {
|
|
15
18
|
|
|
@@ -86,10 +89,10 @@ module.exports = class ProjectReader {
|
|
|
86
89
|
return this.db.length > 0
|
|
87
90
|
},
|
|
88
91
|
get hasHana() {
|
|
89
|
-
return this.requires.some(({resource}) => resource.isHana)
|
|
92
|
+
return this.requires.some(({ resource }) => resource.isHana)
|
|
90
93
|
},
|
|
91
94
|
get hasXsuaa() {
|
|
92
|
-
return this.requires.some(({resource}) => resource.isXsuaa)
|
|
95
|
+
return this.requires.some(({ resource }) => resource.isXsuaa)
|
|
93
96
|
},
|
|
94
97
|
get needsSidecar() {
|
|
95
98
|
return (options && options.add.has('hana') || this.db.length > 0) && (this.isJava || !this.isMultitenant)
|
|
@@ -100,8 +103,9 @@ module.exports = class ProjectReader {
|
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
// setting the effective env as it might have changed by already executed 'add' commands, e.g. cds init foo --add hana,mta
|
|
103
|
-
const cds = require('
|
|
104
|
-
cds.env
|
|
106
|
+
const cds = require('../../cds')
|
|
107
|
+
cds.env // make sure env is initialized, otherwise we cannot set it (exotic case)
|
|
108
|
+
cds.env = env
|
|
105
109
|
|
|
106
110
|
const buildTasks = await new BuildTaskFactory(this.logger.isDebug ? this.logger : nullLogger, cds).getTasks({ root: this.projectPath, resolve: true, mta: false })
|
|
107
111
|
|
|
@@ -117,6 +121,7 @@ module.exports = class ProjectReader {
|
|
|
117
121
|
break
|
|
118
122
|
|
|
119
123
|
case BUILD_TASK_JAVA:
|
|
124
|
+
case BUILD_TASK_JAVA_CF:
|
|
120
125
|
capDescriptor.pLanguage = P_LANGUAGE_JAVA
|
|
121
126
|
capDescriptor.srv = {
|
|
122
127
|
path: relDestPath,
|
|
@@ -125,7 +130,8 @@ module.exports = class ProjectReader {
|
|
|
125
130
|
}
|
|
126
131
|
break
|
|
127
132
|
|
|
128
|
-
case
|
|
133
|
+
case BUILD_TASK_NODEJS:
|
|
134
|
+
case BUILD_TASK_NODE_CF:
|
|
129
135
|
capDescriptor.srv = {
|
|
130
136
|
path: relDestPath,
|
|
131
137
|
name: path.basename(task.src)
|
|
@@ -134,6 +140,7 @@ module.exports = class ProjectReader {
|
|
|
134
140
|
|
|
135
141
|
case BUILD_TASK_FIORI:
|
|
136
142
|
case BUILD_TASK_MTX:
|
|
143
|
+
case BUILD_TASK_MTX_SIDECAR:
|
|
137
144
|
break
|
|
138
145
|
|
|
139
146
|
default:
|
|
@@ -159,7 +166,8 @@ module.exports = class ProjectReader {
|
|
|
159
166
|
// by default spring-boot:repackage is used creating an executable jar archive
|
|
160
167
|
const pomJson = await this._parseXml(path.join(task.src, 'pom.xml'))
|
|
161
168
|
if (pomJson) {
|
|
162
|
-
|
|
169
|
+
// cannot use 'instanceof ManifestTemplate' since ManifestTemplate requires projectReader -> cycle created
|
|
170
|
+
if (this.template.constructor.name === 'ManifestTemplate' && this._isOldJavaRuntime(pomJson)) {
|
|
163
171
|
throw new Error("Projects using the classic CAP Java SDK are not supported")
|
|
164
172
|
}
|
|
165
173
|
|