@sap/cds-dk 6.8.2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/bin/activate.js +15 -7
  2. package/bin/add.js +29 -15
  3. package/bin/bind.js +49 -116
  4. package/bin/build.js +114 -0
  5. package/bin/cds.js +67 -24
  6. package/bin/compile/index.js +2 -2
  7. package/bin/deploy/index.js +46 -39
  8. package/bin/deploy/to-hana.js +11 -8
  9. package/bin/deploy/to-postgres.js +8 -2
  10. package/bin/deploy/to-sqlite.js +0 -1
  11. package/bin/env.js +75 -41
  12. package/bin/eval.js +3 -3
  13. package/bin/extend.js +17 -10
  14. package/bin/help.js +22 -21
  15. package/bin/import.js +10 -7
  16. package/bin/init.js +38 -17
  17. package/bin/login.js +69 -55
  18. package/bin/logout.js +12 -9
  19. package/bin/migrate.js +10 -4
  20. package/bin/pull.js +12 -5
  21. package/bin/push.js +24 -13
  22. package/bin/repl.js +1 -0
  23. package/bin/run.js +25 -0
  24. package/bin/subscribe.js +13 -8
  25. package/bin/unsubscribe.js +15 -8
  26. package/bin/upgrade.js +15 -9
  27. package/bin/util/log.js +24 -0
  28. package/bin/version.js +124 -0
  29. package/bin/watch.js +1 -35
  30. package/bin/watched.js +39 -0
  31. package/lib/bind/KubernetesApiAccessor.js +2 -2
  32. package/lib/bind/bindingManager.js +1 -1
  33. package/lib/bind/bindingUtil.js +0 -9
  34. package/lib/bind/cfKeyProvider.js +10 -72
  35. package/lib/bind/index.js +114 -0
  36. package/lib/bind/kubernetesCredentialsProvider.js +2 -2
  37. package/lib/bind/userCdsrcJsonStorageProvider.js +7 -44
  38. package/lib/build/buildTaskEngine.js +355 -0
  39. package/lib/build/buildTaskFactory.js +284 -0
  40. package/lib/build/buildTaskHandler.js +240 -0
  41. package/lib/build/buildTaskProvider.js +22 -0
  42. package/lib/build/buildTaskProviderFactory.js +182 -0
  43. package/lib/build/constants.js +56 -0
  44. package/lib/build/index.js +21 -0
  45. package/lib/build/provider/buildTaskHandlerEdmx.js +83 -0
  46. package/lib/build/provider/buildTaskHandlerFeatureToggles.js +132 -0
  47. package/lib/build/provider/buildTaskHandlerInternal.js +228 -0
  48. package/lib/build/provider/buildTaskProviderInternal.js +370 -0
  49. package/lib/build/provider/fiori/index.js +167 -0
  50. package/lib/build/provider/hana/2migration.js +179 -0
  51. package/lib/build/provider/hana/index.js +522 -0
  52. package/lib/build/provider/hana/migrationtable.js +472 -0
  53. package/lib/build/provider/hana/template/.hdiconfig-all +163 -0
  54. package/lib/build/provider/hana/template/.hdiconfig-cloud +137 -0
  55. package/lib/build/provider/hana/template/.hdinamespace +4 -0
  56. package/lib/build/provider/hana/template/package.json +12 -0
  57. package/lib/build/provider/hana/template/undeploy.json +5 -0
  58. package/lib/build/provider/java/index.js +93 -0
  59. package/lib/build/provider/java-cf/index.js +1 -0
  60. package/lib/build/provider/mtx/index.js +37 -0
  61. package/lib/build/provider/mtx/resourcesTarBuilder.js +94 -0
  62. package/lib/build/provider/mtx-extension/index.js +131 -0
  63. package/lib/build/provider/mtx-sidecar/index.js +138 -0
  64. package/lib/build/provider/node-cf/index.js +1 -0
  65. package/lib/build/provider/nodejs/index.js +178 -0
  66. package/lib/build/util.js +263 -0
  67. package/lib/cds.js +9 -21
  68. package/lib/client/auth_manager.js +39 -16
  69. package/lib/client/helper/dependency_helper.js +7 -6
  70. package/lib/client/push.js +2 -1
  71. package/lib/client/settings_manager.js +10 -39
  72. package/lib/deploy/to-hana/hana.js +273 -0
  73. package/lib/deploy/to-hana/hdiDeployUtil.js +68 -0
  74. package/lib/deploy/to-hana/mtaUtil.js +171 -0
  75. package/lib/import/asyncapi/importAsyncAPI.js +3 -2
  76. package/lib/import/asyncapi/index.js +5 -2
  77. package/lib/import/asyncapi/parserContext.js +67 -26
  78. package/lib/import/asyncapi/utils.js +34 -3
  79. package/lib/import/common.js +40 -30
  80. package/lib/import/importapi.js +36 -35
  81. package/lib/index.js +12 -17
  82. package/lib/init/constants.js +36 -71
  83. package/lib/init/index.js +18 -52
  84. package/lib/init/template/_merging/registry-mta.js +21 -3
  85. package/lib/init/template/approuter/files/mta.yaml.hbs +29 -29
  86. package/lib/init/template/approuter/files/values.yaml.hbs +5 -5
  87. package/lib/init/template/approuter/files/xs-app.json.hbs +8 -2
  88. package/lib/init/template/approuter/index.js +7 -8
  89. package/lib/init/template/auditlog/files/mta.yaml.hbs +5 -5
  90. package/lib/init/template/auditlog/files/package.json.hbs +13 -13
  91. package/lib/init/template/auditlog/index.js +3 -3
  92. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +22 -22
  93. package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +3 -3
  94. package/lib/init/template/connectivity/files/mta.yaml.hbs +14 -0
  95. package/lib/init/template/connectivity/files/package.json.hbs +17 -0
  96. package/lib/init/template/connectivity/index.js +21 -4
  97. package/lib/init/template/data/index.js +5 -1
  98. package/lib/init/template/destination/files/mta.yaml.hbs +14 -0
  99. package/lib/init/template/destination/files/package.json.hbs +17 -0
  100. package/lib/init/template/{destinations → destination}/index.js +19 -13
  101. package/lib/init/template/enterprise-messaging/files/event-mesh.json.hbs +3 -3
  102. package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +5 -5
  103. package/lib/init/template/enterprise-messaging/files/package.json.hbs +9 -9
  104. package/lib/init/template/enterprise-messaging/files/xs-security.json.hbs +19 -0
  105. package/lib/init/template/enterprise-messaging/index.js +27 -6
  106. package/lib/init/template/enterprise-messaging-shared/files/event-mesh.json.hbs +3 -3
  107. package/lib/init/template/enterprise-messaging-shared/files/mta.yaml.hbs +5 -5
  108. package/lib/init/template/enterprise-messaging-shared/files/package.json.hbs +9 -9
  109. package/lib/init/template/enterprise-messaging-shared/index.js +4 -5
  110. package/lib/init/template/extensibility/files/package.json.hbs +10 -10
  111. package/lib/init/template/extensibility/index.js +8 -9
  112. package/lib/init/template/file-based-messaging/files/package.json.hbs +9 -9
  113. package/lib/init/template/file-based-messaging/index.js +3 -4
  114. package/lib/init/template/hana/files/db/package.json +1 -1
  115. package/lib/init/template/hana/files/mta.yaml.hbs +21 -21
  116. package/lib/init/template/hana/files/package.json.hbs +16 -22
  117. package/lib/init/template/hana/files/values.yaml.hbs +1 -1
  118. package/lib/init/template/hana/index.js +5 -15
  119. package/lib/init/template/helm/files/Chart.yaml.hbs +4 -4
  120. package/lib/init/template/helm/files/values.yaml.hbs +6 -6
  121. package/lib/init/template/helm/index.js +5 -10
  122. package/lib/init/template/helm/subcharts/content-deployment/Chart.yaml +2 -0
  123. package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +37 -31
  124. package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +13 -14
  125. package/lib/init/template/helm/subcharts/content-deployment/templates/secret.yaml +2 -2
  126. package/lib/init/template/helm/subcharts/content-deployment/templates/service-account.yaml +1 -1
  127. package/lib/init/template/helm/subcharts/content-deployment/templates/service-binding.yaml +3 -3
  128. package/lib/init/template/helm/subcharts/content-deployment/values.md +116 -116
  129. package/lib/init/template/helm/subcharts/service-instance/Chart.yaml +2 -0
  130. package/lib/init/template/helm/subcharts/service-instance/templates/_helpers.tpl +9 -9
  131. package/lib/init/template/helm/subcharts/service-instance/templates/serviceinstance.yaml +2 -2
  132. package/lib/init/template/helm/subcharts/service-instance/values.md +15 -15
  133. package/lib/init/template/helm/subcharts/web-application/Chart.yaml +2 -0
  134. package/lib/init/template/helm/subcharts/web-application/templates/NOTES.txt +15 -0
  135. package/lib/init/template/helm/subcharts/web-application/templates/_helpers.tpl +23 -23
  136. package/lib/init/template/helm/subcharts/web-application/templates/api-rule.yaml +4 -4
  137. package/lib/init/template/helm/subcharts/web-application/templates/deployment.yaml +17 -17
  138. package/lib/init/template/helm/subcharts/web-application/templates/network-policy.yaml +24 -3
  139. package/lib/init/template/helm/subcharts/web-application/templates/pod-disruption-budget.yaml +3 -3
  140. package/lib/init/template/helm/subcharts/web-application/templates/secret.yaml +2 -2
  141. package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +1 -1
  142. package/lib/init/template/helm/subcharts/web-application/templates/service-binding.yaml +3 -3
  143. package/lib/init/template/helm/subcharts/web-application/templates/service.yaml +3 -3
  144. package/lib/init/template/helm/subcharts/web-application/values.md +141 -123
  145. package/lib/init/template/helm/subcharts/web-application/values.schema.json +7 -0
  146. package/lib/init/template/helm/subcharts/web-application/values.yaml +1 -0
  147. package/lib/init/template/html5-repo/index.js +4 -5
  148. package/lib/init/template/java/index.js +5 -5
  149. package/lib/init/template/kibana-logging/files/mta.yaml.hbs +5 -5
  150. package/lib/init/template/kibana-logging/files/package.json.hbs +9 -9
  151. package/lib/init/template/kibana-logging/index.js +3 -4
  152. package/lib/init/template/lint/index.js +3 -3
  153. package/lib/init/template/mta/files/mta.yaml.hbs +14 -14
  154. package/lib/init/template/mta/files/package.json +5 -0
  155. package/lib/init/template/mta/index.js +12 -13
  156. package/lib/init/template/mtx/index.js +2 -2
  157. package/lib/init/template/multitenancy/files/mta.yaml.hbs +29 -27
  158. package/lib/init/template/multitenancy/files/package.json.hbs +17 -14
  159. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +7 -7
  160. package/lib/init/template/multitenancy/files/values.yaml.hbs +19 -19
  161. package/lib/init/template/multitenancy/index.js +14 -16
  162. package/lib/init/template/nodejs/files/package.json.hbs +1 -1
  163. package/lib/init/template/nodejs/index.js +5 -8
  164. package/lib/init/template/redis-messaging/files/mta.yaml.hbs +5 -5
  165. package/lib/init/template/redis-messaging/files/package.json.hbs +9 -9
  166. package/lib/init/template/redis-messaging/index.js +4 -5
  167. package/lib/init/template/sample/files/app/_i18n/i18n.properties +43 -0
  168. package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +14 -0
  169. package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +114 -0
  170. package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +8 -0
  171. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +11 -0
  172. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +129 -0
  173. package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +57 -0
  174. package/lib/init/template/sample/files/app/common.cds +263 -0
  175. package/lib/init/template/sample/files/app/index.html +30 -0
  176. package/lib/init/template/sample/files/app/services.cds +5 -0
  177. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +5 -0
  178. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books.csv +6 -0
  179. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books_texts.csv +5 -0
  180. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Genres.csv +16 -0
  181. package/lib/init/template/sample/files/db/schema.cds +31 -0
  182. package/lib/init/template/sample/files/nodejs/admin-service.js +12 -0
  183. package/lib/init/template/sample/files/nodejs/cat-service.js +26 -0
  184. package/lib/init/template/sample/files/srv/admin-service.cds +5 -0
  185. package/lib/init/template/sample/files/srv/cat-service.cds +16 -0
  186. package/lib/init/template/sample/index.js +24 -0
  187. package/lib/init/template/sample-tiny/index.js +39 -0
  188. package/lib/init/template/samples/index.js +5 -56
  189. package/lib/init/template/sqlite/files/package.json.hbs +13 -13
  190. package/lib/init/template/sqlite/index.js +2 -2
  191. package/lib/init/template/templateBase.js +24 -1
  192. package/lib/init/template/toggles/files/package.json.hbs +10 -10
  193. package/lib/init/template/toggles/index.js +3 -3
  194. package/lib/init/template/typer/files/gitignore +1 -0
  195. package/lib/init/template/typer/files/package.json +8 -0
  196. package/lib/init/template/typer/files/xsconfig.json +9 -0
  197. package/lib/init/template/typer/index.js +36 -0
  198. package/lib/init/template/xsuaa/files/mta.yaml.hbs +12 -12
  199. package/lib/init/template/xsuaa/files/package.json.hbs +13 -13
  200. package/lib/init/template/xsuaa/files/values.yaml.hbs +8 -8
  201. package/lib/init/template/xsuaa/index.js +8 -19
  202. package/lib/init/util/merge.js +73 -59
  203. package/lib/init/util/mvn.js +21 -17
  204. package/lib/init/util/projectReader.js +49 -87
  205. package/lib/init/util/xml.js +14 -23
  206. package/lib/util/cfUtil.js +366 -0
  207. package/lib/util/command.js +3 -3
  208. package/lib/util/gitUtil.js +55 -0
  209. package/lib/util/version.js +27 -0
  210. package/npm-shrinkwrap.json +339 -277
  211. package/package.json +6 -6
  212. package/CHANGELOG.md +0 -1453
  213. package/bin/build/all.js +0 -88
  214. package/bin/build/index.js +0 -82
  215. package/lib/compile/index.js +0 -14
  216. /package/lib/init/template/{samples → sample-tiny}/files/nodejs/db/data/my.bookshop-Books.csv +0 -0
  217. /package/lib/init/template/{samples → sample-tiny}/files/nodejs/db/data-model.cds +0 -0
  218. /package/lib/init/template/{samples → sample-tiny}/files/nodejs/srv/cat-service.cds.hbs +0 -0
