Skip to content

Commit 9e58e96

Browse files
committed
Fix - CAP doesn't consistently return credentials from cds.env (until fix is available use fallback API)
1 parent 8fb9a06 commit 9e58e96

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

bin/btp.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,23 @@ export async function handler(argv) {
4444
let tree = []
4545
for (let item of hierarchy.children) {
4646
let children = []
47-
for (let itemSub of item.subaccounts) {
48-
let child = {
49-
name: `🧾 ${itemSub.displayName}`,
50-
value: `{"guid": "${itemSub.guid}", "type": "item" }`,
51-
short: `Selected: ${itemSub.displayName}`
47+
if(item.subaccounts){
48+
for (let itemSub of item.subaccounts) {
49+
let child = {
50+
name: `🧾 ${itemSub.displayName}`,
51+
value: `{"guid": "${itemSub.guid}", "type": "item" }`,
52+
short: `Selected: ${itemSub.displayName}`
53+
}
54+
children.push(child)
5255
}
53-
children.push(child)
54-
}
55-
let leaf = {
56-
name: `📁 ${item.displayName}`,
57-
value: `{"guid": "${item.guid}", "type": "folder" }`,
58-
children: children
56+
let leaf = {
57+
name: `📁 ${item.displayName}`,
58+
value: `{"guid": "${item.guid}", "type": "folder" }`,
59+
children: children
60+
}
61+
tree.push(leaf)
5962
}
60-
tree.push(leaf)
63+
6164
}
6265
for (let item of hierarchy.subaccounts) {
6366
let leaf = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hana-cli",
3-
"version": "3.202309.1",
3+
"version": "3.202309.2",
44
"description": "HANA Developer Command Line Interface",
55
"main": "index.js",
66
"bin": {

utils/connections.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,17 @@ export async function getConnOptions(prompts) {
147147
dotenv.config({ path: dotEnvFile })
148148
} else {
149149
try {
150-
process.env.CDS_ENV = 'hybrid'
151-
let optionsCDS = cds.env.requires.db
152-
let options = { hana: optionsCDS.credentials }
150+
const data = fs.readFileSync(cdsrcPrivate,
151+
{ encoding: 'utf8', flag: 'r' })
152+
const object = JSON.parse(data)
153+
const resolveBinding = base.require('@sap/cds-dk/lib/bind/bindingResolver') //.BindingResolver(LOG)
154+
let resolvedService = await resolveBinding.resolveBinding(null, object.requires['[hybrid]'].db.binding)
155+
let options = { hana: resolvedService.credentials }
156+
157+
/* process.env.CDS_ENV = 'hybrid'
158+
let optionsCDS = cds.env.requires.db
159+
console.log(optionsCDS)
160+
let options = { hana: optionsCDS.credentials } */
153161
options.hana.pooling = true
154162
base.debug(options)
155163
base.debug(base.bundle.getText("connectionFile"))
@@ -161,8 +169,8 @@ export async function getConnOptions(prompts) {
161169
if (e.code !== 'MODULE_NOT_FOUND') {
162170
// Re-throw not "Module not found" errors
163171
throw e
164-
}
165-
throw base.bundle.getText("cds-dk2")
172+
}
173+
throw base.bundle.getText("cds-dk2")
166174
}
167175
}
168176
}

0 commit comments

Comments
 (0)