@sap/cds-dk 7.2.0 → 7.3.1

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 (105) hide show
  1. package/bin/activate.js +2 -2
  2. package/bin/add.js +1 -1
  3. package/bin/build.js +6 -3
  4. package/bin/compile/index.js +9 -5
  5. package/bin/env.js +0 -3
  6. package/bin/extend.js +29 -3
  7. package/bin/import.js +7 -3
  8. package/bin/init.js +31 -37
  9. package/bin/push.js +10 -6
  10. package/bin/repl.js +23 -43
  11. package/bin/watch.js +5 -9
  12. package/lib/bind/bindingResolver.js +2 -1
  13. package/lib/bind/index.js +1 -1
  14. package/lib/build/{buildTaskHandler.js → buildPlugin.js} +40 -27
  15. package/lib/build/buildTaskEngine.js +75 -74
  16. package/lib/build/buildTaskFactory.js +39 -32
  17. package/lib/build/buildTaskProvider.js +24 -19
  18. package/lib/build/buildTaskProviderFactory.js +125 -58
  19. package/lib/build/constants.js +6 -4
  20. package/lib/build/index.js +7 -3
  21. package/lib/build/plugins.js +35 -0
  22. package/lib/build/provider/{buildTaskHandlerEdmx.js → edmxBuildPlugin.js} +11 -7
  23. package/lib/build/provider/{buildTaskHandlerFeatureToggles.js → featureToggleBuildPlugin.js} +5 -5
  24. package/lib/build/provider/fiori/index.js +5 -6
  25. package/lib/build/provider/hana/index.js +54 -30
  26. package/lib/build/provider/{buildTaskHandlerInternal.js → internalBuildPlugin.js} +14 -10
  27. package/lib/build/provider/{buildTaskProviderInternal.js → internalBuildTaskProvider.js} +27 -28
  28. package/lib/build/provider/java/index.js +30 -24
  29. package/lib/build/provider/mtx/index.js +4 -4
  30. package/lib/build/provider/mtx/resourcesTarBuilder.js +8 -8
  31. package/lib/build/provider/mtx-extension/index.js +17 -9
  32. package/lib/build/provider/mtx-sidecar/index.js +17 -11
  33. package/lib/build/provider/nodejs/index.js +14 -13
  34. package/lib/build/util.js +5 -0
  35. package/lib/client/auth_manager.js +6 -12
  36. package/lib/client/base_command.js +1 -1
  37. package/lib/client/download_legacy.js +43 -0
  38. package/lib/client/params.js +6 -0
  39. package/lib/client/push.js +41 -1
  40. package/lib/client/settings_manager.js +28 -17
  41. package/lib/compile/openapi/csdl2openapi.js +1 -1
  42. package/lib/env/schema.js +36 -0
  43. package/lib/env/schemas/cds-rc.json +101 -0
  44. package/lib/import/common.js +23 -10
  45. package/lib/import/importapi.js +2 -2
  46. package/lib/import/message.js +3 -1
  47. package/lib/import/odata/v4parser.js +23 -7
  48. package/lib/index.js +11 -0
  49. package/lib/init/constants.js +5 -2
  50. package/lib/init/index.js +2 -3
  51. package/lib/init/template/_merging/registry-mta.js +33 -0
  52. package/lib/init/template/approuter/files/mta.yaml.hbs +1 -1
  53. package/lib/init/template/approuter/index.js +9 -9
  54. package/lib/init/template/connectivity/index.js +5 -4
  55. package/lib/init/template/destination/index.js +2 -5
  56. package/lib/init/template/helm/subcharts/content-deployment/Chart.yaml +4 -4
  57. package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +4 -2
  58. package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +4 -3
  59. package/lib/init/template/helm/subcharts/content-deployment/values.schema.json +9 -83
  60. package/lib/init/template/helm/subcharts/content-deployment/values.yaml +54 -15
  61. package/lib/init/template/helm/subcharts/service-instance/Chart.yaml +4 -4
  62. package/lib/init/template/helm/subcharts/service-instance/templates/serviceinstance.yaml +1 -1
  63. package/lib/init/template/helm/subcharts/service-instance/values.schema.json +0 -17
  64. package/lib/init/template/helm/subcharts/service-instance/values.yaml +28 -0
  65. package/lib/init/template/helm/subcharts/web-application/Chart.yaml +5 -5
  66. package/lib/init/template/helm/subcharts/web-application/templates/_api.tpl +60 -0
  67. package/lib/init/template/helm/subcharts/web-application/templates/_helpers.tpl +34 -73
  68. package/lib/init/template/helm/subcharts/web-application/templates/api-rule.yaml +4 -4
  69. package/lib/init/template/helm/subcharts/web-application/templates/deployment.yaml +96 -17
  70. package/lib/init/template/helm/subcharts/web-application/templates/network-policy.yaml +19 -3
  71. package/lib/init/template/helm/subcharts/web-application/templates/pod-disruption-budget.yaml +3 -3
  72. package/lib/init/template/helm/subcharts/web-application/templates/rbac.yaml +26 -0
  73. package/lib/init/template/helm/subcharts/web-application/templates/secret.yaml +1 -1
  74. package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +1 -1
  75. package/lib/init/template/helm/subcharts/web-application/templates/service-binding.yaml +1 -1
  76. package/lib/init/template/helm/subcharts/web-application/templates/service.yaml +21 -3
  77. package/lib/init/template/helm/subcharts/web-application/templates/virtual-service.yaml +36 -0
  78. package/lib/init/template/helm/subcharts/web-application/values.schema.json +535 -142
  79. package/lib/init/template/helm/subcharts/web-application/values.yaml +168 -44
  80. package/lib/init/template/html5-repo/index.js +27 -3
  81. package/lib/init/template/mta/index.js +9 -3
  82. package/lib/init/template/nodejs/files/.vscode/launch.json +0 -3
  83. package/lib/init/template/notifications/files/mta.yaml.hbs +17 -0
  84. package/lib/init/template/notifications/files/notificationtypes.json.hbs +16 -0
  85. package/lib/init/template/notifications/files/package.json.hbs +14 -0
  86. package/lib/init/template/notifications/index.js +52 -0
  87. package/lib/init/template/postgres/files/mta.yaml.hbs +27 -0
  88. package/lib/init/template/postgres/files/package.json.hbs +5 -0
  89. package/lib/init/template/postgres/index.js +52 -0
  90. package/lib/init/util/projectReader.js +0 -1
  91. package/lib/util/pruneAxiosErrors.js +25 -8
  92. package/lib/util/term.js +1 -2
  93. package/lib/watch/livereload-server.js +38 -2
  94. package/lib/watch/node-watch.js +3 -2
  95. package/npm-shrinkwrap.json +334 -335
  96. package/package.json +2 -2
  97. package/lib/init/template/helm/subcharts/content-deployment/templating.md +0 -37
  98. package/lib/init/template/helm/subcharts/content-deployment/values-lint.yaml +0 -5
  99. package/lib/init/template/helm/subcharts/content-deployment/values.md +0 -1011
  100. package/lib/init/template/helm/subcharts/service-instance/templating.md +0 -18
  101. package/lib/init/template/helm/subcharts/service-instance/values-lint.yaml +0 -2
  102. package/lib/init/template/helm/subcharts/service-instance/values.md +0 -186
  103. package/lib/init/template/helm/subcharts/web-application/templating.md +0 -51
  104. package/lib/init/template/helm/subcharts/web-application/values-lint.yaml +0 -8
  105. package/lib/init/template/helm/subcharts/web-application/values.md +0 -1363
