@sap/cds-dk 6.0.1 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,36 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
8
8
 
9
+ ## Version 6.0.4 - 2022-08-02
10
+
11
+ ### Changed
12
+
13
+ - `cds init` uses latest Maven Java archetype version 1.26.1 for creating Java projects.
14
+ - Use `@sap/cds` 6.0.4
15
+ - `cds bind` handles orgs and spaces containing commas correctly.
16
+
17
+
18
+ ## Version 6.0.3 - 2022-07-14
19
+
20
+ ### Changed
21
+
22
+ - `cds init` uses latest Maven Java archetype version 1.26.0 for creating Java projects.
23
+ - `cds init` now creates Node.js projects with version 6 of `@sap/cds`
24
+
25
+ ### Fixed
26
+
27
+ - `--vcap-file` parameter of `cds deploy` is available again (removed in 6.0.0)
28
+ - `cds add helm:connectivity`: `connectivity.configMapName` was not used for the `connectivity-proxy-info`.
29
+ - `cds add helm:connectivity`: Environment variables added for connectivity service for Java.
30
+ - `cds add helm`: Generation of `xs-security.json` file works on Windows now (`cds compile srv -2 xsuaa` command failed).
31
+
32
+
33
+ ## Version 6.0.2 - 2022-07-06
34
+
35
+ ### Changed
36
+
37
+ - Use `@sap/cds` 6.0.2
38
+
9
39
  ## Version 6.0.1 - 2022-07-05
10
40
 
11
41
  ### Changed
