@sap/cds-dk 6.1.4 → 6.2.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 (153) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/bin/build/all.js +5 -5
  3. package/bin/cds.js +7 -5
  4. package/bin/deploy/index.js +3 -2
  5. package/bin/deploy/to-sqlite.js +4 -3
  6. package/bin/help.js +4 -0
  7. package/bin/init.js +2 -1
  8. package/bin/login.js +23 -9
  9. package/bin/mock.js +1 -0
  10. package/bin/pull.js +24 -19
  11. package/bin/push.js +20 -9
  12. package/bin/subscribe.js +40 -10
  13. package/bin/watch.js +15 -10
  14. package/lib/bind/kubernetesCredentialsProvider.js +1 -0
  15. package/lib/client/activate.js +42 -51
  16. package/lib/client/auth_manager.js +7 -8
  17. package/lib/client/base_command.js +5 -2
  18. package/lib/client/extend.js +33 -38
  19. package/lib/client/helper/cf_helper.js +11 -11
  20. package/lib/client/helper/dependency_helper.js +2 -2
  21. package/lib/client/helper/errors.js +4 -3
  22. package/lib/client/helper/logging.js +17 -23
  23. package/lib/client/params.js +5 -5
  24. package/lib/client/pull.js +19 -21
  25. package/lib/client/push.js +16 -15
  26. package/lib/client/settings_manager.js +54 -55
  27. package/lib/compile/openapi/csdl2openapi.js +18 -12
  28. package/lib/import/message.js +1 -1
  29. package/lib/import/odata/metadataconverter/MetadataConverter.js +23 -17
  30. package/lib/import/odata/v2parser.js +43 -17
  31. package/lib/import/odata/v4parser.js +77 -22
  32. package/lib/init/constants.js +5 -2
  33. package/lib/init/index.js +16 -4
  34. package/lib/init/template/_merging/registry-mta.js +13 -0
  35. package/lib/init/template/approuter/index.js +9 -0
  36. package/lib/{k8s/connectivity/templates/connectivity.yaml → init/template/auditlog/files/auditlog.yaml} +0 -0
  37. package/lib/init/template/auditlog/index.js +46 -27
  38. package/lib/{k8s/connectivity/templates → init/template/connectivity/files}/connectivity-binding.yaml +0 -0
  39. package/lib/{k8s/connectivity/templates → init/template/connectivity/files}/connectivity-proxy-info.yaml +1 -1
  40. package/lib/init/template/connectivity/files/connectivity.yaml +1 -0
  41. package/lib/init/template/connectivity/files/values.yaml.hbs +26 -0
  42. package/lib/init/template/connectivity/index.js +41 -0
  43. package/lib/init/template/data/index.js +8 -8
  44. package/lib/init/template/destinations/files/destination.yaml +1 -0
  45. package/lib/init/template/destinations/index.js +44 -0
  46. package/lib/init/template/enterprise-messaging/files/cds.package.json +10 -0
  47. package/lib/init/template/enterprise-messaging/files/cds.profile.package.json.hbs +12 -0
  48. package/lib/init/template/enterprise-messaging/files/cdsrc.json +8 -0
  49. package/lib/init/template/enterprise-messaging/files/cdsrc.json.hbs +10 -0
  50. package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +1 -0
  51. package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +13 -0
  52. package/lib/init/template/enterprise-messaging/files/values.yaml +8 -0
  53. package/lib/init/template/enterprise-messaging/index.js +56 -0
  54. package/lib/init/template/extensibility/files/cdsrc.json +5 -0
  55. package/lib/init/template/extensibility/files/cdsrc.json.hbs +7 -0
  56. package/lib/init/template/extensibility/index.js +18 -13
  57. package/lib/{k8s/hana-deployer/templates → init/template/hana/files}/hana-deployer-job.yaml +0 -0
  58. package/lib/init/template/hana/files/java/{cdsrc.json.hbs → cds.json.hbs} +0 -0
  59. package/lib/init/template/hana/files/java/{profile.cdsrc.json.hbs → cds.profile.json.hbs} +0 -0
  60. package/lib/init/template/hana/files/java/cds.shortcut.json.hbs +5 -0
  61. package/lib/init/template/hana/files/java/cds.shortcut.profile.json.hbs +8 -0
  62. package/lib/init/template/hana/files/java/db/package.json +2 -1
  63. package/lib/init/template/hana/files/mta.yaml.hbs +6 -0
  64. package/lib/init/template/hana/files/nodejs/{cds.package.json.hbs → cds.json.hbs} +0 -0
  65. package/lib/init/template/hana/files/nodejs/{cds.profile.package.json.hbs → cds.profile.json.hbs} +0 -0
  66. package/lib/init/template/hana/files/nodejs/cds.shortcut.json.hbs +7 -0
  67. package/lib/init/template/hana/files/nodejs/cds.shortcut.profile.json.hbs +10 -0
  68. package/lib/init/template/hana/files/values.yaml.hbs +19 -0
  69. package/lib/init/template/hana/index.js +29 -29
  70. package/lib/{k8s → init/template/helm}/Model.d.ts +0 -0
  71. package/lib/{k8s/resources → init/template}/helm/chart/templates/NOTES.txt +0 -0
  72. package/lib/{k8s/resources → init/template}/helm/chart/templates/_deployment_helpers.tpl +0 -0
  73. package/lib/{k8s/resources → init/template}/helm/chart/templates/_helpers.tpl +4 -5
  74. package/lib/{k8s/resources → init/template}/helm/chart/templates/_sapcp_helpers.tpl +0 -0
  75. package/lib/{k8s/resources/helm/chart/schemas → init/template/helm/chart}/values.root.schema.json +0 -0
  76. package/lib/{k8s/resources/helm/chart/schemas → init/template/helm/chart}/values.schema.json +0 -0
  77. package/lib/init/template/helm/files/Chart.yaml.hbs +13 -0
  78. package/lib/init/template/helm/files/values.yaml.hbs +26 -0
  79. package/lib/init/template/helm/index.js +74 -14
  80. package/lib/{k8s/deployment → init/template/helm}/subchart/Chart.yaml +0 -0
  81. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/_helpers.tpl +0 -0
  82. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/api-rule.yaml +0 -0
  83. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/deployment.yaml +0 -0
  84. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/network-policy.yaml +0 -0
  85. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/pod-disruption-budget.yaml +0 -0
  86. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/secret.yaml +0 -0
  87. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/service-binding.yaml +0 -0
  88. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/service.yaml +0 -0
  89. package/lib/{k8s/deployment → init/template/helm}/subchart/values-lint.yaml +0 -0
  90. package/lib/{k8s/deployment → init/template/helm}/subchart/values.md +0 -0
  91. package/lib/{k8s/deployment → init/template/helm}/subchart/values.schema.json +0 -0
  92. package/lib/{k8s/deployment → init/template/helm}/subchart/values.yaml +0 -0
  93. package/lib/{k8s/html5-apps-deployer/templates → init/template/html5-repo/files}/_html5_deployment_helpers.tpl +0 -0
  94. package/lib/{k8s/html5-apps-deployer/templates → init/template/html5-repo/files}/html5-apps-deployer-job.yaml +1 -1
  95. package/lib/{k8s/html5-apps-repo-host/templates → init/template/html5-repo/files}/html5-apps-repo-host.yaml +0 -0
  96. package/lib/init/template/html5-repo/index.js +59 -0
  97. package/lib/init/template/kibana-logging/index.js +8 -0
  98. package/lib/init/template/lint/index.js +1 -4
  99. package/lib/init/template/mta/files/mta.yaml.hbs +3 -2
  100. package/lib/init/template/mta/index.js +6 -1
  101. package/lib/init/template/multitenancy/files/java/.cdsrc.json +3 -0
  102. package/lib/init/template/multitenancy/files/java/package.json +2 -6
  103. package/lib/{k8s/multitenancy/templates → init/template/multitenancy/files}/saas-registry.yaml +3 -3
  104. package/lib/init/template/multitenancy/files/xsuaa.yaml +1 -0
  105. package/lib/init/template/multitenancy/index.js +53 -26
  106. package/lib/init/template/nodejs/files/.gitignore.hbs +1 -0
  107. package/lib/init/template/templateBase.js +1 -1
  108. package/lib/init/template/xsuaa/files/values.yaml.hbs +10 -0
  109. package/lib/init/template/xsuaa/files/xsuaa.yaml +1 -0
  110. package/lib/init/template/xsuaa/index.js +34 -22
  111. package/lib/init/util/fsUtil.js +11 -5
  112. package/lib/init/util/projectReader.js +24 -32
  113. package/lib/init/util/templateUtil.js +17 -5
  114. package/lib/lint/Linter.js +9 -17
  115. package/lib/lint/checks.js +0 -1
  116. package/lib/lint/generators.js +2 -192
  117. package/lib/lint/io.js +1 -3
  118. package/lib/watch/node-watch.js +2 -2
  119. package/npm-shrinkwrap.json +1412 -791
  120. package/package.json +5 -4
  121. package/lib/init/template/helm/update/index.js +0 -28
  122. package/lib/k8s/ChartAdder.js +0 -75
  123. package/lib/k8s/ChartBuilder.js +0 -192
  124. package/lib/k8s/Context.js +0 -71
  125. package/lib/k8s/ImageUtil.js +0 -21
  126. package/lib/k8s/auditlog/index.js +0 -29
  127. package/lib/k8s/auditlog/templates/auditlog.yaml +0 -1
  128. package/lib/k8s/buildModel.js +0 -68
  129. package/lib/k8s/connectivity/index.js +0 -80
  130. package/lib/k8s/deployment/index.js +0 -79
  131. package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +0 -81
  132. package/lib/k8s/destinations/index.js +0 -40
  133. package/lib/k8s/destinations/lib.js +0 -16
  134. package/lib/k8s/destinations/templates/destinations.yaml +0 -1
  135. package/lib/k8s/docker/push.js +0 -8
  136. package/lib/k8s/event-mesh/index.js +0 -53
  137. package/lib/k8s/event-mesh/lib.js +0 -9
  138. package/lib/k8s/event-mesh/templates/event-mesh.yaml +0 -1
  139. package/lib/k8s/hana-deployer/index.js +0 -48
  140. package/lib/k8s/helm/Release.js +0 -80
  141. package/lib/k8s/html5-apps-deployer/index.js +0 -53
  142. package/lib/k8s/html5-apps-repo-host/index.js +0 -26
  143. package/lib/k8s/html5-apps-repo-host/lib.js +0 -16
  144. package/lib/k8s/index.js +0 -153
  145. package/lib/k8s/modules.js +0 -36
  146. package/lib/k8s/multitenancy/index.js +0 -24
  147. package/lib/k8s/multitenancy/lib.js +0 -25
  148. package/lib/k8s/readProject.js +0 -14
  149. package/lib/k8s/util.js +0 -186
  150. package/lib/k8s/wrapFeature.js +0 -55
  151. package/lib/k8s/xsuaa/index.js +0 -64
  152. package/lib/k8s/xsuaa/lib.js +0 -17
  153. package/lib/k8s/xsuaa/templates/xsuaa.yaml +0 -1
