@sap/cds-dk 6.4.1 → 6.5.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 (93) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/bin/bind.js +30 -34
  3. package/bin/cds.js +14 -3
  4. package/bin/deploy/index.js +6 -5
  5. package/bin/deploy/to-sqlite.js +2 -1
  6. package/bin/env.js +4 -4
  7. package/bin/migrate.js +25 -4
  8. package/bin/push.js +4 -0
  9. package/bin/watch.js +3 -3
  10. package/lib/bind/KubernetesApiAccessor.js +79 -0
  11. package/lib/bind/{BindingManager.js → bindingManager.js} +16 -15
  12. package/lib/bind/bindingResolver.js +41 -68
  13. package/lib/bind/bindingUtil.js +93 -104
  14. package/lib/bind/cfKeyProvider.js +85 -74
  15. package/lib/bind/kubernetesCredentialsProvider.js +34 -132
  16. package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
  17. package/lib/client/params.js +2 -2
  18. package/lib/client/push.js +11 -6
  19. package/lib/client/settings_manager.js +2 -1
  20. package/lib/client/subscription.js +4 -1
  21. package/lib/import/odata/v2parser.js +32 -8
  22. package/lib/import/odata/v4parser.js +5 -2
  23. package/lib/init/constants.js +1 -1
  24. package/lib/init/index.js +3 -11
  25. package/lib/init/template/approuter/files/approuter-configmap.yaml +4 -1
  26. package/lib/init/template/approuter/files/approuter-mtxs-configmap.yaml +5 -1
  27. package/lib/init/template/approuter/files/package.json +1 -1
  28. package/lib/init/template/approuter/files/values.yaml.hbs +1 -1
  29. package/lib/init/template/approuter/files/xs-app.json.hbs +2 -2
  30. package/lib/init/template/approuter/index.js +4 -5
  31. package/lib/init/template/auditlog/index.js +1 -1
  32. package/lib/init/template/data/index.js +1 -1
  33. package/lib/init/template/destinations/index.js +1 -1
  34. package/lib/init/template/enterprise-messaging/index.js +1 -1
  35. package/lib/init/template/extensibility/index.js +6 -1
  36. package/lib/init/template/hana/files/chart.yaml +4 -0
  37. package/lib/init/template/hana/files/hana.yaml +1 -0
  38. package/lib/init/template/hana/files/java/db/package.json +1 -1
  39. package/lib/init/template/hana/files/values.yaml.hbs +6 -3
  40. package/lib/init/template/hana/index.js +73 -21
  41. package/lib/init/template/helm/chart/templates/_deployment_helpers.tpl +14 -6
  42. package/lib/init/template/helm/chart/values.root.schema.json +10 -0
  43. package/lib/init/template/helm/chart/values.schema.json +11 -110
  44. package/lib/init/template/helm/index.js +2 -2
  45. package/lib/init/template/helm/subcharts/content-deployment/Chart.yaml +5 -0
  46. package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +207 -0
  47. package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +66 -0
  48. package/lib/init/template/helm/subcharts/content-deployment/templates/secret.yaml +10 -0
  49. package/lib/init/template/helm/subcharts/content-deployment/templates/service-account.yaml +4 -0
  50. package/lib/init/template/helm/subcharts/content-deployment/templates/service-binding.yaml +28 -0
  51. package/lib/init/template/helm/subcharts/content-deployment/values-lint.yaml +5 -0
  52. package/lib/init/template/helm/subcharts/content-deployment/values.md +1014 -0
  53. package/lib/init/template/helm/subcharts/content-deployment/values.schema.json +589 -0
  54. package/lib/init/template/helm/subcharts/content-deployment/values.yaml +54 -0
  55. package/lib/init/template/helm/{subchart → subcharts/web-application}/Chart.yaml +0 -0
  56. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/_helpers.tpl +56 -50
  57. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/api-rule.yaml +1 -1
  58. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/deployment.yaml +15 -9
  59. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/network-policy.yaml +0 -0
  60. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/pod-disruption-budget.yaml +2 -2
  61. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/secret.yaml +0 -0
  62. package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +6 -0
  63. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/service-binding.yaml +4 -3
  64. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/service.yaml +0 -0
  65. package/lib/init/template/helm/subcharts/web-application/templating.md +44 -0
  66. package/lib/init/template/helm/{subchart → subcharts/web-application}/values-lint.yaml +0 -0
  67. package/lib/init/template/helm/{subchart → subcharts/web-application}/values.md +254 -200
  68. package/lib/init/template/helm/{subchart → subcharts/web-application}/values.schema.json +82 -28
  69. package/lib/init/template/helm/{subchart → subcharts/web-application}/values.yaml +15 -5
  70. package/lib/init/template/html5-repo/files/chart.yaml +4 -0
  71. package/lib/init/template/html5-repo/files/html5-apps-deployer-configmap.yaml +14 -0
  72. package/lib/init/template/html5-repo/index.js +39 -7
  73. package/lib/init/template/kibana-logging/index.js +1 -1
  74. package/lib/init/template/lint/index.js +1 -1
  75. package/lib/init/template/multitenancy/files/saas-registry.yaml +2 -2
  76. package/lib/init/template/multitenancy/files/service-manager.yaml +1 -0
  77. package/lib/init/template/multitenancy/files/values.yaml.hbs +10 -6
  78. package/lib/init/template/multitenancy/index.js +21 -3
  79. package/lib/init/util/commandUtil.js +5 -5
  80. package/lib/init/util/merge.js +27 -1
  81. package/lib/init/util/mvnArchetypeUtil.js +1 -1
  82. package/lib/init/util/projectReader.js +2 -2
  83. package/lib/util/exec.js +3 -3
  84. package/lib/util/term.js +7 -7
  85. package/lib/watch/livereload-connect.js +187 -0
  86. package/lib/watch/livereload-server.js +12 -12
  87. package/lib/watch/node-watch.js +1 -1
  88. package/npm-shrinkwrap.json +56 -308
  89. package/package.json +1 -4
  90. package/lib/init/template/hana/files/hana-deployer-job.yaml +0 -49
  91. package/lib/init/template/html5-repo/files/_html5_deployment_helpers.tpl +0 -16
  92. package/lib/init/template/html5-repo/files/html5-apps-deployer-job.yaml +0 -61
  93. package/lib/init/util/spinner.js +0 -80
