@sap/cds-dk 7.9.6 → 8.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/CHANGELOG.md +2136 -0
- package/bin/add.js +18 -52
- package/bin/bind.js +2 -2
- package/bin/build.js +29 -4
- package/bin/cds.js +31 -14
- package/bin/compile/index.js +7 -6
- package/bin/completion/index.js +70 -46
- package/bin/completion/scripts/cds-bash.sh +4 -1
- package/bin/completion/scripts/cds-fish.fish +13 -0
- package/bin/completion/scripts/cds-ps.ps1 +2 -1
- package/bin/completion/scripts/cds-zsh.sh +2 -1
- package/bin/deploy/index.js +6 -5
- package/bin/deploy/to-sqlite.js +2 -2
- package/bin/extend.js +19 -50
- package/bin/help.js +2 -2
- package/bin/init.js +10 -77
- package/bin/login.js +13 -5
- package/bin/migrate.js +1 -1
- package/bin/pull.js +11 -0
- package/bin/repl.js +3 -0
- package/bin/test.js +5 -0
- package/bin/version.js +7 -7
- package/bin/watch.js +13 -14
- package/lib/bind/KubernetesApiAccessor.js +10 -9
- package/lib/build/buildTaskEngine.js +11 -7
- package/lib/build/buildTaskFactory.js +15 -43
- package/lib/build/buildTaskProviderFactory.js +16 -44
- package/lib/build/constants.js +4 -3
- package/lib/build/index.js +2 -2
- package/lib/build/{buildPlugin.js → plugin.js} +65 -46
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/Chart.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/Chart.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/_helpers.tpl +7 -0
- package/lib/build/plugins/helm/files/subcharts/service-instance/templates/servicebinding.yaml +32 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/serviceinstance.yaml +3 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.schema.json +63 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.yaml +23 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/Chart.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/deployment.yaml +2 -0
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/hpa.yaml +22 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/pod-disruption-budget.yaml +1 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.schema.json +49 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.yaml +8 -2
- package/lib/{init/template/helm/files/chart → build/plugins/helm/files}/templates/_deployment_helpers.tpl +5 -0
- package/lib/build/plugins/helm/files/templates/_helpers.tpl +13 -0
- package/lib/build/plugins/helm/index.js +81 -0
- package/lib/build/plugins.js +12 -15
- package/lib/build/provider/featureToggleBuildPlugin.js +7 -39
- package/lib/build/provider/hana/2migration.js +168 -124
- package/lib/build/provider/hana/index.js +69 -56
- package/lib/build/provider/hana/template/package.json +4 -3
- package/lib/build/provider/internalBuildPlugin.js +32 -97
- package/lib/build/provider/internalBuildTaskProvider.js +12 -48
- package/lib/build/provider/java/index.js +2 -3
- package/lib/build/provider/mtx/index.js +5 -4
- package/lib/build/provider/mtx-extension/index.js +5 -2
- package/lib/build/provider/mtx-sidecar/index.js +2 -2
- package/lib/build/provider/nodejs/index.js +4 -3
- package/lib/build/util.js +83 -12
- package/lib/compile/to-mermaid.js +108 -0
- package/lib/compile/to_asyncapi.js +7 -0
- package/lib/compile/to_openapi.js +7 -0
- package/lib/deploy/to-hana/hana.js +37 -34
- package/lib/deploy/to-hana/hdiDeployUtil.js +8 -6
- package/lib/env/schemas/cds-rc.js +1 -1
- package/lib/import/common.js +2 -2
- package/lib/import/odata/metadataconverter/MetadataConverter.js +4 -4
- package/lib/import/odata/v2parser.js +83 -197
- package/lib/import/odata/v4parser.js +1 -38
- package/lib/import/openapi/importOpenAPI.js +164 -42
- package/lib/index.js +10 -12
- package/lib/init/bas.js +91 -0
- package/lib/init/constants.js +21 -11
- package/lib/init/index.js +72 -150
- package/lib/init/merge.js +12 -20
- package/lib/init/mvn.js +103 -150
- package/lib/init/plugin.js +11 -7
- package/lib/init/projectReader.js +53 -20
- package/lib/init/registries/mta.js +51 -6
- package/lib/init/template/application-logging/files/package.json.hbs +7 -0
- package/lib/init/template/application-logging/index.js +13 -1
- package/lib/init/template/approuter/files/containerize.yaml.hbs +10 -0
- package/lib/init/template/approuter/files/mta.yaml.hbs +1 -2
- package/lib/init/template/approuter/files/values.yaml.hbs +19 -4
- package/lib/init/template/approuter/files/xs-app.json.hbs +12 -3
- package/lib/init/template/approuter/index.js +29 -25
- package/lib/init/template/attachments/files/mta.yaml.hbs +14 -0
- package/lib/init/template/attachments/files/package.json.hbs +5 -0
- package/lib/init/template/attachments/files/values.yaml +7 -0
- package/lib/init/template/attachments/index.js +53 -0
- package/lib/init/template/{redis-messaging → audit-logging}/files/mta.yaml.hbs +4 -4
- package/lib/init/template/audit-logging/files/package.json.hbs +7 -0
- package/lib/init/template/audit-logging/index.js +66 -0
- package/lib/init/template/cf-manifest/index.js +4 -0
- package/lib/init/template/completion/completionSetup.js +54 -33
- package/lib/init/template/completion/index.js +7 -1
- package/lib/init/template/connectivity/index.js +4 -4
- package/lib/init/template/containerize/files/containerize.yaml.hbs +26 -0
- package/lib/init/template/containerize/index.js +24 -0
- package/lib/init/template/data/index.js +4 -0
- package/lib/init/template/destination/files/mta.yaml.hbs +31 -1
- package/lib/init/template/destination/files/package.sidecar.json +7 -0
- package/lib/init/template/destination/index.js +22 -2
- package/lib/init/template/enterprise-messaging/index.js +6 -3
- package/lib/init/template/enterprise-messaging-shared/index.js +5 -1
- package/lib/init/template/extensibility/files/package.json.hbs +1 -1
- package/lib/init/template/extensibility/files/xs-security.json.hbs +2 -8
- package/lib/init/template/extensibility/index.js +3 -1
- package/lib/init/template/file-based-messaging/index.js +4 -0
- package/lib/init/template/h2/index.js +4 -0
- package/lib/init/template/hana/files/containerize.yaml.hbs +10 -0
- package/lib/init/template/hana/files/db/package.json +3 -2
- package/lib/init/template/hana/files/package.json.hbs +4 -7
- package/lib/init/template/hana/files/values.yaml.hbs +1 -2
- package/lib/init/template/hana/index.js +15 -7
- package/lib/init/template/helm/files/Chart.yaml.hbs +2 -3
- package/lib/init/template/helm/files/values.schema.json +2173 -0
- package/lib/init/template/helm/files/values.yaml.hbs +11 -6
- package/lib/init/template/helm/index.js +77 -18
- package/lib/init/template/helm-unified-runtime/index.js +19 -56
- package/lib/init/template/html5-repo/files/app-package.json.hbs +11 -7
- package/lib/init/template/html5-repo/files/manifest.json +13 -0
- package/lib/init/template/html5-repo/files/mta.yaml.hbs +14 -33
- package/lib/init/template/html5-repo/files/package.sidecar.json +7 -0
- package/lib/init/template/html5-repo/files/ui5-deploy.yaml.hbs +21 -0
- package/lib/init/template/html5-repo/files/ui5.yaml.hbs +2 -29
- package/lib/init/template/html5-repo/files/values.yaml.hbs +6 -2
- package/lib/init/template/html5-repo/files/xs-app.json.hbs +6 -7
- package/lib/init/template/html5-repo/index.js +41 -35
- package/lib/init/template/http/index.js +36 -12
- package/lib/init/template/java/index.js +18 -12
- package/lib/init/template/kafka/index.js +4 -0
- package/lib/init/template/lint/index.js +7 -2
- package/lib/init/template/liquibase/index.js +4 -0
- package/lib/init/template/local-messaging/index.js +4 -0
- package/lib/init/template/malware-scanner/files/mta.yaml.hbs +14 -0
- package/lib/init/template/malware-scanner/files/package.json.hbs +17 -0
- package/lib/init/template/malware-scanner/files/values.yaml +7 -0
- package/lib/init/template/malware-scanner/index.js +47 -0
- package/lib/init/template/mta/files/mta.yaml.hbs +3 -3
- package/lib/init/template/mta/files/package.json +1 -1
- package/lib/init/template/mta/index.js +4 -0
- package/lib/init/template/mtx/index.js +4 -0
- package/lib/init/template/multitenancy/files/containerize.yaml.hbs +10 -0
- package/lib/init/template/multitenancy/files/mta.yaml.hbs +0 -1
- package/lib/init/template/multitenancy/files/package.json.hbs +1 -1
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +6 -5
- package/lib/init/template/multitenancy/files/values.yaml.hbs +14 -24
- package/lib/init/template/multitenancy/index.js +50 -28
- package/lib/init/template/nodejs/files/eslint.config.mjs +2 -0
- package/lib/init/template/nodejs/files/package.json.hbs +2 -3
- package/lib/init/template/nodejs/index.js +4 -0
- package/lib/init/template/notifications/files/mta.yaml.hbs +2 -2
- package/lib/init/template/notifications/index.js +4 -0
- package/lib/init/template/pipeline/files/.pipeline/config.yml +1 -1
- package/lib/init/template/pipeline/files/Jenkinsfile +1 -1
- package/lib/init/template/pipeline/index.js +4 -0
- package/lib/init/template/portal/files/mta.yaml.hbs +52 -0
- package/lib/init/template/portal/files/package.json.hbs +11 -0
- package/lib/init/template/portal/files/package.sidecar.json +7 -0
- package/lib/init/template/portal/files/portal-site/CommonDataModel.json.hbs +97 -0
- package/lib/init/template/portal/files/portal-site/i18n/catalog.properties +1 -0
- package/lib/init/template/portal/files/portal-site/i18n/catalog_de.properties +1 -0
- package/lib/init/template/portal/files/portal-site/i18n/group.properties +1 -0
- package/lib/init/template/portal/files/portal-site/i18n/group_de.properties +1 -0
- package/lib/init/template/portal/index.js +84 -0
- package/lib/init/template/postgres/index.js +5 -1
- package/lib/init/template/redis/files/mta.yaml.hbs +25 -0
- package/lib/init/template/redis/files/package.json.hbs +5 -0
- package/lib/init/template/redis/index.js +44 -0
- package/lib/init/template/redis-messaging/files/package.json.hbs +0 -3
- package/lib/init/template/redis-messaging/index.js +8 -18
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_de.properties +3 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_en.properties +3 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +13 -1
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +2 -2
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_de.properties +3 -0
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_en.properties +4 -0
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +3 -3
- package/lib/init/template/sample/files/app/index.html +1 -1
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +5 -5
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books.csv +6 -6
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books_texts.csv +5 -5
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Genres.csv +16 -16
- package/lib/init/template/sample/files/nodejs/cat-service.js +2 -2
- package/lib/init/template/sample/files/package.json.hbs +3 -0
- package/lib/init/template/sample/index.js +16 -9
- package/lib/init/template/sqlite/index.js +4 -0
- package/lib/init/template/tiny-sample/files/nodejs/db/data/my.bookshop-Books.csv +3 -3
- package/lib/init/template/tiny-sample/files/nodejs/srv/cat-service.cds.hbs +1 -1
- package/lib/init/template/tiny-sample/index.js +4 -0
- package/lib/init/template/toggles/files/package.json.hbs +1 -1
- package/lib/init/template/toggles/index.js +4 -0
- package/lib/init/template/typer/index.js +4 -0
- package/lib/init/template/typescript/files/package.json +12 -0
- package/lib/init/template/typescript/files/tsconfig.json +13 -0
- package/lib/init/template/typescript/index.js +39 -0
- package/lib/init/template/workzone/index.js +9 -0
- package/lib/init/template/workzone-standard/files/manifest.json.hbs +6 -0
- package/lib/init/template/workzone-standard/files/mta.yaml.hbs +59 -0
- package/lib/init/template/workzone-standard/index.js +46 -0
- package/lib/init/template/xsuaa/files/package.json.hbs +1 -1
- package/lib/init/template/xsuaa/files/values.yaml.hbs +3 -2
- package/lib/init/template/xsuaa/index.js +11 -7
- package/lib/init/validate.js +27 -0
- package/lib/lint/generators.js +1 -1
- package/lib/lint/io.js +25 -7
- package/lib/mtx/auth_manager.js +64 -30
- package/lib/mtx/download_legacy.js +2 -2
- package/lib/mtx/index.js +0 -4
- package/lib/mtx/params.js +32 -38
- package/lib/mtx/pull.js +151 -43
- package/lib/mtx/push.js +3 -3
- package/lib/mtx/settings_manager.js +75 -35
- package/lib/mtx/tenant_action.js +1 -1
- package/lib/mtx/util/cf.js +1 -1
- package/lib/mtx/util/fs.js +26 -1
- package/lib/mtx/util/logging.js +7 -3
- package/lib/util/command.js +0 -2
- package/lib/util/fs.js +2 -3
- package/lib/util/question.js +28 -0
- package/lib/util/term.js +5 -3
- package/npm-shrinkwrap.json +225 -1083
- package/package.json +13 -8
- package/bin/activate.js +0 -77
- package/lib/compile/asyncapi/channels.js +0 -22
- package/lib/compile/asyncapi/components/messageTraits/index.js +0 -89
- package/lib/compile/asyncapi/components/messages/index.js +0 -173
- package/lib/compile/asyncapi/components/schemas/annotations.js +0 -33
- package/lib/compile/asyncapi/components/schemas/array.js +0 -8
- package/lib/compile/asyncapi/components/schemas/cache.js +0 -14
- package/lib/compile/asyncapi/components/schemas/definition.js +0 -187
- package/lib/compile/asyncapi/components/schemas/enum.js +0 -16
- package/lib/compile/asyncapi/components/schemas/examples.js +0 -10
- package/lib/compile/asyncapi/components/schemas/index.js +0 -14
- package/lib/compile/asyncapi/components/schemas/localized.js +0 -29
- package/lib/compile/asyncapi/components/schemas/primitiveElement.js +0 -41
- package/lib/compile/asyncapi/components/schemas/ref.js +0 -45
- package/lib/compile/asyncapi/components/schemas/utils.js +0 -108
- package/lib/compile/asyncapi/index.js +0 -247
- package/lib/compile/asyncapi/message.js +0 -13
- package/lib/compile/asyncapi/utils.js +0 -27
- package/lib/compile/openapi/csdl2openapi.js +0 -2448
- package/lib/compile/openapi/index.js +0 -68
- package/lib/init/template/helm/files/chart/templates/NOTES.txt +0 -14
- package/lib/init/template/helm/files/chart/templates/_helpers.tpl +0 -28
- package/lib/init/template/helm/files/chart/values.root.schema.json +0 -61
- package/lib/init/template/helm/files/chart/values.schema.json +0 -366
- package/lib/init/template/helm-unified-runtime/files/Chart.yaml.hbs +0 -10
- package/lib/init/template/helm-unified-runtime/files/templates/_deployment_helpers.tpl +0 -90
- package/lib/init/template/helm-unified-runtime/files/templates/_helpers.tpl +0 -28
- package/lib/init/template/helm-unified-runtime/files/values.root.schema.json +0 -61
- package/lib/init/template/helm-unified-runtime/files/values.schema.json +0 -366
- package/lib/init/template/helm-unified-runtime/files/values.yaml.hbs +0 -26
- package/lib/init/template/helm-unified-runtime/package.json +0 -4
- package/lib/init/template/multitenancy/files/mtxs-configmap-java-approuter.yaml +0 -20
- package/lib/init/template/multitenancy/files/mtxs-configmap-java.yaml +0 -18
- package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs-approuter.yaml +0 -12
- package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs.yaml +0 -12
- package/lib/init/template/multitenancy/files/saas-registry-secret.yaml +0 -9
- package/lib/init/template/nodejs/files/eslint.config.js +0 -13
- package/lib/init/template/notebook/index.js +0 -11
- package/lib/init/template/samples/index.js +0 -9
- package/lib/mtx/activate.js +0 -238
- package/lib/mtx/extend.js +0 -173
- package/lib/util/exec.d.ts +0 -54
- package/lib/util/exec.js +0 -211
- /package/lib/{init/template/approuter/files → build/plugins/helm/files/plugins/approuter}/approuter-configmap.yaml +0 -0
- /package/lib/{init/template/connectivity/files → build/plugins/helm/files/plugins/connectivity}/connectivity-proxy-info.yaml +0 -0
- /package/lib/{init/template/html5-repo/files → build/plugins/helm/files/plugins/html5-repo}/html5-apps-deployer-configmap.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/_helpers.tpl +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/job.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/secret.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-account.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-binding.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.schema.json +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/NOTES.txt +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_api.tpl +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_helpers.tpl +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/api-rule.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/network-policy.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/rbac.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/secret.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-account.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-binding.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/virtual-service.yaml +0 -0
- /package/lib/{init/template/helm-unified-runtime → build/plugins/helm}/files/templates/NOTES.txt +0 -0
- /package/lib/init/template/{nodejs/files → java}/.cdsrc.json +0 -0
- /package/lib/init/template/tiny-sample/files/nodejs/db/{data-model.cds → schema.cds} +0 -0
package/lib/init/mvn.js
CHANGED
|
@@ -1,179 +1,132 @@
|
|
|
1
|
+
const util = require('util')
|
|
2
|
+
const { exec } = require('child_process')
|
|
3
|
+
const execAsync = util.promisify(exec)
|
|
1
4
|
|
|
2
|
-
const
|
|
5
|
+
const term = require('../util/term')
|
|
6
|
+
const cmd = require('../util/command')
|
|
3
7
|
|
|
4
|
-
const cp = require('child_process');
|
|
5
|
-
const util = require('util');
|
|
6
|
-
const execAsync = util.promisify(cp.exec);
|
|
7
|
-
const term = require('../util/term');
|
|
8
|
-
const cmd = require('../util/command');
|
|
9
|
-
|
|
10
|
-
const DEFAULT_GROUP_ID = 'customer';
|
|
11
|
-
|
|
12
|
-
const LOG = console
|
|
13
8
|
const cds = require('../cds')
|
|
14
|
-
const DEBUG = cds.debug('cli')
|
|
15
|
-
|
|
16
|
-
class MvnArchetypeUtil {
|
|
17
|
-
|
|
18
|
-
_scanMvnParams(mvnParams, params) {
|
|
19
|
-
// need to create new regex every call since a constant
|
|
20
|
-
// would keep the match state
|
|
21
|
-
|
|
22
|
-
const quoteRegex = /([\w\-.]+)=([\w\-.]+|\[([\w.\-,]+)\])/g;
|
|
23
|
-
// captures a=1 => a:1
|
|
24
|
-
// -Da=[x,y,z] => -Da:x,y,z (Maven specific)
|
|
25
|
-
// a=[x,y,z] => a:x,y,z
|
|
26
|
-
|
|
27
|
-
let match = quoteRegex.exec(mvnParams);
|
|
28
|
-
while (match != null) {
|
|
29
|
-
const key = (match[1].startsWith('-D') ? match[1] : `-D${match[1]}`);
|
|
30
|
-
params.set(key, match[3] || match[2]);
|
|
31
|
-
match = quoteRegex.exec(mvnParams);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
_finalize(params) {
|
|
36
|
-
params.set(`-Dstyle.color`, `always`);
|
|
37
|
-
|
|
38
|
-
params.set('-B');
|
|
39
|
-
|
|
40
|
-
if (DEBUG) {
|
|
41
|
-
params.set('-X'); params.set('-e');
|
|
42
|
-
}
|
|
43
|
-
if (process.env.CI) {
|
|
44
|
-
params.set('--batch-mode');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return Array.from(params, ([arg, val]) => val !== null && val !== undefined ? `${arg}=${val}` : arg)
|
|
48
|
-
}
|
|
9
|
+
const DEBUG = cds.debug('cli|init|add|mvn')
|
|
49
10
|
|
|
50
|
-
|
|
51
|
-
async add(feature) {
|
|
52
|
-
return this.execMvn(this.getAddArgs(feature))
|
|
53
|
-
}
|
|
11
|
+
const { URLS, MAVEN_ARCHETYPE_VERSION, OPTIONS: { JAVA_PACKAGE, HANA }, REGEX_JAVA_PACKAGE } = require('./constants')
|
|
54
12
|
|
|
55
|
-
|
|
56
|
-
|
|
13
|
+
module.exports.add = async function (feature) {
|
|
14
|
+
const params = new Map()
|
|
57
15
|
|
|
58
|
-
|
|
16
|
+
const { 'java:mvn': javaMvn, force } = cds.cli.options
|
|
17
|
+
if (javaMvn) _scan(javaMvn).forEach(([k,v]) => params.set(k,v))
|
|
18
|
+
const archetypeVersion = params.get('-DarchetypeVersion') ?? MAVEN_ARCHETYPE_VERSION
|
|
19
|
+
if (feature === HANA) { // REVISIT: compat for HANA when -Dfeature HANA is provided by Java
|
|
20
|
+
params.set(`com.sap.cds:cds-maven-plugin:${archetypeVersion}:addTargetPlatform`)
|
|
21
|
+
params.set(`-DtargetPlatform`, `cloudfoundry`) // REVISIT: No special handling for HANA
|
|
22
|
+
} else {
|
|
23
|
+
params.set(`com.sap.cds:cds-maven-plugin:${archetypeVersion}:add`)
|
|
59
24
|
params.set(`-Dfeature`, feature)
|
|
60
25
|
const profile = cds.cli.options.for
|
|
61
26
|
params.set(`-Dprofile`, profile === 'production' ? 'cloud' : profile ?? 'default')
|
|
62
|
-
|
|
63
|
-
const { options } = cds.cli
|
|
64
|
-
if (options[JAVA_MVN]) {
|
|
65
|
-
this._scanMvnParams(options[JAVA_MVN], params);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (options.force) {
|
|
69
|
-
params.set(`-Doverwrite`, true);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return this._finalize(params);
|
|
73
27
|
}
|
|
74
28
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const javaMvn = cds.cli.options[JAVA_MVN]
|
|
82
|
-
if (javaMvn) {
|
|
83
|
-
this._scanMvnParams(javaMvn, params);
|
|
29
|
+
if (force) params.set(`-Doverwrite`, true)
|
|
30
|
+
try {
|
|
31
|
+
await cmd.spawnCommand('mvn', _finalize(params), { cwd: cds.root })
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (err.code === 'ENOENT' && err.path === 'mvn') {
|
|
34
|
+
throw `Maven executable 'mvn' not found. Follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
|
|
84
35
|
}
|
|
85
|
-
|
|
86
|
-
return this._finalize(params);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
sanitizePackageName(packageName) {
|
|
90
|
-
return packageName.toLowerCase().replace(/-/g, '_').replace(/\.([0-9])/g, '._$1').replace(/^([0-9])/, '_$1').replace(/\.+/g, '.');
|
|
36
|
+
throw err
|
|
91
37
|
}
|
|
38
|
+
}
|
|
92
39
|
|
|
93
|
-
|
|
94
|
-
|
|
40
|
+
module.exports.init = async function (projectName, options = cds.cli.options) {
|
|
41
|
+
const params = new Map()
|
|
95
42
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
43
|
+
// set header
|
|
44
|
+
params.set(`archetype:generate`);
|
|
45
|
+
params.set(`-DarchetypeArtifactId`, `cds-services-archetype`);
|
|
46
|
+
params.set(`-DarchetypeGroupId`, `com.sap.cds`);
|
|
47
|
+
params.set(`-DarchetypeVersion`, MAVEN_ARCHETYPE_VERSION);
|
|
48
|
+
params.set('-DinteractiveMode', false);
|
|
102
49
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
50
|
+
// set defaults, might be changed by java:mvn param
|
|
51
|
+
params.set(`-DartifactId`, projectName);
|
|
52
|
+
params.set(`-DgroupId`, 'customer');
|
|
106
53
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
params.set(`-DtargetPlatform`, `cloudfoundry`);
|
|
110
|
-
}
|
|
54
|
+
const { 'java:mvn': javaMvn } = options
|
|
55
|
+
if (javaMvn) _scan(javaMvn).forEach(([k,v]) => params.set(k,v))
|
|
111
56
|
|
|
112
|
-
|
|
113
|
-
|
|
57
|
+
// -DjdkVersion=[11|17]
|
|
58
|
+
if (!params.get('-DjdkVersion')) {
|
|
59
|
+
let javaVersion
|
|
60
|
+
try {
|
|
61
|
+
javaVersion = await execAsync('java -version');
|
|
62
|
+
} catch (err) {
|
|
63
|
+
DEBUG?.(err);
|
|
114
64
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} catch (err) {
|
|
122
|
-
DEBUG?.(err);
|
|
123
|
-
}
|
|
124
|
-
const [,version] = javaVersion?.stderr?.match(/version\s*"?(\d+\.\d+\.\d+)"?/) ?? [];
|
|
125
|
-
if (version) {
|
|
126
|
-
const [major] = version.split('.').map(Number);
|
|
127
|
-
if (major < 17) {
|
|
128
|
-
if (process.env.WS_BASE_URL) {
|
|
129
|
-
throw `Java version ${version} is not supported. Use Java 17 or higher. You can use command 'Java: Set Default JDK' to switch to Java 17.`
|
|
130
|
-
}
|
|
131
|
-
throw `Java version ${version} is not supported. Use Java 17 or higher.`
|
|
65
|
+
const [,version] = javaVersion?.stderr?.match(/version\s*"?(\d+\.\d+\.\d+)"?/) ?? [];
|
|
66
|
+
if (version) {
|
|
67
|
+
const [major] = version.split('.').map(Number);
|
|
68
|
+
if (major < 17) {
|
|
69
|
+
if (process.env.WS_BASE_URL) {
|
|
70
|
+
throw `Java version ${version} is not supported. Use Java 17 or higher. You can use command 'Java: Set Default JDK' to switch to Java 17.`
|
|
132
71
|
}
|
|
72
|
+
throw `Java version ${version} is not supported. Use Java 17 or higher.`
|
|
133
73
|
}
|
|
134
74
|
}
|
|
75
|
+
}
|
|
135
76
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const artifactId = params.get('-DartifactId');
|
|
141
|
-
|
|
142
|
-
const packageFromParam = params.get(`-Dpackage`);
|
|
143
|
-
if (packageFromParam) {
|
|
144
|
-
// explicitly specified, so do not modify
|
|
145
|
-
if (!options.force && !packageFromParam.match(REGEX_JAVA_PACKAGE)) {
|
|
146
|
-
throw `Package '${packageFromParam}' is an invalid Java package name. Use --force to use it anyway.`
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
// potentially overwritten by mvn param
|
|
150
|
-
const groupId = params.get(`-DgroupId`);
|
|
151
|
-
let packageName = `${groupId}.${projectName}`;
|
|
152
|
-
|
|
153
|
-
if (!packageName.match(REGEX_JAVA_PACKAGE)) {
|
|
154
|
-
packageName = this.sanitizePackageName(packageName);
|
|
155
|
-
LOG.warn(`The derived package name '${groupId}.${projectName}' is not a valid Java package name. Using '${packageName}' instead.`);
|
|
156
|
-
}
|
|
157
|
-
params.set(`-Dpackage`, packageName);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
cmdLine: this._finalize(params),
|
|
162
|
-
archetypeVersion: params.get('-DarchetypeVersion'),
|
|
163
|
-
artifactId
|
|
164
|
-
};
|
|
77
|
+
if (options[JAVA_PACKAGE]) {
|
|
78
|
+
params.set(`-Dpackage`, options[JAVA_PACKAGE]);
|
|
165
79
|
}
|
|
166
80
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
81
|
+
const packageFromParam = params.get(`-Dpackage`);
|
|
82
|
+
if (packageFromParam) {
|
|
83
|
+
// explicitly specified, so do not modify
|
|
84
|
+
if (!options.force && !packageFromParam.match(REGEX_JAVA_PACKAGE)) {
|
|
85
|
+
throw `Package '${packageFromParam}' is an invalid Java package name. Use --force to use it anyway.`
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
// potentially overwritten by mvn param
|
|
89
|
+
const groupId = params.get(`-DgroupId`);
|
|
90
|
+
let packageName = `${groupId}.${projectName}`;
|
|
91
|
+
|
|
92
|
+
if (!packageName.match(REGEX_JAVA_PACKAGE)) {
|
|
93
|
+
packageName = sanitize(packageName);
|
|
94
|
+
console.warn(`The derived package name '${groupId}.${projectName}' is not a valid Java package name. Using '${packageName}' instead.`);
|
|
175
95
|
}
|
|
96
|
+
params.set(`-Dpackage`, packageName);
|
|
176
97
|
}
|
|
98
|
+
|
|
99
|
+
const artifactId = params.get('-DartifactId')
|
|
100
|
+
const archetypeVersion = params.get('-DarchetypeVersion')
|
|
101
|
+
return { params: _finalize(params), archetypeVersion, artifactId }
|
|
177
102
|
}
|
|
178
103
|
|
|
179
|
-
module.exports =
|
|
104
|
+
const sanitize = module.exports.sanitize = name => name
|
|
105
|
+
.toLowerCase()
|
|
106
|
+
.replace(/-/g, '_')
|
|
107
|
+
.replace(/\.([0-9])/g, '._$1')
|
|
108
|
+
.replace(/^([0-9])/, '_$1')
|
|
109
|
+
.replace(/\.+/g, '.')
|
|
110
|
+
|
|
111
|
+
function _scan(mvnParams) {
|
|
112
|
+
// need to create new regex every call since a constant
|
|
113
|
+
// would keep the match state
|
|
114
|
+
// captures a=1 => a:1
|
|
115
|
+
// -Da=[x,y,z] => -Da:x,y,z (Maven specific)
|
|
116
|
+
// a=[x,y,z] => a:x,y,z
|
|
117
|
+
const quoteRegex = /([\w\-.]+)=([\w\-.]+|\[([\w.\-,]+)\])/g
|
|
118
|
+
return [...mvnParams.matchAll(quoteRegex)].map(([,key,value,listValues]) => {
|
|
119
|
+
key = key.startsWith('-D') ? key : `-D${key}`
|
|
120
|
+
return [key, listValues || value]
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _finalize(params) {
|
|
125
|
+
params.set(`-Dstyle.color`, `always`)
|
|
126
|
+
if (DEBUG) params.set('-X')
|
|
127
|
+
if (DEBUG) params.set('-e')
|
|
128
|
+
if (process.env.CI) params.set('--batch-mode')
|
|
129
|
+
const final = Array.from(params, ([arg, val]) => val !== null && val !== undefined ? `${arg}=${val}` : arg)
|
|
130
|
+
DEBUG?.(term.highlight('mvn' + final.join(' ')))
|
|
131
|
+
return final
|
|
132
|
+
}
|
package/lib/init/plugin.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const { join } = require('path')
|
|
2
2
|
const cds = require('../cds')
|
|
3
3
|
const { readdir } = cds.utils
|
|
4
|
-
const DEBUG = cds.debug('add')
|
|
5
|
-
const { env4 } = require('./projectReader')
|
|
4
|
+
const DEBUG = cds.debug('cli|add')
|
|
6
5
|
|
|
7
6
|
module.exports = class Plugin {
|
|
8
7
|
|
|
@@ -28,13 +27,20 @@ module.exports = class Plugin {
|
|
|
28
27
|
*/
|
|
29
28
|
async canRun() { return true }
|
|
30
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Gets a brief help text for the plugin.
|
|
32
|
+
* Displayed when all plugins are listed with `cds add`.
|
|
33
|
+
* @returns {string} The help text.
|
|
34
|
+
*/
|
|
35
|
+
static help() { return '' }
|
|
36
|
+
|
|
31
37
|
/**
|
|
32
38
|
* Determines if the plugin has already been added to the project.
|
|
33
39
|
* @param {import('@sap/cds').env} env - The env for the 'production' profile.
|
|
34
40
|
* @returns {boolean} - Returns `true` if the template has been added, otherwise `false`.
|
|
35
41
|
*/
|
|
36
42
|
static hasInProduction(env) { // eslint-disable-line no-unused-vars
|
|
37
|
-
return
|
|
43
|
+
return true
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
/**
|
|
@@ -48,9 +54,6 @@ module.exports = class Plugin {
|
|
|
48
54
|
async combine() { }
|
|
49
55
|
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
57
|
/* ––––––––––––
|
|
55
58
|
Yeoman Generator
|
|
56
59
|
–––––––––––– */
|
|
@@ -58,7 +61,7 @@ module.exports = class Plugin {
|
|
|
58
61
|
/**
|
|
59
62
|
* Runs the finalize operations.
|
|
60
63
|
*/
|
|
61
|
-
async finalize() { }
|
|
64
|
+
async finalize() { }
|
|
62
65
|
|
|
63
66
|
/* ––––––––––––
|
|
64
67
|
Private APIs
|
|
@@ -69,6 +72,7 @@ module.exports = class Plugin {
|
|
|
69
72
|
DEBUG && console.log('Plugins active for production:')
|
|
70
73
|
const fromDk = await readdir(join(__dirname, './template'))
|
|
71
74
|
const { registered } = require('./add')
|
|
75
|
+
const { env4 } = require('./projectReader')
|
|
72
76
|
const processPlugins = async (plugins) => {
|
|
73
77
|
for (const plugin of plugins) {
|
|
74
78
|
const Plugin = registered.get(plugin) ?? require('./template/' + plugin)
|
|
@@ -9,7 +9,9 @@ module.exports = new class ProjectReader {
|
|
|
9
9
|
|
|
10
10
|
constructor() {
|
|
11
11
|
this.readProject = this.readProject.bind(this)
|
|
12
|
+
}
|
|
12
13
|
|
|
14
|
+
#setPackageInfo() {
|
|
13
15
|
// 1. Use project name and static default values
|
|
14
16
|
this.appVersion = cds.cli.options.add?.has('java') ? '1.0.0-SNAPSHOT' : '1.0.0'
|
|
15
17
|
this.appName = this.appId = basename(cds.root)
|
|
@@ -39,7 +41,6 @@ module.exports = new class ProjectReader {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
// REVISIT: There should an API provided by cds.env
|
|
43
44
|
/**
|
|
44
45
|
* Returns cds.env using 'production' profile by default as mta deployment is executed with having production profile set.
|
|
45
46
|
*/
|
|
@@ -69,6 +70,8 @@ module.exports = new class ProjectReader {
|
|
|
69
70
|
* @property {boolean} hasUIEmbedded Indicates if the project uses an embedded UI.
|
|
70
71
|
* @property {boolean} hasUIModule Indicates if the project is using a modular UI.
|
|
71
72
|
* @property {boolean} hasUI Indicates if the project has a UI.
|
|
73
|
+
* @property {boolean} hasUI5 Indicates if the project is a UI5 project.
|
|
74
|
+
* @property {boolean} isUI5 Indicates if the project is a UI5 project.
|
|
72
75
|
* @property {boolean} isJava Indicates if the project is using Java.
|
|
73
76
|
* @property {boolean} isNodejs Indicates if the project is using Node.js.
|
|
74
77
|
* @property {boolean} hasHelmUnifiedRuntime Indicates if the project uses Unified Runtime Helm deployment.
|
|
@@ -82,9 +85,14 @@ module.exports = new class ProjectReader {
|
|
|
82
85
|
* @property {boolean} hasHana Indicates if the project uses HANA.
|
|
83
86
|
* @property {boolean} hasPostgres Indicates if the project uses PostgreSQL.
|
|
84
87
|
* @property {boolean} hasEnterpriseMessaging Indicates if the project uses SAP BTP Event Mesh.
|
|
88
|
+
* @property {boolean} hasAttachments Indicates if the project uses SAP BTP Object Store Service.
|
|
85
89
|
* @property {boolean} hasApprouter Indicates if the project uses the SAP Application Router.
|
|
86
90
|
* @property {boolean} hasHtml5Repo Indicates if the project uses the SAP BTP HTML5 Application Repository.
|
|
91
|
+
* @property {boolean} hasPortal Indicates if the project uses the SAP Cloud Portal serivce.
|
|
87
92
|
* @property {boolean} hasDestination Indicates if the project uses the SAP BTP Destination service.
|
|
93
|
+
* @property {boolean} hasMTXRoute Indicates if the approuter should have a multitenant route.
|
|
94
|
+
* @property {boolean} hasMTXRouteJava Indicates if the approuter should have a multitenant subscription route (java).
|
|
95
|
+
* @property {boolean} hasMalwareScanner Indicates if the project uses the SAP Malware Scanning service.
|
|
88
96
|
*
|
|
89
97
|
*/
|
|
90
98
|
|
|
@@ -95,22 +103,30 @@ module.exports = new class ProjectReader {
|
|
|
95
103
|
* @returns {ProjectConfig} An object representing the project configuration.
|
|
96
104
|
*/
|
|
97
105
|
readProject() {
|
|
106
|
+
if (!this.appName) this.#setPackageInfo()
|
|
98
107
|
const env = this.env4('production')
|
|
99
108
|
const { appVersion, appName, appId, appDescription, jdkVersion } = this
|
|
100
109
|
DEBUG?.({ env })
|
|
101
110
|
|
|
102
111
|
const _inProd = plugin => require(`./template/${plugin}`).hasInProduction(env)
|
|
112
|
+
const _ui5 = () => exists('package.json') && !!JSON.parse(fs.readFileSync(path.resolve(cds.root, 'package.json'))).sapux
|
|
113
|
+
const _uiEmbedded = () => exists(join(env.folders.app, 'xs-app.json'))
|
|
114
|
+
const _uiModule = () => !_uiEmbedded() && isdir(env.folders.app) && fs.readdirSync(resolve(cds.root, env.folders.app)).length > 0
|
|
115
|
+
const _isJava = () => exists('pom.xml') || cds.cli.options?.add?.has('java')
|
|
116
|
+
const isApp = name => name !== 'appconfig' && !name.startsWith('_') && name !== 'router' && name !== 'portal'
|
|
103
117
|
const reserved = {
|
|
104
118
|
has: x => _inProd(x),
|
|
105
119
|
shortcut: () => true,
|
|
106
120
|
profile: () => cds.cli.options?.for,
|
|
107
121
|
language: () => exists('pom.xml') ? 'java' : 'nodejs',
|
|
108
|
-
isJava: () =>
|
|
109
|
-
isNodejs: () => !
|
|
122
|
+
isJava: () => _isJava(),
|
|
123
|
+
isNodejs: () => !_isJava(),
|
|
110
124
|
srvPath: () => join(env.build.target, env.folders.srv.replace(/\/$/, '')).replace(/\\/g, '/'),
|
|
111
125
|
archiveName: () => {
|
|
112
|
-
const
|
|
113
|
-
|
|
126
|
+
const pomXmlPath = resolve(cds.root, env.folders.srv, 'pom.xml')
|
|
127
|
+
const pom = exists(pomXmlPath) ? parseXml(pomXmlPath) : {}
|
|
128
|
+
const { artifactId = [basename(cds.root)], packaging = ['jar'] } = pom
|
|
129
|
+
return artifactId[0] + '-exec.' + packaging[0]
|
|
114
130
|
},
|
|
115
131
|
db: () => {
|
|
116
132
|
const folder = env.folders.db
|
|
@@ -119,27 +135,51 @@ module.exports = new class ProjectReader {
|
|
|
119
135
|
return { folder, name, path }
|
|
120
136
|
},
|
|
121
137
|
configFile: () => exists('pom.xml') ? '.cdsrc.json' : 'package.json',
|
|
122
|
-
apps: () =>
|
|
123
|
-
|
|
124
|
-
|
|
138
|
+
apps: () => {
|
|
139
|
+
const apps = fs.readdirSync(path.resolve(cds.root, cds.env.folders.app)).filter(e =>
|
|
140
|
+
isdir(path.join(cds.root, cds.env.folders.app, e)) && isApp(e)
|
|
141
|
+
)
|
|
142
|
+
return apps.map((app, i) => {
|
|
143
|
+
const manifestPath = path.resolve(cds.root, cds.env.folders.app, app, 'webapp/manifest.json')
|
|
144
|
+
const manifest = exists(manifestPath) ? JSON.parse(fs.readFileSync(manifestPath, 'utf-8')) : {}
|
|
145
|
+
const inbounds = manifest?.['sap.app']?.crossNavigation?.inbounds
|
|
146
|
+
const [firstInbound] = Object.values(inbounds ?? { intent: { semanticObject: 'Books', action: 'display' }})
|
|
147
|
+
const vizId = firstInbound.semanticObject + '-' + firstInbound.action
|
|
148
|
+
return { app, strippedApp: app.replace(/-/g, ''), vizId, isNotLast: i < apps.length - 1 }
|
|
149
|
+
})
|
|
150
|
+
},
|
|
125
151
|
appUIPaths: () => (fs.readdirSync(path.resolve(cds.root, cds.env.folders.app))).filter(e =>
|
|
126
|
-
isdir(join(cds.root, cds.env.folders.app, e)) && e
|
|
152
|
+
isdir(join(cds.root, cds.env.folders.app, e)) && isApp(e)
|
|
127
153
|
),
|
|
128
154
|
appPath: () => env.folders.app,
|
|
129
155
|
appVersion: () => appVersion,
|
|
130
156
|
jdkVersion: () => jdkVersion,
|
|
131
|
-
approuterPath: () => join(env.folders.app, 'router'),
|
|
157
|
+
approuterPath: () => _uiEmbedded() ? join(env.folders.app) : join(env.folders.app, 'router'),
|
|
132
158
|
appName: () => appName,
|
|
133
159
|
cleanedAppName: () => appName.replaceAll('_', '-'),
|
|
160
|
+
strippedAppName: () => appName.replace(/-/g, ''),
|
|
134
161
|
appId: () => appId,
|
|
135
162
|
appDescription: () => appDescription,
|
|
136
|
-
hasUIEmbedded:
|
|
137
|
-
hasUIModule:
|
|
138
|
-
hasUI: () =>
|
|
163
|
+
hasUIEmbedded: _uiEmbedded,
|
|
164
|
+
hasUIModule: _uiModule,
|
|
165
|
+
hasUI: () => _uiEmbedded() || _uiModule(),
|
|
166
|
+
isUI5: _ui5,
|
|
167
|
+
hasUI5: _ui5,
|
|
168
|
+
hasMTXRoute: () => _inProd('extensibility') || (_inProd('multitenancy') && !_isJava()),
|
|
169
|
+
hasMTXRouteJava: () => (_inProd('helm-unified-runtime') || _inProd('helm')) && _isJava() && _inProd('multitenancy'),
|
|
139
170
|
}
|
|
140
171
|
|
|
172
|
+
// Automatically creates availability checks for `cds add` commands.
|
|
173
|
+
// Maps to the `hasInProduction` implemented in the command.
|
|
174
|
+
// E.g. `cds add hana` can be checked using `hasHana` or `isHana`
|
|
141
175
|
const project = (() => {
|
|
142
176
|
const defined = {}
|
|
177
|
+
const _get = property => { const p = property
|
|
178
|
+
if (p in reserved) return reserved[p]()
|
|
179
|
+
for (const prefix of ['has', 'is']) if (p.startsWith(prefix) && p.length > prefix.length) {
|
|
180
|
+
return _inProd(p.slice(prefix.length).replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())
|
|
181
|
+
}
|
|
182
|
+
}
|
|
143
183
|
return new Proxy({}, {
|
|
144
184
|
get(_, p) { return _get(p) ?? defined[p] },
|
|
145
185
|
set(_, p, value) { defined[p] = value; return true },
|
|
@@ -147,13 +187,6 @@ module.exports = new class ProjectReader {
|
|
|
147
187
|
})
|
|
148
188
|
})()
|
|
149
189
|
|
|
150
|
-
const _get = property => { const p = property
|
|
151
|
-
if (p in reserved) return reserved[p]()
|
|
152
|
-
for (const prefix of ['has', 'is']) if (p.startsWith(prefix) && p.length > prefix.length) {
|
|
153
|
-
return _inProd(p.slice(prefix.length).replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
190
|
DEBUG?.({ project })
|
|
158
191
|
return project
|
|
159
192
|
}
|
|
@@ -3,7 +3,10 @@ const cds = require('../../cds')
|
|
|
3
3
|
|
|
4
4
|
const srvNode4 = path => ({ in: 'modules', where: { type: 'nodejs', path } })
|
|
5
5
|
const srvJava4 = path => ({ in: 'modules', where: { type: 'java', path } })
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
// REVISIT: Clean up
|
|
8
|
+
const isJava = process.argv[process.argv.indexOf('--add') + 1].split(',').includes('java') || cds.env['project-nature'] === 'java' || cds.cli.options?.add?.has('java')
|
|
9
|
+
const srv4 = isJava ? srvJava4 : srvNode4
|
|
7
10
|
|
|
8
11
|
const approuter = { in: 'modules', where: { type: 'approuter.nodejs' } }
|
|
9
12
|
|
|
@@ -17,6 +20,11 @@ const destination = {
|
|
|
17
20
|
where: { type: 'org.cloudfoundry.managed-service', 'parameters.service': 'destination' }
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
const destinations = {
|
|
24
|
+
in: 'modules',
|
|
25
|
+
where: { type: 'com.sap.application.content', 'build-parameters.no-source': true }
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
const connectivity = {
|
|
21
29
|
in: 'resources',
|
|
22
30
|
where: { type: 'org.cloudfoundry.managed-service', 'parameters.service': 'connectivity' }
|
|
@@ -42,6 +50,16 @@ const applicationLogging = {
|
|
|
42
50
|
where: { type: 'org.cloudfoundry.managed-service', 'parameters.service': 'application-logs' }
|
|
43
51
|
}
|
|
44
52
|
|
|
53
|
+
const attachments = {
|
|
54
|
+
in: 'resources',
|
|
55
|
+
where: { type: 'org.cloudfoundry.managed-service', 'parameters.service': 'objectstore' }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const malwareScanner = {
|
|
59
|
+
in: 'resources',
|
|
60
|
+
where: { type: 'org.cloudfoundry.managed-service', 'parameters.service': 'malware-scanner' }
|
|
61
|
+
}
|
|
62
|
+
|
|
45
63
|
const hdbDeployer = {
|
|
46
64
|
in: 'modules',
|
|
47
65
|
where: { type: 'hdb' }
|
|
@@ -122,11 +140,16 @@ const providedJavaApprouterApi = {
|
|
|
122
140
|
where: { 'properties.url': '${default-url}' }
|
|
123
141
|
}
|
|
124
142
|
|
|
125
|
-
const
|
|
143
|
+
const approuterMTXRoute = {
|
|
126
144
|
in: 'routes',
|
|
127
145
|
where: { source: '^/-/cds/.*', destination: 'mtx-api', authenticationType: 'none' }
|
|
128
146
|
}
|
|
129
147
|
|
|
148
|
+
const approuterMTXRouteJava = {
|
|
149
|
+
in: 'routes',
|
|
150
|
+
where: { source: '^/mt/.*', destination: 'srv-api', authenticationType: 'none' }
|
|
151
|
+
}
|
|
152
|
+
|
|
130
153
|
const html5RepoHost = {
|
|
131
154
|
in: 'resources',
|
|
132
155
|
where: { 'parameters.service': 'html5-apps-repo', 'parameters.service-plan': 'app-host' }
|
|
@@ -137,9 +160,24 @@ const html5Runtime = {
|
|
|
137
160
|
where: { 'parameters.service': 'html5-apps-repo', 'parameters.service-plan': 'app-runtime' }
|
|
138
161
|
}
|
|
139
162
|
|
|
140
|
-
const
|
|
163
|
+
const appDeployer = {
|
|
141
164
|
in: 'modules',
|
|
142
|
-
where: { type: 'com.sap.application.content' }
|
|
165
|
+
where: { type: 'com.sap.application.content', path: isJava ? '.' : 'gen' }
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const portal = {
|
|
169
|
+
in: 'resources',
|
|
170
|
+
where: { 'parameters.service': 'portal' },
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const portalDeployer = {
|
|
174
|
+
in: 'modules',
|
|
175
|
+
where: { type: 'com.sap.application.content', path: 'app/portal' }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const auditlog = {
|
|
179
|
+
in: 'resources',
|
|
180
|
+
where: { type: 'org.cloudfoundry.managed-service', 'parameters.service': 'auditlog' }
|
|
143
181
|
}
|
|
144
182
|
|
|
145
183
|
module.exports = {
|
|
@@ -147,6 +185,7 @@ module.exports = {
|
|
|
147
185
|
approuter,
|
|
148
186
|
xsuaa,
|
|
149
187
|
destination,
|
|
188
|
+
destinations,
|
|
150
189
|
connectivity,
|
|
151
190
|
enterpriseMessaging,
|
|
152
191
|
kafkaMessaging,
|
|
@@ -168,8 +207,14 @@ module.exports = {
|
|
|
168
207
|
providedJavaApprouterApi4,
|
|
169
208
|
providedJavaApprouterApi,
|
|
170
209
|
applicationLogging,
|
|
171
|
-
|
|
210
|
+
approuterMTXRoute,
|
|
211
|
+
approuterMTXRouteJava,
|
|
172
212
|
html5RepoHost,
|
|
173
213
|
html5Runtime,
|
|
174
|
-
|
|
214
|
+
appDeployer,
|
|
215
|
+
portal,
|
|
216
|
+
portalDeployer,
|
|
217
|
+
auditlog,
|
|
218
|
+
attachments,
|
|
219
|
+
malwareScanner,
|
|
175
220
|
}
|
|
@@ -4,8 +4,12 @@ const { srv4, mtxSidecar4, applicationLogging, approuter } = require('../../regi
|
|
|
4
4
|
|
|
5
5
|
module.exports = class ApplicationLoggingTemplate extends require('../../plugin') {
|
|
6
6
|
|
|
7
|
+
static help() {
|
|
8
|
+
return 'SAP BTP Application Logging Service'
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
static hasInProduction(env) {
|
|
8
|
-
return !!env.
|
|
12
|
+
return !!env.requires?.['application-logging']
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
async canRun() {
|
|
@@ -14,6 +18,14 @@ module.exports = class ApplicationLoggingTemplate extends require('../../plugin'
|
|
|
14
18
|
return true
|
|
15
19
|
}
|
|
16
20
|
|
|
21
|
+
async run() {
|
|
22
|
+
const project = readProject()
|
|
23
|
+
const { isNodejs } = project
|
|
24
|
+
if (isNodejs) {
|
|
25
|
+
await merge(__dirname, 'files/package.json.hbs').into('package.json')
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
async combine() {
|
|
18
30
|
const project = readProject()
|
|
19
31
|
const { hasMta, hasApprouter, isJava, hasMultitenancy, srvPath } = project
|