package/bin/cds.js CHANGED
@@ -67,8 +67,12 @@ const cli = { //NOSONAR
67
67
 
68
68
  const DEBUG = /\b(cli)\b/.test (process.env.DEBUG) && console.error
69
69
 
70
- function _local (id) {
71
- return require.resolve (id, {paths:[process.cwd(), __dirname]})
70
+ function _local (id, _else) {
71
+ try { return require.resolve (id, {paths:[process.cwd(), __dirname]}) }
72
+ catch(e) {
73
+ if (_else) return _else(e)
74
+ else throw e
75
+ }
72
76
  }
73
77
 
74
78
  function _defaultCompile (argv, _force) {
@@ -80,7 +84,7 @@ function _defaultCompile (argv, _force) {
80
84
 
81
85
  function _is_model (argv) {
82
86
  // IMPORTANT: have a separate env here, so that the normal one is not initialized before `cds_cli.args` above
83
- const env = require (_local('@sap/cds/lib/env')).for('cds')
87
+ const env = require (_local('@sap/cds/lib/env/cds-env', ()=>_local('@sap/cds/lib/env'))).for('cds')
84
88
  const cds = require (_local('@sap/cds'))
85
89
  return !!cds.resolve(argv,{env,cache:{}})
86
90
  }
@@ -1,5 +1,5 @@
1
1
  module.exports = Object.assign(deploy, {
2
- options: ['--to', '--tunnel-address'],
2
+ options: ['--to', '--tunnel-address', '--vcap-file'],
3
3
  flags: [ '--no-save', '--auto-undeploy', '--dry', '--with-mocks', '--store-credentials', '--bind' ],
4
4
  shortcuts: ['-2'],
5
5
  help: `
@@ -42,6 +42,12 @@ module.exports = Object.assign(deploy, {
42
42
  Deploy through the given address (host:port) rather than the original
43
43
  database address. The tunnel must have been opened before, e.g. using 'cf ssh'.
44
44
 
45
+ *--vcap-file* (beta feature)
46
+
47
+ Use credentials from the given file when deploying to *SAP HANA*, instead of
48
+ creating new credentials. File must be in *default-env.json* format, with a root
49
+ node *VCAP_SERVICES*.
50
+
45
51
  *--store-credentials* (only in combination with *--to hana*)
46
52
 
47
53
  Stores credentials in *default-env.json file*. This is the former default behavior
@@ -1,11 +1,10 @@
1
- const Config = require('@sap/cds/lib/env')
2
1
  const cds = require('../cds')
3
2
  const LOG = cds.log('bind');
4
3
  const resolveBinding = resolver(LOG);
5
4
  const { platformText, bindingText } = require('./bindingUtil');
6
5
 
7
6
  function getUnresolvedBindings({cwd = process.cwd(), env}) {
8
- if (!env) env = Config.for('cds', cwd)
7
+ if (!env) env = cds.env.for('cds', cwd)
9
8
  if (feature(env) === false || feature(env) === "false") return {}
10
9
 
11
10
  const bindings = {}
@@ -89,13 +89,13 @@ class CFKeyProvider {
89
89
 
90
90
 
91
91
  const { org, space } = target;
92
- const orgs = await this._req(targetWithAuth, `/v3/organizations?names=${org}`);
92
+ const orgs = await this._req(targetWithAuth, `/v3/organizations?names=${encodeURIComponent(encodeURIComponent(org))}`);
93
93
  if (!(orgs && orgs.resources.length === 1)) {
94
94
  throw new Error(`CF org ${org} not found!`);
95
95
  }
96
96
 
97
97
  const orgGuid = orgs.resources[0].guid;
98
- const spaces = await this._req(targetWithAuth, `/v3/spaces?names=${space}&organization_guids=${orgGuid}`)
98
+ const spaces = await this._req(targetWithAuth, `/v3/spaces?names=${encodeURIComponent(encodeURIComponent(space))}&organization_guids=${encodeURIComponent(encodeURIComponent(orgGuid))}`)
99
99
  if (!(spaces && spaces.resources.length === 1)) {
100
100
  throw new Error(`CF space ${space} not found in org ${org}!`);
101
101
  }
@@ -243,7 +243,7 @@ class BatchRequest {
243
243
  }
244
244
 
245
245
  const params = Object.keys(filterParams).map(
246
- name => `${name}=${filterParams[name].map(value => encodeURIComponent(value)).join(',')}`
246
+ name => `${name}=${encodeURIComponent(filterParams[name].map(value => encodeURIComponent(value)).join(','))}`
247
247
  ).join("&");
248
248
 
249
249
  const url = this.url + (this.url.match(/\?/) ? '&' : '?') + params;
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '1.25.0';
3
+ const MAVEN_ARCHETYPE_VERSION = '1.26.1';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
@@ -7,6 +7,7 @@ const term = require('../../../util/term');
7
7
  const ProjectReader = require('../../util/projectReader');
8
8
 
9
9
  const TemplateBase = require('../templateBase');
10
+ const versionCompare = require('../../util/versionCompare');
10
11
 
11
12
  const { PROJECT_TYPE, OPTION_JAVA, URLS, OPTION_HELM_UPDATE } = require('../../constants');
12
13
  const { nullLogger } = require('../../util/logger');
@@ -34,9 +35,8 @@ module.exports = class HanaTemplate extends TemplateBase {
34
35
  }
35
36
 
36
37
  async checkEnabled() {
37
- const { lt } = require('semver')
38
38
  const cds = require('../../../cds')
39
- if (lt(cds.version, '5.9.0')) {
39
+ if (versionCompare(cds.version, '5.9.0') < 0) {
40
40
  cds.error('The added configuration requires @sap/cds 5.9.0 or higher. Please update @sap/cds to the latest version and run \x1b[1mcds add hana\x1b[0m again.')
41
41
  }
42
42
  return true
@@ -8,7 +8,7 @@ const io = require("../../../lint/io");
8
8
  const readline = require("readline");
9
9
 
10
10
  const { OPTION_LINT_DEV, OPTION_LINT_GLOBAL } = require("../../constants");
11
- const { mkdirp, fs } = require("@sap/cds/lib/utils");
11
+ const { mkdirp, fs } = require("@sap/cds").utils;
12
12
  const { getConfigPath, getFileExtensions } = require("@sap/eslint-plugin-cds/lib/api");
13
13
  const generators = require("../../../lint/generators");
14
14
 
@@ -1,5 +1,5 @@
1
+ const cds = require('@sap/cds');
1
2
  const path = require('path');
2
- const Config = require('@sap/cds/lib/env');
3
3
 
4
4
  const TemplateUtil = require('../util/templateUtil');
5
5
 
@@ -59,7 +59,7 @@ module.exports = class TemplateBase {
59
59
  projectPath = this.cwd;
60
60
  }
61
61
 
62
- return Config.for('cds', projectPath);
62
+ return cds.env.for('cds', projectPath);
63
63
  }
64
64
 
65
65
  /**
@@ -1,7 +1,7 @@
1
1
  const path = require('path')
2
2
  const { nullLogger } = require('../util/logger')
3
3
  const { BuildTaskFactory } = require('@sap/cds/bin/build')
4
- const { fs } = require('@sap/cds/lib/utils')
4
+ const { fs } = require('@sap/cds').utils
5
5
  const P_LANGUAGE_JAVA = 'java'
6
6
  const P_LANGUAGE_NODEJS = 'nodejs'
7
7
  const DEFAULT_P_LANGUAGE = P_LANGUAGE_NODEJS
@@ -5,6 +5,12 @@ module.exports = wrapFeature('connectivity', {
5
5
  const model = await context.get('model');
6
6
  const prefix = model.app.name;
7
7
 
8
+ deployment.env = {
9
+ ...(deployment.env || {}),
10
+ CDS_ENVIRONMENT_K8S_SERVICEBINDINGS_CONNECTIVITY_SECRETSPATH: '/bindings/connectivity',
11
+ CDS_ENVIRONMENT_K8S_SERVICEBINDINGS_CONNECTIVITY_SERVICE: 'connectivity'
12
+ };
13
+
8
14
  deployment.additionalVolumes = deployment.additionalVolumes || [];
9
15
  deployment.additionalVolumes.push(
10
16
  {
@@ -1,8 +1,10 @@
1
- {{- $ := merge (dict "name" "connectivity-proxy-info") . }}
1
+ {{- if .Values.connectivity }}
2
+ {{- if or (not (hasKey .Values.connectivity "enabled")) .Values.connectivity.enabled }}
3
+ {{- $ := merge (dict "name" "connectivity-proxy-info") . }}
2
4
  apiVersion: v1
3
5
  kind: ConfigMap
4
6
  metadata:
5
- name: {{ .Release.Name }}-connectivity-proxy-info
7
+ name: {{ .Values.connectivity.configMapName }}
6
8
  namespace: {{ .Release.Namespace }}
7
9
  labels: {{- include "cap.labels" $ | nindent 4 }}
8
10
  data:
@@ -13,4 +15,6 @@ data:
13
15
  onpremise_proxy_ldap_port: "20001"
14
16
  onpremise_proxy_port: "20003"
15
17
  onpremise_proxy_rfc_port: "20001"
16
- onpremise_socks5_proxy_port: "20004"
18
+ onpremise_socks5_proxy_port: "20004"
19
+ {{- end }}
20
+ {{- end }}
@@ -1,12 +1,15 @@
1
- const { exec } = require("../../util/exec");
1
+ const cds = require('../../compile')
2
+ const Path = require('path');
2
3
 
3
4
  async function renderXsSecurityJson(projectPath) {
4
- const result = await exec({
5
- cwd: projectPath,
6
- stdio: ["inherit", "pipe", "inherit"],
7
- })`cds compile srv -2 xsuaa`;
8
- const xsSecurityJson = result.stdout;
9
- return xsSecurityJson;
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);
10
13
  }
11
14
 
12
15
  module.exports = {
@@ -2,7 +2,7 @@ const fs = require("fs");
2
2
  const os = require("os");
3
3
  const cp = require("child_process");
4
4
  const path = require("path");
5
- const { mkdirp } = require("@sap/cds/lib/utils");
5
+ const { mkdirp } = require("@sap/cds").utils;
6
6
  const term = require("../util/term");
7
7
 
8
8
  const IS_WIN = os.platform() === "win32";