@sap/cds-dk 8.4.1 → 8.4.2
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 +17 -2
- package/bin/add.js +2 -12
- package/bin/cds.js +5 -0
- package/lib/bind/index.js +1 -1
- package/lib/build/provider/hana/index.js +1 -1
- package/lib/index.js +14 -14
- package/lib/init/constants.js +1 -1
- package/lib/init/template/data/as-csv.js +1 -1
- package/lib/init/template/data/as-json.js +4 -4
- package/lib/init/template/hana/files/package.json.hbs +18 -4
- package/lib/init/template/http/index.js +6 -4
- package/lib/init/template/side-by-side-extensibility/index.js +1 -0
- package/npm-shrinkwrap.json +8 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
9
9
|
|
|
10
|
+
## Version 8.4.2 - 2024-11-19
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `cds init` uses latest Maven Java archetype version 3.4.1 for creating Java projects.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- `cds add -p/--package` correctly parse plugin-contributed options.
|
|
19
|
+
- `cds add side-by-side-extensibility` does not throw an error.
|
|
20
|
+
- fix method name in `cds bind` credential handling.
|
|
21
|
+
- `cds add --help` no longer has missing line breaks in help text.
|
|
22
|
+
- `cds` commands no longer fail with an error `cds.extend is not a function` with very old versions of `@sap/cds`.
|
|
23
|
+
- `cds add hana` adds the `requires.db` entry to `.cdsrc.json` for Java projects.
|
|
24
|
+
- `cds add data` creates decimal values with correct scale `0` if only precision is given, like in `Decimal(15)`.
|
|
25
|
+
|
|
26
|
+
|
|
10
27
|
## Version 8.4.1 - 2024-11-08
|
|
11
28
|
|
|
12
29
|
### Added
|
|
@@ -14,8 +31,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
14
31
|
- `cds deploy --no-build` lets you skip the implicit `cds build`.
|
|
15
32
|
- `cds add data/http` supports new type `cds.Map`.
|
|
16
33
|
|
|
17
|
-
### Changed
|
|
18
|
-
|
|
19
34
|
### Fixed
|
|
20
35
|
|
|
21
36
|
- `cds compile --to <unknown>` shows a cleaner error message.
|
package/bin/add.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const cds = require('../lib/cds'), { fs } = cds.utils
|
|
2
2
|
const DEBUG = cds.debug('add')
|
|
3
3
|
const { join } = require('path')
|
|
4
|
-
const cmd = require('../lib/util/command')
|
|
5
4
|
|
|
6
5
|
const fromDk = fs.readdirSync(join(__dirname, '../lib/init/template'))
|
|
7
6
|
const fromPlugins = require('../lib/init/add').registered
|
|
@@ -60,7 +59,7 @@ ${Object.entries(conf).sort(([a], [b]) => a.localeCompare(b)).flatMap(([pluginNa
|
|
|
60
59
|
const text4 = arr => arr.map(({ key, help, short }) => help && ` ${key}${short ? ' | '+short : ''}\n\n ${help}`).join('\n\n')
|
|
61
60
|
const optionsText = text4(options), flagsText = text4(flags)
|
|
62
61
|
if (!optionsText && !flagsText) return []
|
|
63
|
-
return ` *cds add ${pluginName}
|
|
62
|
+
return ` *cds add ${pluginName}*${optionsText?`\n\n${optionsText}`:''}${flagsText?`\n\n${flagsText}`:''}`
|
|
64
63
|
}).join('\n\n\n')}
|
|
65
64
|
|
|
66
65
|
|
|
@@ -100,17 +99,8 @@ async function handleCompletion(currentWord, previousWord, argv, util) {
|
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
async function add(args) {
|
|
103
|
-
// await cds.plugins
|
|
104
102
|
const CDSGenerator = require('../lib/init')
|
|
105
103
|
const generator = new CDSGenerator()
|
|
106
104
|
const features = args.map(f => f.split(/[,\s]/)).flat()
|
|
107
|
-
|
|
108
|
-
console.log(`running with --package, adding dependency ${cds.cli.options.package}`)
|
|
109
|
-
await cmd.spawnCommand(`npm`, ['add', cds.cli.options.package], { cwd: cds.root })
|
|
110
|
-
await cmd.spawnCommand(`cds`, ['add', ...features], { cwd: cds.root }) // plugins need to reload
|
|
111
|
-
// await cds.plugins
|
|
112
|
-
// await generator.add(features)
|
|
113
|
-
} else {
|
|
114
|
-
await generator.add(features)
|
|
115
|
-
}
|
|
105
|
+
await generator.add(features)
|
|
116
106
|
}
|
package/bin/cds.js
CHANGED
|
@@ -62,6 +62,11 @@ const cli = {
|
|
|
62
62
|
// REVISIT: Have to load plugins to allow for plugin-contributed flags!
|
|
63
63
|
if (cmd === 'add') {
|
|
64
64
|
cds.cli = { command: 'add' }
|
|
65
|
+
if (argv.includes('-p') || argv.includes('--package')) {
|
|
66
|
+
const p = argv[argv.indexOf('-p') + 1] || argv[argv.indexOf('--package') + 1]
|
|
67
|
+
console.log(`running with --package, adding dependency ${p}`)
|
|
68
|
+
await require('../lib/util/command').spawnCommand(`npm`, ['add', p], { cwd: cds.root })
|
|
69
|
+
}
|
|
65
70
|
await cds.plugins
|
|
66
71
|
for (const [, Plugin] of cds.add.registered) {
|
|
67
72
|
const all = Object.entries((new Plugin).options())
|
package/lib/bind/index.js
CHANGED
|
@@ -118,7 +118,7 @@ function mergeCredentials(credentials, customCredentials) {
|
|
|
118
118
|
if (!credentials[key]) {
|
|
119
119
|
credentials[key] = {};
|
|
120
120
|
}
|
|
121
|
-
credentials[key] = this.
|
|
121
|
+
credentials[key] = this.mergeCredentials(credentials[key], customCredentials[key]);
|
|
122
122
|
} else {
|
|
123
123
|
credentials[key] = customCredentials[key];
|
|
124
124
|
}
|
|
@@ -56,7 +56,7 @@ class HanaBuildPlugin extends InternalBuildPlugin {
|
|
|
56
56
|
}
|
|
57
57
|
// copy native hana artifacts from workspaces
|
|
58
58
|
if (workspaceFiles) {
|
|
59
|
-
const dest = path.join(this.task.dest, 'src/gen')
|
|
59
|
+
const dest = path.join(this.task.dest, this.isStagingBuild() ? 'src' : 'src/gen')
|
|
60
60
|
await Promise.all(
|
|
61
61
|
workspaceFiles.map((src) => {
|
|
62
62
|
const { dir, filePath } = src
|
package/lib/index.js
CHANGED
|
@@ -35,6 +35,20 @@ class CdsDk {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
const REQUIRED_CDS_MAJOR = 7, REQUIRED_CDS_MINOR = 2
|
|
39
|
+
const [major, minor] = cds.version.split('.').map(Number)
|
|
40
|
+
if (major < REQUIRED_CDS_MAJOR || major === REQUIRED_CDS_MAJOR && minor < REQUIRED_CDS_MINOR) {
|
|
41
|
+
const [dkVersion] = require('../package.json').version.split('.')
|
|
42
|
+
|
|
43
|
+
console.error(`
|
|
44
|
+
This application uses '@sap/cds' version ${major}.${minor}, which is not compatible with the installed '@sap/cds-dk' version ${dkVersion}.
|
|
45
|
+
You can either:
|
|
46
|
+
- update '@sap/cds' to the latest version (recommended)
|
|
47
|
+
- downgrade '@sap/cds-dk' to version ${REQUIRED_CDS_MAJOR}
|
|
48
|
+
`)
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
51
|
+
|
|
38
52
|
cds.extend (cds.constructor) .with (CdsDk)
|
|
39
53
|
|
|
40
54
|
class CdsDkAdd {
|
|
@@ -49,20 +63,6 @@ if (process.argv[2] in { add:1, init:1, help:1 }) {
|
|
|
49
63
|
cds.extend (cds.constructor) .with (CdsDkBuild)
|
|
50
64
|
}
|
|
51
65
|
|
|
52
|
-
const REQUIRED_CDS_MAJOR = 7, REQUIRED_CDS_MINOR = 2
|
|
53
|
-
const [major, minor] = cds.version.split('.').map(Number)
|
|
54
|
-
if (major < REQUIRED_CDS_MAJOR || major === REQUIRED_CDS_MAJOR && minor < REQUIRED_CDS_MINOR) {
|
|
55
|
-
const [dkVersion] = require('../package.json').version.split('.')
|
|
56
|
-
|
|
57
|
-
console.error(`
|
|
58
|
-
This application uses '@sap/cds' version ${major}.${minor}, which is not compatible with the installed '@sap/cds-dk' version ${dkVersion}.
|
|
59
|
-
You can either:
|
|
60
|
-
- update '@sap/cds' to the latest version (recommended)
|
|
61
|
-
- downgrade '@sap/cds-dk' to version ${REQUIRED_CDS_MAJOR}
|
|
62
|
-
`)
|
|
63
|
-
process.exit(1)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
66
|
function _local (id) {
|
|
67
67
|
return require.resolve (id, {paths:[
|
|
68
68
|
process.cwd(), // project-local module is preferred
|
package/lib/init/constants.js
CHANGED
|
@@ -39,7 +39,7 @@ module.exports = async (data={}, csn, { headerOnly=false, separator=',' }={}) =>
|
|
|
39
39
|
}
|
|
40
40
|
record.push(...Object.values(value))
|
|
41
41
|
}
|
|
42
|
-
else if (element.is_struct) {
|
|
42
|
+
else if (element.is_struct && element.type !== 'cds.Map') {
|
|
43
43
|
if (i === 0) {
|
|
44
44
|
header.push(...Object.keys(value).map(structField => name + '_' + structField))
|
|
45
45
|
}
|
|
@@ -229,9 +229,11 @@ function dataForField(element, artifact, csn, record, data, parent, depth, refer
|
|
|
229
229
|
}
|
|
230
230
|
case 'cds.hana.REAL':
|
|
231
231
|
case 'cds.Decimal': {
|
|
232
|
-
const
|
|
232
|
+
const prec = element.precision ? Math.min(Math.pow(10, element.precision), Number.MAX_SAFE_INTEGER) : 100
|
|
233
|
+
const range = { from: 0, to: prec }
|
|
234
|
+
const scale = element.scale ?? (element.precision ? 0 : 2) // scale is 0 if only precision is given
|
|
233
235
|
annotatedIntRange(element, range)
|
|
234
|
-
return +(randomDecimalInRange(range).toFixed(
|
|
236
|
+
return +(randomDecimalInRange(range).toFixed(scale))
|
|
235
237
|
}
|
|
236
238
|
case 'cds.Double': {
|
|
237
239
|
const range = {from: 0, to: 100}
|
|
@@ -309,8 +311,6 @@ function dataForField(element, artifact, csn, record, data, parent, depth, refer
|
|
|
309
311
|
return
|
|
310
312
|
case 'cds.Vector': // TODO add Vector
|
|
311
313
|
return
|
|
312
|
-
case 'cds.Map':
|
|
313
|
-
return {}
|
|
314
314
|
default: {
|
|
315
315
|
console.error(`Unknown type ${element._type} (${element.type}) in '${artifact.name}:${element.name}'`)
|
|
316
316
|
return
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@cap-js/hana": "^1"
|
|
5
5
|
},
|
|
6
|
-
{{/isNodejs}}
|
|
7
|
-
{{#isNodejs}}
|
|
8
6
|
"cds": {
|
|
9
|
-
{{/isNodejs}}
|
|
10
7
|
"sql": {
|
|
11
8
|
"native_hana_associations": false
|
|
12
9
|
}{{#profile}},
|
|
@@ -22,7 +19,24 @@
|
|
|
22
19
|
{{/shortcut}}
|
|
23
20
|
}
|
|
24
21
|
}{{/profile}}
|
|
25
|
-
{{#isNodejs}}
|
|
26
22
|
}
|
|
27
23
|
{{/isNodejs}}
|
|
24
|
+
{{#isJava}}
|
|
25
|
+
"requires": {
|
|
26
|
+
{{#profile}}
|
|
27
|
+
"[{{profile}}]": {
|
|
28
|
+
{{/profile}}
|
|
29
|
+
{{#shortcut}}
|
|
30
|
+
"db": "hana"
|
|
31
|
+
{{/shortcut}}
|
|
32
|
+
{{^shortcut}}
|
|
33
|
+
"db": {
|
|
34
|
+
"kind": "hana"
|
|
35
|
+
}
|
|
36
|
+
{{/shortcut}}
|
|
37
|
+
{{#profile}}
|
|
38
|
+
}
|
|
39
|
+
{{/profile}}
|
|
40
|
+
}
|
|
41
|
+
{{/isJava}}
|
|
28
42
|
}
|
|
@@ -29,12 +29,14 @@ module.exports = class HttpTemplate extends require('../../plugin') {
|
|
|
29
29
|
'for-app': {
|
|
30
30
|
type: 'string',
|
|
31
31
|
short: 'a',
|
|
32
|
-
help:
|
|
32
|
+
help: `Specify the name of the app to generate requests for.
|
|
33
|
+
If not specified, localhost and default auth will be used.`
|
|
33
34
|
},
|
|
34
35
|
'out': {
|
|
35
36
|
type: 'string',
|
|
36
37
|
short: 'o',
|
|
37
|
-
help:
|
|
38
|
+
help: `The output directory.
|
|
39
|
+
By default, an \`http\` dir is created in either \`test/\`, \`tests/\`, \`__tests__/\`, or at the root level.`
|
|
38
40
|
},
|
|
39
41
|
'dry': {
|
|
40
42
|
type: 'boolean',
|
|
@@ -179,11 +181,11 @@ module.exports = class HttpTemplate extends require('../../plugin') {
|
|
|
179
181
|
else {
|
|
180
182
|
const postBody = JSON.stringify(entityData, null, 2)
|
|
181
183
|
let id
|
|
182
|
-
const compositeKey = Object.keys(e.keys).length > 1
|
|
184
|
+
const compositeKey = Object.keys(e.keys||{}).length > 1
|
|
183
185
|
if (compositeKey) {
|
|
184
186
|
id = [...e.keys].map(k => k.type === 'cds.String' ? `${k.name}='${entityData[k.name]}'` : `${k.name}=${entityData[k.name]}`).join(',')
|
|
185
187
|
} else {
|
|
186
|
-
id = entityData[Object.keys(e.keys)[0]]
|
|
188
|
+
id = entityData[Object.keys(e.keys||{})[0]]
|
|
187
189
|
}
|
|
188
190
|
compositeKey ? id = `(${id})` : id = `/${id}`
|
|
189
191
|
requests.push(`${requestTitle}\n# @name ${nameSlug}_POST\nPOST ${url}\n${headers}\n\n${postBody}\n`)
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap/cds-dk",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@sap/cds-dk",
|
|
9
|
-
"version": "8.4.
|
|
9
|
+
"version": "8.4.2",
|
|
10
10
|
"license": "SEE LICENSE IN LICENSE",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@cap-js/asyncapi": "^1.0.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"node_modules/@cap-js/db-service": {
|
|
46
|
-
"version": "1.
|
|
46
|
+
"version": "1.15.0",
|
|
47
47
|
"license": "SEE LICENSE",
|
|
48
48
|
"optional": true,
|
|
49
49
|
"dependencies": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"node_modules/@cap-js/sqlite": {
|
|
67
|
-
"version": "1.7.
|
|
67
|
+
"version": "1.7.7",
|
|
68
68
|
"license": "SEE LICENSE",
|
|
69
69
|
"optional": true,
|
|
70
70
|
"dependencies": {
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
}
|
|
225
225
|
},
|
|
226
226
|
"node_modules/@sap/cds": {
|
|
227
|
-
"version": "8.4.
|
|
227
|
+
"version": "8.4.2",
|
|
228
228
|
"license": "SEE LICENSE IN LICENSE",
|
|
229
229
|
"dependencies": {
|
|
230
230
|
"@sap/cds-compiler": ">=5.1",
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
}
|
|
251
251
|
},
|
|
252
252
|
"node_modules/@sap/cds-compiler": {
|
|
253
|
-
"version": "5.4.
|
|
253
|
+
"version": "5.4.4",
|
|
254
254
|
"license": "SEE LICENSE IN LICENSE",
|
|
255
255
|
"dependencies": {
|
|
256
256
|
"antlr4": "4.9.3"
|
|
@@ -728,7 +728,7 @@
|
|
|
728
728
|
"license": "MIT"
|
|
729
729
|
},
|
|
730
730
|
"node_modules/cross-spawn": {
|
|
731
|
-
"version": "7.0.
|
|
731
|
+
"version": "7.0.5",
|
|
732
732
|
"license": "MIT",
|
|
733
733
|
"dependencies": {
|
|
734
734
|
"path-key": "^3.1.0",
|
|
@@ -1701,7 +1701,7 @@
|
|
|
1701
1701
|
}
|
|
1702
1702
|
},
|
|
1703
1703
|
"node_modules/object-inspect": {
|
|
1704
|
-
"version": "1.13.
|
|
1704
|
+
"version": "1.13.3",
|
|
1705
1705
|
"license": "MIT",
|
|
1706
1706
|
"engines": {
|
|
1707
1707
|
"node": ">= 0.4"
|