@sap/cds-dk
Advanced tools
Comparing version 7.9.1 to 7.9.2
@@ -29,3 +29,6 @@ const cds = require('../cds'); | ||
await Promise.all(Object.keys(bindings).map(async name => { | ||
// Serialized because of parallelization issues in the cf CLI, | ||
// see https://github.com/cloudfoundry/cli/issues/2232 | ||
// await Promise.all(Object.keys(bindings).map(async name => { | ||
for (const name of Object.keys(bindings)) { | ||
const binding = bindings[name] | ||
@@ -41,3 +44,3 @@ const cacheKey = JSON.stringify(binding) | ||
resolvedBindings[name] = resolvedBinding | ||
})) | ||
} | ||
return Object.keys(resolvedBindings).length > 0 ? resolvedBindings : undefined | ||
@@ -44,0 +47,0 @@ } |
@@ -34,6 +34,9 @@ const cds = require('../cds'); | ||
if (!options['to-app-services']) logger.log(`Retrieving data from ${bold(onText)}...`); | ||
let resolvedServices | ||
const targets = options.to.split(/,/g); | ||
resolvedServices = await Promise.all(targets.map(async target => { | ||
// Serialized because of parallelization issues in the cf CLI, | ||
// see https://github.com/cloudfoundry/cli/issues/2232 | ||
// resolvedServices = await Promise.all(targets.map(async target => { | ||
const resolvedServices = []; | ||
for (const target of targets) { | ||
let binding; | ||
@@ -52,4 +55,4 @@ if (on === 'k8s') { | ||
resolvedService.binding.resolved = false; | ||
return resolvedService; | ||
})); | ||
resolvedServices.push(resolvedService); | ||
} | ||
@@ -56,0 +59,0 @@ if (options.kind) { |
@@ -292,4 +292,3 @@ const { randomUUID } = require('node:crypto') | ||
if (files[0].endsWith('.csv')) { | ||
const content = cds.utils.fs.readFileSync(files[0]).toString() | ||
const toCSV = (content) => { | ||
const records = cds.parse.csv(content) | ||
@@ -301,3 +300,6 @@ if (records?.length > 1) { | ||
for (let i = 0; i < records[0].length; i++) { | ||
result[header[i]] = randomRecord[i] | ||
// For csv, which is all strings, convert to correct JSON type. | ||
// For simplicity, try to convert the value instead of dispatching on the type. | ||
const val = toNum(randomRecord[i]) ?? randomRecord[i] // boolean is already covered by CSV parser | ||
result[header[i]] = val | ||
} | ||
@@ -307,15 +309,25 @@ return result | ||
} | ||
const toJSON = (records) => { | ||
if (records.length === 1) | ||
return records[0] | ||
else if (records.length > 1) | ||
return records[randomIntInRange({from: 0, to: records.length-1} )] | ||
} | ||
if (files[0].endsWith('.csv')) { | ||
const content = cds.utils.fs.readFileSync(files[0]).toString() | ||
return toCSV(content) | ||
} | ||
else if (files[0].endsWith('.json')) { | ||
const content = cds.utils.fs.readFileSync(files[0]).toString() | ||
const records = JSON.parse(content) | ||
return toJSON(records) | ||
} | ||
else { | ||
let content | ||
if (files[0].endsWith('.json')) { | ||
content = cds.utils.fs.readFileSync(files[0]).toString() | ||
} else { | ||
content = files[0] // for tests, assuming the content is given inline | ||
} | ||
if (content) { | ||
const content = files[0] // for tests, assuming the content is given inline | ||
try { | ||
const records = JSON.parse(content) | ||
if (records.length === 1) | ||
return records[0] | ||
else if (records.length > 1) | ||
return records[randomIntInRange({from: 0, to: records.length-1} )] | ||
return toJSON(records) | ||
} catch { | ||
return toCSV(content) | ||
} | ||
@@ -530,1 +542,8 @@ } | ||
} | ||
function toNum(str){ | ||
if (typeof(str) === 'number') | ||
return str | ||
if (typeof(str) === 'string') | ||
return +str | ||
} |
{ | ||
"name": "@sap/cds-dk", | ||
"version": "7.9.1", | ||
"version": "7.9.2", | ||
"description": "Command line client and development toolkit for the SAP Cloud Application Programming Model", | ||
@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1687173
37394