@sap/cds-dk 7.0.1 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/add.js +36 -40
- package/bin/bind.js +0 -1
- package/bin/build.js +4 -0
- package/bin/cds.js +14 -8
- package/bin/compile/index.js +3 -3
- package/bin/deploy/to-hana.js +1 -1
- package/bin/help.js +2 -3
- package/bin/init.js +2 -2
- package/lib/bind/cfKeyProvider.js +1 -0
- package/lib/bind/index.js +3 -0
- package/lib/bind/userCdsrcJsonStorageProvider.js +2 -10
- package/lib/build/buildTaskEngine.js +1 -1
- package/lib/build/constants.js +16 -14
- package/lib/build/provider/buildTaskHandlerFeatureToggles.js +2 -1
- package/lib/build/provider/java/index.js +2 -2
- package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -6
- package/lib/build/provider/mtx-sidecar/index.js +15 -11
- package/lib/build/util.js +8 -0
- package/lib/cds.js +2 -2
- package/lib/client/base_command.js +3 -6
- package/lib/compile/asyncapi/components/messages/index.js +41 -18
- package/lib/compile/asyncapi/index.js +23 -2
- package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -0
- package/lib/init/constants.js +5 -5
- package/lib/init/index.js +68 -76
- package/lib/init/template/_merging/registry-mta.js +2 -2
- package/lib/init/template/approuter/index.js +10 -7
- package/lib/init/template/auditlog/index.js +3 -4
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +15 -23
- package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +22 -17
- package/lib/init/template/cf-manifest/index.js +5 -5
- package/lib/init/template/connectivity/index.js +2 -3
- package/lib/init/template/data/index.js +6 -6
- package/lib/init/template/destination/index.js +3 -5
- package/lib/init/template/enterprise-messaging/index.js +4 -5
- package/lib/init/template/enterprise-messaging-shared/index.js +3 -4
- package/lib/init/template/extensibility/index.js +2 -3
- package/lib/init/template/file-based-messaging/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +1 -1
- package/lib/init/template/hana/index.js +39 -63
- package/lib/init/template/helm/index.js +15 -14
- package/lib/init/template/html5-repo/index.js +3 -7
- package/lib/init/template/java/index.js +6 -6
- package/lib/init/template/kibana/files/mta.yaml.hbs +29 -0
- package/lib/init/template/kibana/index.js +54 -0
- package/lib/init/template/lint/index.js +8 -7
- package/lib/init/template/mta/index.js +3 -2
- package/lib/init/template/multitenancy/files/package.json.hbs +0 -3
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
- package/lib/init/template/multitenancy/index.js +25 -40
- package/lib/init/template/nodejs/index.js +4 -5
- package/lib/init/template/pipeline/index.js +3 -3
- package/lib/init/template/redis-messaging/index.js +3 -4
- package/lib/init/template/sample/files/app/_i18n/i18n.properties +3 -32
- package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +2 -2
- package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +6 -7
- package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +3 -3
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +3 -11
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +117 -113
- package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +38 -0
- package/lib/init/template/sample/files/app/browse/fiori-service.cds +56 -0
- package/lib/init/template/sample/files/app/browse/webapp/Component.js +7 -0
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +4 -0
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +139 -0
- package/lib/init/template/sample/files/app/common.cds +78 -81
- package/lib/init/template/sample/files/app/services.cds +1 -0
- package/lib/init/template/sample/files/srv/admin-service.cds +1 -1
- package/lib/init/template/sample/files/srv/cat-service.cds +1 -1
- package/lib/init/template/sample/index.js +6 -5
- package/lib/init/template/sqlite/index.js +1 -1
- package/lib/init/template/templateBase.js +9 -19
- package/lib/init/template/tiny-sample/index.js +6 -6
- package/lib/init/template/toggles/index.js +1 -2
- package/lib/init/template/typer/files/xsconfig.json +0 -1
- package/lib/init/template/typer/index.js +1 -1
- package/lib/init/template/xsuaa/index.js +3 -4
- package/lib/init/util/indent.js +57 -0
- package/lib/init/util/merge.js +71 -15
- package/lib/init/util/mvn.js +24 -10
- package/lib/init/util/projectReader.js +53 -169
- package/lib/init/util/template.js +12 -11
- package/lib/init/util/xml.js +6 -6
- package/lib/util/pruneAxiosErrors.js +22 -0
- package/lib/watch/open.js +6 -3
- package/npm-shrinkwrap.json +20 -37
- package/package.json +1 -2
- package/lib/init/template/kibana-logging/files/cds.package.json +0 -7
- package/lib/init/template/kibana-logging/files/mta.yaml.hbs +0 -14
- package/lib/init/template/kibana-logging/index.js +0 -45
- /package/lib/init/template/{kibana-logging → kibana}/files/package.json.hbs +0 -0
|
@@ -15,14 +15,13 @@ module.exports = class DestinationTemplate extends require('../templateBase') {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
async run() {
|
|
18
|
-
const project = await readProject(
|
|
18
|
+
const project = await readProject()
|
|
19
19
|
const { configFile } = project
|
|
20
20
|
await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), project)
|
|
21
|
-
await this.runDependentMerging()
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
async runDependentMerging(context = {}) {
|
|
25
|
-
const project = await readProject(
|
|
24
|
+
const project = await readProject()
|
|
26
25
|
const { isJava, hasHelm, hasDestination, hasMta, srvPath, hasHtml5Repo } = project
|
|
27
26
|
|
|
28
27
|
if (hasMta) {
|
|
@@ -36,7 +35,6 @@ module.exports = class DestinationTemplate extends require('../templateBase') {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
if (hasHelm) {
|
|
39
|
-
//const env = await this.getEnv()
|
|
40
38
|
const binding = hasDestination && { srv: { bindings: { destination: { serviceInstanceName: 'destination' }}}}
|
|
41
39
|
const html5Binding = hasHtml5Repo && { 'html5-apps-deployer': { bindings: { destination: { serviceInstanceName: 'destination' }}}}
|
|
42
40
|
|
|
@@ -64,7 +62,7 @@ module.exports = class DestinationTemplate extends require('../templateBase') {
|
|
|
64
62
|
|
|
65
63
|
// copy service instance chart if it is not present
|
|
66
64
|
const HelmTemplate = require(`../helm`);
|
|
67
|
-
const helmTemplate = new HelmTemplate(
|
|
65
|
+
const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
|
|
68
66
|
isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
|
|
69
67
|
|
|
70
68
|
// add dependency entry in chart.yaml
|
|
@@ -10,7 +10,7 @@ const { srvNode4, srvJava4, enterpriseMessaging } = require('../_merging/registr
|
|
|
10
10
|
module.exports = class EnterpriseMessagingTemplate extends require('../templateBase') {
|
|
11
11
|
|
|
12
12
|
async canRun() {
|
|
13
|
-
const { isJava } = await readProject(
|
|
13
|
+
const { isJava } = await readProject()
|
|
14
14
|
if (isJava) throw `'cds add enterprise-messaging' is not available for Java yet`
|
|
15
15
|
return true
|
|
16
16
|
}
|
|
@@ -20,14 +20,13 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async run() {
|
|
23
|
-
const project = await readProject(
|
|
23
|
+
const project = await readProject()
|
|
24
24
|
const { configFile } = project
|
|
25
25
|
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
26
|
-
await this.runDependentMerging()
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
async runDependentMerging(context = {}) {
|
|
30
|
-
const project = await readProject(
|
|
29
|
+
const project = await readProject()
|
|
31
30
|
const { hasXsuaa, hasHelm, hasMta, isNodejs, srvPath, appName } = project
|
|
32
31
|
|
|
33
32
|
if (hasMta) {
|
|
@@ -81,7 +80,7 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
|
|
|
81
80
|
|
|
82
81
|
// copy service instance chart if it is not present
|
|
83
82
|
const HelmTemplate = require(`../helm`);
|
|
84
|
-
const helmTemplate = new HelmTemplate(
|
|
83
|
+
const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
|
|
85
84
|
isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
|
|
86
85
|
|
|
87
86
|
// add dependency entry in chart.yaml
|
|
@@ -8,7 +8,7 @@ const { srvNode4, srvJava4, enterpriseMessaging } = require('../_merging/registr
|
|
|
8
8
|
module.exports = class EnterpriseMessagingSharedTemplate extends require('../templateBase') {
|
|
9
9
|
|
|
10
10
|
async canRun() {
|
|
11
|
-
const { hasMta, hasHelm, isJava } = await readProject(
|
|
11
|
+
const { hasMta, hasHelm, isJava } = await readProject()
|
|
12
12
|
if (isJava) throw `'cds add enterprise-messaging-shared' is not available for Java yet`
|
|
13
13
|
if (hasHelm && !hasMta) throw `'cds add enterprise-messaging-shared' is not available for Kyma yet`
|
|
14
14
|
return true
|
|
@@ -19,16 +19,15 @@ module.exports = class EnterpriseMessagingSharedTemplate extends require('../tem
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async run() {
|
|
22
|
-
const project = await readProject(
|
|
22
|
+
const project = await readProject()
|
|
23
23
|
const { configFile } = project
|
|
24
24
|
project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
|
|
25
25
|
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
26
26
|
await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), project)
|
|
27
|
-
await this.runDependentMerging()
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
async runDependentMerging() {
|
|
31
|
-
const project = await readProject(
|
|
30
|
+
const project = await readProject()
|
|
32
31
|
const { hasMta, isNodejs, srvPath } = project
|
|
33
32
|
|
|
34
33
|
if (hasMta) {
|
|
@@ -21,14 +21,13 @@ module.exports = class ExtensibilityTemplate extends require('../templateBase')
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async run() {
|
|
24
|
-
const project = await readProject(
|
|
24
|
+
const project = await readProject()
|
|
25
25
|
const { configFile } = project
|
|
26
26
|
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
27
|
-
await this.runDependentMerging()
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
async runDependentMerging() {
|
|
31
|
-
const project = await readProject(
|
|
30
|
+
const project = await readProject()
|
|
32
31
|
const { hasXsuaa } = project
|
|
33
32
|
if (hasXsuaa) {
|
|
34
33
|
await mergeJSON(
|
|
@@ -6,7 +6,7 @@ const { mergeJSON } = require('../../util/merge')
|
|
|
6
6
|
module.exports = class FileBasedMessagingTemplate extends require('../templateBase') {
|
|
7
7
|
|
|
8
8
|
async canRun() {
|
|
9
|
-
const { isJava } = await readProject(
|
|
9
|
+
const { isJava } = await readProject()
|
|
10
10
|
if (isJava) throw `'cds add file-based-messaging' is not available for Java yet`
|
|
11
11
|
return true
|
|
12
12
|
}
|
|
@@ -16,7 +16,7 @@ module.exports = class FileBasedMessagingTemplate extends require('../templateBa
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async run() {
|
|
19
|
-
const project = await readProject(
|
|
19
|
+
const project = await readProject()
|
|
20
20
|
const { configFile } = project
|
|
21
21
|
project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
|
|
22
22
|
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
const { join } = require('path')
|
|
1
|
+
const { join } = require('path')
|
|
2
2
|
const cds = require('../../../cds')
|
|
3
3
|
const { read, write, exists, rmdir } = cds.utils
|
|
4
|
-
const
|
|
5
|
-
const mvnArchetypes = require('../../util/mvn');
|
|
6
|
-
const term = require('../../../util/term');
|
|
4
|
+
const { readProject } = require('../../util/projectReader')
|
|
7
5
|
const { mergeJSON, mergeYAML, removeFromYAML, removeFromYAMLArray } = require('../../util/merge')
|
|
6
|
+
const mvn = require('../../util/mvn')
|
|
8
7
|
const { parseMd5File, writeMd5File } = require('../../util/md5')
|
|
9
8
|
const { copyFiles } = require('../../util/template')
|
|
10
|
-
const { readProject } = require('../../util/projectReader');
|
|
11
9
|
|
|
12
|
-
const { OPTIONS: { JAVA }
|
|
10
|
+
const { OPTIONS: { JAVA } } = require('../../constants')
|
|
13
11
|
|
|
14
|
-
const { srvNode4, srvJava4, hdbDeployer, serviceManager, hdiContainer, mtxSidecar4 } = require('../_merging/registry-mta')
|
|
12
|
+
const { srvNode4, srvJava4, hdbDeployer, serviceManager, hdiContainer, mtxSidecar4 } = require('../_merging/registry-mta')
|
|
15
13
|
|
|
16
14
|
module.exports = class HanaTemplate extends require('../templateBase') {
|
|
17
15
|
|
|
@@ -20,56 +18,40 @@ module.exports = class HanaTemplate extends require('../templateBase') {
|
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
async run() {
|
|
23
|
-
const project = await readProject(
|
|
24
|
-
const { isJava, configFile } = project
|
|
21
|
+
const project = await readProject()
|
|
22
|
+
const { isJava, configFile, db } = project
|
|
25
23
|
project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
|
|
26
24
|
|
|
27
|
-
const env = await this.getEnv() // REVISIT: Get info from project
|
|
28
|
-
|
|
29
25
|
// REVISIT: Let cds build generate by default
|
|
30
|
-
const hdiConfigPath = join(
|
|
26
|
+
const hdiConfigPath = join(db.folder, 'src', '.hdiconfig')
|
|
31
27
|
const hdiConfigTemplatePath = join(__dirname, 'files', 'src', '.hdiconfig')
|
|
32
28
|
await mergeJSON(hdiConfigPath, hdiConfigTemplatePath)
|
|
33
29
|
|
|
34
30
|
// REVISIT: Let csd build generate by default
|
|
35
|
-
const undeployJSONPath = join(
|
|
31
|
+
const undeployJSONPath = join(db.folder, 'undeploy.json')
|
|
36
32
|
const undeployJSONTemplatePath = join(__dirname, 'files', 'undeploy.json')
|
|
37
33
|
await mergeJSON(undeployJSONPath, undeployJSONTemplatePath)
|
|
38
34
|
|
|
39
35
|
if (isJava) {
|
|
40
|
-
await copyFiles(join(__dirname, 'files', 'db'),
|
|
41
|
-
|
|
36
|
+
await copyFiles(join(__dirname, 'files', 'db'), db.folder, {}, cds.cli.options.force)
|
|
37
|
+
// REVISIT: shouldn't behave differently during cds init
|
|
38
|
+
// if called during cds init the project generation call to AT will add settings
|
|
39
|
+
if (!cds.cli.options.add.has(JAVA)) await mvn.execMvn(mvn.getAddHanaCmdArgs())
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project, { forceOverwrite: true })
|
|
42
|
+
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project, { forceOverwrite: true }) // REVISIT: forceOverwrite: true as default?
|
|
45
43
|
|
|
46
|
-
const packageJson = exists('package.json') ? await read('package.json') :
|
|
44
|
+
const packageJson = exists('package.json') ? await read('package.json') : null
|
|
47
45
|
if (packageJson?.dependencies) {
|
|
48
46
|
delete packageJson.dependencies['@sap/hana-client']
|
|
49
47
|
await write('package.json', packageJson, { spaces: 2 })
|
|
50
48
|
}
|
|
51
|
-
await this.runDependentMerging()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async removeEntriesFromContext(context, key) {
|
|
55
|
-
Object.keys(context.oldTrackingData).forEach(fileName => {
|
|
56
|
-
if (fileName.startsWith(key)) {
|
|
57
|
-
delete context.oldTrackingData[fileName];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
Object.keys(context.newTrackingData).forEach(fileName => {
|
|
62
|
-
if (fileName.startsWith(key)) {
|
|
63
|
-
delete context.newTrackingData[fileName];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
49
|
}
|
|
67
50
|
|
|
68
51
|
async runDependentMerging(context = {}) {
|
|
69
|
-
const project = await readProject(
|
|
52
|
+
const project = await readProject()
|
|
70
53
|
const { hasMta, hasHelm, hasHtml5Repo, isJava, isMultitenant, srvPath } = project
|
|
71
54
|
|
|
72
|
-
|
|
73
55
|
if (hasMta) {
|
|
74
56
|
const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
|
|
75
57
|
const db = isMultitenant ? serviceManager : hdiContainer
|
|
@@ -92,26 +74,23 @@ module.exports = class HanaTemplate extends require('../templateBase') {
|
|
|
92
74
|
into: [srv, 'requires', 'name']
|
|
93
75
|
}]
|
|
94
76
|
|
|
95
|
-
if (
|
|
77
|
+
if (isMultitenant) {
|
|
96
78
|
relationships.push({
|
|
97
|
-
insert: [
|
|
98
|
-
into: [
|
|
79
|
+
insert: [serviceManager, 'name'],
|
|
80
|
+
into: [mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar'), 'requires', 'name']
|
|
99
81
|
})
|
|
100
82
|
} else {
|
|
101
83
|
relationships.push({
|
|
102
|
-
insert: [
|
|
103
|
-
into: [
|
|
84
|
+
insert: [hdiContainer, 'name'],
|
|
85
|
+
into: [hdbDeployer, 'requires', 'name']
|
|
104
86
|
})
|
|
105
87
|
}
|
|
106
88
|
|
|
107
|
-
const modules =
|
|
89
|
+
const modules = isMultitenant ? [srv] : [srv, hdbDeployer]
|
|
108
90
|
|
|
109
|
-
await mergeYAML(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
project,
|
|
113
|
-
{ additions: [...modules, db].filter(a => a), deletions, relationships }
|
|
114
|
-
)
|
|
91
|
+
await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, {
|
|
92
|
+
additions: [...modules, db].filter(a => a), deletions, relationships
|
|
93
|
+
})
|
|
115
94
|
}
|
|
116
95
|
|
|
117
96
|
if (hasHelm) {
|
|
@@ -123,7 +102,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
|
|
|
123
102
|
}
|
|
124
103
|
|
|
125
104
|
const HelmTemplate = require(`../helm`);
|
|
126
|
-
const helmTemplate = new HelmTemplate(
|
|
105
|
+
const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
|
|
127
106
|
|
|
128
107
|
if(isMultitenant){
|
|
129
108
|
shouldUpdateTrackingFile = true;
|
|
@@ -137,7 +116,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
|
|
|
137
116
|
// remove content-deployment subchart if html5Repo doesn't exist
|
|
138
117
|
if(!hasHtml5Repo) {
|
|
139
118
|
const contentDeploymentEntriesPattern = "charts/content-deployment/"
|
|
140
|
-
|
|
119
|
+
this.removeEntriesFromContext(context, contentDeploymentEntriesPattern);
|
|
141
120
|
|
|
142
121
|
const contentDeploymentSubchartPath = join('chart', 'charts', 'content-deployment');
|
|
143
122
|
if(exists(contentDeploymentSubchartPath)) {
|
|
@@ -193,21 +172,18 @@ module.exports = class HanaTemplate extends require('../templateBase') {
|
|
|
193
172
|
}
|
|
194
173
|
}
|
|
195
174
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
await commandUtil.spawnCommand('mvn', mvnAddHanaArgs, {
|
|
202
|
-
cwd: cds.root
|
|
203
|
-
});
|
|
204
|
-
} catch (err) {
|
|
205
|
-
// REVISIT: This should not have to be checked and tested in a facet implementation, move to Maven util
|
|
206
|
-
if (err.code === 'ENOENT' && err.path === 'mvn') {
|
|
207
|
-
throw new Error(`Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`);
|
|
208
|
-
}
|
|
209
|
-
throw err;
|
|
175
|
+
// REVISIT: tracking data massaging is getting too much -> revisit md5 tracking
|
|
176
|
+
removeEntriesFromContext(context, key) {
|
|
177
|
+
Object.keys(context.oldTrackingData).forEach(fileName => {
|
|
178
|
+
if (fileName.startsWith(key)) {
|
|
179
|
+
delete context.oldTrackingData[fileName]
|
|
210
180
|
}
|
|
211
|
-
}
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
Object.keys(context.newTrackingData).forEach(fileName => {
|
|
184
|
+
if (fileName.startsWith(key)) {
|
|
185
|
+
delete context.newTrackingData[fileName]
|
|
186
|
+
}
|
|
187
|
+
})
|
|
212
188
|
}
|
|
213
189
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
const { join } = require('path');
|
|
2
|
-
const
|
|
2
|
+
const cds = require('../../../cds')
|
|
3
|
+
const { exists, rimraf } = cds.utils
|
|
3
4
|
const { readProject } = require('../../util/projectReader');
|
|
4
5
|
const { mergeYAML } = require('../../util/merge')
|
|
5
6
|
const { parseMd5File, writeMd5File, copyAndTrack } = require('../../util/md5')
|
|
6
7
|
|
|
7
8
|
module.exports = class HelmTemplate extends require('../templateBase') {
|
|
8
9
|
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
10
|
+
constructor(oldTrackingData = undefined, newTrackingData = {}) {
|
|
11
|
+
super()
|
|
11
12
|
this.oldTrackingData = oldTrackingData;
|
|
12
13
|
this.newTrackingData = newTrackingData;
|
|
13
14
|
}
|
|
@@ -16,18 +17,19 @@ module.exports = class HelmTemplate extends require('../templateBase') {
|
|
|
16
17
|
return ['hana', 'xsuaa', 'auditlog', 'enterprise-messaging', 'destination' , 'multitenancy', 'extensibility', 'approuter', 'connectivity']
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
static hasFacet(
|
|
20
|
+
static hasFacet() {
|
|
20
21
|
// REVISIT: this works, but could be semantically nicer with a 'shouldRunDependentMerging' or the like
|
|
21
|
-
|
|
22
|
+
const { add } = cds.cli.options
|
|
23
|
+
if (add.has('mta') && !add.has('helm')) return false
|
|
22
24
|
return exists(join('chart', 'values.yaml'))
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
async canRun() {
|
|
26
|
-
if (
|
|
28
|
+
if (cds.cli.options.force) {
|
|
27
29
|
await rimraf(join('chart'))
|
|
28
|
-
return true
|
|
30
|
+
return true
|
|
29
31
|
}
|
|
30
|
-
return true
|
|
32
|
+
return true
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
async addSubChart(subchart, force = false) {
|
|
@@ -47,11 +49,11 @@ module.exports = class HelmTemplate extends require('../templateBase') {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
async isInternal() {
|
|
50
|
-
return !exists(join('chart', 'charts', 'web-application')) ||
|
|
52
|
+
return !exists(join('chart', 'charts', 'web-application')) || cds.cli.options['internal-unified-runtime-charts'];
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
async addDependency(name, alias){
|
|
54
|
-
const project = await readProject(
|
|
56
|
+
const project = await readProject();
|
|
55
57
|
const isInternal = await this.isInternal();
|
|
56
58
|
await mergeYAML(
|
|
57
59
|
join('chart', 'Chart.yaml'),
|
|
@@ -77,8 +79,8 @@ module.exports = class HelmTemplate extends require('../templateBase') {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
async run() {
|
|
80
|
-
const project = await readProject(
|
|
81
|
-
const isInternal =
|
|
82
|
+
const project = await readProject()
|
|
83
|
+
const isInternal = cds.cli.options['internal-unified-runtime-charts'] !== undefined && cds.cli.options['internal-unified-runtime-charts'];
|
|
82
84
|
this.oldTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'));
|
|
83
85
|
await this.addSubChart('web-application', !isInternal);
|
|
84
86
|
await copyAndTrack(
|
|
@@ -100,7 +102,6 @@ module.exports = class HelmTemplate extends require('../templateBase') {
|
|
|
100
102
|
join(__dirname, 'files', 'values.yaml.hbs'),
|
|
101
103
|
project
|
|
102
104
|
)
|
|
103
|
-
await this.runDependentMerging();
|
|
104
105
|
await writeMd5File(join('chart', '.cds-add-helm-files.md5'), this.newTrackingData);
|
|
105
106
|
}
|
|
106
|
-
}
|
|
107
|
+
}
|
|
@@ -13,7 +13,7 @@ module.exports = class Html5RepoTemplate extends require('../templateBase') {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async canRun() {
|
|
16
|
-
const project = await readProject(
|
|
16
|
+
const project = await readProject()
|
|
17
17
|
const { hasMta, hasHelm } = project
|
|
18
18
|
if (!hasHelm && hasMta) {
|
|
19
19
|
throw `'cds add html5-repo' is not available for Cloud Foundry yet`
|
|
@@ -26,12 +26,8 @@ module.exports = class Html5RepoTemplate extends require('../templateBase') {
|
|
|
26
26
|
return exists(join('chart', 'templates', 'html5-apps-deployer-configmap.yaml'))
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
async run() {
|
|
30
|
-
await this.runDependentMerging()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
29
|
async runDependentMerging(context = {}) {
|
|
34
|
-
const { appName, hasHelm } = await readProject(
|
|
30
|
+
const { appName, hasHelm } = await readProject()
|
|
35
31
|
|
|
36
32
|
if (hasHelm) {
|
|
37
33
|
//in case facet is being added to the already exisiting charts folder
|
|
@@ -78,7 +74,7 @@ module.exports = class Html5RepoTemplate extends require('../templateBase') {
|
|
|
78
74
|
|
|
79
75
|
// copy content deployment chart if it is not present
|
|
80
76
|
const HelmTemplate = require(`../helm`);
|
|
81
|
-
const helmTemplate = new HelmTemplate(
|
|
77
|
+
const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
|
|
82
78
|
isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('content-deployment');
|
|
83
79
|
|
|
84
80
|
// add dependency entry in chart.yaml
|
|
@@ -14,25 +14,25 @@ module.exports = class JavaTemplate extends require('../templateBase') {
|
|
|
14
14
|
|
|
15
15
|
async canRun() {
|
|
16
16
|
if (cds.cli.command === COMMAND_ADD) {
|
|
17
|
-
throw
|
|
17
|
+
throw `You can't change the runtime of an existing project.`
|
|
18
18
|
}
|
|
19
19
|
if (cds.cli.options.add?.has(NODEJS)) {
|
|
20
|
-
throw
|
|
20
|
+
throw `Only one runtime per project is supported. Specify either ${term.bold(JAVA)} or ${term.bold(NODEJS)}.`
|
|
21
21
|
}
|
|
22
22
|
return true
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async run() {
|
|
26
|
-
const { cmdLine, artifactId, archetypeVersion } = await mvn.getGenerateCmdArgs(
|
|
26
|
+
const { cmdLine, artifactId, archetypeVersion } = await mvn.getGenerateCmdArgs(path.basename(cds.root))
|
|
27
27
|
console.log(`Using Maven archetype version ${archetypeVersion}`)
|
|
28
28
|
|
|
29
|
-
const temp = await fs.promises.mkdtemp(join(os.tmpdir(), `${
|
|
29
|
+
const temp = await fs.promises.mkdtemp(join(os.tmpdir(), `${path.basename(cds.root)}_`))
|
|
30
30
|
try {
|
|
31
31
|
await cmd.spawnCommand('mvn', cmdLine, { cwd: temp })
|
|
32
|
-
await copy(join(temp, artifactId),
|
|
32
|
+
await copy(join(temp, artifactId), cds.root);
|
|
33
33
|
} catch (err) {
|
|
34
34
|
if (err.code === 'ENOENT' && err.path === 'mvn') {
|
|
35
|
-
throw
|
|
35
|
+
throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
|
|
36
36
|
}
|
|
37
37
|
throw err;
|
|
38
38
|
} finally {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
modules:
|
|
3
|
+
- name: {{appName}}-srv
|
|
4
|
+
type: {{language}}
|
|
5
|
+
path: {{& srvPath}}
|
|
6
|
+
requires:
|
|
7
|
+
- name: {{appName}}-logging
|
|
8
|
+
|
|
9
|
+
{{#isMultitenant}}
|
|
10
|
+
- name: {{appName}}-mtx
|
|
11
|
+
type: nodejs
|
|
12
|
+
path: {{#isNodejs}}gen/{{/isNodejs}}mtx/sidecar
|
|
13
|
+
requires:
|
|
14
|
+
- name: {{appName}}-logging
|
|
15
|
+
{{/isMultitenant}}
|
|
16
|
+
|
|
17
|
+
{{#hasApprouter}}
|
|
18
|
+
- name: {{appName}}
|
|
19
|
+
type: approuter.nodejs
|
|
20
|
+
requires:
|
|
21
|
+
- name: {{appName}}-logging
|
|
22
|
+
{{/hasApprouter}}
|
|
23
|
+
|
|
24
|
+
resources:
|
|
25
|
+
- name: {{appName}}-logging
|
|
26
|
+
type: org.cloudfoundry.managed-service
|
|
27
|
+
parameters:
|
|
28
|
+
service: application-logs
|
|
29
|
+
service-plan: lite
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const { join } = require('path')
|
|
2
|
+
const { readProject } = require('../../util/projectReader')
|
|
3
|
+
const { mergeJSON, mergeYAML } = require('../../util/merge')
|
|
4
|
+
const { srvNode4, srvJava4, mtxSidecar4, kibana, approuter } = require('../_merging/registry-mta')
|
|
5
|
+
|
|
6
|
+
module.exports = class KibanaTemplate extends require('../templateBase') {
|
|
7
|
+
|
|
8
|
+
static hasFacet(env) {
|
|
9
|
+
return env.features.kibana_formatter
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async canRun() {
|
|
13
|
+
const { hasMta, hasHelm, isJava } = await readProject()
|
|
14
|
+
if (hasHelm && !hasMta) throw `'cds add kibana' is not available for Kyma yet`
|
|
15
|
+
if (isJava) throw `'cds add kibana' is not available for Java yet`
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async run() {
|
|
20
|
+
const project = await readProject()
|
|
21
|
+
const { configFile } = project
|
|
22
|
+
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async runDependentMerging() {
|
|
26
|
+
const project = await readProject()
|
|
27
|
+
const { hasMta, hasApprouter, isJava, isMultitenant, srvPath } = project
|
|
28
|
+
|
|
29
|
+
if (hasMta) {
|
|
30
|
+
const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
|
|
31
|
+
const additions = [srv, kibana]
|
|
32
|
+
const relationships = [{
|
|
33
|
+
insert: [kibana, 'name'],
|
|
34
|
+
into: [srv, 'requires', 'name']
|
|
35
|
+
}]
|
|
36
|
+
if (isMultitenant) {
|
|
37
|
+
const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar')
|
|
38
|
+
additions.push(mtxSidecar)
|
|
39
|
+
relationships.push({
|
|
40
|
+
insert: [kibana, 'name'],
|
|
41
|
+
into: [mtxSidecar, 'requires', 'name']
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
if (hasApprouter) {
|
|
45
|
+
additions.push(approuter)
|
|
46
|
+
relationships.push({
|
|
47
|
+
insert: [kibana, 'name'],
|
|
48
|
+
into: [approuter, 'requires', 'name']
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, { additions, relationships })
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -19,8 +19,8 @@ const VSCODE_FILE_ASSOCIATIONS = {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
module.exports = class LintTemplate extends require('../templateBase') {
|
|
22
|
-
constructor(
|
|
23
|
-
super(
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
24
|
this.customPath = path.join(cds.root, ".eslint");
|
|
25
25
|
this.docsPath = path.join(this.customPath, "docs");
|
|
26
26
|
this.rulesPath = path.join(this.customPath, "rules");
|
|
@@ -32,13 +32,14 @@ module.exports = class LintTemplate extends require('../templateBase') {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async canRun() {
|
|
35
|
-
|
|
35
|
+
const { lint } = cds.cli.options
|
|
36
|
+
if (lint) {
|
|
36
37
|
// If custom rule example is requested, also trigger
|
|
37
38
|
// "custom" rule type of setup
|
|
38
|
-
if (
|
|
39
|
+
if (lint.has(LINT_DEV)) {
|
|
39
40
|
this.customRuleExample = true;
|
|
40
41
|
}
|
|
41
|
-
if (
|
|
42
|
+
if (lint.has(LINT_GLOBAL)) {
|
|
42
43
|
this.lintType = "global";
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -98,7 +99,7 @@ module.exports = class LintTemplate extends require('../templateBase') {
|
|
|
98
99
|
"names"
|
|
99
100
|
].join(" ")}`;
|
|
100
101
|
|
|
101
|
-
if (
|
|
102
|
+
if (cds.cli.options.force) {
|
|
102
103
|
LOG.info(
|
|
103
104
|
`\n\nAlmost done - installing ${this.missingNpmDependencies["names"].length} npm dependencies:\n${task}`
|
|
104
105
|
);
|
|
@@ -187,7 +188,7 @@ module.exports = class LintTemplate extends require('../templateBase') {
|
|
|
187
188
|
clearTimeout(timerID);
|
|
188
189
|
received = answer.trim().toLowerCase();
|
|
189
190
|
// If user confirms or force flag is set, install dependencies
|
|
190
|
-
if (["y", "yes"].includes(received) ||
|
|
191
|
+
if (["y", "yes"].includes(received) || cds.cli.options.force) {
|
|
191
192
|
resolve(this._runTask(task));
|
|
192
193
|
// If use declines or question timeout is reached, print todos
|
|
193
194
|
} else if (["n", "no"].includes(received.toLowerCase())) {
|
|
@@ -7,7 +7,8 @@ const { mergeJSON, sort } = require('../../util/merge')
|
|
|
7
7
|
|
|
8
8
|
module.exports = class MtaTemplate extends require('../templateBase') {
|
|
9
9
|
|
|
10
|
-
static hasFacet(
|
|
10
|
+
static hasFacet() {
|
|
11
|
+
const { options } = cds.cli
|
|
11
12
|
if (!options?.add.has('mta') && options?.add.has('helm')) return false
|
|
12
13
|
return exists('mta.yaml')
|
|
13
14
|
}
|
|
@@ -17,7 +18,7 @@ module.exports = class MtaTemplate extends require('../templateBase') {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
async run() {
|
|
20
|
-
const project = await readProject(
|
|
21
|
+
const project = await readProject()
|
|
21
22
|
if (!exists('mta.yaml')) {
|
|
22
23
|
await copyRenderedYAML(join(__dirname, 'files', 'mta.yaml.hbs'), 'mta.yaml', project)
|
|
23
24
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"start": "cds-serve"{{#isJava}},
|
|
16
|
-
"build": "cds build ../.. --for mtx-sidecar --production &&
|
|
16
|
+
"build": "cds build ../.. --for mtx-sidecar --production && npm ci --prefix gen"{{/isJava}}
|
|
17
17
|
},
|
|
18
18
|
"cds": {
|
|
19
19
|
"profile": "mtx-sidecar"
|