@sap/cds-dk 6.8.3 → 7.0.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/bin/activate.js +15 -7
- package/bin/add.js +29 -15
- package/bin/bind.js +49 -116
- package/bin/build.js +114 -0
- package/bin/cds.js +67 -24
- package/bin/compile/index.js +2 -2
- package/bin/deploy/index.js +46 -39
- package/bin/deploy/to-hana.js +11 -8
- package/bin/deploy/to-postgres.js +8 -2
- package/bin/deploy/to-sqlite.js +0 -1
- package/bin/env.js +75 -41
- package/bin/eval.js +3 -3
- package/bin/extend.js +17 -10
- package/bin/help.js +22 -21
- package/bin/import.js +10 -7
- package/bin/init.js +38 -17
- package/bin/login.js +69 -55
- package/bin/logout.js +12 -9
- package/bin/migrate.js +10 -4
- package/bin/pull.js +12 -5
- package/bin/push.js +24 -13
- package/bin/repl.js +1 -0
- package/bin/run.js +25 -0
- package/bin/subscribe.js +13 -8
- package/bin/unsubscribe.js +15 -8
- package/bin/upgrade.js +15 -9
- package/bin/util/log.js +24 -0
- package/bin/version.js +124 -0
- package/bin/watch.js +1 -35
- package/bin/watched.js +39 -0
- package/lib/bind/KubernetesApiAccessor.js +2 -2
- package/lib/bind/bindingManager.js +1 -1
- package/lib/bind/bindingUtil.js +0 -9
- package/lib/bind/cfKeyProvider.js +10 -72
- package/lib/bind/index.js +114 -0
- package/lib/bind/kubernetesCredentialsProvider.js +2 -2
- package/lib/bind/userCdsrcJsonStorageProvider.js +7 -44
- package/lib/build/buildTaskEngine.js +355 -0
- package/lib/build/buildTaskFactory.js +284 -0
- package/lib/build/buildTaskHandler.js +240 -0
- package/lib/build/buildTaskProvider.js +22 -0
- package/lib/build/buildTaskProviderFactory.js +182 -0
- package/lib/build/constants.js +56 -0
- package/lib/build/index.js +21 -0
- package/lib/build/provider/buildTaskHandlerEdmx.js +83 -0
- package/lib/build/provider/buildTaskHandlerFeatureToggles.js +132 -0
- package/lib/build/provider/buildTaskHandlerInternal.js +228 -0
- package/lib/build/provider/buildTaskProviderInternal.js +370 -0
- package/lib/build/provider/fiori/index.js +167 -0
- package/lib/build/provider/hana/2migration.js +179 -0
- package/lib/build/provider/hana/index.js +522 -0
- package/lib/build/provider/hana/migrationtable.js +472 -0
- package/lib/build/provider/hana/template/.hdiconfig-all +163 -0
- package/lib/build/provider/hana/template/.hdiconfig-cloud +137 -0
- package/lib/build/provider/hana/template/.hdinamespace +4 -0
- package/lib/build/provider/hana/template/package.json +12 -0
- package/lib/build/provider/hana/template/undeploy.json +5 -0
- package/lib/build/provider/java/index.js +93 -0
- package/lib/build/provider/java-cf/index.js +1 -0
- package/lib/build/provider/mtx/index.js +37 -0
- package/lib/build/provider/mtx/resourcesTarBuilder.js +94 -0
- package/lib/build/provider/mtx-extension/index.js +131 -0
- package/lib/build/provider/mtx-sidecar/index.js +138 -0
- package/lib/build/provider/node-cf/index.js +1 -0
- package/lib/build/provider/nodejs/index.js +178 -0
- package/lib/build/util.js +263 -0
- package/lib/cds.js +9 -21
- package/lib/client/auth_manager.js +39 -16
- package/lib/client/helper/dependency_helper.js +7 -6
- package/lib/client/push.js +2 -1
- package/lib/client/settings_manager.js +10 -39
- package/lib/deploy/to-hana/hana.js +273 -0
- package/lib/deploy/to-hana/hdiDeployUtil.js +68 -0
- package/lib/deploy/to-hana/mtaUtil.js +171 -0
- package/lib/import/asyncapi/importAsyncAPI.js +3 -2
- package/lib/import/asyncapi/index.js +5 -2
- package/lib/import/asyncapi/parserContext.js +67 -26
- package/lib/import/asyncapi/utils.js +34 -3
- package/lib/import/common.js +40 -30
- package/lib/import/importapi.js +36 -35
- package/lib/index.js +12 -17
- package/lib/init/constants.js +36 -71
- package/lib/init/index.js +18 -52
- package/lib/init/template/_merging/registry-mta.js +21 -3
- package/lib/init/template/approuter/files/mta.yaml.hbs +29 -29
- package/lib/init/template/approuter/files/values.yaml.hbs +5 -5
- package/lib/init/template/approuter/files/xs-app.json.hbs +8 -2
- package/lib/init/template/approuter/index.js +7 -8
- package/lib/init/template/auditlog/files/mta.yaml.hbs +5 -5
- package/lib/init/template/auditlog/files/package.json.hbs +13 -13
- package/lib/init/template/auditlog/index.js +3 -3
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +22 -22
- package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +3 -3
- package/lib/init/template/connectivity/files/mta.yaml.hbs +14 -0
- package/lib/init/template/connectivity/files/package.json.hbs +17 -0
- package/lib/init/template/connectivity/index.js +21 -4
- package/lib/init/template/data/index.js +5 -1
- package/lib/init/template/destination/files/mta.yaml.hbs +14 -0
- package/lib/init/template/destination/files/package.json.hbs +17 -0
- package/lib/init/template/{destinations → destination}/index.js +19 -13
- package/lib/init/template/enterprise-messaging/files/event-mesh.json.hbs +3 -3
- package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +5 -5
- package/lib/init/template/enterprise-messaging/files/package.json.hbs +9 -9
- package/lib/init/template/enterprise-messaging/files/xs-security.json.hbs +19 -0
- package/lib/init/template/enterprise-messaging/index.js +27 -6
- package/lib/init/template/enterprise-messaging-shared/files/event-mesh.json.hbs +3 -3
- package/lib/init/template/enterprise-messaging-shared/files/mta.yaml.hbs +5 -5
- package/lib/init/template/enterprise-messaging-shared/files/package.json.hbs +9 -9
- package/lib/init/template/enterprise-messaging-shared/index.js +4 -5
- package/lib/init/template/extensibility/files/package.json.hbs +10 -10
- package/lib/init/template/extensibility/index.js +8 -9
- package/lib/init/template/file-based-messaging/files/package.json.hbs +9 -9
- package/lib/init/template/file-based-messaging/index.js +3 -4
- package/lib/init/template/hana/files/db/package.json +1 -1
- package/lib/init/template/hana/files/mta.yaml.hbs +21 -21
- package/lib/init/template/hana/files/package.json.hbs +16 -22
- package/lib/init/template/hana/files/values.yaml.hbs +1 -1
- package/lib/init/template/hana/index.js +5 -15
- package/lib/init/template/helm/files/Chart.yaml.hbs +4 -4
- package/lib/init/template/helm/files/values.yaml.hbs +6 -6
- package/lib/init/template/helm/index.js +5 -10
- package/lib/init/template/helm/subcharts/content-deployment/Chart.yaml +2 -0
- package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +37 -31
- package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +13 -14
- package/lib/init/template/helm/subcharts/content-deployment/templates/secret.yaml +2 -2
- package/lib/init/template/helm/subcharts/content-deployment/templates/service-account.yaml +1 -1
- package/lib/init/template/helm/subcharts/content-deployment/templates/service-binding.yaml +3 -3
- package/lib/init/template/helm/subcharts/content-deployment/values.md +116 -116
- package/lib/init/template/helm/subcharts/service-instance/Chart.yaml +2 -0
- package/lib/init/template/helm/subcharts/service-instance/templates/_helpers.tpl +9 -9
- package/lib/init/template/helm/subcharts/service-instance/templates/serviceinstance.yaml +2 -2
- package/lib/init/template/helm/subcharts/service-instance/values.md +15 -15
- package/lib/init/template/helm/subcharts/web-application/Chart.yaml +2 -0
- package/lib/init/template/helm/subcharts/web-application/templates/NOTES.txt +15 -0
- package/lib/init/template/helm/subcharts/web-application/templates/_helpers.tpl +23 -23
- package/lib/init/template/helm/subcharts/web-application/templates/api-rule.yaml +4 -4
- package/lib/init/template/helm/subcharts/web-application/templates/deployment.yaml +17 -17
- package/lib/init/template/helm/subcharts/web-application/templates/network-policy.yaml +24 -3
- package/lib/init/template/helm/subcharts/web-application/templates/pod-disruption-budget.yaml +3 -3
- package/lib/init/template/helm/subcharts/web-application/templates/secret.yaml +2 -2
- package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +1 -1
- package/lib/init/template/helm/subcharts/web-application/templates/service-binding.yaml +3 -3
- package/lib/init/template/helm/subcharts/web-application/templates/service.yaml +3 -3
- package/lib/init/template/helm/subcharts/web-application/values.md +141 -123
- package/lib/init/template/helm/subcharts/web-application/values.schema.json +7 -0
- package/lib/init/template/helm/subcharts/web-application/values.yaml +1 -0
- package/lib/init/template/html5-repo/index.js +4 -5
- package/lib/init/template/java/index.js +5 -5
- package/lib/init/template/kibana-logging/files/mta.yaml.hbs +5 -5
- package/lib/init/template/kibana-logging/files/package.json.hbs +9 -9
- package/lib/init/template/kibana-logging/index.js +3 -4
- package/lib/init/template/lint/index.js +3 -3
- package/lib/init/template/mta/files/mta.yaml.hbs +14 -14
- package/lib/init/template/mta/files/package.json +5 -0
- package/lib/init/template/mta/index.js +12 -13
- package/lib/init/template/mtx/index.js +2 -2
- package/lib/init/template/multitenancy/files/mta.yaml.hbs +29 -27
- package/lib/init/template/multitenancy/files/package.json.hbs +17 -14
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +7 -7
- package/lib/init/template/multitenancy/files/values.yaml.hbs +19 -19
- package/lib/init/template/multitenancy/index.js +14 -16
- package/lib/init/template/nodejs/files/package.json.hbs +1 -1
- package/lib/init/template/nodejs/index.js +5 -8
- package/lib/init/template/redis-messaging/files/mta.yaml.hbs +5 -5
- package/lib/init/template/redis-messaging/files/package.json.hbs +9 -9
- package/lib/init/template/redis-messaging/index.js +4 -5
- package/lib/init/template/sample/files/app/_i18n/i18n.properties +43 -0
- package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +14 -0
- package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +114 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +8 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +11 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +129 -0
- package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +57 -0
- package/lib/init/template/sample/files/app/common.cds +263 -0
- package/lib/init/template/sample/files/app/index.html +30 -0
- package/lib/init/template/sample/files/app/services.cds +5 -0
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +5 -0
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books.csv +6 -0
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books_texts.csv +5 -0
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Genres.csv +16 -0
- package/lib/init/template/sample/files/db/schema.cds +31 -0
- package/lib/init/template/sample/files/nodejs/admin-service.js +12 -0
- package/lib/init/template/sample/files/nodejs/cat-service.js +26 -0
- package/lib/init/template/sample/files/srv/admin-service.cds +5 -0
- package/lib/init/template/sample/files/srv/cat-service.cds +16 -0
- package/lib/init/template/sample/index.js +24 -0
- package/lib/init/template/sample-tiny/index.js +39 -0
- package/lib/init/template/samples/index.js +5 -56
- package/lib/init/template/sqlite/files/package.json.hbs +13 -13
- package/lib/init/template/sqlite/index.js +2 -2
- package/lib/init/template/templateBase.js +24 -1
- package/lib/init/template/toggles/files/package.json.hbs +10 -10
- package/lib/init/template/toggles/index.js +3 -3
- package/lib/init/template/typer/files/gitignore +1 -0
- package/lib/init/template/typer/files/package.json +8 -0
- package/lib/init/template/typer/files/xsconfig.json +9 -0
- package/lib/init/template/typer/index.js +36 -0
- package/lib/init/template/xsuaa/files/mta.yaml.hbs +12 -12
- package/lib/init/template/xsuaa/files/package.json.hbs +13 -13
- package/lib/init/template/xsuaa/files/values.yaml.hbs +8 -8
- package/lib/init/template/xsuaa/index.js +8 -19
- package/lib/init/util/merge.js +73 -59
- package/lib/init/util/mvn.js +21 -17
- package/lib/init/util/projectReader.js +49 -87
- package/lib/init/util/xml.js +14 -23
- package/lib/util/cfUtil.js +366 -0
- package/lib/util/command.js +3 -3
- package/lib/util/gitUtil.js +55 -0
- package/lib/util/version.js +27 -0
- package/npm-shrinkwrap.json +337 -275
- package/package.json +6 -6
- package/CHANGELOG.md +0 -1460
- package/bin/build/all.js +0 -88
- package/bin/build/index.js +0 -82
- package/lib/compile/index.js +0 -14
- /package/lib/init/template/{samples → sample-tiny}/files/nodejs/db/data/my.bookshop-Books.csv +0 -0
- /package/lib/init/template/{samples → sample-tiny}/files/nodejs/db/data-model.cds +0 -0
- /package/lib/init/template/{samples → sample-tiny}/files/nodejs/srv/cat-service.cds.hbs +0 -0
package/lib/init/util/mvn.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
const { MAVEN_ARCHETYPE_VERSION,
|
|
3
|
-
OPTION_JAVA_PACKAGE, OPTION_SAMPLES, REGEX_JAVA_PACKAGE, OPTION_HANA } = require('../constants');
|
|
2
|
+
const { MAVEN_ARCHETYPE_VERSION, OPTIONS: { JAVA_MVN, JAVA_PACKAGE, SAMPLES, HANA }, REGEX_JAVA_PACKAGE } = require('../constants');
|
|
4
3
|
|
|
5
4
|
const { CliError } = require('../../client/helper/errors');
|
|
6
5
|
|
|
@@ -16,6 +15,7 @@ const LOG = console
|
|
|
16
15
|
const cds = require('../../cds')
|
|
17
16
|
const DEBUG = cds.debug('cli')
|
|
18
17
|
|
|
18
|
+
|
|
19
19
|
class MvnArchetypeUtil {
|
|
20
20
|
|
|
21
21
|
_scanMvnParams(mvnParams, params) {
|
|
@@ -56,8 +56,8 @@ class MvnArchetypeUtil {
|
|
|
56
56
|
|
|
57
57
|
params.set(`com.sap.cds:cds-maven-plugin:${MAVEN_ARCHETYPE_VERSION}:addSample`);
|
|
58
58
|
|
|
59
|
-
if (options[
|
|
60
|
-
this._scanMvnParams(options[
|
|
59
|
+
if (options[JAVA_MVN]) {
|
|
60
|
+
this._scanMvnParams(options[JAVA_MVN], params);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (options.force) {
|
|
@@ -72,8 +72,8 @@ class MvnArchetypeUtil {
|
|
|
72
72
|
|
|
73
73
|
params.set(`com.sap.cds:cds-maven-plugin:${MAVEN_ARCHETYPE_VERSION}:addIntegrationTest`);
|
|
74
74
|
|
|
75
|
-
if (options[
|
|
76
|
-
this._scanMvnParams(options[
|
|
75
|
+
if (options[JAVA_MVN]) {
|
|
76
|
+
this._scanMvnParams(options[JAVA_MVN], params);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (options.force) {
|
|
@@ -89,8 +89,8 @@ class MvnArchetypeUtil {
|
|
|
89
89
|
params.set(`com.sap.cds:cds-maven-plugin:${MAVEN_ARCHETYPE_VERSION}:addTargetPlatform`);
|
|
90
90
|
params.set(`-DtargetPlatform`, `cloudfoundry`);
|
|
91
91
|
|
|
92
|
-
if (options[
|
|
93
|
-
this._scanMvnParams(options[
|
|
92
|
+
if (options[JAVA_MVN]) {
|
|
93
|
+
this._scanMvnParams(options[JAVA_MVN], params);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
return this._finalize(params);
|
|
@@ -114,17 +114,17 @@ class MvnArchetypeUtil {
|
|
|
114
114
|
params.set(`-DartifactId`, projectName);
|
|
115
115
|
params.set(`-DgroupId`, DEFAULT_GROUP_ID);
|
|
116
116
|
|
|
117
|
-
const hasHana = !!(options.add && options.add.has(
|
|
117
|
+
const hasHana = !!(options.add && options.add.has(HANA));
|
|
118
118
|
if (hasHana) {
|
|
119
119
|
params.set(`-DtargetPlatform`, `cloudfoundry`);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
const hasSamples = !!(options.add && options.add.has(
|
|
122
|
+
const hasSamples = !!(options.add && options.add.has(SAMPLES));
|
|
123
123
|
params.set(`-DincludeModel`, hasSamples);
|
|
124
124
|
params.set(`-DincludeIntegrationTest`, hasSamples);
|
|
125
125
|
|
|
126
|
-
if (options[
|
|
127
|
-
this._scanMvnParams(options[
|
|
126
|
+
if (options[JAVA_MVN]) {
|
|
127
|
+
this._scanMvnParams(options[JAVA_MVN], params);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// -DjdkVersion=[11|17]
|
|
@@ -136,9 +136,13 @@ class MvnArchetypeUtil {
|
|
|
136
136
|
const segments = match[1]?.split('.');
|
|
137
137
|
const version = new Number(segments?.[0]);
|
|
138
138
|
switch (true) {
|
|
139
|
-
case (version <
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
case (version < 17):
|
|
140
|
+
if (process.env.WS_BASE_URL) {
|
|
141
|
+
throw new CliError(`Java version ${match[1]} is not supported. Use Java 17 or higher. You can use command 'Java: Set Default JDK' to switch to Java 17.`)
|
|
142
|
+
}
|
|
143
|
+
throw new CliError(`Java version ${match[1]} is not supported. Use Java 17 or higher.`)
|
|
144
|
+
case (version < 20): params.set(`-DjdkVersion`, 17); break;
|
|
145
|
+
case (version >= 20): params.set(`-DjdkVersion`, 20); break;
|
|
142
146
|
default:
|
|
143
147
|
}
|
|
144
148
|
}
|
|
@@ -150,8 +154,8 @@ class MvnArchetypeUtil {
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
|
|
153
|
-
if (options[
|
|
154
|
-
params.set(`-Dpackage`, options[
|
|
157
|
+
if (options[JAVA_PACKAGE]) {
|
|
158
|
+
params.set(`-Dpackage`, options[JAVA_PACKAGE]);
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
const artifactId = params.get('-DartifactId');
|
|
@@ -5,7 +5,6 @@ const P_LANGUAGE_JAVA = 'java'
|
|
|
5
5
|
const P_LANGUAGE_NODEJS = 'nodejs'
|
|
6
6
|
const DEFAULT_P_LANGUAGE = P_LANGUAGE_NODEJS
|
|
7
7
|
const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) && console.debug
|
|
8
|
-
const LOG = console
|
|
9
8
|
|
|
10
9
|
module.exports = new class ProjectReader {
|
|
11
10
|
|
|
@@ -34,18 +33,9 @@ module.exports = new class ProjectReader {
|
|
|
34
33
|
const env = this.getEnv()
|
|
35
34
|
DEBUG && DEBUG({ env })
|
|
36
35
|
|
|
37
|
-
const cap = await this._getCapDescriptor(env, options)
|
|
38
|
-
const ui = this._getUiDescriptor(env)
|
|
39
|
-
const projectDescriptor = { cap, ui }
|
|
40
|
-
|
|
41
|
-
DEBUG && DEBUG({ projectDescriptor })
|
|
42
|
-
return projectDescriptor
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async _getCapDescriptor(env, options) {
|
|
46
36
|
const _hasFacet = template => require(`../template/${template}`).hasFacet(env, options)
|
|
47
|
-
const
|
|
48
|
-
|
|
37
|
+
const project = {
|
|
38
|
+
profile: options?.for,
|
|
49
39
|
language: DEFAULT_P_LANGUAGE,
|
|
50
40
|
srv: {},
|
|
51
41
|
db: [],
|
|
@@ -62,10 +52,11 @@ module.exports = new class ProjectReader {
|
|
|
62
52
|
get hasXsuaa() { return _hasFacet('xsuaa') },
|
|
63
53
|
get hasAuditlog() { return _hasFacet('auditlog') },
|
|
64
54
|
get hasApprouter() { return _hasFacet('approuter') },
|
|
65
|
-
get hasDestination() { return _hasFacet('
|
|
55
|
+
get hasDestination() { return _hasFacet('destination') },
|
|
66
56
|
get hasHtml5Repo() { return _hasFacet('html5-repo') },
|
|
67
57
|
get hasMta() { return _hasFacet('mta') },
|
|
68
58
|
get hasHelm() { return _hasFacet('helm') },
|
|
59
|
+
get appPath() { return env.folders.app },
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
// setting the effective env as it might have changed by already executed 'add' commands, e.g. cds init foo --add hana,mta
|
|
@@ -74,29 +65,30 @@ module.exports = new class ProjectReader {
|
|
|
74
65
|
cds.env = env
|
|
75
66
|
|
|
76
67
|
// check whether we have a hana service binding defined as a hana build task is returned by default for compatibility reasons if neither hana, nor sqlite has been defined
|
|
77
|
-
if (
|
|
68
|
+
if (env?.requires?.db?.kind === 'hana') {
|
|
78
69
|
const dbFolder = env.folders.db.replace(/\/$/, '')
|
|
79
70
|
const relDbDestPath = path.join(env.build.target, dbFolder).replace(/\\/g, '/')
|
|
80
|
-
|
|
71
|
+
project.db.push({ path: relDbDestPath, name: dbFolder })
|
|
81
72
|
}
|
|
82
73
|
|
|
83
74
|
const srvFolder = env.folders.srv.replace(/\/$/, '')
|
|
84
75
|
const relSrvDestPath = path.join(env.build.target, srvFolder).replace(/\\/g, '/')
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
project.srvPath = relSrvDestPath
|
|
77
|
+
project.srvName = srvFolder
|
|
87
78
|
|
|
88
79
|
if (env['project-nature'] === 'java') {
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
project.language = P_LANGUAGE_JAVA
|
|
81
|
+
project.srvExt = await this._getJavaExtDescriptor(path.resolve(cds.root, srvFolder))
|
|
91
82
|
}
|
|
92
83
|
|
|
93
84
|
// setting app name, app description...
|
|
94
|
-
await this._setAppDetails(
|
|
85
|
+
await this._setAppDetails(project)
|
|
95
86
|
|
|
96
87
|
// setting required resource information
|
|
97
|
-
this._setResourceDependencies(env,
|
|
88
|
+
this._setResourceDependencies(env, project)
|
|
98
89
|
|
|
99
|
-
|
|
90
|
+
DEBUG && DEBUG({ project })
|
|
91
|
+
return project
|
|
100
92
|
}
|
|
101
93
|
|
|
102
94
|
/**
|
|
@@ -105,85 +97,60 @@ module.exports = new class ProjectReader {
|
|
|
105
97
|
*/
|
|
106
98
|
async _getJavaExtDescriptor(srcPath) {
|
|
107
99
|
// by default spring-boot:repackage is used creating an executable jar archive
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
const dependencies =
|
|
100
|
+
const pom = await parseXml(path.join(srcPath, 'pom.xml'))
|
|
101
|
+
if (pom) {
|
|
102
|
+
const dependencies = pom?.dependencies?.[0]?.dependency
|
|
111
103
|
const isOldJavaRuntime = [...dependencies].some(d => /com\.sap\.cloud\.servicesdk/.test(d?.groupId?.[0]))
|
|
112
104
|
if (isOldJavaRuntime) {
|
|
113
105
|
throw new Error("Projects using the classic CAP Java SDK are not supported")
|
|
114
106
|
}
|
|
115
107
|
|
|
116
108
|
const descriptor = { archiveName: path.basename(cds.root) + "-exec.jar" }
|
|
117
|
-
const archiveName =
|
|
118
|
-
const suffix =
|
|
109
|
+
const archiveName = pom?.artifactId?.[0]
|
|
110
|
+
const suffix = pom?.packaging?.[0]
|
|
119
111
|
if (archiveName) descriptor.archiveName = archiveName + '-exec.' + suffix
|
|
120
112
|
return descriptor
|
|
121
113
|
}
|
|
122
114
|
}
|
|
123
115
|
|
|
124
|
-
_getUiDescriptor(env) {
|
|
125
|
-
const absoluteAppPath = path.join(cds.root, env.folders.app)
|
|
126
|
-
return {
|
|
127
|
-
appPath: exists(absoluteAppPath) ? env.folders.app : null
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
116
|
async _setAppDetails(cap) {
|
|
132
117
|
if (cap.language !== P_LANGUAGE_JAVA && cap.language !== P_LANGUAGE_NODEJS) {
|
|
133
118
|
throw Error(`${cap.language} not supported`)
|
|
134
119
|
}
|
|
135
120
|
|
|
136
|
-
//
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// if not compliant we use a static default value, see below...
|
|
152
|
-
if (/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/.test(version)) {
|
|
153
|
-
cap.appVersion = version
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (artifactId) {
|
|
157
|
-
cap.appName = artifactId.split(/-parent/)[0]
|
|
158
|
-
}
|
|
159
|
-
if (description) {
|
|
160
|
-
cap.appDescription = description
|
|
161
|
-
}
|
|
121
|
+
// Use either pom.xml or package.json
|
|
122
|
+
if (exists('pom.xml')) {
|
|
123
|
+
const pom = await parseXml('pom.xml')
|
|
124
|
+
const [artifactId] = pom?.artifactId ?? []
|
|
125
|
+
const [description] = pom?.description ?? []
|
|
126
|
+
let [version] = pom?.version ?? []
|
|
127
|
+
// might need to resolve <version>${revision}</version> property
|
|
128
|
+
if (version === '${revision}') {
|
|
129
|
+
version = pom?.properties?.[0].revision[0]
|
|
130
|
+
}
|
|
131
|
+
if (version) {
|
|
132
|
+
// check compliance with mta version format - copied from mbt build error message
|
|
133
|
+
// if not compliant we use a static default value, see below...
|
|
134
|
+
if (/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/.test(version)) {
|
|
135
|
+
cap.appVersion = version
|
|
162
136
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
137
|
+
}
|
|
138
|
+
if (artifactId) {
|
|
139
|
+
cap.appName = artifactId.split(/-parent/)[0]
|
|
140
|
+
}
|
|
141
|
+
if (description) {
|
|
142
|
+
cap.appDescription = description
|
|
166
143
|
}
|
|
167
144
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (name) {
|
|
178
|
-
const segments = name.trim().replace(/@/g, '').split('/').map(encodeURIComponent)
|
|
179
|
-
cap.appName = cap.appName ?? segments[segments.length - 1]
|
|
180
|
-
cap.appId = cap.appId ?? segments.join('.')
|
|
181
|
-
cap.appDescription = cap.appDescription ?? cap.appName
|
|
182
|
-
}
|
|
183
|
-
} catch (e) {
|
|
184
|
-
LOG.error(`Failed to read file ${packageJsonPath} - skip application data`)
|
|
185
|
-
LOG.error(e)
|
|
186
|
-
}
|
|
145
|
+
else if (exists('package.json')) {
|
|
146
|
+
const { name, version, description } = await read('package.json')
|
|
147
|
+
cap.appDescription = cap.appDescription ?? description
|
|
148
|
+
cap.appVersion = cap.appVersion ?? version
|
|
149
|
+
if (name) {
|
|
150
|
+
const segments = name.trim().replace(/@/g, '').split('/').map(encodeURIComponent)
|
|
151
|
+
cap.appName = cap.appName ?? segments[segments.length - 1]
|
|
152
|
+
cap.appId = cap.appId ?? segments.join('.')
|
|
153
|
+
cap.appDescription = cap.appDescription ?? cap.appName
|
|
187
154
|
}
|
|
188
155
|
}
|
|
189
156
|
|
|
@@ -194,11 +161,6 @@ module.exports = new class ProjectReader {
|
|
|
194
161
|
cap.appVersion = cap.appVersion ?? '1.0.0'
|
|
195
162
|
}
|
|
196
163
|
|
|
197
|
-
_hasHanaServiceBinding(env) {
|
|
198
|
-
const db = env?.requires?.db
|
|
199
|
-
return db?.kind === 'hana' || db?.kind === 'sql' && (db?.dialect === 'hana' || db?.use === 'hana')
|
|
200
|
-
}
|
|
201
|
-
|
|
202
164
|
// REVISIT: Only used for orphaned cds add cf-manifest. Still needed?
|
|
203
165
|
_setResourceDependencies(env, cap) {
|
|
204
166
|
for (const [key, require] of Object.entries(env.requires)) {
|
package/lib/init/util/xml.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const cds = require('../../cds')
|
|
2
2
|
const { read } = cds.utils
|
|
3
|
-
const LOG = console
|
|
4
3
|
|
|
5
4
|
/*
|
|
6
5
|
Remove the _text attributes and convert value it into array
|
|
@@ -29,28 +28,20 @@ function _removeTextAttributes(value, parentElement) {
|
|
|
29
28
|
|
|
30
29
|
async function parseXml(pomXmlPath) {
|
|
31
30
|
const xmljs = require('xml-js')
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
textFn: _removeTextAttributes
|
|
47
|
-
})).project[0]
|
|
48
|
-
return xmljsParse
|
|
49
|
-
} catch (e) {
|
|
50
|
-
// REVISIT: We shouldn't continue with errors
|
|
51
|
-
LOG.error(`Failed to read file ${pomXmlPath} - skip pom.xml data`)
|
|
52
|
-
LOG.error(e)
|
|
53
|
-
}
|
|
31
|
+
const xml = await read(pomXmlPath, 'utf-8')
|
|
32
|
+
return JSON.parse(xmljs.xml2json(xml, {
|
|
33
|
+
ignoreComment: true,
|
|
34
|
+
compact: true,
|
|
35
|
+
alwaysArray: true,
|
|
36
|
+
ignoreDeclaration: true,
|
|
37
|
+
attributesKey: "$",
|
|
38
|
+
trim: true,
|
|
39
|
+
nativeType: true,
|
|
40
|
+
ignoreInstruction: true,
|
|
41
|
+
ignoreCdata: true,
|
|
42
|
+
ignoreDoctype: true,
|
|
43
|
+
textFn: _removeTextAttributes
|
|
44
|
+
}))?.project?.[0]
|
|
54
45
|
}
|
|
55
46
|
|
|
56
47
|
module.exports = { parseXml }
|