@@ -1,7 +1,7 @@
1
1
  module.exports = Object.assign(deploy, {
2
- options: ['--to', '--tunnel-address', '--vcap-file'],
3
- flags: [ '--no-save', '--auto-undeploy', '--dry', '--xdry', '--with-mocks', '--store-credentials', '--bind' ],
4
- shortcuts: ['-2'],
2
+ options: ['--to', '--for', '--tunnel-address', '--vcap-file', '--delta-from' ],
3
+ flags: ['--no-save', '--auto-undeploy', '--dry', '--xdry', '--with-mocks', '--store-credentials', '--model-only', '--with-auto-schema-evolution' ],
4
+ shortcuts: ['-2', '-4'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
@@ -21,6 +21,17 @@ module.exports = Object.assign(deploy, {
21
21
  Where <database> is 'sqlite' or 'hana', <database specific parameter>
22
22
  can be a path to the database file (sqlite) or the service name (hana).
23
23
 
24
+ *-4* | *--for* <profile> (only in combination with *--to hana*)
25
+
26
+ Specify the profile to be used to call 'cds bind' after successful deployment.
27
+ Refer to the help of 'cds bind' for further information.
28
+ The profile *hybrid* is used by default.
29
+
30
+ *--profile* <profile,...>
31
+
32
+ Loads the configuration data for the specified profile(s). 'cds build' is executed based on this profile settings.
33
+ The *development* profile is used by default.
34
+
24
35
  *--dry*
25
36
 
26
37
  Just print the SQL statements without executing them.
@@ -31,7 +42,7 @@ module.exports = Object.assign(deploy, {
31
42
 
32
43
  *--no-save*
33
44
 
34
- Do not modify the package.json file.
45
+ Deprecated. The package.json file is no longer modified.
35
46
 
36
47
  *--auto-undeploy* (beta feature)
37
48
 
@@ -55,6 +66,20 @@ module.exports = Object.assign(deploy, {
55
66
  which has been replaced by creating and storing connection information in file
56
67
  *.cdsrc-private.json*.
57
68
 
69
+ *--model-only*
70
+
71
+ This is a schema evolution option, to only update the information about
72
+ the prior cds model. In combination with *--dry* it writes the CSN to
73
+ stdout, so you can store it to a file. Use that to migrate existing
74
+ databases to auto schema evolution.
75
+
76
+ *--delta-from* <filename>
77
+
78
+ This is a schema evolution option, to read the information about the
79
+ prior cds model from the given file, which has been created by
80
+ *cds deploy --model-only --dry*. When used with *--dry* it writes the
81
+ generated SQL to stdout.
82
+
58
83
 
59
84
  # EXAMPLES
60
85
  cds deploy --to sqlite:db
@@ -65,16 +90,20 @@ module.exports = Object.assign(deploy, {
65
90
 
66
91
  const cds = require('../../lib/cds')
67
92
 
68
- async function deploy (_model, options) { // NOSONAR
93
+ async function deploy(_model, options) { // NOSONAR
69
94
 
70
- if (options.bind) {
71
- console.log (`Option '--bind' is now active by default and can therefore be omitted.`)
95
+ if (process.stdout.isTTY && options['no-save']) {
96
+ console.warn('Option --no-save is deprecated. By default, package.json will no longer be modified.')
72
97
  }
73
98
 
74
- if (_model && _model.length === 0) _model = undefined // empty array (no model args) means default models
75
- const { 'to':url, 'no-save':no_save = cds.env.deploy.no_save } = options
76
- if (!options.mocked) { options.mocked = options['with-mocks'] }
77
- if (!url && !cds.env.requires.db) throw new Error(
99
+ if (_model && _model.length === 0) _model = undefined // empty array (no model args) means default models
100
+
101
+ // IMPORTANT: call plugins before subsequent access to cds.env
102
+ await cds.plugins
103
+
104
+ const { 'to': url } = options
105
+ if (!options.mocked && options['with-mocks']) options.mocked = true
106
+ if (!url && !cds.env.requires.db) throw new Error(
78
107
  `Please specify a database kind or url, e.g.:
79
108
 
80
109
  cds deploy --to sql
@@ -83,44 +112,22 @@ async function deploy (_model, options) { // NOSONAR
83
112
  `)
84
113
 
85
114
  const conf = cds.env.requires.db || {}
86
- const [,_kind,_db] = /(\w+)?(?::(.*))?/.exec(url||'')
87
- const kind = _kind || conf.dialect || conf.use || conf.kind
115
+ const [, _kind, _db] = /(\w+)?(?::(.*))?/.exec(url || '')
116
+ const kind = _kind || conf.dialect || conf.kind
88
117
 
89
118
  try {
90
- var deployer = require ('./to-'+kind)
119
+ var deployer = require('./to-' + kind)
91
120
  } catch (e) {
92
121
  if (e.code === 'MODULE_NOT_FOUND') {
93
122
  throw new Error(`Didn't find a deployer module for '${kind}'`)
94
123
  }
95
124
  }
96
125
  try {
97
- await deployer.deploy (_model, _db, options)
98
- if (options.dry) return
99
- if (kind === 'hana') return // REVISIT: the hana deployer is a bit special
100
- if (url && !no_save) await update_package_json (_kind, _model, _db)
126
+ await deployer.deploy(_model, _db, options)
101
127
  } catch (e) {
102
128
  if (e.code === 'MODEL_NOT_FOUND') {
103
- if (!_model) throw new Error ('No .cds models found, please specify one as an argument')
104
- throw new Error (`No cds models found at/in '${_model}'`)
129
+ if (!_model) throw new Error('No .cds models found, please specify one as an argument')
130
+ throw new Error(`No cds models found at/in '${_model}'`)
105
131
  } else throw e
106
132
  }
107
133
  }
108
-
109
-
110
- async function update_package_json (kind, model, database) {
111
- const { fs, path, isfile } = cds.utils
112
- const { readFile, writeFile } = fs.promises
113
- const package_json = path.resolve (cds.root, 'package.json'), exists = isfile (package_json)
114
- const conf = exists ? JSON.parse (await readFile (package_json)) : {}
115
- conf.cds?.requires || (conf.cds = {requires: {}})
116
- const requires = conf.cds.requires
117
- const { schema_evolution } = requires.db ?? {}
118
- requires.db = cds.env.requires.db = { kind, model }
119
- if (database) requires.db.credentials = { database }
120
- else if (kind === 'sqlite') requires.db.credentials = { database:'db.sqlite' }
121
- if (schema_evolution) requires.db.schema_evolution = schema_evolution
122
- await writeFile (package_json, JSON.stringify(conf,null,2))
123
- console.log (`/> ${ exists ? 'updated' : 'created' } .${path.sep}package.json`)
124
- }
125
-
126
- /* eslint no-console: off */
@@ -1,10 +1,13 @@
1
- const { join } = require('path');
1
+ exports.deploy = (model, serviceName, options) => {
2
+ const hanaDeployer = require('../../lib/deploy/to-hana/hana');
2
3
 
3
- exports.deploy = (_model, _db, options) => {
4
- // locate deployer relative to sap/cds
5
- const cdsHome = require('../../lib/cds').home;
6
- const deployer = require(join(cdsHome, 'bin/deploy/to-hana'));
7
-
8
- const bind = !options['store-credentials'] ? require('../bind') : undefined;
9
- return deployer.deploy(_model, _db, options, bind);
4
+ return hanaDeployer.deploy({
5
+ ...options,
6
+ model,
7
+ serviceName,
8
+ tunnelAddress: options['tunnel-address'],
9
+ vcapFile: options['vcap-file'],
10
+ hdiOptions: { autoUndeploy: options['auto-undeploy'] },
11
+ storeCredentials: options['store-credentials']
12
+ });
10
13
  }
@@ -1,4 +1,10 @@
1
- exports.deploy = function deploy_to_sql (model, db, options) {
1
+ exports.deploy = async function deploy_to_sql(model, db = 'db', options) {
2
2
  options.dialect = 'postgres'
3
- return require('./to-sql') .deploy (model, db, options)
3
+ try {
4
+ // Connect here to be able to later on disconnect in the finally
5
+ if (!db.run) db = await require('../../lib/cds').connect.to(db)
6
+ await require('./to-sql').deploy(model, db, options)
7
+ } finally {
8
+ await db?.disconnect?.()
9
+ }
4
10
  }
@@ -1,6 +1,5 @@
1
1
  exports.deploy = function deploy_to_sqlite (_model, _db, options) {
2
2
 
3
- if (options.dialect === 'postgres' && !options.dry) console.error('\nDeploying into a PostgreSQL database is not yet supported\n')
4
3
  if (options.dialect === 'h2' && !options.dry) console.error('\nDeploying into a H2 database is not yet supported\n')
5
4
 
6
5
  const cds = require('../../lib/cds')
package/bin/env.js CHANGED
@@ -1,24 +1,44 @@
1
1
  module.exports = Object.assign (env, {
2
- options: ['--for', '--mocked'], flags: ['--process-env', '--resolve-bindings'], shortcuts: ['-4', undefined, '-P', '-b'],
2
+ options: ['--for', '--mocked'],
3
+ flags: ['--keys', '--properties', '--list', '--json', '--raw', '--process-env', '--resolve-bindings', '--sources'],
4
+ shortcuts: ['-4', 0, '-k', '-p', '-l', '-j', '-r', '-P', '-b'],
3
5
  help: `
4
6
  # SYNOPSIS
5
7
 
6
- *cds env* [get] [<key>]
7
- *cds env* list [<key>]
8
- *cds env* ls [<key>]
9
- *cds env* src
8
+ *cds env* [<key>] [<options>]
10
9
 
11
10
  # EXPLANATION
12
11
 
13
12
  Displays the effective configuration for the given key, or all of the
14
- current environment. By default and when using *get* the output is in
15
- _object_ format. When using *list* or *ls* it's in _.properties_ format.
13
+ current environment.
16
14
 
17
15
  # OPTIONS
18
16
 
17
+ *--sources*
18
+
19
+ Lists the sources from with the current env has been compiled.
20
+
21
+ *-k* | *--keys*
22
+
23
+ Prints (top-level) keys of matching properties only
24
+
25
+ *-p* | *--properties*
26
+ *-l* | *--list*
27
+
28
+ Prints output in .properties format
29
+
30
+ *-j* | *--json*
31
+
32
+ Prints output in JSON format
33
+
34
+ *-r* | *--raw*
35
+
36
+ Prints output with minimum formatting or decoration
37
+
19
38
  *-4* | *--for* | *--profile* <profile,...>
20
39
 
21
40
  Load configuration for the specified profile(s).
41
+ The *development* profile is used by default.
22
42
 
23
43
  *-P* | *--process-env*
24
44
 
@@ -26,74 +46,80 @@ module.exports = Object.assign (env, {
26
46
 
27
47
  *-b* | *--resolve-bindings*
28
48
 
29
- Resolve _cds bind_ bindings.
49
+ Resolve remote service bindings configured via *cds bind*.
30
50
  `})
31
51
 
32
- const path = require('path')
33
-
34
- const {inspect} = require('util')
35
- const term = require('../lib/util/term')
36
- const info = (s) => process.stdout.isTTY ? term.info (s) : s
37
52
 
38
53
  async function env ([cmd, key, value], options={}) {
39
54
 
40
55
  if (options.for) process.env.CDS_ENV = options.for
41
56
 
42
57
  const cds = require('../lib/cds')
58
+ const path = require('path')
43
59
  const fn = (
44
60
  options["process-env"] ? processEnvCommands[cmd] :
61
+ options.sources ? commands.sources :
45
62
  commands[cmd] || ((key = cmd), commands.get)
46
63
  )
47
64
 
65
+ // Ensure loading plugins before calling cds.env!
66
+ await cds.plugins
67
+
48
68
  let env = cds.env
49
69
  if (options["resolve-bindings"]) {
50
70
  const BindingManager = require('../lib/bind/bindingManager')
51
71
  const bindingManager = new BindingManager({ env, silent: true })
52
72
  const bindingEnv = await bindingManager.bindingEnv()
53
73
  Object.assign(process.env, bindingEnv)
54
- env = cds.env.for(options.for || 'cds') // reload env
55
74
  }
56
75
  env['_home_cds-dk'] = path.resolve(__dirname, '..') // to help tools find the DK
57
76
 
58
- if (!options.for && options.mocked) await cds.service.bindings
59
- return fn (env, key, value)
77
+ if (!options.for && options.mocked) await cds.service.bindings
78
+ return fn (env, key, value, options)
60
79
  }
61
80
 
62
81
 
82
+ const { inspect, format } = require('node:util')
63
83
  const commands = {
64
84
 
65
- get ls() { return this.list },
66
-
67
- // eslint-disable-next-line no-unused-vars
68
- list (conf, _key, val) { // NOSONAR
69
- (function _list (o = _key ? conf.get(_key.replace(/^cds\./,'')) : conf, key = _key || '') { // NOSONAR, ...tzefix!!
70
- if (o && typeof o === 'object' && !Array.isArray(o)) for (let p of Object.keys(o).sort()) {
71
- const d = Reflect.getOwnPropertyDescriptor (o,p)
72
- if (d.value === undefined && d.get === undefined) continue
73
- if (o[p] !== undefined) _list (o[p], (key ? key+'.' : '')+p)
74
- } else console.log (info(key), '=',o)
75
- })()
76
- },
85
+ json: (env,k,v,o) => commands.get (env,k,v,{...o,json:true}),
86
+ list: (env,k,v,o) => commands.get (env,k,v,{...o,list:true}),
87
+ ls: (env,k,v,o) => commands.get (env,k,v,{...o,list:true}),
77
88
 
78
- // eslint-disable-next-line no-unused-vars
79
- src (conf, key, val) {
89
+ sources: (..._) => commands.src (..._),
90
+ src (conf,k,v,o) {
91
+ if (!o.raw) console.log('\nCurrent cds.env was loaded from these sources:')
80
92
  console.log()
81
93
  for (let each of [...conf._sources].reverse()) console.log (' ', each)
82
94
  console.log()
83
95
  },
84
96
 
85
- get (conf, key, val) {
86
- if (!process.stdout.isTTY) return commands.json (conf, key, val)
87
- // tty: display formatted object
88
- const obj = key ? conf.get(key.replace(/^cds\./,'')) : conf
89
- console.log (inspect (obj, {depth:22,colors:true}).replace(/\s+use:.*\[Getter\][^,]+,?/g,''))
90
- },
97
+ get (conf, key, val, options) {
98
+ let fmt = !process.stdout.isTTY ? x => inspect (x, {depth:22}) : x => inspect (x, {depth:22,colors:true})
99
+
100
+ let obj = (
101
+ !key ? conf
102
+ : key === 'process.env' ? process.env
103
+ : key.startsWith('process.env') ? process.env[key.slice(12)]
104
+ : conf.get(key.replace(/^cds\./,''))
105
+ )
106
+
107
+ if (options.json) {
108
+ fmt = x => JSON.stringify(x,0,2)
109
+ }
110
+ if (options.raw) {
111
+ fmt = x => typeof x !== 'object' ? x : JSON.stringify(x)
112
+ }
91
113
 
92
- // eslint-disable-next-line no-unused-vars
93
- json (conf, key, val) {
94
- const obj = (key ? conf.get(key.replace(/^cds\./,'')) : conf)
95
- const str = JSON.stringify(obj, null, 2)
96
- return console.log (str ? str.replace(/\s+use:.*\[Getter\][^,]+,?/g,'') : str)
114
+ if (options.list || options.properties) {
115
+ return console.log(), _list(obj,key,fmt), console.log()
116
+ }
117
+
118
+ if (options.keys) {
119
+ return console.log (`\n ${Object.keys(obj).map(k=>fmt(k)).join('\n ')}\n`)
120
+ }
121
+
122
+ console.log (fmt(obj))
97
123
  },
98
124
 
99
125
  set () {
@@ -101,6 +127,14 @@ const commands = {
101
127
  }
102
128
  }
103
129
 
130
+ function _list (o, key='', fmt = format) {
131
+ if (o && typeof o === 'object' && !Array.isArray(o)) for (let p of Object.keys(o).sort()) {
132
+ const d = Reflect.getOwnPropertyDescriptor (o,p)
133
+ if (d.value === undefined && d.get === undefined) continue
134
+ if (o[p] !== undefined) _list (o[p], (key ? key+'.' : '')+p, fmt)
135
+ } else console.log (key,'=',fmt(o))
136
+ }
137
+
104
138
  const processEnvCommands = {
105
139
  get [undefined]() { return processEnvCommands.list },
106
140
  get ''() { return processEnvCommands.list },
package/bin/eval.js CHANGED
@@ -4,9 +4,9 @@ module.exports = Object.assign ( run, { help: `
4
4
  *cds eval* <code snippet>
5
5
  *cds -e* <code snippet>
6
6
 
7
- Evaluates and executes the given JavaScript code snippet. The snippet can refer
8
- to the already loaded *cds* variable. If it starts with a '.', 'cds' is
9
- automatically prepended, like shown in the following examples.
7
+ Evaluates and executes the given JavaScript code snippet. The snippet can
8
+ refer to the already loaded *cds* variable. If it starts with a '.', 'cds'
9
+ is automatically prepended, like shown in the following examples.
10
10
  The -e variant is just a reminiscence to node.
11
11
 
12
12
  # EXAMPLES
package/bin/extend.js CHANGED
@@ -12,17 +12,20 @@ module.exports = Object.assign(extend, {
12
12
  Create an extension project from an extensible SaaS app.
13
13
  Obtain the app URL from the SaaS application provider.
14
14
 
15
- To facilitate running this multiple times against the same app, refer to the *cds login* command.
15
+ To facilitate running this multiple times against the same app, refer to the
16
+ *cds login* command.
16
17
 
17
18
  # OPTIONS
18
19
 
19
20
  *-d* | *--directory* <project-extension-directory>
20
21
 
21
- Specify the target directory of your extension project. By default, the current working directory is used.
22
+ Specify the target directory of your extension project. By default, the
23
+ current working directory is used.
22
24
 
23
25
  *-s* | *--subdomain* <tenant-subdomain>
24
26
 
25
- Specify your tenant's subdomain. By default, it's determined from the app URL.
27
+ Specify your tenant's subdomain. By default, it's determined from the
28
+ app URL.
26
29
 
27
30
  *-p* | *--passcode* <passcode>
28
31
 
@@ -34,24 +37,28 @@ module.exports = Object.assign(extend, {
34
37
 
35
38
  *-c* | *--clientid* <clientid>
36
39
 
37
- Client ID for authentication. This will override the default Client ID from environment.
40
+ Client ID for authentication. This will override the default Client ID
41
+ from environment.
38
42
 
39
43
  *--force*
40
44
 
41
- Overwrite existing content. Make sure you are using a version control system (like git) to avoid data loss.
45
+ Overwrite existing content. Make sure you are using a version control
46
+ system (like git) to avoid data loss.
42
47
 
43
48
  *--templates*
44
49
 
45
- Download only the templates provided by the SaaS application you want to extend.
50
+ Download only the templates provided by the SaaS application you want to
51
+ extend.
46
52
 
47
53
  # SEE ALSO
48
54
 
49
55
  *cds activate* to activate an extension project.
50
56
 
51
- # SEE ALSO
52
-
53
- *cds pull* to get the CDS model of a SaaS app based on current MTX Services (@sap/cds-mtxs).
54
- https://cap.cloud.sap/docs/guides/multitenancy/mtxs for information on @sap/cds-mtxs.
57
+ *cds pull* to get the CDS model of a SaaS app based on current MTX Services
58
+ (@sap/cds-mtxs).
59
+
60
+ https://cap.cloud.sap/docs/guides/multitenancy/mtxs for information on
61
+ @sap/cds-mtxs.
55
62
 
56
63
  `})
57
64
 
package/bin/help.js CHANGED
@@ -8,27 +8,28 @@ module.exports = exports = Object.assign (help, {formatHelp, help:`
8
8
 
9
9
  # COMMANDS
10
10
 
11
- *i* | *init* jump-start cds-based projects
12
- *a* | *add* add a feature to an existing project
13
- *y* | *bind* bind application to remote services
14
- *m* | *import* add models from external sources
15
- *c* | *compile* compile cds models to different outputs
16
- *p* | *parse* parses given cds models
17
- *s* | *serve* run your services in local server
18
- *w* | *watch* run and restart on file changes
19
- *r* | *repl* read-eval-event loop
20
- *e* | *env* inspect effective configuration
21
- *b* | *build* prepare for deployment
22
- *d* | *deploy* deploy to databases or cloud
23
- *l* | *login* login to extendable SaaS application
24
- *x* | *extend* create extension project from SaaS application
25
- *t* | *lint* [beta] run linter for env or model checks
26
- *v* | *version* get detailed version information
27
- *?* | *help* get detailed usage information
28
- * * | *pull* pull the base model for your SaaS app extension.
29
- * * | *push* push your extension to the SaaS app in order to enable or update it
30
- * * | *subscribe* subscribe a tenant to a multitenant SaaS app
31
- * * | *mock* call _cds serve_ with mocked service
11
+ *i* | *init* jump-start cds-based projects
12
+ *a* | *add* add a feature to an existing project
13
+ *y* | *bind* bind application to remote services
14
+ *m* | *import* add models from external sources
15
+ *c* | *compile* compile cds models to different outputs
16
+ *p* | *parse* parses given cds models
17
+ *s* | *serve* run your services in local server
18
+ *w* | *watch* run and restart on file changes
19
+ * * | *mock* call _cds serve_ with mocked service
20
+ *r* | *repl* read-eval-event loop
21
+ *e* | *env* inspect effective configuration
22
+ *b* | *build* prepare for deployment
23
+ *d* | *deploy* deploy to databases or cloud
24
+ * * | *subscribe* subscribe a tenant to a multitenant SaaS app
25
+ * * | *unsubscribe* unsubscribe a tenant from a multitenant SaaS app
26
+ *l* | *login* login to extensible multitenant SaaS app
27
+ * * | *logout* logout from extensible multitenant SaaS app
28
+ * * | *pull* pull base model of extensible SaaS app
29
+ * * | *push* push extension to extensible SaaS app
30
+ *t* | *lint* [beta] run linter for env or model checks
31
+ *v* | *version* get detailed version information
32
+ *?* | *help* get detailed usage information
32
33
 
33
34
  Learn more about each command using:
34
35
  *cds help* <command> or
package/bin/import.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  module.exports = Object.assign(_import, {
3
2
  _name: 'import',
4
3
  options: ['--out', '--as', '--include-namespaces', '--from'],
@@ -34,13 +33,16 @@ module.exports = Object.assign(_import, {
34
33
  Writes the converted csn to stdout only.
35
34
 
36
35
  *-as | --as <output_file_format>*
37
- Converts the input file into one of these supported formats "cds", "csn" or "json".
36
+ Converts the input file into one of these supported formats "cds", "csn"
37
+ or "json".
38
38
 
39
39
  *-f | --force*
40
- Forcefully overwrites the contents in the CDS file and updates the checksum
40
+ Forcefully overwrites the contents in the CDS file and updates the
41
+ checksum
41
42
 
42
43
  *--from*
43
- Imports the model from the one of the given options "edmx", "openapi" or "asyncapi".
44
+ Imports the model from the one of the given options "edmx", "openapi" or
45
+ "asyncapi".
44
46
 
45
47
  *Below options are valid for OData only*
46
48
 
@@ -50,7 +52,8 @@ module.exports = Object.assign(_import, {
50
52
 
51
53
  *-ns | --include-namespaces <string_of_namespaces> or* "\x2A"
52
54
  Imports only entities matching to the given list of namespaces.
53
- For OData V2 attributes with the namespace "sap" & "m" are captured by default.
55
+ For OData V2 attributes with the namespace "sap" & "m" are captured by
56
+ default.
54
57
 
55
58
 
56
59
 
@@ -78,7 +81,7 @@ async function _import(file, options = {}) {
78
81
  let cwd = process.cwd();
79
82
  if (Array.isArray(file)) file = file[0];
80
83
  if (!file) return this.help('import');
81
- //process options
84
+ // process options
82
85
  await common.processOptions(options, apiOptions);
83
86
  const [srcFilePath, destFilePath] = await common.preProcess(file, options, cwd);
84
87
 
@@ -91,7 +94,7 @@ async function _import(file, options = {}) {
91
94
  csn = await cdsImport.import(srcFilePath, apiOptions);
92
95
  }
93
96
 
94
- //reads the file version
97
+ // reads the file version
95
98
  options.inputFileVersion = apiOptions.odataVersion;
96
99
 
97
100
  // postprocess
package/bin/init.js CHANGED
@@ -22,35 +22,56 @@ module.exports = Object.assign(init, {
22
22
  Add one or more features while creating the project.
23
23
  <feature> can be one of the following:
24
24
 
25
- *nodejs* - prepares as a Node.js-based project, cannot be used with *java*
25
+ *nodejs* - prepares as a Node.js-based project, cannot be used with *java*
26
26
 
27
- *java* - prepares as a Java-based project, cannot be used with *nodejs*
27
+ *java* - prepares as a Java-based project, cannot be used with *nodejs*
28
28
 
29
- This feature uses the 'Java Maven archetype' to create a project
30
- using the *Java* programming language.
29
+ This feature uses a Java Maven archetype to create a
30
+ project using the *Java* programming language.
31
31
 
32
- *mtx* - prepares a multitenant project
32
+ *hana* - adds configuration for SAP HANA databases
33
33
 
34
- This version only supports Node.js projects.
34
+ *sqlite* - adds configuration for SQLite databases
35
35
 
36
- *hana* - adds configuration for SAP HANA deployment
36
+ *xsuaa* - adds configuration for authentication via XSUAA
37
37
 
38
- *mta* - adds an _mta.yaml_ file for MTA based SAP Business Technology Platform deployment
38
+ *multitenancy* - adds configuration for multitenancy
39
39
 
40
- *cf-manifest* - adds _manifest.yml_ and _services-manifest.yml_ files for Cloud Foundry native deployment
40
+ *toggles* - adds configuration for feature toggles
41
41
 
42
- This approach makes use of the 'Create-Service-Push Plugin' that has to be installed
43
- separately using _cf install-plugin Create-Service-Push_.
44
- _cf create-service-push_ creates the service(s) and pushes the application(s) to the
45
- SAP Business Technology Platform.
42
+ *extensibility* - adds configuration for extensibility
46
43
 
47
- *pipeline* - adds files for CI/CD pipeline integration
44
+ *mtx* - adds configuration for multitenancy, feature toggles and
45
+ extensibility
48
46
 
49
- *samples* - adds simple sample files
47
+ *approuter* - adds configuration for the Cloud Foundry approuter
50
48
 
51
- *notebook* - adds a Jupyter Notebook (beta)
49
+ *mta* - adds an _mta.yaml_ file for MTA-based SAP Business
50
+ Technology Platform deployment
52
51
 
53
- *helm* - adds helm chart folder that contains the files needed to deploy the application using Kyma.
52
+ *cf-manifest* - adds _manifest.yml_ and _services-manifest.yml_ files for
53
+ Cloud Foundry native deployment
54
+
55
+ This approach makes use of the 'Create-Service-Push
56
+ Plugin' that has to be installed separately using
57
+ _cf install-plugin Create-Service-Push_.
58
+ _cf create-service-push_ creates the service(s) and pushes
59
+ the application(s) to the SAP Business Technology
60
+ Platform.
61
+
62
+ *pipeline* - adds files for CI/CD pipeline integration
63
+
64
+ *sample* - adds sample files including Fiori UI
65
+
66
+ *sample-tiny* - adds minimal sample files
67
+
68
+ *data* - adds data content for CSN model entities (as csv files)
69
+
70
+ *helm* - adds helm chart folder that contains the files needed to
71
+ deploy the application using Kyma.
72
+
73
+ *html5-repo* - adds configuration for HTML5 Application Deployer to Helm
74
+ Chart (Kyma Only).
54
75
 
55
76
  *--java:mvn* <Comma separated maven archetype specific parameters>
56
77