package/bin/activate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = Object.assign(activate, {
2
2
  options: ['--subdomain', '--passcode', '--username', '--clientid', '--to', '--sync'],
3
3
  flags: ['--undeploy', '--wsdl'],
4
- shortcuts: ['-s', '-p', '-u', '-c'],
4
+ shortcuts: ['-s', '-p', '-u', '-c', '-2'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
@@ -55,7 +55,7 @@ module.exports = Object.assign(activate, {
55
55
 
56
56
  *cds push* to push an extension to a SaaS app based on current MTX Services
57
57
  (@sap/cds-mtxs).
58
-
58
+
59
59
  https://cap.cloud.sap/docs/guides/multitenancy/mtxs for information on
60
60
  @sap/cds-mtxs.
61
61
 
package/bin/add.js CHANGED
@@ -33,7 +33,7 @@ module.exports = Object.assign(add, {
33
33
 
34
34
  *redis-messaging* - add support for Redis messaging
35
35
 
36
- *kibana-logging* - add support for Kibana formatting
36
+ *kibana* - add support for Kibana formatting
37
37
 
38
38
  *mta* - add support for MTA-based deployment
39
39
 
package/bin/build.js CHANGED
@@ -1,6 +1,7 @@
1
1
  module.exports = Object.assign(build, {
2
- options: ['--project', '--src', '--dest', '--for', '--workspaces', '--use', '--opts', '--log-level', '--options-model', '--clean'],
3
- shortcuts: ['-in', '-s', '-o', '-4', '-ws'],
2
+ options: ['--project', '--src', '--dest', '--for', '--use', '--opts', '--log-level', '--options-model'],
3
+ shortcuts: ['-in', '-s', '-o', '-4'],
4
+ flags: ['--ws', '--clean'],
4
5
  help: `
5
6
  # SYNOPSIS
6
7
 
@@ -88,11 +89,13 @@ module.exports = Object.assign(build, {
88
89
  async function build([project], options = {}) {
89
90
  const path = require('path')
90
91
  const cds = require('../lib/cds')
92
+
93
+ // plugins are loaded based on cds.root path
94
+ cds.root = path.resolve(process.cwd(), project || options.project || '.')
91
95
 
92
96
  // IMPORTANT: call plugins before subsequent access to cds.env
93
97
  await cds.plugins
94
98
 
95
- cds.root = path.resolve(process.cwd(), project || options.project || '.')
96
99
  cds.env = cds.env.for('cds', cds.root);
97
100
  delete options.project // avoid that relative project paths are resolved twice
98
101
 
@@ -114,7 +114,7 @@ module.exports = Object.assign ( compile, {
114
114
  The servers definition used in the generated OpenAPI document. *--openapi:url* is
115
115
  ignored when this option is specified.
116
116
 
117
- *--odata-version* 4.0|4.01
117
+ *--odata-version* 4.0|4.01
118
118
 
119
119
  Adds the OData version's functionality of the input CDS/CSN file to the generated OpenAPI document.
120
120
 
@@ -126,7 +126,7 @@ module.exports = Object.assign ( compile, {
126
126
 
127
127
  A single AsyncAPI document is generated using the details of all input services. Information of _title_
128
128
  and _version_ should be provided as preset.
129
-
129
+
130
130
  # EXAMPLES
131
131
 
132
132
  *cds* compile model.cds
@@ -136,11 +136,13 @@ module.exports = Object.assign ( compile, {
136
136
 
137
137
  `})
138
138
 
139
- function compile_all (root='.') {
139
+ async function compile_all (root='.') {
140
140
 
141
141
  const {exec} = require ('child_process')
142
142
  const cds = require('../../lib') // get the enhanced cds w/ additional compile processors
143
143
 
144
+ await cds.plugins // ensure plugins that extend compile targets are loaded
145
+
144
146
  exec(`find ${root} -name *.cds ! -path '*/node_modules/*'`, (_,stdout)=>{
145
147
  const all = stdout.split('\n').slice(0,-1)
146
148
  const info = `\n/ compiled ${all.length} cds models in`
@@ -156,13 +158,15 @@ function compile_all (root='.') {
156
158
 
157
159
  }
158
160
 
159
- function compile (models, options={}) {
161
+ async function compile (models, options={}) {
160
162
 
161
163
  if (options.all) return compile_all (models[0])
162
164
 
163
165
  const { inspect } = require('util')
164
166
  const cds = require('../../lib') // get the enhanced cds w/ additional compile processors
165
167
 
168
+ await cds.plugins // ensure plugins that extend compile targets are loaded
169
+
166
170
  let model, src, _suffix; //> be filled in below
167
171
  if (!options.as && !/,/.test(options.to)) options.as = 'str'
168
172
  if (options.beta) options.betaMode = true
@@ -278,7 +282,7 @@ function compile (models, options={}) {
278
282
  return console.log (o)
279
283
  }
280
284
 
281
- function suffix4 (x) { return x && ({
285
+ function suffix4 (x) { return x && x !== 'hdbtable' && ({
282
286
  edmx: '.xml',
283
287
  "edmx-v2": '.xml',
284
288
  "edmx-v4": '.xml',
package/bin/env.js CHANGED
@@ -62,9 +62,6 @@ async function env ([cmd, key, value], options={}) {
62
62
  commands[cmd] || ((key = cmd), commands.get)
63
63
  )
64
64
 
65
- // Ensure loading plugins before calling cds.env!
66
- await cds.plugins
67
-
68
65
  let env = cds.env
69
66
  if (options["resolve-bindings"]) {
70
67
  const BindingManager = require('../lib/bind/bindingManager')
package/bin/extend.js CHANGED
@@ -1,6 +1,6 @@
1
1
  module.exports = Object.assign(extend, {
2
- options: ['--directory', '--subdomain', '--passcode', '--username', '--clientid'],
3
- flags: ['--wsdl', '--templates', '--force'],
2
+ options: ['--directory', '--subdomain', '--passcode', '--username', '--clientid', '--tagRule', '--defaultTag'],
3
+ flags: ['--wsdl', '--templates', '--force', '--download-migrated-projects'],
4
4
  shortcuts: ['-d', '-s', '-p', '-u', '-c'],
5
5
  help: `
6
6
  # SYNOPSIS
@@ -50,13 +50,25 @@ module.exports = Object.assign(extend, {
50
50
  Download only the templates provided by the SaaS application you want to
51
51
  extend.
52
52
 
53
+ *--download-migrated-projects*
54
+
55
+ To be used only after change to @sap/cds-mtxs. Allows to download migrated extension projects.
56
+
57
+ *--tagRule*
58
+
59
+ Rule used to split up migrated extension projects into separate projects (please check migration documentation for more).
60
+
61
+ *--defaultTag*
62
+
63
+ Default tag used for migrated extension projects, default is 'migrated' (please check migration documentation for more).
64
+
53
65
  # SEE ALSO
54
66
 
55
67
  *cds activate* to activate an extension project.
56
68
 
57
69
  *cds pull* to get the CDS model of a SaaS app based on current MTX Services
58
70
  (@sap/cds-mtxs).
59
-
71
+
60
72
  https://cap.cloud.sap/docs/guides/multitenancy/mtxs for information on
61
73
  @sap/cds-mtxs.
62
74
 
@@ -64,6 +76,20 @@ module.exports = Object.assign(extend, {
64
76
 
65
77
 
66
78
  async function extend ([url], options = {}) {
79
+
80
+ if (options['download-migrated-projects']) {
81
+ const [username, password] = options.username?.split(':') ?? [];
82
+ delete options.user;
83
+
84
+ await require('../lib/client/download_legacy').run({
85
+ ...options,
86
+ url,
87
+ username,
88
+ password
89
+ });
90
+ return
91
+ }
92
+
67
93
  if (options.force) {
68
94
  if (! await require('../lib/client/helper/question').askBooleanQuestion('Using option --force will overwrite existing files. Continue (yN)? ', false, false)) {
69
95
  console.log('Extend cancelled')
package/bin/import.js CHANGED
@@ -1,8 +1,8 @@
1
1
  module.exports = Object.assign(_import, {
2
2
  _name: 'import',
3
- options: ['--out', '--as', '--include-namespaces', '--from'],
3
+ options: ['--out', '--as', '--include-namespaces', '--from', '--config'],
4
4
  flags: ['--dry', '--force', '--no-copy', '--no-save', '--keep-namespace'],
5
- shortcuts: ['-o', '-as', '-ns', undefined, '-', '-f'],
5
+ shortcuts: ['-o', '-as', '-ns', undefined, '-c', '-', '-f'],
6
6
  help: `
7
7
  # SYNOPSIS
8
8
 
@@ -43,6 +43,9 @@ module.exports = Object.assign(_import, {
43
43
  *--from*
44
44
  Imports the model from the one of the given options "edmx", "openapi" or
45
45
  "asyncapi".
46
+
47
+ *-c | --config* <JSON Object>
48
+ Adds the provided JSON Object as custom configuration data to the package.json.
46
49
 
47
50
  *Below options are valid for OData only*
48
51
 
@@ -68,6 +71,7 @@ module.exports = Object.assign(_import, {
68
71
  cds import ~/Downloads/Petstore_OpenAPI.json --from openapi
69
72
  cds import ~/Downloads/BookStore_AsyncAPI.json
70
73
  cds import ~/Downloads/BookStore_AsyncAPI.json --from asyncapi
74
+ cds import ~/Downloads/API_BUSINESS_PARTNER.edmx -c {\\"[production]\\":{\\"credentials\\":{\\"destination\\":\\"UI3_noauth\\",\\"path\\":\\"/sap/cap/odata\\"}}}
71
75
 
72
76
  `})
73
77
  const messages = require('../lib/import/message').getMessages();
@@ -95,7 +99,7 @@ async function _import(file, options = {}) {
95
99
  }
96
100
 
97
101
  // reads the file version
98
- options.inputFileVersion = apiOptions.odataVersion;
102
+ options.inputFileKind = apiOptions.odataVersion ? apiOptions.odataVersion : apiOptions.inputFileKind;
99
103
 
100
104
  // postprocess
101
105
  return await common.postProcess(destFilePath, options, csn, cwd);
package/bin/init.js CHANGED
@@ -22,56 +22,51 @@ 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* - creates as a Node.js-based project
26
26
 
27
- *java* - prepares as a Java-based project, cannot be used with *nodejs*
27
+ *java* - creates as a Java-based project
28
28
 
29
- This feature uses a Java Maven archetype to create a
30
- project using the *Java* programming language.
29
+ *hana* - add support for SAP HANA
31
30
 
32
- *hana* - adds configuration for SAP HANA databases
31
+ *sqlite* - add support for SQLite databases
33
32
 
34
- *sqlite* - adds configuration for SQLite databases
33
+ *xsuaa* - add support for authentication via XSUAA
35
34
 
36
- *xsuaa* - adds configuration for authentication via XSUAA
35
+ *multitenancy* - add support for multitenancy
37
36
 
38
- *multitenancy* - adds configuration for multitenancy
37
+ *toggles* - add support for feature toggles
39
38
 
40
- *toggles* - adds configuration for feature toggles
39
+ *extensibility* - add support for extensibility
41
40
 
42
- *extensibility* - adds configuration for extensibility
41
+ *approuter* - add support for application routing
43
42
 
44
- *mtx* - adds configuration for multitenancy, feature toggles and
45
- extensibility
43
+ *file-based-messaging* - add support for file-based messaging
46
44
 
47
- *approuter* - adds configuration for the Cloud Foundry approuter
45
+ *enterprise-messaging* - add support for SAP Event Mesh
48
46
 
49
- *mta* - adds an _mta.yaml_ file for MTA-based SAP Business
50
- Technology Platform deployment
47
+ *redis-messaging* - add support for Redis messaging
51
48
 
52
- *cf-manifest* - adds _manifest.yml_ and _services-manifest.yml_ files for
53
- Cloud Foundry native deployment
49
+ *kibana* - add support for Kibana formatting
54
50
 
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.
51
+ *mta* - add support for MTA-based deployment
61
52
 
62
- *pipeline* - adds files for CI/CD pipeline integration
53
+ *cf-manifest* - add support for CF-native deployment
63
54
 
64
- *sample* - adds sample files including Fiori UI
55
+ *helm* - add support for Helm-based Kyma deployment
65
56
 
66
- *sample-tiny* - adds minimal sample files
57
+ *html5-repo* - add support for the HTML5 repository
67
58
 
68
- *data* - adds data content for CSN model entities (as csv files)
59
+ *pipeline* - add files for CI/CD pipeline integration
69
60
 
70
- *helm* - adds helm chart folder that contains the files needed to
71
- deploy the application using Kyma.
61
+ *tiny-sample* - add minimal sample files
72
62
 
73
- *html5-repo* - adds configuration for HTML5 Application Deployer to Helm
74
- Chart (Kyma Only).
63
+ *sample* - add sample files including Fiori UI
64
+
65
+ *data* - add CSV headers for modeled entities
66
+
67
+ *typer* - add type generation for CDS models
68
+
69
+ *lint* - add support for CDS Lint
75
70
 
76
71
  *--java:mvn* <Comma separated maven archetype specific parameters>
77
72
 
@@ -85,16 +80,15 @@ module.exports = Object.assign(init, {
85
80
 
86
81
  # EXAMPLES
87
82
 
88
- *cds init* test
89
- *cds init* test --add java
90
- *cds init* test --add java,hana
91
- *cds init* --add mta
92
- *cds init* --add cf-manifest
83
+ *cds init* bookshop
84
+ *cds init* bookshop --add java
85
+ *cds init* bookshop --add java,hana
86
+ *cds init* bookshop --add multitenancy,mta
93
87
  *cds init* --add java --java:mvn groupId=myGroup,artifactId=newId,package=my.company
94
88
 
95
89
  # SEE ALSO
96
90
 
97
- *cds add* as shortcut for _cds init --add_.
91
+ *cds add* - to augment your projects later on
98
92
 
99
93
  `})
100
94
 
package/bin/push.js CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = Object.assign(push, {
2
- options: ['--subdomain', '--passcode', '--user', '--client', '--to'],
2
+ options: ['--subdomain', '--passcode', '--user', '--client', '--to', '--sync'],
3
3
  flags: [],
4
- shortcuts: ['-s', '-p', '-u', '-c'],
4
+ shortcuts: ['-s', '-p', '-u', '-c', '-2'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
@@ -13,9 +13,9 @@ module.exports = Object.assign(push, {
13
13
  a local file or as a URL to download it from.
14
14
  A download URL may contain Basic-Auth credentials as in
15
15
  'https://user:pass@host'.
16
-
16
+
17
17
  By default, the current working directory is used as project directory.
18
-
18
+
19
19
  Unless a custom archive is given, the extension project will be
20
20
  automatically built in order to update the generated extension archive. This
21
21
  ensures the most recent extension model is pushed.
@@ -48,13 +48,17 @@ module.exports = Object.assign(push, {
48
48
 
49
49
  Client ID and optionally Client Secret for authentication.
50
50
 
51
+ *--sync*
52
+
53
+ Use the synchronous server API to upload extensions.
54
+
51
55
 
52
56
  # SEE ALSO
53
57
 
54
58
  *cds pull* to get the CDS model of the SaaS app.
55
-
59
+
56
60
  *cds login* for more information on authentication options.
57
-
61
+
58
62
  *cds login* to save project settings and authentication data, simplifying
59
63
  multiple runs of this command.
60
64
 
package/bin/repl.js CHANGED
@@ -12,62 +12,42 @@ module.exports = Object.assign (repl, { options: [], help: `
12
12
  *cds eval* to evaluate and execute JavaScript.
13
13
  `})
14
14
 
15
- function repl (_, options={}) {
16
-
17
- // enable `await` statement for Node.js < 16
18
- if (!process.env['CDS_REPL_SPAWNED'] && process.version.split('.')[0].slice(1) < '16') {
19
- process.env['CDS_REPL_SPAWNED'] = true
20
- return require('child_process').spawn('node',['--experimental-repl-await',
21
- ...process.argv.slice(1) ], {stdio:'inherit'}
22
- )
23
- }
15
+ async function repl (_, options={}) {
24
16
 
25
17
  const cds = require('../lib/cds')
26
- const path = require('path')
27
- const {inspect} = require('util')
18
+ console.log('\x1b[32m\x1b[1m'+'Welcome to cds repl v', cds.version, '\x1b[0m')
19
+
20
+ await cds.plugins
21
+
22
+ const { inspect } = require('util')
23
+ inspect.defaultOptions.colors = true
24
+ inspect.defaultOptions.depth = 11
28
25
 
29
- const colors = options.colors !== false
30
- const log = options.log || console.log
31
- const info = colors ? require('../lib/util/term').info : s => s
32
- log(info('Welcome to cds repl v'+ cds.version))
33
26
 
34
- const cdsr = require('repl').start ({...options, writer:_writer, ignoreUndefined:true })
35
- Object.defineProperty (cds,'repl',{value:cdsr})
27
+ const repl = require('repl').start ({
28
+ ...options, ignoreUndefined: true,
29
+ writer: o => {
30
+ if (!o || typeof o !== 'object') return o
31
+ return inspect(o).replace(/\[Object: null prototype\] /g, '')
32
+ }
33
+ })
36
34
 
37
- cds.lazify (Object.assign (cdsr.context,{ cds,
35
+ Object.defineProperty (cds,'repl',{value:repl})
36
+ cds.lazify (Object.assign (repl.context,{ cds,
38
37
  Foo: lazy => new cds.entity ({name:'Foo'}),
39
38
  Bar: lazy => new cds.entity ({name:'Bar'}),
40
39
  }))
41
40
 
42
- // cosmetics: don't show cds.env when inspecting cds
43
- if (Reflect.getOwnPropertyDescriptor(cds,'env')) {
44
- Reflect.defineProperty (cds,'env',{ value:cds.env, enumerable:false })
45
- }
46
-
47
- inspect.defaultOptions.colors = true
48
- inspect.defaultOptions.depth = 11
49
- function _writer (o) {
50
- if (!o || typeof o !== 'object') return o
51
- return inspect(o).replace(/\[Object: null prototype\] /g, '')
52
- }
53
-
41
+ repl.history = new Array(222)
54
42
  const home = process.env.HOME || process.env.USERPROFILE
55
- const history = path.join(home,'.cds-repl-history')
56
- if (cdsr.setupHistory) { // since Node.js 11
57
- cdsr.setupHistory (history,()=>{})
58
- } else {
59
- const fs = require('fs')
60
- const historySize = 111
61
- fs.readFile(history, 'utf-8', (e, txt) => e || (cdsr.history = txt.split('\n')))
62
- cdsr.on('exit', () => {
63
- if (cdsr.history) fs.writeFile(history, cdsr.history.slice(-historySize).join('\n'), () => {})
64
- })
65
- }
66
-
43
+ const history = require('path').join(home,'.cds-repl-history')
44
+ const fs = require('fs')
45
+ fs.readFile(history, 'utf-8', (e, txt) => e || Object.assign(repl.history, txt.split('\n')))
46
+ repl.on('exit', () => fs.writeFile(history, repl.history.join('\n'), () => {}))
67
47
 
68
48
  process.on('uncaughtException', console.error)
69
49
  process.on('unhandledRejection', console.error)
70
50
 
71
51
  }
72
- /* eslint no-console:0 */
52
+
73
53
  if (!module.parent) repl()
package/bin/watch.js CHANGED
@@ -59,8 +59,7 @@ const t = module.exports.codes = {
59
59
  orange: colors ? '\x1b[38;2;255;140;0m' : '' // darker orange, works with bright and dark background
60
60
  }
61
61
  const extDefaults = 'cds,csn,csv,ts,mjs,cjs,js,json,properties,edmx,xml,env'
62
- const fioriIncludes = /_?(change|variant)$/ // according to fiori: change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change.
63
- const ignore = RegExp(`app${sep}.*${sep}?webapp${sep}|node_modules|target|\\.cds-services\\.json$`)
62
+ const ignore = RegExp(`(node_modules\\${sep}|@cds-models\\${sep}|@types\\${sep}|app(\\${sep}.+)?\\${sep}((webapp|dist|target)\\${sep}|\\.cds-services\\.json$|tsconfig\\.json$|.*\\.tsbuildinfo$))`)
64
63
 
65
64
  async function watch ([cwd], {
66
65
  args = ['serve', 'all'],
@@ -88,16 +87,14 @@ async function watch ([cwd], {
88
87
  env.NODE_PATH = [...paths(cwd||process.cwd()), ...paths(__dirname)].join(delimiter)
89
88
 
90
89
  if (typeof ext !== 'string') ext = extDefaults
90
+ const delay = parseInt(process.env.CDS_WATCH_DELAY) || 200
91
91
 
92
- let includes
93
92
  let liveReload //= ...
94
93
  let firstTime = true
95
94
  if (!/false|no/.test(options['livereload']) && cds.env.for('cds', cwd||process.cwd()).livereload !== false) {
96
- ext += ',css,gif,html,jpg,png,svg'
97
- includes = fioriIncludes
98
95
  liveReload = new (require ('../lib/watch/livereload-server'))
99
96
  env.CDS_LIVERELOAD_PATH = require.resolve ('../lib/watch/livereload-connect')
100
- env.CDS_LIVERELOAD_URL = await liveReload.start (options['livereload'])
97
+ env.CDS_LIVERELOAD_URL = await liveReload.start (options['livereload'], cwd, delay)
101
98
  .catch(err => { console.log(`Error starting live reload: ${err.message}`); liveReload = null })
102
99
  }
103
100
 
@@ -113,7 +110,6 @@ async function watch ([cwd], {
113
110
  log ()
114
111
  log (`${t.bold}cds ${args.join(' ')}`)
115
112
  DEBUG && log (process.pid, 'watching:', ext, '...')
116
- includes && DEBUG && log (`also watching: ${includes.source}`)
117
113
  DEBUG && log ('ignoring:', ignore.source)
118
114
  if (liveReload) log (`live reload enabled for browsers`)
119
115
 
@@ -124,8 +120,8 @@ async function watch ([cwd], {
124
120
 
125
121
  const nodemon = require('../lib/watch/node-watch')
126
122
  const watcher = nodemon ({
127
- script: resolve(__dirname,'watched'), cwd, env, ext, includes, ignore,
128
- delay: parseInt(process.env.CDS_WATCH_DELAY) || 200,
123
+ script: resolve(__dirname,'watched'), cwd, env, ext, ignore,
124
+ delay,
129
125
  options
130
126
  }).on('restart', (files)=>{
131
127
  log (`\n${t.bold} ___________________________\n`)
@@ -1,10 +1,11 @@
1
1
  const cds = require('../cds');
2
+ const path = require('path');
2
3
  const { platformText, bindingText, logger } = require('./bindingUtil');
3
4
 
4
5
  class BindingResolver {
5
6
  getUnresolvedBindings({ cwd = process.cwd(), env } = {}) {
6
7
  if (!env) {
7
- env = cds.env.for('cds', cwd) // REVISIT: This might load cds.env too early!
8
+ env = cds.env.for('cds', path.resolve(cwd)) // REVISIT: This might load cds.env too early!
8
9
  }
9
10
  const bindings = {}
10
11
  const requires = env.requires || {}
package/lib/bind/index.js CHANGED
@@ -101,7 +101,7 @@ function runCmd(profile, isJavaProject) {
101
101
  profile = parseProfile(profile);
102
102
  if (isJavaProject) {
103
103
  const p = profile === 'hybrid' ? '' : ` --profile ${profile}`;
104
- return `cds bind exec${p} mvn spring-boot:run`;
104
+ return `cds bind --exec${p} mvn spring-boot:run`;
105
105
  } else {
106
106
  const p = profile === 'development' ? '' : ` --profile ${profile}`;
107
107
  return `cds watch${p}`;