@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
|
@@ -1,52 +1,78 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const parser = require('./migrationtable')
|
|
3
|
-
const { BuildError,
|
|
3
|
+
const { BuildError, BuildMessage } = require('../../util')
|
|
4
4
|
const { SEVERITY_WARNING } = require('../../constants')
|
|
5
5
|
const cds = require('../../../cds'), { compiler: cdsc } = cds
|
|
6
6
|
const cdscVersion = `-- generated by cds-compiler version ${cdsc.version()}`
|
|
7
7
|
const { getArtifactCdsPersistenceName } = cdsc
|
|
8
|
-
const ANNO_PERSISTENCE_JOURNAL = '@cds.persistence.journal'
|
|
9
8
|
const DEBUG = cds.debug('cli|build')
|
|
10
9
|
|
|
11
|
-
module.exports = async (model,
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
module.exports = async (model, beforeImage, srcPath, options = {}) => {
|
|
11
|
+
const { definitions, migrations, afterImage, journalFileNames } = _compileToHana(model, options, beforeImage)
|
|
12
|
+
const definitionResult = []
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
for (const { name, suffix, sql } of definitions) {
|
|
15
|
+
let definitionEntry = { name, suffix, content: sql }
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
if (suffix === '.hdbtable') {
|
|
18
|
+
if (journalFileNames.has(name)) {
|
|
19
|
+
const migration = migrations.find(migration => migration.name === name)
|
|
20
|
+
definitionEntry = await _2migrationtable(srcPath, migration || _emptyMigration(name), sql)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (definitionEntry) {
|
|
24
|
+
definitionResult.push(definitionEntry)
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
return { definitions: definitionResult, deletions, afterImage: _filterJournalArtifacts(afterImage) }
|
|
27
|
+
return { definitions: definitionResult, afterImage }
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
function _compileToHana(model, options, beforeImage) {
|
|
31
|
+
let definitions = []
|
|
32
|
+
let migrations = []
|
|
33
|
+
let afterImage
|
|
34
|
+
|
|
35
|
+
if (cds.compile.to.hana) {
|
|
36
|
+
const result = cds.compile.to.hana(model, options, beforeImage);
|
|
37
|
+
|
|
38
|
+
for (const [content, { file }] of result) {
|
|
39
|
+
switch (file) {
|
|
40
|
+
case 'deletions.json':
|
|
41
|
+
break
|
|
42
|
+
case 'migrations.json':
|
|
43
|
+
migrations = content
|
|
44
|
+
break
|
|
45
|
+
case 'afterImage.json':
|
|
46
|
+
afterImage = content
|
|
47
|
+
break
|
|
48
|
+
default: {
|
|
49
|
+
const { name, ext: suffix } = path.parse(file)
|
|
50
|
+
definitions.push({ name, suffix, sql: content })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
45
53
|
}
|
|
46
|
-
|
|
54
|
+
} else {
|
|
55
|
+
// compatibility with cds < 8.0.0
|
|
56
|
+
const result = cdsc.to.hdi.migration(cds.minify(model), options, beforeImage)
|
|
57
|
+
definitions = result.definitions
|
|
58
|
+
migrations = result.migrations
|
|
59
|
+
afterImage = result.afterImage
|
|
60
|
+
}
|
|
61
|
+
let journalFileNames = new Set()
|
|
62
|
+
if (afterImage) {
|
|
63
|
+
// 1. determine journal file names before _filterJournalArtifacts is called as getArtifactCdsPersistenceName
|
|
64
|
+
// might no longer return the proper file name for the reduced CSN, e.g. for draft entities
|
|
65
|
+
journalFileNames = _getJournalFileNames(afterImage, options)
|
|
66
|
+
|
|
67
|
+
// 2. leave only persisted journal-related entities in afterImage
|
|
68
|
+
afterImage = _filterJournalArtifacts(afterImage)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_debug(definitions, migrations, journalFileNames)
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
definitions, migrations, afterImage, journalFileNames
|
|
47
75
|
}
|
|
48
|
-
}
|
|
49
|
-
return { ...result, journalFileNames }
|
|
50
76
|
}
|
|
51
77
|
|
|
52
78
|
/**
|
|
@@ -58,118 +84,136 @@ ${migration ? migration.changeset.map(change => change.sql).join('\n') : 'Empty
|
|
|
58
84
|
* @returns {Object} Providing access to 'content' and 'fileName'.
|
|
59
85
|
*/
|
|
60
86
|
async function _2migrationtable(srcPath, migration, tableSql) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (migrationTableModel) {
|
|
71
|
-
// adding new changeset if change exist, ignore otherwise
|
|
72
|
-
const migrationEntry = _getNewMigrationEntry(migration.changeset, migrationTableModel.versionNumber)
|
|
73
|
-
if (migrationEntry) {
|
|
74
|
-
const versionNumber = migrationTableModel.versionNumber + 1
|
|
75
|
-
const migrationCount = migrationTableModel.migrations.entries.length
|
|
76
|
-
const migrations = `${migrationEntry.content}${migrationCount > 0 ? '\n' : ''}${migrationTableModel.migrations.toString()}${migrationCount > 0 ? '\n' : ''}`
|
|
77
|
-
return {
|
|
78
|
-
name: migration.name,
|
|
79
|
-
suffix: migration.suffix,
|
|
80
|
-
content: `== version=${versionNumber}\n${tableSql}\n\n${migrations}`,
|
|
81
|
-
changed: true,
|
|
82
|
-
dropColumns: migrationEntry.dropColumns
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
// existing migration file version
|
|
86
|
-
return { name: migration.name, suffix: migration.suffix, content: migrationTableModel.toString(), changed: false }
|
|
87
|
+
let migrationTableModel = null
|
|
88
|
+
const file = path.join(srcPath, migration.name + migration.suffix)
|
|
89
|
+
try {
|
|
90
|
+
migrationTableModel = await parser.read(file)
|
|
91
|
+
} catch (e) {
|
|
92
|
+
// abort build in order to ensure consistent afterImage model state / hdbmigrationtable file state
|
|
93
|
+
throw new BuildError(`${path.relative(process.cwd(), file)}: ${e.message}`)
|
|
87
94
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
|
|
96
|
+
if (migrationTableModel) {
|
|
97
|
+
// adding new changeset if change exist, ignore otherwise
|
|
98
|
+
const migrationEntry = _getNewMigrationEntry(migration.changeset, migrationTableModel.versionNumber)
|
|
99
|
+
if (migrationEntry) {
|
|
100
|
+
const versionNumber = migrationTableModel.versionNumber + 1
|
|
101
|
+
const migrationCount = migrationTableModel.migrations.entries.length
|
|
102
|
+
const migrations = `${migrationEntry.content}${migrationCount > 0 ? '\n' : ''}${migrationTableModel.migrations.toString()}${migrationCount > 0 ? '\n' : ''}`
|
|
103
|
+
return {
|
|
104
|
+
name: migration.name,
|
|
105
|
+
suffix: migration.suffix,
|
|
106
|
+
content: `== version=${versionNumber}\n${tableSql}\n\n${migrations}`,
|
|
107
|
+
changed: true,
|
|
108
|
+
dropColumns: migrationEntry.dropColumns
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// existing migration file version
|
|
112
|
+
return { name: migration.name, suffix: migration.suffix, content: migrationTableModel.toString(), changed: false }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// initial migration file version
|
|
116
|
+
return { name: migration.name, suffix: migration.suffix, content: `== version=1\n${tableSql}\n`, changed: true }
|
|
91
117
|
}
|
|
92
118
|
|
|
93
119
|
function _getNewMigrationEntry(changeset, currentVersion) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
if (changeset && changeset.length > 0) {
|
|
121
|
+
const dropColumns = changeset.some(e => e.drop)
|
|
122
|
+
const manualChange = changeset.some(e => !e.sql)
|
|
123
|
+
const enableDrop = cds.env.hana?.journal?.['enable-drop']
|
|
124
|
+
const content = changeset.reduce((acc, e) => {
|
|
125
|
+
if (!acc) {
|
|
126
|
+
acc = `== migration=${currentVersion + 1}\n`
|
|
127
|
+
acc += `${cdscVersion}\n`
|
|
128
|
+
|
|
129
|
+
if (dropColumns && enableDrop !== true) {
|
|
130
|
+
acc += `>>>>> Manual resolution required - DROP statements causing data loss are disabled by default.
|
|
105
131
|
>>>>> You may either:
|
|
106
132
|
>>>>> uncomment statements to allow incompatible changes, or
|
|
107
133
|
>>>>> refactor statements, e.g. replace DROP/ADD by single RENAME statement
|
|
108
134
|
>>>>> After manual resolution delete all lines starting with >>>>>\n`
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
} else if (manualChange) {
|
|
136
|
+
acc += `>>>>> Manual resolution required - insert ALTER statement(s) as described below.
|
|
111
137
|
>>>>> After manual resolution delete all lines starting with >>>>>\n`
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (e.sql) {
|
|
141
|
+
if (e.drop && enableDrop !== true) {
|
|
142
|
+
acc += `${e.sql.replace(/^/gm, '-- ')}\n`;
|
|
143
|
+
} else {
|
|
144
|
+
acc += `${e.sql}\n`
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
acc +=
|
|
148
|
+
`>>>>> Insert ALTER statement for: ${e.description}\n`
|
|
149
|
+
}
|
|
150
|
+
return acc
|
|
151
|
+
}, null)
|
|
152
|
+
return { dropColumns, content }
|
|
153
|
+
}
|
|
154
|
+
return null
|
|
129
155
|
}
|
|
130
156
|
|
|
131
157
|
function _emptyMigration(name) {
|
|
132
|
-
|
|
158
|
+
return { name, suffix: ".hdbmigrationtable", changeset: [] }
|
|
133
159
|
}
|
|
134
160
|
|
|
135
161
|
function _getJournalFileNames(model, options) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
162
|
+
const journalNames = new Set(cds.reflect(model).all(item => {
|
|
163
|
+
if (item.kind === 'entity' && item['@cds.persistence.journal'] === true) {
|
|
164
|
+
if (item['@cds.persistence.skip'] === true || item['@cds.persistence.exists'] === true) {
|
|
165
|
+
options.messages?.push(new BuildMessage(`[hdbmigrationtable] annotation @cds.persistence.journal skipped for entity '${item.name}' as persistence exists`, SEVERITY_WARNING))
|
|
166
|
+
}
|
|
167
|
+
return true
|
|
168
|
+
}
|
|
169
|
+
return false
|
|
170
|
+
}).map(entity => getArtifactCdsPersistenceName(entity.name, 'quoted', model, 'hana')))
|
|
145
171
|
|
|
146
|
-
|
|
147
|
-
|
|
172
|
+
DEBUG?.(`\n[hdbmigrationtable] found ${journalNames.size} model entities annotated with '@cds.persistence.journal`)
|
|
173
|
+
DEBUG?.(`[hdbmigrationtable] ${[...journalNames].join(', ')}\n`)
|
|
148
174
|
|
|
149
|
-
|
|
175
|
+
return journalNames
|
|
150
176
|
}
|
|
151
177
|
|
|
152
|
-
//
|
|
153
|
-
function _filterJournalArtifacts(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
const dict = csn.definitions
|
|
158
|
-
for (const name in dict) {
|
|
159
|
-
if (!_isPersistedAsJournalTable(dict[name])) {
|
|
160
|
-
delete dict[name]
|
|
178
|
+
// only keep journal related entities
|
|
179
|
+
function _filterJournalArtifacts(afterImage) {
|
|
180
|
+
if (!afterImage) {
|
|
181
|
+
return
|
|
161
182
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
183
|
+
const dict = afterImage.definitions
|
|
184
|
+
for (const name in dict) {
|
|
185
|
+
if (!_isPersistedAsJournalTable(dict[name])) {
|
|
186
|
+
delete dict[name]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// mark CSN as modified by cds
|
|
190
|
+
afterImage.meta.build = `CDS Build v${cds.version}`
|
|
191
|
+
return afterImage
|
|
166
192
|
}
|
|
167
193
|
|
|
168
194
|
// see cds-compiler/lib/model/csnUtils.js#isPersistedAsTable
|
|
169
195
|
function _isPersistedAsJournalTable(artifact) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
196
|
+
return (
|
|
197
|
+
artifact.kind === 'entity' &&
|
|
198
|
+
artifact['@cds.persistence.journal'] &&
|
|
199
|
+
!artifact.abstract &&
|
|
200
|
+
!artifact['@cds.persistence.skip'] &&
|
|
201
|
+
!artifact['@cds.persistence.exists'] &&
|
|
202
|
+
((!artifact.query && !artifact.projection) || artifact['@cds.persistence.table'])
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function _debug(definitions, migrations, journalFileNames) {
|
|
207
|
+
if (DEBUG) {
|
|
208
|
+
DEBUG('compile.to.hana returned')
|
|
209
|
+
for (const { name, suffix, sql } of definitions) {
|
|
210
|
+
if (suffix === '.hdbtable' && journalFileNames.has(name)) {
|
|
211
|
+
const migration = migrations.find(migration => migration.name === name)
|
|
212
|
+
DEBUG(`File ${name + '.hdbmigrationtable'} - ${migration ? migration.changeset.length : 0} new changes
|
|
213
|
+
${sql}
|
|
214
|
+
${migration ? migration.changeset.map(change => change.sql).join('\n') : 'Empty changeset'}
|
|
215
|
+
`)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
175
219
|
}
|
|
@@ -3,10 +3,10 @@ const path = require('path')
|
|
|
3
3
|
const cds = require('../../../cds')
|
|
4
4
|
const to_hdbmigration = require('./2migration')
|
|
5
5
|
const InternalBuildPlugin = require('../internalBuildPlugin')
|
|
6
|
-
const { BuildError, relativePaths, BuildMessage, getWorkspaces, hasOptionValue } = require('../../util')
|
|
6
|
+
const { BuildError, relativePaths, BuildMessage, getWorkspaces, hasOptionValue, getFiles } = require('../../util')
|
|
7
7
|
const { OUTPUT_MODE_NONE, OUTPUT_MODE, CONTENT_PACKAGE_JSON, CONTENT_HDBTABLEDATA, CSV_FILE_DETECTION,
|
|
8
8
|
CONTENT_ENV, CONTENT_DEFAULT_ENV_JSON, CONTENT_NODE_MODULES, OUTPUT_MODE_RESULT, CONTINUE_UNRESOLVED_SCHEMA_CHANGES,
|
|
9
|
-
CSV_FILE_TARGET,
|
|
9
|
+
CSV_FILE_TARGET, OPTION_WS } = require('../../constants')
|
|
10
10
|
const { WARNING } = InternalBuildPlugin
|
|
11
11
|
const DEFAULT_COMPILE_DEST_FOLDER = path.normalize("src/gen")
|
|
12
12
|
const FILE_EXT_CSV = ".csv"
|
|
@@ -38,9 +38,14 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
38
38
|
if (!model) {
|
|
39
39
|
return
|
|
40
40
|
}
|
|
41
|
+
let workspaceFiles
|
|
42
|
+
if (cds.cli.options?.[OPTION_WS] || hasOptionValue(this.task.options[OPTION_WS], true)) {
|
|
43
|
+
workspaceFiles = await this._getWorkspaceFiles()
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
// the order of 1 and 2 is important
|
|
42
47
|
// 1. compile
|
|
43
|
-
const hdiPlugins = await this._compileToHana(model)
|
|
48
|
+
const hdiPlugins = await this._compileToHana(model, workspaceFiles)
|
|
44
49
|
|
|
45
50
|
if (!this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_NONE)) {
|
|
46
51
|
// 2. copy resources
|
|
@@ -49,9 +54,15 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
49
54
|
} else {
|
|
50
55
|
await this._copyResourcesExt(src, dest, model)
|
|
51
56
|
}
|
|
52
|
-
// copy native hana artifacts from
|
|
53
|
-
if (
|
|
54
|
-
|
|
57
|
+
// copy native hana artifacts from workspaces
|
|
58
|
+
if (workspaceFiles) {
|
|
59
|
+
const dest = path.join(this.task.dest, 'src/gen')
|
|
60
|
+
await Promise.all(
|
|
61
|
+
workspaceFiles.map((src) => {
|
|
62
|
+
const { dir, filePath } = src
|
|
63
|
+
return this.copy(path.join(dir, filePath)).to(path.join(dest, filePath))
|
|
64
|
+
})
|
|
65
|
+
)
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
// create additional stuff in dest
|
|
@@ -163,9 +174,10 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
163
174
|
})
|
|
164
175
|
}
|
|
165
176
|
|
|
166
|
-
// handle *.csv and *.hdbtabledata located in '<dbSrc>/data' and '<dbSrc>/csv' folder
|
|
177
|
+
// handle *.csv and *.hdbtabledata located in '<dbSrc>/data' and '<dbSrc>/csv' folder,
|
|
178
|
+
// subfolders are not supported
|
|
167
179
|
const allFiles = csvDirs.reduce((acc, csvDir) => {
|
|
168
|
-
return acc.concat(
|
|
180
|
+
return acc.concat(getFiles(csvDir, (entry) => {
|
|
169
181
|
if (fs.statSync(entry).isDirectory()) {
|
|
170
182
|
return false
|
|
171
183
|
}
|
|
@@ -193,7 +205,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
193
205
|
const tableDataDirs = new Set()
|
|
194
206
|
const destSrcDir = path.join(this.task.dest, "src")
|
|
195
207
|
|
|
196
|
-
const allCsvFiles =
|
|
208
|
+
const allCsvFiles = getFiles(destSrcDir, (entry) => {
|
|
197
209
|
if (fs.statSync(entry).isDirectory()) {
|
|
198
210
|
return true
|
|
199
211
|
}
|
|
@@ -253,18 +265,20 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
253
265
|
*
|
|
254
266
|
* @param {object} model The compiled csn model
|
|
255
267
|
*/
|
|
256
|
-
async _compileToHana(model) {
|
|
268
|
+
async _compileToHana(model, workspaceFiles) {
|
|
257
269
|
// compile to old format (.hdbcds) or new format (.hdbtable / .hdbview)
|
|
258
270
|
const format = this.getBuildOption(DEPLOY_FORMAT) || cds.env.requires.db?.[DEPLOY_FORMAT] || cds.env.hana?.[DEPLOY_FORMAT]
|
|
259
271
|
if (!cds.compile.to[format]) {
|
|
260
272
|
return Promise.reject(new Error(`Invalid deploy-format defined: ${format}`))
|
|
261
273
|
}
|
|
262
274
|
|
|
263
|
-
|
|
264
|
-
|
|
275
|
+
if (cds.env.features.journal === false
|
|
276
|
+
|| format === 'hdbcds'
|
|
277
|
+
|| (!cds.compile.to.hana && Object.values(model.definitions).every(def => !def['@cds.persistence.journal']))) {
|
|
278
|
+
// compatibility with existing cds.compile.to.hdbtable plugins cds < 8.0.0
|
|
265
279
|
return await this._compileToHdb(model, format)
|
|
266
280
|
} else {
|
|
267
|
-
return await this._compileToHdbmigration(model, format)
|
|
281
|
+
return await this._compileToHdbmigration(model, format, workspaceFiles)
|
|
268
282
|
}
|
|
269
283
|
}
|
|
270
284
|
|
|
@@ -300,7 +314,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
300
314
|
return hdiPlugins
|
|
301
315
|
}
|
|
302
316
|
|
|
303
|
-
async _compileToHdbmigration(model, format) {
|
|
317
|
+
async _compileToHdbmigration(model, format, workspaceFiles) {
|
|
304
318
|
const hdiPlugins = new Set()
|
|
305
319
|
const relDestDir = path.relative(this.task.dest, this.task.options.compileDest)
|
|
306
320
|
const relDbDestDir = path.relative(cds.root, this.task.options.compileDest)
|
|
@@ -318,43 +332,44 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
318
332
|
// enforces sqlNames option for compiler in tests, pass options from cds env, ensures that the correct format is taken
|
|
319
333
|
const options = { ...this.options(), messages: this.messages, sql_mapping: cds.env.sql.names, "deploy-format": format }
|
|
320
334
|
|
|
321
|
-
const
|
|
322
|
-
const definitions = compilationResult.definitions
|
|
323
|
-
const afterImage = compilationResult.afterImage
|
|
335
|
+
const { definitions, afterImage } = await to_hdbmigration(model, lastDev, dbSrcDir, options)
|
|
324
336
|
let validationError
|
|
325
337
|
|
|
326
338
|
for (const { name, suffix, content, changed } of definitions) {
|
|
327
339
|
hdiPlugins.add(suffix)
|
|
328
|
-
const
|
|
340
|
+
const fileName = name + suffix
|
|
329
341
|
if (suffix === FILE_EXT_HDBMIGRATIONTABLE) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
342
|
+
// Skip the .hdbmigrationtable file if its origin is a different workspace.
|
|
343
|
+
// The workspace build copies artifacts located in 'db/src/**' workspace folders.
|
|
344
|
+
if (!workspaceFiles?.find(wsFile => wsFile.fileName === fileName)) {
|
|
345
|
+
migrationTableFiles.push(path.join(relDbSrcDir, fileName))
|
|
346
|
+
if (changed) {
|
|
347
|
+
if (this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_RESULT)) {
|
|
348
|
+
this._result.hana.push(path.join("src", fileName))
|
|
349
|
+
}
|
|
350
|
+
promises.push(this.write(content).to(path.join(dbSrcDir, fileName)))
|
|
351
|
+
} else {
|
|
352
|
+
DEBUG?.(`no change, keep existing ${fileName}`)
|
|
334
353
|
}
|
|
335
|
-
promises.push(this.write(content).to(path.join(dbSrcDir, file)))
|
|
336
|
-
} else {
|
|
337
|
-
DEBUG?.(`no change, keep existing ${file}`)
|
|
338
354
|
}
|
|
339
355
|
} else {
|
|
340
356
|
if (this.hasBuildOption(OUTPUT_MODE, OUTPUT_MODE_RESULT)) {
|
|
341
|
-
this._result.hana.push(path.join(relDestDir,
|
|
357
|
+
this._result.hana.push(path.join(relDestDir, fileName))
|
|
342
358
|
}
|
|
343
|
-
promises.push(this.write(content).to(path.join(this.task.options.compileDest,
|
|
359
|
+
promises.push(this.write(content).to(path.join(this.task.options.compileDest, fileName)))
|
|
344
360
|
if (suffix === FILE_EXT_HDBTABLE) {
|
|
345
361
|
// issue an error in case a .hdbmigrationtable file already exists
|
|
346
362
|
if (fs.existsSync(path.join(dbSrcDir, name + FILE_EXT_HDBMIGRATIONTABLE))) {
|
|
347
|
-
validationError = new BuildError(`Multiple files exist defining the same HANA artifact - [${path.join(relDbSrcDir, name + FILE_EXT_HDBMIGRATIONTABLE)}, ${path.join(relDbDestDir,
|
|
363
|
+
validationError = new BuildError(`Multiple files exist defining the same HANA artifact - [${path.join(relDbSrcDir, name + FILE_EXT_HDBMIGRATIONTABLE)}, ${path.join(relDbDestDir, fileName)}].\nEither annotate the model entity using @cds.persistence.journal or undeploy the file [${path.join('src', name + FILE_EXT_HDBMIGRATIONTABLE)}] using an undeploy.json file.`)
|
|
348
364
|
}
|
|
349
365
|
}
|
|
350
366
|
}
|
|
351
367
|
}
|
|
352
|
-
//
|
|
353
|
-
//
|
|
354
|
-
// cds build command is again executed
|
|
368
|
+
// The last-dev CSN shall only be updated, if all .hdbmigrationtable files could be successfully updated.
|
|
369
|
+
// Of course, .hdbmigrationtable files already written would need to be manually reverted before the
|
|
370
|
+
// cds build command is again executed.
|
|
355
371
|
await Promise.all(promises)
|
|
356
372
|
|
|
357
|
-
// ensure
|
|
358
373
|
try {
|
|
359
374
|
if (validationError) {
|
|
360
375
|
throw validationError
|
|
@@ -363,21 +378,16 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
363
378
|
} finally {
|
|
364
379
|
// update last-dev CSN version
|
|
365
380
|
if (afterImage) {
|
|
366
|
-
if (
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
await this.write(template).to(path.join(dbSrcDir, FILE_NAME_HDICONFIG))
|
|
374
|
-
}
|
|
381
|
+
if (!HanaBuildPlugin._toEqualIgnoreMeta(lastDev, afterImage)) {
|
|
382
|
+
await this.write(afterImage).to(lastDevCsnDir)
|
|
383
|
+
}
|
|
384
|
+
// add src/.hdiconfig if not existing
|
|
385
|
+
if (migrationTableFiles.length > 0 && !fs.existsSync(path.join(dbSrcDir, FILE_NAME_HDICONFIG))) {
|
|
386
|
+
const template = await HanaBuildPlugin._readTemplateAsJson('.hdiconfig-cloud')
|
|
387
|
+
await this.write(template).to(path.join(dbSrcDir, FILE_NAME_HDICONFIG))
|
|
375
388
|
}
|
|
376
389
|
}
|
|
377
390
|
}
|
|
378
|
-
if (!afterImage) {
|
|
379
|
-
throw new BuildError(`Inconsistent CDS compilation results - file ${lastDevCsnFolder} missing`)
|
|
380
|
-
}
|
|
381
391
|
return hdiPlugins
|
|
382
392
|
}
|
|
383
393
|
|
|
@@ -507,7 +517,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
507
517
|
|
|
508
518
|
async _validateMigrationTableFiles() {
|
|
509
519
|
const dbSrcDir = path.join(this.task.src, "src")
|
|
510
|
-
const migrationTableFiles =
|
|
520
|
+
const migrationTableFiles = getFiles(dbSrcDir, (res) => {
|
|
511
521
|
return fs.statSync(res).isFile() && path.extname(res) === FILE_EXT_HDBMIGRATIONTABLE
|
|
512
522
|
})
|
|
513
523
|
if (migrationTableFiles.length > 0) {
|
|
@@ -536,35 +546,38 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
536
546
|
}
|
|
537
547
|
}
|
|
538
548
|
|
|
539
|
-
|
|
540
549
|
/**
|
|
541
|
-
*
|
|
550
|
+
* Returns all hana native artifacts located in db/src/** workspace folders.
|
|
551
|
+
* @returns {Array} Array of workspace files, each entry contains the db src directory,
|
|
552
|
+
* the relative file path and the file name.
|
|
542
553
|
*/
|
|
543
|
-
async
|
|
544
|
-
const
|
|
554
|
+
async _getWorkspaceFiles() {
|
|
555
|
+
const dbPaths = new Set()
|
|
545
556
|
const workspaces = await getWorkspaces()
|
|
546
557
|
|
|
547
558
|
workspaces.forEach(workspace => {
|
|
548
559
|
const dbSrc = path.join(cds.root, workspace, 'db/src')
|
|
549
560
|
const dbCfg = path.join(cds.root, workspace, 'db/cfg')
|
|
550
561
|
if (fs.existsSync(dbSrc)) {
|
|
551
|
-
|
|
562
|
+
dbPaths.add(dbSrc)
|
|
552
563
|
}
|
|
553
564
|
if (fs.existsSync(dbCfg)) {
|
|
554
|
-
|
|
565
|
+
dbPaths.add(dbCfg)
|
|
555
566
|
}
|
|
556
567
|
})
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
for (const src of srcPaths) {
|
|
560
|
-
await this.copyNativeContent(src, dest, (entry) => {
|
|
568
|
+
const workspaceFiles = [...dbPaths].reduce((acc, src) => {
|
|
569
|
+
const files = getFiles(src, (entry) => {
|
|
561
570
|
if (entry.match(/(\/|\\)gen(\/|\\)?$/)) {
|
|
562
571
|
// skip gen folder content
|
|
563
572
|
return false
|
|
564
573
|
}
|
|
565
574
|
return true
|
|
566
575
|
})
|
|
567
|
-
|
|
576
|
+
files.forEach(file => acc.add({ dir: src, filePath: path.relative(src, file), fileName: path.basename(file) }))
|
|
577
|
+
return acc
|
|
578
|
+
}, new Set())
|
|
579
|
+
|
|
580
|
+
return [...workspaceFiles]
|
|
568
581
|
}
|
|
569
582
|
|
|
570
583
|
static async _readTemplateAsJson(template) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deploy",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"
|
|
4
|
+
"hdb": "^0",
|
|
5
|
+
"@sap/hdi-deploy": "^5"
|
|
5
6
|
},
|
|
6
7
|
"engines": {
|
|
7
|
-
"node": "^
|
|
8
|
+
"node": "^18 || ^20"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
|
-
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
|
11
|
+
"start": "node node_modules/@sap/hdi-deploy/deploy.js --use-hdb"
|
|
11
12
|
}
|
|
12
13
|
}
|