@@ -1,14 +0,0 @@
1
-
2
-
3
- const { ProjectReader, TemplateBase, CDSGenerator } = require('./modules');
4
-
5
- async function readProject(path = '') {
6
- /* TODO: Ugly way to access project information -> talk to the guys */
7
- const reader = new ProjectReader(new ProjectTemplate(path, new CDSGenerator(), ''));
8
- return await reader.read();
9
- }
10
-
11
- class ProjectTemplate extends TemplateBase {
12
- }
13
-
14
- module.exports = readProject;
package/lib/k8s/util.js DELETED
@@ -1,186 +0,0 @@
1
-
2
- const { glob } = require('./modules');
3
- const Path = require('path');
4
- const fs = require('fs');
5
- const { $, exec, execSync } = require('../util/exec');
6
- const os = require('os');
7
- /**
8
- *
9
- * @param {string} msg
10
- * @returns {never}
11
- */
12
- function throwError(msg = 'Internal Error', ...args) {
13
- if (Array.isArray(msg)) {
14
- msg = format(msg, ...args);
15
- }
16
-
17
- throw new Error(msg);
18
- }
19
-
20
- function resource(path, plugin) {
21
- return plugin == undefined ? Path.join(__dirname, 'resources', path)
22
- : Path.join(__dirname, plugin, path)
23
- }
24
-
25
- function cp(from, to) {
26
- const content = fs.readFileSync(from);
27
- fs.writeFileSync(to, content);
28
- }
29
-
30
- function format(text, ...args) {
31
- if (Array.isArray(text)) {
32
- text = text.slice(0,-1).map( (str, index) => `${str}$${index}` ).concat(text.slice(-1)).join('');
33
- }
34
-
35
- const forTTY = process.stdout.isTTY;
36
- if (forTTY) {
37
- text = text
38
- .replace(/\n# ([^\n]*)\n/g, `\n\x1b[1m$1\x1b[0m\n`)
39
- .replace(/ \*([^*]+)\*/g, ` \x1b[1m$1\x1b[0m`)
40
- .replace(/ _([^_]+)_/g, ` \x1b[4m$1\x1b[0m`);
41
- } else {
42
- text = text
43
- .replace(/\n# ([^\n]*)\n/g, `\n$\n`)
44
- .replace(/ \*([^*]+)\*/g, `$1`)
45
- .replace(/ _([^_]+)_/g, `$1`);
46
- }
47
-
48
- return text.replace(/\$(\d+)/, (match, value) => args[value]);
49
- }
50
-
51
- function help(text) {
52
- console.log(format(text))
53
- }
54
-
55
- function checkDebug(category) {
56
- const debug = (process.env.DEBUG || '').split(/\W+/);
57
- return debug.indexOf(category)>=0;
58
- }
59
-
60
- function dirExists(path) {
61
- try {
62
- const stat = fs.statSync(path);
63
- return stat.isDirectory();
64
- } catch (error) {
65
- if (error.code === 'ENOENT' || error.code === 'ENOTDIR')
66
- return false;
67
- else
68
- throw error;
69
- }
70
- }
71
-
72
- function globSingleFile(pattern) {
73
- const result = glob.sync(pattern);
74
- if (result.length !== 1) throwError `Expect 1 file matching the pattern *${ pattern }*. Found ${ result.length }.`;
75
- return result[0];
76
- }
77
-
78
- function getProperty(obj, name, handleUndefined) {
79
- const path = name.split('.');
80
- for (const field of path) {
81
- if (typeof obj !== 'object') throwError `Invalid property *${name}*.`;
82
- obj = obj[field];
83
- if (typeof obj === 'undefined') return handleUndefined(name);
84
- }
85
-
86
- return obj;
87
- }
88
-
89
- function checkProperties(properties, obj, onError = name => throwError `Expect property *${name}*`, path = '') {
90
- for (const name of Object.keys(properties)) {
91
- const property = properties[name];
92
- if (typeof property === 'object') {
93
- checkProperties(property, obj[name] || {}, onError, path = `${path}${name}.`);
94
- } else if (property) {
95
- if (!obj[name]) onError(`${path}${name}`);
96
- }
97
- }
98
- }
99
-
100
- function mergeDeep(...objs) {
101
- const target = {...objs[0]};
102
- const obj = objs[1];
103
- for (const name of Object.keys(obj)) {
104
- if (name === '__proto__') continue;
105
- const property = obj[name];
106
- if (typeof property === 'object') {
107
- if (target[name]) {
108
- target[name] = mergeDeep(target[name], property);
109
- } else {
110
- delete property.__proto__;
111
- target[name] = {...property};
112
- }
113
- } else {
114
- target[name] = property;
115
- }
116
- }
117
-
118
- if (objs.length > 2) {
119
- return mergeDeep(target, objs.slice(2));
120
- } else {
121
- return target;
122
- }
123
- }
124
-
125
- async function readFileIfExists(path, encoding) {
126
- try {
127
- return await fs.promises.readFile(path, encoding);
128
- } catch(error) {
129
- if (error.code === 'ENOENT' || error.code === 'EISDIR') return undefined;
130
- else throw error;
131
- }
132
- }
133
-
134
- /**
135
- * Takes path of md5 file as an argument and returns a JSON object containing hashes of files stored in MD5 file.
136
- * @param {String} path
137
- * @returns {JSON}
138
- */
139
- async function parseMd5File(path) {
140
- let md5Hashes = {};
141
- const md5FileContent = await readFileIfExists(path);
142
- if(md5FileContent == undefined) return md5Hashes;
143
- let md5Checksums = md5FileContent.toString().split(os.EOL)
144
- md5Checksums.forEach((checksum) => {
145
- checksum = checksum.split(" ")
146
- md5Hashes[checksum[1]] = checksum[0];
147
- })
148
- return md5Hashes;
149
- }
150
-
151
- /**
152
- * Takes json object containing key as filename and value as MD5 hash and generates a md5sum format file.
153
- * @param {String} path
154
- * @param {JSON} data
155
- */
156
- async function writeMd5File(path, data) {
157
- let md5_output;
158
- Object.keys(data).forEach(key => {
159
- var currMd5 = `${data[key]} ${key}`;
160
- if(md5_output == undefined)
161
- md5_output = currMd5;
162
- else
163
- md5_output += os.EOL + currMd5;
164
- })
165
- await fs.promises.writeFile(path, md5_output);
166
- }
167
-
168
- module.exports = {
169
- throwError,
170
- resource,
171
- cp,
172
- format,
173
- help,
174
- checkDebug,
175
- dirExists,
176
- readFileIfExists,
177
- globSingleFile,
178
- getProperty,
179
- checkProperties,
180
- mergeDeep,
181
- $,
182
- exec,
183
- execSync,
184
- parseMd5File,
185
- writeMd5File
186
- }
@@ -1,55 +0,0 @@
1
- function wrapFeature(name, impl) {
2
- return async function (context) {
3
-
4
- const isRequired = once(async function () {
5
- const features = await context.get('features');
6
- const isRequired = impl.isRequired ? (context => impl.isRequired(context)) : (() => false);
7
-
8
- return features.has(name) || await isRequired(context);
9
- });
10
-
11
- const init = once(async function () {
12
- const enabled = await isRequired();
13
- if (enabled && impl.init) await impl.init(context);
14
- return enabled;
15
- });
16
-
17
- const handler = {
18
- get(target, prop) {
19
- if (typeof impl[prop] !== 'function') return undefined;
20
-
21
- switch (prop) {
22
- case 'addToChart':
23
- return async (builder, values) => {
24
- if (impl.addToChart && values[name] && values[name].enabled !== false)
25
- return impl.addToChart(builder, values);
26
- }
27
-
28
- default:
29
- return async (...args) => {
30
- if (await init()) {
31
- return impl[prop](...args);
32
- }
33
- }
34
- }
35
- },
36
- };
37
-
38
- return new Proxy(impl, handler);
39
- }
40
- }
41
-
42
- function once(func) {
43
- let result;
44
- let called;
45
-
46
- return function () {
47
- if (!called) {
48
- result = func();
49
- called = true;
50
- }
51
- return result;
52
- }
53
- }
54
-
55
- module.exports = wrapFeature;
@@ -1,64 +0,0 @@
1
- const { renderXsSecurityJson } = require('./lib');
2
- const wrapFeature = require('../wrapFeature');
3
-
4
- module.exports = wrapFeature('xsuaa', {
5
- async getXsuaaRequiresServiceName(context) {
6
- const env = await context.get('env');
7
- if (env.requires.auth && env.requires.auth.kind === 'xsuaa') return 'auth';
8
- else if (env.requires.uaa && env.requires.uaa.kind === 'xsuaa') return 'uaa';
9
- else undefined;
10
- },
11
-
12
- async isRequired(context) {
13
- return !!await this.getXsuaaRequiresServiceName(context)
14
- },
15
-
16
- async init(context) {
17
- const model = await context.get('model');
18
- const { services } = model;
19
- delete services.auth;
20
- delete services.xsuaa;
21
- delete services.uaa;
22
- // remove database bindings as they need a workaround
23
- delete services.db;
24
- delete services['db-mt'];
25
-
26
- this.bindingName = await this.getXsuaaRequiresServiceName(context)
27
- },
28
-
29
- async getChartCapabilities(context) {
30
- const model = await context.get('model');
31
-
32
- return {
33
- xsuaa: {
34
- serviceOfferingName: 'xsuaa',
35
- servicePlanName: 'application',
36
- parameters: {
37
- xsappname: model.app.name
38
- },
39
- config: 'xs-security.json'
40
- }
41
- }
42
- },
43
-
44
- // eslint-disable-next-line no-unused-vars
45
- async getServiceBindings(context) {
46
- return {
47
- [this.bindingName || 'auth']: {
48
- serviceInstanceName: 'xsuaa'
49
- }
50
- }
51
- },
52
-
53
- async addToChart(builder, { xsuaa }) {
54
- await builder.addAllTemplates(__dirname);
55
-
56
- const { config } = xsuaa;
57
- if (config) {
58
- if (!await builder.addChartFile(config, { optional: true })) {
59
- const xsSecurityJson = await renderXsSecurityJson(builder.rootPath, config);
60
- await builder.writeChartFile(config, xsSecurityJson);
61
- }
62
- }
63
- }
64
- });
@@ -1,17 +0,0 @@
1
- const cds = require('../../compile')
2
- const Path = require('path');
3
-
4
- async function renderXsSecurityJson(projectPath) {
5
- const xsSecurityJson = await(async () => {
6
- try {
7
- const models = await cds.load(Path.join(projectPath, cds.env.folders.srv))
8
- return cds.compile.to.xsuaa(models)
9
- } catch (error) { /* ignore */ }
10
- })() || { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
11
-
12
- return JSON.stringify(xsSecurityJson, null, 2);
13
- }
14
-
15
- module.exports = {
16
- renderXsSecurityJson
17
- };
@@ -1 +0,0 @@
1
- {{- include "cap.service-instance" . }}