@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/index.js
CHANGED
|
@@ -1,102 +1,60 @@
|
|
|
1
|
-
const path = require('path')
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const term = require('../util/term')
|
|
3
|
+
const validate = require('./validate')
|
|
2
4
|
|
|
3
|
-
const
|
|
5
|
+
const { OPTIONS, COMMAND_INIT, PROJECT_FILES } = require('./constants')
|
|
6
|
+
const { readdirSync } = require('fs')
|
|
7
|
+
const { join } = require('path')
|
|
8
|
+
const { NODEJS, JAVA } = OPTIONS
|
|
4
9
|
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
NODEJS, JAVA,
|
|
8
|
-
HANA, APPROUTER, XSUAA, APPLICATION_LOGGING, ENTERPRISE_MESSAGING,
|
|
9
|
-
MTA, MULTITENANCY, PIPELINE,
|
|
10
|
-
TINY_SAMPLE, SAMPLE
|
|
11
|
-
} = OPTIONS
|
|
12
|
-
|
|
13
|
-
const cds = require('..'), { exists, readdir } = cds.utils
|
|
10
|
+
const cds = require('..'), { exists } = cds.utils
|
|
14
11
|
const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) ? console.debug : undefined
|
|
15
12
|
|
|
16
13
|
module.exports = class CDSGenerator {
|
|
17
|
-
constructor() {
|
|
18
|
-
this.cwd = process.cwd()
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
await this._validateProjectName(value);
|
|
30
|
-
await this._validateProjectFolder(path.join(this.cwd, value), this.cwd);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
return e
|
|
33
|
-
}
|
|
15
|
+
/** @returns {string[]} */
|
|
16
|
+
static #findPlugins(excluded) {
|
|
17
|
+
// actually needs to be sync to be usable in module.exports of dk/bin/init.js
|
|
18
|
+
const fromDk = readdirSync(join(__dirname, 'template'))
|
|
19
|
+
const fromPlugins = Object.keys(Object.fromEntries(require('./add').registered))
|
|
20
|
+
return [...fromDk, ...fromPlugins]
|
|
21
|
+
.filter(plugin => !excluded?.includes(plugin))
|
|
22
|
+
}
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
hint: `Choose any combination of features enriching the capabilities of your project. You can also add features later with ${term.bold('cds add')}`
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
title: 'Deployment',
|
|
73
|
-
description: 'Choose which way to deploy your project.',
|
|
74
|
-
default: '',
|
|
75
|
-
choices: [
|
|
76
|
-
{ name: 'Cloud Foundry: MTA Deployment', value: MTA },
|
|
77
|
-
// { name: 'Kyma: Helm Deployment', value: HELM },
|
|
78
|
-
{ name: 'Multitenancy', value: MULTITENANCY },
|
|
79
|
-
{ name: 'CI/CD Pipeline Integration', value: PIPELINE },
|
|
80
|
-
],
|
|
81
|
-
multiple: true,
|
|
82
|
-
target: 'add',
|
|
83
|
-
guiOptions: {
|
|
84
|
-
hint: `Choose any combination of features enriching the capabilities of your project. You can also add features later with ${term.bold('cds add')}`
|
|
85
|
-
}
|
|
86
|
-
}, {
|
|
87
|
-
title: 'Samples',
|
|
88
|
-
description: `Add sample content to your project.`,
|
|
89
|
-
default: '',
|
|
90
|
-
choices: [
|
|
91
|
-
{ name: 'Minimal Sample', value: TINY_SAMPLE },
|
|
92
|
-
{ name: 'Extended Sample with UI', value: SAMPLE }
|
|
93
|
-
],
|
|
94
|
-
multiple: true,
|
|
95
|
-
target: 'add',
|
|
96
|
-
guiOptions: {
|
|
97
|
-
hint: 'Speed up your ramp-up phase with sample files in your project.'
|
|
98
|
-
}
|
|
99
|
-
}]
|
|
24
|
+
static help({ exclude = [] } = {}) {
|
|
25
|
+
const plugins = this.readPlugins(exclude)
|
|
26
|
+
const nameFixedLength = Math.max(...plugins.map(plugin => plugin.name.length))
|
|
27
|
+
return plugins
|
|
28
|
+
.map(({name, module}) => {
|
|
29
|
+
const help = module.help?.() ?? ''
|
|
30
|
+
return ` *${name}*${' '.repeat(nameFixedLength - name.length)} - ${help}`
|
|
31
|
+
})
|
|
32
|
+
.join('\n\n')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @returns {{name: string, module: import('module')}[]}
|
|
37
|
+
*/
|
|
38
|
+
static readPlugins(excluded = []) {
|
|
39
|
+
const plugins = this.#findPlugins(excluded)
|
|
40
|
+
.map(plugin => ({
|
|
41
|
+
name: plugin,
|
|
42
|
+
module: cds.add.registered.get(plugin) ?? require('./template/' + plugin)
|
|
43
|
+
}))
|
|
44
|
+
const cmds = Object.values(OPTIONS)
|
|
45
|
+
const byPriority = (lhs, rhs) => {
|
|
46
|
+
const a = cmds.indexOf(lhs.name), b = cmds.indexOf(rhs.name)
|
|
47
|
+
if (a === -1 && b === -1) return 0
|
|
48
|
+
if (a === -1) return 1
|
|
49
|
+
if (b === -1) return -1
|
|
50
|
+
return a - b
|
|
51
|
+
}
|
|
52
|
+
return plugins.sort(byPriority)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
constructor() {
|
|
56
|
+
this.cwd = process.cwd()
|
|
57
|
+
this.uiConfig = require('./bas') // Used by CAP Generator
|
|
100
58
|
}
|
|
101
59
|
|
|
102
60
|
/**
|
|
@@ -113,7 +71,7 @@ module.exports = class CDSGenerator {
|
|
|
113
71
|
// `add data` can live without project metadata
|
|
114
72
|
const nonProjectFacets = { completion:1, data:1 }
|
|
115
73
|
const needsProject = facets.some(facet => !nonProjectFacets[facet])
|
|
116
|
-
if (needsProject && !PROJECT_FILES.
|
|
74
|
+
if (needsProject && !PROJECT_FILES.some(exists)) {
|
|
117
75
|
throw `The current folder doesn't seem to contain a project. None of the following files found: ${PROJECT_FILES.join(', ')}.`
|
|
118
76
|
}
|
|
119
77
|
|
|
@@ -124,12 +82,12 @@ module.exports = class CDSGenerator {
|
|
|
124
82
|
/**
|
|
125
83
|
* @param {string} projectName, the project name
|
|
126
84
|
*/
|
|
127
|
-
async
|
|
85
|
+
async init(projectName) {
|
|
128
86
|
await this.stepInit(projectName);
|
|
129
87
|
await this.stepEnd();
|
|
130
88
|
}
|
|
131
89
|
|
|
132
|
-
async stepInit(projectName, options) {
|
|
90
|
+
async stepInit(projectName, options) { // Also used by CAP Generator
|
|
133
91
|
if (options) {
|
|
134
92
|
// called from CAP generator with options
|
|
135
93
|
cds.cli = {
|
|
@@ -177,13 +135,18 @@ module.exports = class CDSGenerator {
|
|
|
177
135
|
async _process(facets) {
|
|
178
136
|
DEBUG?.(`Project path: ${cds.root}`);
|
|
179
137
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
138
|
+
const { options, command } = cds.cli
|
|
139
|
+
if (command === COMMAND_INIT) {
|
|
140
|
+
validate.projectName(this.projectName)
|
|
141
|
+
validate.projectFolder(this.cwd)
|
|
142
|
+
}
|
|
183
143
|
const plugins = command === COMMAND_INIT ? options.add : new Set(facets)
|
|
184
144
|
await this._fillTemplateList(plugins)
|
|
185
145
|
|
|
186
|
-
|
|
146
|
+
const cmds = Object.values(OPTIONS)
|
|
147
|
+
const byPriority = (a, b) => cmds.indexOf(a) - cmds.indexOf(b)
|
|
148
|
+
const sorted = Array.from(plugins).sort(byPriority)
|
|
149
|
+
for (const [i, facet] of Object.entries(sorted)) {
|
|
187
150
|
if (!cds.cli.options.dry) console.log(`Adding feature '${facet}'...`);
|
|
188
151
|
const template = this.templateList[i]
|
|
189
152
|
await template.run();
|
|
@@ -209,16 +172,16 @@ module.exports = class CDSGenerator {
|
|
|
209
172
|
return new Plugin(this)
|
|
210
173
|
} catch (err) {
|
|
211
174
|
if (err.code === 'MODULE_NOT_FOUND') {
|
|
212
|
-
const entries =
|
|
213
|
-
.filter(entry =>
|
|
214
|
-
!entry.startsWith('_') &&
|
|
215
|
-
!entry.endsWith('.js') &&
|
|
216
|
-
entry !== 'nodejs' &&
|
|
217
|
-
entry !== 'java'
|
|
218
|
-
);
|
|
175
|
+
const entries = this.constructor.readPlugins()
|
|
219
176
|
const fuzzySearch = require('../../bin/util/fuzzySearch')
|
|
220
|
-
const [bestMatch] = fuzzySearch(plugin, entries)
|
|
221
|
-
|
|
177
|
+
const [bestMatch] = fuzzySearch(plugin, entries.map(e => e.name))
|
|
178
|
+
const max = entries.reduce((max, {name}) => Math.max(max, name.length), 0)
|
|
179
|
+
const allFacetsText = entries.map(({name, module}) => {
|
|
180
|
+
const help = module.help?.() ?? ''
|
|
181
|
+
return `${term.bold(name) + ' '.repeat(max - name.length)} ${term.dim(help)}`
|
|
182
|
+
}).join('\n')
|
|
183
|
+
DEBUG?.(err)
|
|
184
|
+
throw `Unknown facet '${term.bold(plugin)}'. Did you mean ${term.bold(`cds add ${bestMatch}`)}?\n\nHaven't found the proper facet yet? Here are all supported facets:\n\n${allFacetsText}\n`
|
|
222
185
|
}
|
|
223
186
|
throw err
|
|
224
187
|
}
|
|
@@ -226,7 +189,6 @@ module.exports = class CDSGenerator {
|
|
|
226
189
|
|
|
227
190
|
async _fillTemplateList(plugins) {
|
|
228
191
|
const templates = new Map
|
|
229
|
-
|
|
230
192
|
for (let plugin of plugins) {
|
|
231
193
|
// Compat
|
|
232
194
|
if (plugin === 'helm' && cds.cli.options['internal-unified-runtime-charts']) {
|
|
@@ -262,12 +224,10 @@ module.exports = class CDSGenerator {
|
|
|
262
224
|
})
|
|
263
225
|
.map((entry) => entry[1])
|
|
264
226
|
|
|
265
|
-
// check debug to avoid lengthy computation when not in debug mode
|
|
266
227
|
DEBUG?.(`Features: ${this.templateList.map(({ name }) => name).join(', ')}`);
|
|
267
228
|
}
|
|
268
229
|
|
|
269
|
-
// CAP Generator
|
|
270
|
-
async stepEnd() {
|
|
230
|
+
async stepEnd() { // Also used by CAP Generator
|
|
271
231
|
for (const template of this.templateList) {
|
|
272
232
|
await template.finalize();
|
|
273
233
|
}
|
|
@@ -307,42 +267,4 @@ module.exports = class CDSGenerator {
|
|
|
307
267
|
options.add.add(NODEJS);
|
|
308
268
|
}
|
|
309
269
|
}
|
|
310
|
-
|
|
311
|
-
async _validateOptions() {
|
|
312
|
-
const { options, command } = cds.cli
|
|
313
|
-
if (options.force) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (command === COMMAND_INIT) {
|
|
318
|
-
await this._validateProjectName(this.projectName);
|
|
319
|
-
await this._validateProjectFolder(this.cwd);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
async _validateProjectName(projectName) {
|
|
324
|
-
if (!projectName) {
|
|
325
|
-
throw 'Specify a project name.'
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// remove duplicates by using a set
|
|
329
|
-
const invalidChars = new Set(projectName.match(REGEX_PROJECT_NAME));
|
|
330
|
-
if (invalidChars.size > 0) {
|
|
331
|
-
throw `Project name '${projectName}' contains at least one character ('${[...invalidChars]}') which is not supported in npm package names.
|
|
332
|
-
Specify a different project name by replacing characters with '_' or '-', for example '${projectName.replace(REGEX_PROJECT_NAME, '_')}' or '${projectName.replace(REGEX_PROJECT_NAME, '-')}'.`
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
async _validateProjectFolder(cwd) {
|
|
337
|
-
const existingProjectFile = PROJECT_FILES.find(exists)
|
|
338
|
-
if (existingProjectFile) {
|
|
339
|
-
let message;
|
|
340
|
-
if (cwd === cds.root) {
|
|
341
|
-
message = `You seem to be working in a project which is already initialized. Use ${term.bold('cds add')} to add more features.`;
|
|
342
|
-
} else {
|
|
343
|
-
message = `You seem to be trying to initialize an existing project. Use a different project name instead.`;
|
|
344
|
-
}
|
|
345
|
-
throw `${message}\nDetails: File '${existingProjectFile}' exists in the project folder which indicates an existing project. Use ${term.bold('cds add')} to add more features.`
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
270
|
}
|
package/lib/init/merge.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { EOL } = require('node:os')
|
|
2
|
+
const { inspect } = require('node:util')
|
|
2
3
|
const cds = require('../cds')
|
|
3
|
-
const { copy, read, write, exists } = cds.utils
|
|
4
|
+
const { copy, read, write, exists, path, yaml: YAML } = cds.utils
|
|
4
5
|
const { readYAML, writeYAML, readJSON } = require('../util/fs')
|
|
5
|
-
const { EOL } = require('node:os')
|
|
6
6
|
const { detectIndent } = require('./indent')
|
|
7
|
+
const { colors } = require('../util/term')
|
|
7
8
|
|
|
8
9
|
function _isObject(item) {
|
|
9
10
|
return item && typeof item === 'object' && !Array.isArray(item)
|
|
@@ -28,7 +29,7 @@ function _mergeObject(target, source) {
|
|
|
28
29
|
return target ?? source
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
async function
|
|
32
|
+
module.exports.sort = async function(path, key) {
|
|
32
33
|
const json = await read(path)
|
|
33
34
|
json[key] = Object.fromEntries(
|
|
34
35
|
Object.entries(json[key]).sort(([a],[b]) => a>b ? 1 : -1)
|
|
@@ -41,7 +42,7 @@ async function sort(path, key) {
|
|
|
41
42
|
* @param {string | string[]} from - either path to file (string) or lines from source gitignore (string[])
|
|
42
43
|
* @returns {Promise<string[]>} the lines of the updated .gitignore
|
|
43
44
|
*/
|
|
44
|
-
async function
|
|
45
|
+
module.exports.mergeGitignore = async function(into, from) {
|
|
45
46
|
const source = typeof from === 'string' ? (await read(from)).split(EOL) : from
|
|
46
47
|
|
|
47
48
|
if (typeof into === 'string' && !exists(into)) {
|
|
@@ -196,7 +197,7 @@ async function _mergeYAML(into, from, project, semantics = {}) {
|
|
|
196
197
|
}
|
|
197
198
|
} else if (YAML.isPair(node) && node.value?.items) {
|
|
198
199
|
collectionStack.unshift(node.value)
|
|
199
|
-
} else if (YAML.isScalar(node) && semantics.forceOverwrite && templateNode) {
|
|
200
|
+
} else if (YAML.isScalar(node) && semantics.forceOverwrite && templateNode && node.comment != 'cds.noOverwrite') {
|
|
200
201
|
node.value = templateNode.value ?? templateNode.items?.[0]?.value?.value
|
|
201
202
|
}
|
|
202
203
|
|
|
@@ -326,9 +327,11 @@ async function _mergeYAML(into, from, project, semantics = {}) {
|
|
|
326
327
|
})
|
|
327
328
|
.filter(item => !entryMap.get(item))
|
|
328
329
|
.forEach(item => {
|
|
330
|
+
if (!templateEntryMap.get(item)) throw 'Error: did not find entry in template for ' + inspect(item, { colors }) + ' in ' + from
|
|
329
331
|
const templateNode = templateEntryMap.get(item).node
|
|
330
332
|
item.at !== undefined ? targetNode.items.splice(item.at, 0, templateNode) : targetNode.add(templateNode)
|
|
331
333
|
})
|
|
334
|
+
|
|
332
335
|
}
|
|
333
336
|
},
|
|
334
337
|
}, source.contents)
|
|
@@ -372,7 +375,7 @@ async function _mergeYAML(into, from, project, semantics = {}) {
|
|
|
372
375
|
return target
|
|
373
376
|
}
|
|
374
377
|
|
|
375
|
-
async function
|
|
378
|
+
module.exports.removeFromYAML = async function (name, keyPaths) {
|
|
376
379
|
const yaml = await readYAML(name)
|
|
377
380
|
for (const keyPath of keyPaths) {
|
|
378
381
|
let node = yaml
|
|
@@ -389,7 +392,7 @@ async function removeFromYAML(name, keyPaths) {
|
|
|
389
392
|
await writeYAML(name, yaml)
|
|
390
393
|
}
|
|
391
394
|
|
|
392
|
-
async function
|
|
395
|
+
module.exports.removeFromYAMLArray = async function(name, keyPath, aliasToRemove) {
|
|
393
396
|
const yaml = await readYAML(name)
|
|
394
397
|
|
|
395
398
|
let node = yaml
|
|
@@ -414,16 +417,13 @@ async function removeFromYAMLArray(name, keyPath, aliasToRemove) {
|
|
|
414
417
|
await writeYAML(name, yaml)
|
|
415
418
|
}
|
|
416
419
|
|
|
417
|
-
|
|
418
|
-
const path = require('path')
|
|
419
|
-
|
|
420
420
|
/**
|
|
421
421
|
* @param {...(string | Object | YAML.Document)} src The source to merge from.
|
|
422
422
|
* @returns {{
|
|
423
423
|
* into: (dst: (string | Object | YAML.Document), options?: {project?: Object, semantics?: MergingSemantics}) => Promise<any>
|
|
424
424
|
* }} An object with an 'into' method to merge the sources into the specified destination.
|
|
425
425
|
*/
|
|
426
|
-
|
|
426
|
+
module.exports.merge = (...src) => {
|
|
427
427
|
return {
|
|
428
428
|
/**
|
|
429
429
|
* Merges sources into the specified destination.
|
|
@@ -447,11 +447,3 @@ const merge = (...src) => {
|
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
|
|
451
|
-
module.exports = {
|
|
452
|
-
merge,
|
|
453
|
-
sort,
|
|
454
|
-
mergeGitignore,
|
|
455
|
-
removeFromYAML,
|
|
456
|
-
removeFromYAMLArray
|
|
457
|
-
}
|