@sap/cds-dk 6.2.3 → 6.3.0
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 +27 -0
- package/bin/bind.js +4 -4
- package/bin/deploy/to-h2.js +4 -0
- package/bin/deploy/to-sqlite.js +6 -4
- package/bin/help.js +1 -1
- package/bin/login.js +1 -0
- package/bin/push.js +29 -7
- package/lib/bind/userCdsrcJsonStorageProvider.js +4 -4
- package/lib/client/activate.js +1 -1
- package/lib/client/base_command.js +10 -10
- package/lib/client/helper/dependency_helper.js +10 -1
- package/lib/client/helper/logging.js +6 -2
- package/lib/client/pull.js +6 -6
- package/lib/client/push.js +33 -14
- package/lib/client/settings_manager.js +52 -21
- package/lib/compile/openapi/csdl2openapi.js +1 -1
- package/lib/compile/to-xsuaa.js +1 -1
- package/lib/import/odata/v2parser.js +37 -1
- package/lib/import/odata/v4parser.js +101 -23
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +23 -45
- package/lib/init/template/approuter/index.js +44 -48
- package/lib/init/template/auditlog/index.js +14 -10
- package/lib/init/template/cf-manifest/index.js +9 -11
- package/lib/init/template/connectivity/index.js +10 -10
- package/lib/init/template/data/index.js +20 -19
- package/lib/init/template/destinations/index.js +14 -9
- package/lib/init/template/enterprise-messaging/index.js +14 -9
- package/lib/init/template/extensibility/index.js +14 -9
- package/lib/init/template/hana/index.js +51 -57
- package/lib/init/template/helm/index.js +27 -59
- package/lib/init/template/helm/subchart/templates/_helpers.tpl +38 -0
- package/lib/init/template/helm/subchart/templates/deployment.yaml +12 -12
- package/lib/init/template/helm/subchart/values.md +565 -194
- package/lib/init/template/helm/subchart/values.schema.json +163 -8
- package/lib/init/template/helm/subchart/values.yaml +17 -1
- package/lib/init/template/html5-repo/index.js +15 -11
- package/lib/init/template/java/index.js +15 -11
- package/lib/init/template/kibana-logging/index.js +30 -31
- package/lib/init/template/lint/index.js +17 -18
- package/lib/init/template/mta/index.js +18 -40
- package/lib/init/template/mtx/index.js +2 -3
- package/lib/init/template/multitenancy/index.js +27 -20
- package/lib/init/template/nodejs/index.js +18 -20
- package/lib/init/template/notebook/index.js +5 -434
- package/lib/init/template/pipeline/index.js +10 -10
- package/lib/init/template/samples/index.js +7 -16
- package/lib/init/template/templateBase.js +17 -18
- package/lib/init/template/toggles/files/cdsrc.json +5 -0
- package/lib/init/template/toggles/files/cdsrc.json.hbs +7 -0
- package/lib/init/template/toggles/index.js +12 -6
- package/lib/init/template/xsuaa/index.js +44 -41
- package/lib/init/types.d.ts +0 -59
- package/lib/init/util/commandUtil.js +6 -7
- package/lib/init/util/fsUtil.js +23 -109
- package/lib/init/util/merge.js +319 -0
- package/lib/init/util/mvnArchetypeUtil.js +6 -5
- package/lib/init/util/projectReader.js +125 -300
- package/lib/init/util/spinner.js +10 -8
- package/lib/init/util/templateUtil.js +25 -368
- package/lib/lint/Linter.js +2 -3
- package/lib/lint/checks.js +0 -1
- package/lib/lint/io.js +18 -34
- package/npm-shrinkwrap.json +102 -239
- package/package.json +3 -3
- package/lib/init/template/notebook/cap_magic.py +0 -118
- package/lib/init/template/notebook/files/{{{name}}}.ipynb.hbs +0 -90
- package/lib/init/template/notebook/files/{{{name}}}.json +0 -102
- package/lib/init/template/notebook/notebook.js +0 -394
- package/lib/init/util/logger.js +0 -42
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { join } = require('path')
|
|
2
|
-
const TemplateBase = require('../templateBase')
|
|
3
2
|
const ProjectReader = require('../../util/projectReader')
|
|
3
|
+
const { mergeJSON, mergeYAML, sortDependencies } = require('../../util/merge')
|
|
4
4
|
const { OPTION_XSUAA, PROJECT_TYPE } = require('../../constants')
|
|
5
5
|
const {
|
|
6
6
|
srvNode, srvJava, approuter, // Modules
|
|
@@ -10,17 +10,21 @@ const {
|
|
|
10
10
|
approuterExtensibility, approuterExtensibilityJava // xs-app.json config
|
|
11
11
|
} = require('../_merging/registry-mta')
|
|
12
12
|
|
|
13
|
-
module.exports = class ApprouterTemplate extends
|
|
13
|
+
module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
14
14
|
|
|
15
15
|
constructor(projectPath, generator) {
|
|
16
16
|
super(projectPath, generator, __dirname)
|
|
17
|
-
this.projectReader = new ProjectReader(
|
|
17
|
+
this.projectReader = new ProjectReader(projectPath)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
static hasFacet(env) {
|
|
21
|
+
return !!env.requires?.approuter
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async canRun() {
|
|
21
25
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
22
|
-
const {
|
|
23
|
-
if (
|
|
26
|
+
const { hasMta, hasHelm } = projectDescriptor.cap
|
|
27
|
+
if (hasHelm && !hasMta) {
|
|
24
28
|
throw `'cds add approuter' is not available for Kyma yet`
|
|
25
29
|
}
|
|
26
30
|
return true
|
|
@@ -30,53 +34,16 @@ module.exports = class ApprouterTemplate extends TemplateBase {
|
|
|
30
34
|
return [OPTION_XSUAA]
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
async runDependentMerging() {
|
|
34
|
-
const projectDescriptor = await this.projectReader.read(this.options)
|
|
35
|
-
const { isNodejs, isJava, isExtensible, isMultitenant, hasMtaDeployment } = projectDescriptor.cap
|
|
36
|
-
|
|
37
|
-
if (hasMtaDeployment) {
|
|
38
|
-
const srv = isNodejs ? srvNode : srvJava
|
|
39
|
-
const apis = isJava ? [requiredJavaApprouterAPI, providedJavaApprouterAPI] : []
|
|
40
|
-
if (isNodejs && isMultitenant) apis.push(requiredMtxAPI, requiredAppAPI, providedAppAPI)
|
|
41
|
-
if (isJava && isMultitenant) apis.push(requiredMtxAPI)
|
|
42
|
-
const additions = [srv, approuter, xsuaa, ...apis]
|
|
43
|
-
const mtaYAMLPath = join(this.projectPath, 'mta.yaml')
|
|
44
|
-
await this.templateUtil.mergeYAML(mtaYAMLPath, `${__dirname}/files/mta.yaml.hbs`, projectDescriptor, {
|
|
45
|
-
additions,
|
|
46
|
-
relationships: [{
|
|
47
|
-
insert: [xsuaa, 'name'],
|
|
48
|
-
into: [srv, 'requires', 'name']
|
|
49
|
-
}, {
|
|
50
|
-
insert: [xsuaa, 'name'],
|
|
51
|
-
into: [approuter, 'requires', 'name']
|
|
52
|
-
}],
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
57
|
-
const additions = isExtensible && isJava ? [{ ...approuterExtensibilityJava, at: 0 }] :
|
|
58
|
-
isExtensible && isNodejs ? [{ ...approuterExtensibility, at: 0 }] : []
|
|
59
|
-
await this.templateUtil.mergeJSON(
|
|
60
|
-
`${appPath}/xs-app.json`,
|
|
61
|
-
`${__dirname}/files/xs-app.json.hbs`,
|
|
62
|
-
projectDescriptor,
|
|
63
|
-
{ additions }
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
37
|
async run() {
|
|
68
38
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
69
39
|
const { for: forProfile } = projectDescriptor.cap
|
|
70
40
|
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
71
41
|
const appPackageJSONPath = join(appPath, 'package.json')
|
|
72
42
|
|
|
73
|
-
await
|
|
74
|
-
await
|
|
43
|
+
await mergeJSON(appPackageJSONPath, join(__dirname, 'files', 'package.json'))
|
|
44
|
+
await sortDependencies(appPackageJSONPath)
|
|
75
45
|
|
|
76
|
-
await
|
|
77
|
-
`${appPath}/default-env.json`,
|
|
78
|
-
`${__dirname}/files/default-env.json`
|
|
79
|
-
)
|
|
46
|
+
await mergeJSON(`${appPath}/default-env.json`, `${__dirname}/files/default-env.json`)
|
|
80
47
|
|
|
81
48
|
const projectType = await this.getProjectType()
|
|
82
49
|
switch (projectType) {
|
|
@@ -84,18 +51,47 @@ module.exports = class ApprouterTemplate extends TemplateBase {
|
|
|
84
51
|
const cdsrcJSONPath = join(this.projectPath, '.cdsrc.json')
|
|
85
52
|
const cdsTemplateFile = forProfile ? 'cds.cdsrc.json.hbs' : 'cds.cdsrc.json'
|
|
86
53
|
const cdsPackageJSONPath = join(__dirname, 'files', cdsTemplateFile)
|
|
87
|
-
await
|
|
54
|
+
await mergeJSON(cdsrcJSONPath, cdsPackageJSONPath, projectDescriptor)
|
|
88
55
|
break
|
|
89
56
|
}
|
|
90
57
|
case PROJECT_TYPE.nodejs: {
|
|
91
58
|
const packageJSONPath = join(this.projectPath, 'package.json')
|
|
92
59
|
const cdsTemplateFile = forProfile ? 'cds.package.json.hbs' : 'cds.package.json'
|
|
93
60
|
const cdsPackageJSONPath = join(__dirname, 'files', cdsTemplateFile)
|
|
94
|
-
await
|
|
61
|
+
await mergeJSON(packageJSONPath, cdsPackageJSONPath, projectDescriptor)
|
|
95
62
|
break
|
|
96
63
|
}
|
|
97
64
|
}
|
|
98
65
|
|
|
99
66
|
await this.runDependentMerging()
|
|
100
67
|
}
|
|
68
|
+
|
|
69
|
+
async runDependentMerging() {
|
|
70
|
+
const projectDescriptor = await this.projectReader.read(this.options)
|
|
71
|
+
const { isNodejs, isJava, isExtensible, isMultitenant, hasMta } = projectDescriptor.cap
|
|
72
|
+
|
|
73
|
+
if (hasMta) {
|
|
74
|
+
const srv = isNodejs ? srvNode : srvJava
|
|
75
|
+
const apis = isJava ? [requiredJavaApprouterAPI, providedJavaApprouterAPI] : []
|
|
76
|
+
if (isNodejs && isMultitenant) apis.push(requiredMtxAPI, requiredAppAPI, providedAppAPI)
|
|
77
|
+
if (isJava && isMultitenant) apis.push(requiredMtxAPI)
|
|
78
|
+
const additions = [srv, approuter, xsuaa, ...apis]
|
|
79
|
+
const mtaYAMLPath = join(this.projectPath, 'mta.yaml')
|
|
80
|
+
await mergeYAML(mtaYAMLPath, `${__dirname}/files/mta.yaml.hbs`, projectDescriptor, {
|
|
81
|
+
additions,
|
|
82
|
+
relationships: [{
|
|
83
|
+
insert: [xsuaa, 'name'],
|
|
84
|
+
into: [srv, 'requires', 'name']
|
|
85
|
+
}, {
|
|
86
|
+
insert: [xsuaa, 'name'],
|
|
87
|
+
into: [approuter, 'requires', 'name']
|
|
88
|
+
}],
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
93
|
+
const additions = isExtensible && isJava ? [{ ...approuterExtensibilityJava, at: 0 }] :
|
|
94
|
+
isExtensible && isNodejs ? [{ ...approuterExtensibility, at: 0 }] : []
|
|
95
|
+
await mergeJSON(`${appPath}/xs-app.json`, `${__dirname}/files/xs-app.json.hbs`, projectDescriptor, { additions })
|
|
96
|
+
}
|
|
101
97
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
const
|
|
2
|
+
const { copy } = require('../../../cds').utils
|
|
3
3
|
const ProjectReader = require('../../util/projectReader')
|
|
4
|
+
const { mergeYAML } = require('../../util/merge')
|
|
4
5
|
const { srvNode, srvJava, auditlog } = require('../_merging/registry-mta')
|
|
5
|
-
const cds = require('../../../cds'), { fs } = cds.utils
|
|
6
6
|
|
|
7
|
-
module.exports = class AuditlogTemplate extends
|
|
7
|
+
module.exports = class AuditlogTemplate extends require('../templateBase') {
|
|
8
8
|
constructor(projectPath, generator) {
|
|
9
9
|
super(projectPath, generator, __dirname)
|
|
10
|
-
this.projectReader = new ProjectReader(
|
|
10
|
+
this.projectReader = new ProjectReader(projectPath)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static hasFacet() {
|
|
14
|
+
return false // TODO: Need a `cds.requires.auditlog` or some other way to detect if enabled.
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
async run() {
|
|
@@ -16,12 +20,12 @@ module.exports = class AuditlogTemplate extends TemplateBase {
|
|
|
16
20
|
|
|
17
21
|
async runDependentMerging() {
|
|
18
22
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
19
|
-
const { isNodejs,
|
|
23
|
+
const { isNodejs, hasMta, hasHelm } = projectDescriptor.cap
|
|
20
24
|
|
|
21
|
-
if (
|
|
25
|
+
if (hasMta) {
|
|
22
26
|
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
|
|
23
27
|
const srv = isNodejs ? srvNode : srvJava
|
|
24
|
-
await
|
|
28
|
+
await mergeYAML(
|
|
25
29
|
mtaYAMLPath,
|
|
26
30
|
`${__dirname}/files/mta.yaml.hbs`,
|
|
27
31
|
projectDescriptor,
|
|
@@ -35,8 +39,8 @@ module.exports = class AuditlogTemplate extends TemplateBase {
|
|
|
35
39
|
)
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
if (
|
|
39
|
-
await
|
|
42
|
+
if (hasHelm) {
|
|
43
|
+
await mergeYAML(
|
|
40
44
|
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
41
45
|
{
|
|
42
46
|
srv: { bindings: {
|
|
@@ -49,7 +53,7 @@ module.exports = class AuditlogTemplate extends TemplateBase {
|
|
|
49
53
|
},
|
|
50
54
|
null, { forceOverwrite: true }
|
|
51
55
|
)
|
|
52
|
-
await
|
|
56
|
+
await copy(path.join(__dirname, 'files', 'auditlog.yaml'), path.join(this.projectPath, 'chart', 'templates', 'auditlog.yaml'))
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
const
|
|
2
|
+
const { exists } = require('../../../cds').utils
|
|
3
3
|
const ProjectReader = require('../../util/projectReader');
|
|
4
|
-
|
|
4
|
+
const { copyFiles } = require('../../util/templateUtil')
|
|
5
5
|
const { OPTION_CF_MANIFEST } = require('../../constants')
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const MANIFEST_FILE = MANIFEST + '.yml'
|
|
9
|
-
const SERVICES_MANIFEST_FILE = SERVICES_MANIFEST + '.yml'
|
|
6
|
+
const MANIFEST_FILE = 'manifest.yml'
|
|
7
|
+
const SERVICES_MANIFEST_FILE = 'services-manifest.yml'
|
|
10
8
|
|
|
11
|
-
module.exports = class ManifestTemplate extends
|
|
9
|
+
module.exports = class ManifestTemplate extends require('../templateBase') {
|
|
12
10
|
constructor(projectPath, generator) {
|
|
13
11
|
super(projectPath, generator, __dirname)
|
|
14
|
-
this.projectReader = new ProjectReader(
|
|
12
|
+
this.projectReader = new ProjectReader(projectPath)
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
async
|
|
15
|
+
async canRun() {
|
|
18
16
|
if (!this.options.add.has(OPTION_CF_MANIFEST)) {
|
|
19
17
|
return false;
|
|
20
18
|
}
|
|
@@ -23,7 +21,7 @@ module.exports = class ManifestTemplate extends TemplateBase {
|
|
|
23
21
|
return true;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
if (
|
|
24
|
+
if (exists(path.join(this.projectPath, MANIFEST_FILE)) || exists(path.join(this.projectPath, SERVICES_MANIFEST_FILE))) {
|
|
27
25
|
throw new Error(`File ${MANIFEST_FILE} or ${SERVICES_MANIFEST_FILE} already exist in current folder. Use --force to overwrite.`);
|
|
28
26
|
}
|
|
29
27
|
return true;
|
|
@@ -31,6 +29,6 @@ module.exports = class ManifestTemplate extends TemplateBase {
|
|
|
31
29
|
|
|
32
30
|
async run() {
|
|
33
31
|
const projectDescriptor = await this.projectReader.read()
|
|
34
|
-
await
|
|
32
|
+
await copyFiles(path.join(__dirname, 'files'), this.projectPath, projectDescriptor, this.options.force);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
const TemplateBase = require('../templateBase')
|
|
3
2
|
const ProjectReader = require('../../util/projectReader')
|
|
4
|
-
const
|
|
3
|
+
const { mergeYAML } = require('../../util/merge')
|
|
4
|
+
const cds = require('../../../cds'), { copy } = cds.utils
|
|
5
5
|
|
|
6
|
-
module.exports = class ConnectivityTemplate extends
|
|
6
|
+
module.exports = class ConnectivityTemplate extends require('../templateBase') {
|
|
7
7
|
constructor(projectPath, generator) {
|
|
8
8
|
super(projectPath, generator, __dirname)
|
|
9
|
-
this.projectReader = new ProjectReader(
|
|
9
|
+
this.projectReader = new ProjectReader(projectPath)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async run() {
|
|
@@ -15,10 +15,10 @@ module.exports = class ConnectivityTemplate extends TemplateBase {
|
|
|
15
15
|
|
|
16
16
|
async runDependentMerging() {
|
|
17
17
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
18
|
-
const {
|
|
18
|
+
const { hasHelm } = projectDescriptor.cap
|
|
19
19
|
|
|
20
|
-
if (
|
|
21
|
-
await
|
|
20
|
+
if (hasHelm) {
|
|
21
|
+
await mergeYAML(
|
|
22
22
|
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
23
23
|
path.join(__dirname, 'files', 'values.yaml.hbs'),
|
|
24
24
|
projectDescriptor,
|
|
@@ -33,9 +33,9 @@ module.exports = class ConnectivityTemplate extends TemplateBase {
|
|
|
33
33
|
)
|
|
34
34
|
const filesPath = path.join(__dirname, 'files')
|
|
35
35
|
const templatesPath = path.join(this.projectPath, 'chart', 'templates')
|
|
36
|
-
await
|
|
37
|
-
await
|
|
38
|
-
await
|
|
36
|
+
await copy(path.join(filesPath, 'connectivity-binding.yaml'), path.join(templatesPath, 'connectivity-binding.yaml'))
|
|
37
|
+
await copy(path.join(filesPath, 'connectivity-proxy-info.yaml'), path.join(templatesPath, 'connectivity-proxy-info.yaml'))
|
|
38
|
+
await copy(path.join(filesPath, 'connectivity.yaml'), path.join(templatesPath, 'connectivity.yaml'))
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
const TemplateBase = require('../templateBase');
|
|
2
|
-
const cds = require('../../../cds');
|
|
3
|
-
const {resolve, join, relative} = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
1
|
|
|
6
|
-
|
|
2
|
+
const cds = require('../../../cds')
|
|
3
|
+
const { exists, fs } = cds.utils
|
|
4
|
+
const { resolve, join, relative } = require('path');
|
|
5
|
+
const LOG = console
|
|
6
|
+
const DEBUG = /\bcli\b/.test(process.env.DEBUG) && console.debug
|
|
7
|
+
|
|
8
|
+
module.exports = class DataTemplate extends require('../templateBase') {
|
|
7
9
|
constructor(projectPath, generator) {
|
|
8
10
|
super(projectPath, generator, __dirname);
|
|
9
11
|
}
|
|
@@ -18,14 +20,13 @@ module.exports = class DataTemplate extends TemplateBase {
|
|
|
18
20
|
|
|
19
21
|
const nameFilter = asRegex(this.options['data:for'] || this.options.for)
|
|
20
22
|
const force = this.options.force;
|
|
21
|
-
const logger = this.logger;
|
|
22
23
|
|
|
23
24
|
cds.root = this.projectPath;
|
|
24
25
|
let csn = await cds.compile.to.csn(cds.env.roots); // normal CSN
|
|
25
26
|
|
|
26
27
|
// Also include 'external' entities w/ cds.persistence.skip (similar to 'mocked' option of serve).
|
|
27
28
|
// Could be too much sometimes, but don't want to bother users w/ a separate option for this.
|
|
28
|
-
includeExternalEntities(csn
|
|
29
|
+
includeExternalEntities(csn)
|
|
29
30
|
|
|
30
31
|
csn = cds.compile.for.sql(csn, { names:env.sql.names, messages:[] }) // CSN w/ persistence information
|
|
31
32
|
csn = cds.reflect(csn); // reflected model (adds additional helper functions)
|
|
@@ -34,15 +35,15 @@ module.exports = class DataTemplate extends TemplateBase {
|
|
|
34
35
|
.filter (e => e.name.match(nameFilter)) // --for prefix|regex
|
|
35
36
|
.filter (e => !e.query) // exclude entities with queries (projection on, select from ...)
|
|
36
37
|
.filter (e => e.name !== 'DRAFT.DraftAdministrativeData' && !e.name.endsWith('.drafts')) // exclude draft stuff
|
|
37
|
-
.forEach(e => processEntity(e, dest, this.projectPath, csn, force
|
|
38
|
+
.forEach(e => processEntity(e, dest, this.projectPath, csn, force));
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
function includeExternalEntities(model
|
|
42
|
+
function includeExternalEntities(model) {
|
|
42
43
|
for (let each in model.definitions) {
|
|
43
44
|
const def = model.definitions[each]
|
|
44
45
|
if (def['@cds.persistence.skip'] === true) {
|
|
45
|
-
|
|
46
|
+
DEBUG && DEBUG('Including skipped entity '+each)
|
|
46
47
|
delete def['@cds.persistence.skip']
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -65,7 +66,7 @@ function asRegex(spec) {
|
|
|
65
66
|
return /.*/
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
function processEntity (entity, dest, projectPath, csn, force
|
|
69
|
+
function processEntity (entity, dest, projectPath, csn, force) {
|
|
69
70
|
let dataFileName;
|
|
70
71
|
const namespace = getNamespace(csn, entity.name);
|
|
71
72
|
if (!namespace || namespace == entity.name) {
|
|
@@ -82,21 +83,21 @@ function processEntity (entity, dest, projectPath, csn, force, logger) {
|
|
|
82
83
|
// otherwise use the new '.texts' format
|
|
83
84
|
const dataFileNameOldFormat = dataFileName.replace('.texts.csv','_texts.csv');
|
|
84
85
|
const dataFilePathOldFormat = join(dest, dataFileNameOldFormat);
|
|
85
|
-
if (
|
|
86
|
-
createDataFile(true, dataFilePathOldFormat, dest, projectPath, force, entity
|
|
86
|
+
if (exists(dataFilePathOldFormat)) {
|
|
87
|
+
createDataFile(true, dataFilePathOldFormat, dest, projectPath, force, entity);
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
const dataFilePath = join(dest, dataFileName);
|
|
92
|
-
createDataFile(
|
|
93
|
+
createDataFile(exists(dataFilePath), dataFilePath, dest, projectPath, force, entity);
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
function getDefaultTargetFolder (env, projectPath) {
|
|
96
97
|
const dbFolder = env.folders.db;
|
|
97
98
|
// csv files should be located in the 'db/data' folder unless a 'db/csv' folder already exists
|
|
98
99
|
let mockDataFolder;
|
|
99
|
-
if (
|
|
100
|
+
if (exists(join(projectPath, dbFolder, 'csv'))) {
|
|
100
101
|
mockDataFolder = 'csv';
|
|
101
102
|
} else {
|
|
102
103
|
mockDataFolder = 'data';
|
|
@@ -105,7 +106,7 @@ function getDefaultTargetFolder (env, projectPath) {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
|
|
108
|
-
function createDataFile (isFileExists, dataFilePath, dest, projectPath, force, entity
|
|
109
|
+
function createDataFile (isFileExists, dataFilePath, dest, projectPath, force, entity) {
|
|
109
110
|
let relFilePath = dataFilePath;
|
|
110
111
|
if (dataFilePath.indexOf(projectPath) == 0) {
|
|
111
112
|
// use relative path in log (for readability), only when data files are added within the project
|
|
@@ -113,15 +114,15 @@ function createDataFile (isFileExists, dataFilePath, dest, projectPath, force, e
|
|
|
113
114
|
relFilePath = relative(projectPath, dataFilePath);
|
|
114
115
|
}
|
|
115
116
|
if (isFileExists && !force) {
|
|
116
|
-
|
|
117
|
+
LOG.info(`Skipping ${relFilePath}`);
|
|
117
118
|
}
|
|
118
119
|
else {
|
|
119
120
|
// continue only if file not already exists, or '--force' option provided
|
|
120
121
|
const dataFileContent = prepareDataFileContent(entity);
|
|
121
122
|
if (dataFileContent && dataFileContent.length) {
|
|
122
|
-
if (!
|
|
123
|
+
if (!exists(dest)) fs.mkdirSync(dest, {recursive: true})
|
|
123
124
|
fs.writeFileSync(dataFilePath, dataFileContent);
|
|
124
|
-
isFileExists ?
|
|
125
|
+
isFileExists ? LOG.info(`Overwriting `+relFilePath) : LOG.info(`Creating `+relFilePath)
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
const TemplateBase = require('../templateBase')
|
|
3
2
|
const ProjectReader = require('../../util/projectReader')
|
|
4
|
-
const
|
|
3
|
+
const { mergeYAML } = require('../../util/merge')
|
|
4
|
+
const { copy } = require('../../../cds').utils
|
|
5
5
|
|
|
6
|
-
module.exports = class DestinationsTemplate extends
|
|
6
|
+
module.exports = class DestinationsTemplate extends require('../templateBase') {
|
|
7
7
|
constructor(projectPath, generator) {
|
|
8
8
|
super(projectPath, generator, __dirname)
|
|
9
|
-
this.projectReader = new ProjectReader(
|
|
9
|
+
this.projectReader = new ProjectReader(projectPath)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static hasFacet(env) {
|
|
13
|
+
const kinds = { odata: 1, 'odata-v2': 1, 'odata-v4': 1, rest: 1 }
|
|
14
|
+
return Object.entries(env.requires).some(([service, require]) => !kinds[service] && kinds[require.kind])
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
async run() {
|
|
@@ -15,14 +20,14 @@ module.exports = class DestinationsTemplate extends TemplateBase {
|
|
|
15
20
|
|
|
16
21
|
async runDependentMerging() {
|
|
17
22
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
18
|
-
const {
|
|
23
|
+
const { hasHelm, hasDestination, hasHtml5Repo } = projectDescriptor.cap
|
|
19
24
|
|
|
20
|
-
if (
|
|
21
|
-
const env = await this.getEnv()
|
|
25
|
+
if (hasHelm) {
|
|
26
|
+
//const env = await this.getEnv()
|
|
22
27
|
const binding = hasDestination && { srv: { bindings: { destination: { serviceInstanceName: 'destinations' }}}}
|
|
23
28
|
const html5Binding = hasHtml5Repo && { html5_apps_deployer: { bindings: { destination: { serviceInstanceName: 'destination' }}}}
|
|
24
29
|
|
|
25
|
-
await
|
|
30
|
+
await mergeYAML(
|
|
26
31
|
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
27
32
|
{
|
|
28
33
|
...binding,
|
|
@@ -38,7 +43,7 @@ module.exports = class DestinationsTemplate extends TemplateBase {
|
|
|
38
43
|
},
|
|
39
44
|
null, { forceOverwrite: true }
|
|
40
45
|
)
|
|
41
|
-
await
|
|
46
|
+
await copy(path.join(__dirname, 'files', 'destination.yaml'), path.join(this.projectPath, 'chart', 'templates', 'destination.yaml'))
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
const
|
|
2
|
+
const { copy } = require('../../../cds').utils
|
|
3
3
|
const ProjectReader = require('../../util/projectReader')
|
|
4
|
+
const { mergeJSON, mergeYAML } = require('../../util/merge')
|
|
4
5
|
const { srvNode, srvJava, enterpriseMessaging } = require('../_merging/registry-mta')
|
|
5
6
|
|
|
6
7
|
module.exports = class EnterpriseMessagingTemplate extends require('../templateBase') {
|
|
7
8
|
constructor(projectPath, generator) {
|
|
8
9
|
super(projectPath, generator, __dirname)
|
|
9
|
-
this.projectReader = new ProjectReader(
|
|
10
|
+
this.projectReader = new ProjectReader(projectPath)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static hasFacet(env) {
|
|
14
|
+
return env.requires?.messaging === 'enterprise-messaging'
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
async run() {
|
|
@@ -16,18 +21,18 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
|
|
|
16
21
|
const cdsTemplateFile = (isNodejs ? 'cds.package.json' : 'cdsrc.json') + (forProfile ? '.hbs' : '')
|
|
17
22
|
const cdsTemplatePath = path.join(templatePath, cdsTemplateFile)
|
|
18
23
|
const configPath = path.join(this.projectPath, isNodejs ? 'package.json' : '.cdsrc.json')
|
|
19
|
-
await
|
|
24
|
+
await mergeJSON(configPath, cdsTemplatePath, projectDescriptor)
|
|
20
25
|
await this.runDependentMerging()
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
async runDependentMerging() {
|
|
24
29
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
25
|
-
const {
|
|
30
|
+
const { hasHelm, hasMta, isNodejs } = projectDescriptor.cap
|
|
26
31
|
|
|
27
|
-
if (
|
|
32
|
+
if (hasMta) {
|
|
28
33
|
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
|
|
29
34
|
const srv = isNodejs ? srvNode : srvJava
|
|
30
|
-
await
|
|
35
|
+
await mergeYAML(
|
|
31
36
|
mtaYAMLPath,
|
|
32
37
|
`${__dirname}/files/mta.yaml.hbs`,
|
|
33
38
|
projectDescriptor,
|
|
@@ -41,13 +46,13 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
|
|
|
41
46
|
)
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
if (
|
|
45
|
-
await
|
|
49
|
+
if (hasHelm) {
|
|
50
|
+
await mergeYAML(
|
|
46
51
|
path.join(this.projectPath, 'chart', 'values.yaml'),
|
|
47
52
|
path.join(__dirname, 'files', 'values.yaml'),
|
|
48
53
|
null, { forceOverwrite: true }
|
|
49
54
|
)
|
|
50
|
-
await
|
|
55
|
+
await copy(
|
|
51
56
|
path.join(__dirname, 'files', 'event-mesh.yaml'),
|
|
52
57
|
path.join(this.projectPath, 'chart', 'templates', 'event-mesh.yaml')
|
|
53
58
|
)
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
const cds = require('../../../cds')
|
|
2
|
-
const
|
|
1
|
+
const cds = require('../../../cds')
|
|
2
|
+
const { copy, path } = cds.utils
|
|
3
3
|
const ProjectReader = require('../../util/projectReader')
|
|
4
|
+
const { mergeJSON } = require('../../util/merge')
|
|
4
5
|
|
|
5
|
-
module.exports = class ExtensibilityTemplate extends
|
|
6
|
+
module.exports = class ExtensibilityTemplate extends require('../templateBase') {
|
|
6
7
|
constructor(projectPath, generator) {
|
|
7
8
|
super(projectPath, generator, __dirname)
|
|
8
|
-
this.projectReader = new ProjectReader(
|
|
9
|
+
this.projectReader = new ProjectReader(projectPath)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static hasFacet(env) {
|
|
13
|
+
return !!env.requires?.extensibility
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
async run() {
|
|
@@ -13,15 +18,15 @@ module.exports = class ExtensibilityTemplate extends TemplateBase {
|
|
|
13
18
|
const { for: forProfile, isJava } = projectDescriptor.cap
|
|
14
19
|
const cdsConfigPath = path.join(this.projectPath, isJava ? '.cdsrc.json' : 'package.json')
|
|
15
20
|
const cdsTemplateFile = forProfile ? (isJava ? 'cdsrc.json.hbs' : 'cds.package.json.hbs') : (isJava ? 'cdsrc.json' : 'cds.package.json')
|
|
16
|
-
await
|
|
21
|
+
await mergeJSON(cdsConfigPath, path.join(__dirname, 'files', cdsTemplateFile), projectDescriptor)
|
|
17
22
|
await this.runDependentMerging()
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
async runDependentMerging() {
|
|
21
26
|
const projectDescriptor = await this.projectReader.read()
|
|
22
|
-
const { hasXsuaa,
|
|
27
|
+
const { hasXsuaa, hasHelm } = projectDescriptor.cap
|
|
23
28
|
if (hasXsuaa) {
|
|
24
|
-
await
|
|
29
|
+
await mergeJSON(
|
|
25
30
|
path.join(this.projectPath, 'xs-security.json'),
|
|
26
31
|
path.join(__dirname, 'files', 'xs-security.json.hbs'),
|
|
27
32
|
projectDescriptor,
|
|
@@ -42,9 +47,9 @@ module.exports = class ExtensibilityTemplate extends TemplateBase {
|
|
|
42
47
|
}
|
|
43
48
|
)
|
|
44
49
|
}
|
|
45
|
-
if (hasXsuaa &&
|
|
50
|
+
if (hasXsuaa && hasHelm) {
|
|
46
51
|
// REVISIT: Shared xs-security.json location for Helm and MTA?
|
|
47
|
-
await
|
|
52
|
+
await copy(
|
|
48
53
|
path.join(this.projectPath, 'xs-security.json'),
|
|
49
54
|
path.join(this.projectPath, 'chart', 'xs-security.json')
|
|
50
55
|
)
|