@@ -0,0 +1,187 @@
1
+ const DEBUG = /\b(y|all|cli|livereload)\b/.test(process.env.DEBUG) && console.debug
2
+
3
+ module.exports = function livereload(opt) {
4
+ // options
5
+ opt = opt || {};
6
+ const ignore = opt.ignore || opt.excludeList || [/\.js(\?.*)?$/, /\.css(\?.*)?$/, /\.svg(\?.*)?$/, /\.ico(\?.*)?$/,
7
+ /\.woff(\?.*)?$/, /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/,
8
+ /\.json(\?.*)?$/
9
+ ];
10
+
11
+ const include = opt.include || [/.*/];
12
+ const html = opt.html || _html;
13
+ const rules = opt.rules || [{
14
+ match: /<\/body>(?![\s\S]*<\/body>)/i,
15
+ fn: prepend
16
+ }, {
17
+ match: /<\/html>(?![\s\S]*<\/html>)/i,
18
+ fn: prepend
19
+ }, {
20
+ match: /<!DOCTYPE.+?>/i,
21
+ fn: append
22
+ }];
23
+ const disableCompression = opt.disableCompression || false;
24
+ const port = opt.port || 35729;
25
+ const plugins = opt.plugins || [];
26
+
27
+ function snippet(host) {
28
+ const src = opt.src || '//' + host + ':' + port + '/livereload.js?snipver=1';
29
+ return [src].concat(plugins).map(function(source) {
30
+ return '<script src="' + source + '" async="" defer=""></script>';
31
+ }).join('');
32
+ }
33
+
34
+ // helper functions
35
+ const regex = (function () {
36
+ const matches = rules.map(function (item) {
37
+ return item.match.source;
38
+ }).join('|');
39
+
40
+ return new RegExp(matches, 'i');
41
+ })();
42
+
43
+ function prepend(w, s) {
44
+ return s + w;
45
+ }
46
+
47
+ function append(w, s) {
48
+ return w + s;
49
+ }
50
+
51
+ function _html(str) {
52
+ if (!str) return false;
53
+ return /<[:_-\w\s!/="']+>/i.test(str);
54
+ }
55
+
56
+ function exists(body) {
57
+ if (!body) return false;
58
+ return regex.test(body);
59
+ }
60
+
61
+ function snip(body) {
62
+ if (!body) return false;
63
+ return (~body.lastIndexOf('/livereload.js'));
64
+ }
65
+
66
+ function snap(body, host) {
67
+ let _body = body;
68
+ rules.some(function (rule) {
69
+ if (rule.match.test(body)) {
70
+ _body = body.replace(rule.match, function(w) {
71
+ return rule.fn(w, snippet(host));
72
+ });
73
+ return true;
74
+ }
75
+ return false;
76
+ });
77
+ return _body;
78
+ }
79
+
80
+ function accept(req) {
81
+ const ha = req.headers['accept'];
82
+ if (!ha) return false;
83
+ return (~ha.indexOf('html'));
84
+ }
85
+
86
+ function acceptContentType(res) {
87
+ const ha = res.getHeader('content-type');
88
+ if (ha && ha.indexOf('html') >= 0) {
89
+ DEBUG && DEBUG('[livereload] accepting content-type', ha)
90
+ return true;
91
+ }
92
+ DEBUG && DEBUG('[livereload] rejecting content-type', ha)
93
+ return false;
94
+ }
95
+
96
+ function check(str, arr) {
97
+ if (!str) return true;
98
+ return arr.some(function (item) {
99
+ if ((item.test && item.test(str)) || ~str.indexOf(item)) return true;
100
+ return false;
101
+ });
102
+ }
103
+
104
+ // middleware
105
+ return function livereload(req, res, next) {
106
+ const hostName = req.headers[':authority'] || req.headers.host;
107
+ const host = opt.hostname || hostName.split(':')[0];
108
+
109
+ if (res._livereload) return next();
110
+ res._livereload = true;
111
+
112
+ if (!accept(req) || !check(req.url, include) || check(req.url, ignore)) {
113
+ return next();
114
+ }
115
+ DEBUG && DEBUG('[livereload] accepting URL', req.url)
116
+
117
+ // Disable G-Zip to enable proper inspecting of HTML
118
+ if (disableCompression) {
119
+ req.headers['accept-encoding'] = 'identity';
120
+ }
121
+
122
+ let runPatches = () => acceptContentType(res);
123
+ // const runPatches = () => true;
124
+ const writeHead = res.writeHead;
125
+ const write = res.write;
126
+ const end = res.end;
127
+
128
+ res.push = function (chunk) {
129
+ res.data = (res.data || '') + chunk;
130
+ };
131
+
132
+ res.inject = res.write = function (string, encoding) {
133
+ if (!runPatches()) return write.call(res, string, encoding);
134
+
135
+ if (string !== undefined) {
136
+ const body = string instanceof Buffer ? string.toString(encoding) : string;
137
+ // If this chunk must receive a snip, do so
138
+ if (exists(body) && !snip(res.data)) {
139
+ res.push(snap(body, host));
140
+ return true;
141
+ }
142
+ // If in doubt, simply buffer the data for later inspection (on `end` function)
143
+ else {
144
+ res.push(body);
145
+ return true;
146
+ }
147
+ }
148
+ return true;
149
+ };
150
+
151
+ res.writeHead = function () {
152
+ if (!runPatches()) return writeHead.apply(res, arguments);
153
+
154
+ const headers = arguments[arguments.length - 1];
155
+ if (typeof headers === 'object') {
156
+ for (const name in headers) {
157
+ if (/content-length/i.test(name)) {
158
+ delete headers[name];
159
+ }
160
+ }
161
+ }
162
+
163
+ if (res.getHeader('content-length')) res.removeHeader('content-length');
164
+
165
+ writeHead.apply(res, arguments);
166
+ };
167
+
168
+ res.end = function (string, encoding) {
169
+ if (!runPatches()) return end.call(res, string, encoding);
170
+
171
+ // If there are remaining bytes, save them as well
172
+ // Also, some implementations call "end" directly with all data.
173
+ res.inject(string, encoding);
174
+ runPatches = () => false;
175
+ // Check if our body is HTML, and if it does not already have the snippet.
176
+ if (html(res.data) && exists(res.data) && !snip(res.data)) {
177
+ // Include, if necessary, replacing the entire res.data with the included snippet.
178
+ res.data = snap(res.data, host);
179
+ }
180
+ if (res.data !== undefined && !res._header) res.setHeader('content-length', Buffer.byteLength(res.data, encoding));
181
+ end.call(res, res.data, encoding);
182
+ };
183
+
184
+ next();
185
+ };
186
+
187
+ };
@@ -1,4 +1,4 @@
1
- const debug = /\b(y|all|livereload)\b/.test (process.env.DEBUG) && console.warn // eslint-disable-line
1
+ const DEBUG = /\b(y|all|cli|livereload)\b/.test(process.env.DEBUG) && console.debug
2
2
  const axios = require('axios')
3
3
  const ws = require('ws')
4
4
  const express = require('express')
@@ -19,7 +19,7 @@ module.exports = class LiveReload {
19
19
  const {address,port} = server.address()
20
20
  startWs(server)
21
21
  this.url = await livereloadURL(address, port)
22
- debug && debug(`[cds] - live reload available at ${this.url}`)
22
+ DEBUG && DEBUG(`[cds] - live reload available at ${this.url}`)
23
23
  resolve(this.url)
24
24
  }
25
25
  // start server
@@ -39,13 +39,13 @@ module.exports = class LiveReload {
39
39
  const startWs = (server) => {
40
40
  this.wsServer = new ws.Server({ server })
41
41
  this.wsServer.on('connection', (socket) => {
42
- debug && debug('Client connected')
42
+ DEBUG && DEBUG('Client connected')
43
43
  socket.on('message', (msg) => {
44
- debug && debug('Client message', msg)
44
+ DEBUG && DEBUG('Client message', msg)
45
45
  const request = JSON.parse(msg)
46
46
 
47
47
  if (request.command === 'hello') {
48
- debug && debug('Client handshake')
48
+ DEBUG && DEBUG('Client handshake')
49
49
  const data = JSON.stringify({
50
50
  command: 'hello',
51
51
  protocols: [
@@ -59,14 +59,14 @@ module.exports = class LiveReload {
59
59
  })
60
60
  socket.send(data)
61
61
  } else if (request.command === 'info') {
62
- debug && debug('Server received client data. Not sending response.')
62
+ DEBUG && DEBUG('Server received client data. Not sending response.')
63
63
  }
64
64
  })
65
65
  })
66
- this.wsServer.on('close', () => { debug && debug('Socket closed') })
67
- this.wsServer.on('error', (e) => debug && debug(e))
66
+ this.wsServer.on('close', () => { DEBUG && DEBUG('Socket closed') })
67
+ this.wsServer.on('error', (e) => DEBUG && DEBUG(e))
68
68
  }
69
- const close = () => { this.wsServer.close(); server.close(); debug && debug('Reload server closed') }
69
+ const close = () => { this.wsServer.close(); server.close(); DEBUG && DEBUG('Reload server closed') }
70
70
  process.once('SIGTERM', close)
71
71
  process.once('SIGINT', close)
72
72
  })
@@ -81,7 +81,7 @@ module.exports = class LiveReload {
81
81
  command: 'reload',
82
82
  path: this.files.length ? this.files[0] : '',
83
83
  })
84
- debug && debug(`[cds] - live reload for ${this.files}. ${this.wsServer.clients.size} ws clients`)
84
+ DEBUG && DEBUG(`[cds] - live reload for ${this.files}. ${this.wsServer.clients.size} ws clients`)
85
85
  broadcast(data, this.wsServer.clients)
86
86
  this.files = []
87
87
  }
@@ -93,8 +93,8 @@ module.exports = class LiveReload {
93
93
 
94
94
  function broadcast(data, sockets) {
95
95
  sockets.forEach(socket => {
96
- debug && debug(`Sending ${data}`)
97
- socket.send(data, err=> debug && debug(err))
96
+ DEBUG && DEBUG(`Sending ${data}`)
97
+ socket.send(data, err=> DEBUG && DEBUG(err))
98
98
  })
99
99
  }
100
100
 
@@ -1,4 +1,4 @@
1
- const DEBUG = /\bwatch\b/.test(process.env.DEBUG) && console.debug
1
+ const DEBUG = /\b(y|all|cli|watch)\b/.test(process.env.DEBUG) && console.debug
2
2
 
3
3
  module.exports = ({ cwd, script, ext, includes=RegExp(), ignore=RegExp(), env={}, delay=200, options={} })=>{
4
4