@sap/cds-dk 8.2.0 → 8.2.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 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.2.2 - 2024-09-17
11
+
12
+ ### Fixed
13
+
14
+ - BDSA-2024-6188: vulnerability with express.js 4.19.2
15
+ - `cds import --out` copies the given metadata file to the correct output folder. CLI options are propagated to the `cds.import` API.
16
+ - `cds add sample` no longer creates a irregular whitespace in `admin-service.js`.
17
+ - `cds login` now correctly fetches tokens again with client credentials (or hints at invalid credentials).
18
+ - `cds add handler` can now also be called from the `srv` dir.
19
+
20
+ ## Version 8.2.1 - 2024-09-05
21
+
22
+ ### Fixed
23
+
24
+ - Update `@sap/hdi-deploy` to fix CVE-2024-4067 with `micromatch` 4.0.7
25
+ - `cds add` plugins now correctly parse flags (options with `type: 'boolean'`) if not used as the last argument.
26
+
10
27
  ## Version 8.2.0 - 2024-09-02
11
28
 
12
29
  ### Added
package/bin/cds.js CHANGED
@@ -60,7 +60,11 @@ const cli = {
60
60
  cds.cli = { command: 'add' }
61
61
  await cds.plugins
62
62
  for (const [, Plugin] of cds.add.registered) {
63
- task.options.push(...Object.keys((new Plugin).options()).map(key => '--'+key))
63
+ const all = Object.entries((new Plugin).options())
64
+ const flags = all.filter(([,f]) => f.type === 'boolean')
65
+ const options = all.filter(([,o]) => o.type !== 'boolean')
66
+ task.options.push(...options.map(([key]) => '--'+key))
67
+ task.flags.push(...flags.map(([key]) => '--'+key))
64
68
  }
65
69
  }
66
70
  const args = this.args(task, argv)
@@ -17,7 +17,7 @@ let optionsMapping = {
17
17
  };
18
18
 
19
19
  let apiOptions = ['includeNamespaces', 'keepNamespace', 'beta'];
20
- let commonOptions = ['no_copy', 'no_save', 'out', 'dry', 'as', 'from', 'force', 'config'];
20
+ let commonOptions = ['no_copy', 'no_save', 'out', 'dry', 'as', 'from', 'force', 'config', 'destination'];
21
21
 
22
22
  async function generateEDMX2JSON(edmx) {
23
23
  let cjson = convert.xml2json(edmx, {
@@ -155,7 +155,7 @@ async function preProcess(file, options, cwd) {
155
155
  return srcFilePath;
156
156
  }
157
157
 
158
- async function processOptions(cliOptions, odataOptions) {
158
+ async function processOptions(cliOptions, options) {
159
159
  // maps to renaming of variables
160
160
  for (let [key, value] of Object.entries(optionsMapping)) {
161
161
  if (cliOptions[key]) {
@@ -165,9 +165,18 @@ async function processOptions(cliOptions, odataOptions) {
165
165
  }
166
166
  // segregating cli/odata options
167
167
  apiOptions.forEach(function (item) {
168
- odataOptions[item] = cliOptions[item];
169
- delete cliOptions[item];
168
+ if (cliOptions[item]) {
169
+ options[item] = cliOptions[item];
170
+ delete cliOptions[item];
171
+ }
172
+ });
173
+ // forward cli options to api options
174
+ commonOptions.forEach(function (item) {
175
+ if (cliOptions[item]) {
176
+ options[item] = cliOptions[item];
177
+ }
170
178
  });
179
+
171
180
  // reads cli options from environment
172
181
  readEnvVariables(cliOptions, true);
173
182
  }
@@ -322,18 +331,21 @@ async function _updatePackageJson(dest, services, kind, cwd, config) {
322
331
  const package_json = path.resolve(cwd, 'package.json');
323
332
  const conf = await exists(package_json) ? require(package_json) : {};
324
333
  const requires = ['cds', 'requires'].reduce((p, n) => p[n] || (p[n] = {}), conf);
325
- if (kind !== 'rest') {
334
+ if (kind !== 'rest' && kind !== 'rfc') {
326
335
  kind = (kind === "V2") ? 'odata-v2' : 'odata';
327
336
  }
328
337
  let package_json_updated = false;
329
338
  for (let service of services) {
330
- // always update from given config data - e.g. delta imports may want to add service configuration data
339
+ // existing service configuration data can be updated, e.g. in case of delta imports
331
340
  const model = path.relative(cwd, dest).replace(/\\/g, '/'); // cds env must not be platform specific
332
- cds.env.requires[service] = requires[service] = { kind: kind, model, ...config };
333
- await write(package_json, JSON.stringify(conf, null, ' '));
334
- package_json_updated = true;
341
+ const serviceConfig = { kind, model, ...config }
342
+ if (!requires[service] || JSON.stringify(serviceConfig) !== JSON.stringify(requires[service])) {
343
+ cds.env.requires[service] = requires[service] = serviceConfig;
344
+ package_json_updated = true;
345
+ }
335
346
  }
336
347
  if (package_json_updated) {
348
+ await write(package_json, JSON.stringify(conf, null, ' '));
337
349
  console.log(`[cds] - updated ./package.json`);
338
350
  }
339
351
  }
@@ -358,8 +370,7 @@ async function postProcess(filePath, options, csn, cwd) {
358
370
  config.credentials = { destination: options.destination };
359
371
  }
360
372
 
361
- const external = path.resolve(cwd, 'srv/external');
362
- const destFilePath = path.join(external, path.basename(filePath));
373
+ const destFilePath = path.resolve(cwd, options.out ? path.join(options.out, path.basename(filePath)) : path.join('srv/external/', path.basename(filePath)));
363
374
  if (options.out) options.out = _validateAndComputeOutputFilePath(options.out, options.as, destFilePath);
364
375
  const kind = options.inputFileKind;
365
376
  const result = await _getResult(csn, options.as, options.out || destFilePath.replace(/\.[^.]+$/, ''), options.force, kind);
package/lib/init/mvn.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const util = require('util')
2
- const path = require('path');
3
2
  const { exec } = require('child_process')
4
3
  const execAsync = util.promisify(exec)
5
4
 
@@ -105,11 +104,11 @@ module.exports.init = async function (projectName, options = cds.cli.options) {
105
104
 
106
105
  module.exports.generate = async function (feature, options = cds.cli.options) {
107
106
  const command = this.generateMvnParams(feature, options)
108
- const cwd = options.cwd
107
+ const cwd = options.cwd ?? cds.root
109
108
 
110
109
  try {
111
110
  console.log(`Executing command: `, term.highlight('mvn ' + command.join(' ')))
112
- await cmd.spawnCommand('mvn', command, { cwd: cwd ?? path.join(cds.root, 'srv') })
111
+ await cmd.spawnCommand('mvn', command, { cwd: cwd })
113
112
  return command
114
113
  } catch (err) {
115
114
  if (err.code === 'ENOENT' && err.path === 'mvn') {
@@ -125,7 +124,7 @@ module.exports.generateMvnParams = function (feature, options = cds.cli.options)
125
124
  const { 'java:mvn': javaMvn, force, filter, out } = options
126
125
  if (javaMvn) _scan(javaMvn).forEach(([k,v]) => params.set(k,v))
127
126
  const archVersion = params.get(`-DarchetypeVersion`) ?? ''
128
- params.set(`cds:${archVersion}:generate`)
127
+ params.set(`com.sap.cds:cds-maven-plugin:${archVersion}:generate`)
129
128
 
130
129
  switch (feature) {
131
130
  case 'handler':
@@ -9,8 +9,8 @@ module.exports = class AdminService extends cds.ApplicationService { init(){
9
9
  */
10
10
  this.before ('NEW', Books.drafts, async (req) => {
11
11
  if (req.data.ID) return
12
- const { ID:id1 } = await SELECT.one.from(Books).columns('max(ID) as ID')
13
- const { ID:id2 } = await SELECT.one.from(Books.drafts).columns('max(ID) as ID')
12
+ const { ID:id1 } = await SELECT.one.from(Books).columns('max(ID) as ID')
13
+ const { ID:id2 } = await SELECT.one.from(Books.drafts).columns('max(ID) as ID')
14
14
  req.data.ID = Math.max(id1||0, id2||0) + 1
15
15
  })
16
16
  return super.init()
@@ -13,7 +13,7 @@ const Question = require('./util/question');
13
13
  const { httpSchema, httpsSchema, schemaRegex, localhostRegex } = require('./util/urls');
14
14
  const { capitalize } = require('./util/strings');
15
15
 
16
- const LOG = cds.log('cli'), DEBUG = cds.debug('cli');
16
+ const DEBUG = cds.debug('cli');
17
17
 
18
18
  const { ParamCollection, Persistence } = require('./params');
19
19
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sap/cds-dk",
9
- "version": "8.2.0",
9
+ "version": "8.2.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.12.0",
46
+ "version": "1.12.1",
47
47
  "license": "SEE LICENSE",
48
48
  "optional": true,
49
49
  "dependencies": {
@@ -139,7 +139,7 @@
139
139
  }
140
140
  },
141
141
  "node_modules/@eslint/js": {
142
- "version": "9.9.1",
142
+ "version": "9.10.0",
143
143
  "license": "MIT",
144
144
  "engines": {
145
145
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -152,6 +152,16 @@
152
152
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
153
153
  }
154
154
  },
155
+ "node_modules/@eslint/plugin-kit": {
156
+ "version": "0.1.0",
157
+ "license": "Apache-2.0",
158
+ "dependencies": {
159
+ "levn": "^0.4.1"
160
+ },
161
+ "engines": {
162
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
163
+ }
164
+ },
155
165
  "node_modules/@humanwhocodes/module-importer": {
156
166
  "version": "1.0.1",
157
167
  "license": "Apache-2.0",
@@ -204,7 +214,7 @@
204
214
  }
205
215
  },
206
216
  "node_modules/@sap/cds": {
207
- "version": "8.2.0",
217
+ "version": "8.2.2",
208
218
  "license": "SEE LICENSE IN LICENSE",
209
219
  "dependencies": {
210
220
  "@sap/cds-compiler": ">=5.1",
@@ -278,7 +288,7 @@
278
288
  }
279
289
  },
280
290
  "node_modules/@sap/eslint-plugin-cds": {
281
- "version": "3.0.4",
291
+ "version": "3.0.5",
282
292
  "license": "See LICENSE file",
283
293
  "dependencies": {
284
294
  "@sap/cds": ">=7",
@@ -314,16 +324,16 @@
314
324
  }
315
325
  },
316
326
  "node_modules/@sap/hdi-deploy": {
317
- "version": "5.2.1",
327
+ "version": "5.2.3",
318
328
  "hasInstallScript": true,
319
329
  "license": "See LICENSE file",
320
330
  "dependencies": {
321
331
  "@sap/hdi": "4.5.2",
322
332
  "@sap/xsenv": "5.2.0",
323
- "async": "3.2.5",
333
+ "async": "3.2.6",
324
334
  "dotenv": "16.4.5",
325
335
  "handlebars": "4.7.8",
326
- "micromatch": "4.0.7"
336
+ "micromatch": "4.0.8"
327
337
  },
328
338
  "engines": {
329
339
  "node": "^18.0.0 || ^20.0.0"
@@ -442,7 +452,7 @@
442
452
  }
443
453
  },
444
454
  "node_modules/async": {
445
- "version": "3.2.5",
455
+ "version": "3.2.6",
446
456
  "license": "MIT"
447
457
  },
448
458
  "node_modules/asynckit": {
@@ -482,7 +492,7 @@
482
492
  "optional": true
483
493
  },
484
494
  "node_modules/better-sqlite3": {
485
- "version": "11.2.1",
495
+ "version": "11.3.0",
486
496
  "hasInstallScript": true,
487
497
  "license": "MIT",
488
498
  "optional": true,
@@ -492,7 +502,7 @@
492
502
  }
493
503
  },
494
504
  "node_modules/big.js": {
495
- "version": "6.2.1",
505
+ "version": "6.2.2",
496
506
  "license": "MIT",
497
507
  "engines": {
498
508
  "node": "*"
@@ -521,7 +531,7 @@
521
531
  }
522
532
  },
523
533
  "node_modules/body-parser": {
524
- "version": "1.20.2",
534
+ "version": "1.20.3",
525
535
  "license": "MIT",
526
536
  "dependencies": {
527
537
  "bytes": "3.1.2",
@@ -532,7 +542,7 @@
532
542
  "http-errors": "2.0.0",
533
543
  "iconv-lite": "0.4.24",
534
544
  "on-finished": "2.4.1",
535
- "qs": "6.11.0",
545
+ "qs": "6.13.0",
536
546
  "raw-body": "2.5.2",
537
547
  "type-is": "~1.6.18",
538
548
  "unpipe": "1.0.0"
@@ -824,7 +834,7 @@
824
834
  "license": "MIT"
825
835
  },
826
836
  "node_modules/encodeurl": {
827
- "version": "1.0.2",
837
+ "version": "2.0.0",
828
838
  "license": "MIT",
829
839
  "engines": {
830
840
  "node": ">= 0.8"
@@ -870,14 +880,15 @@
870
880
  }
871
881
  },
872
882
  "node_modules/eslint": {
873
- "version": "9.9.1",
883
+ "version": "9.10.0",
874
884
  "license": "MIT",
875
885
  "dependencies": {
876
886
  "@eslint-community/eslint-utils": "^4.2.0",
877
887
  "@eslint-community/regexpp": "^4.11.0",
878
888
  "@eslint/config-array": "^0.18.0",
879
889
  "@eslint/eslintrc": "^3.1.0",
880
- "@eslint/js": "9.9.1",
890
+ "@eslint/js": "9.10.0",
891
+ "@eslint/plugin-kit": "^0.1.0",
881
892
  "@humanwhocodes/module-importer": "^1.0.1",
882
893
  "@humanwhocodes/retry": "^0.3.0",
883
894
  "@nodelib/fs.walk": "^1.2.8",
@@ -900,7 +911,6 @@
900
911
  "is-glob": "^4.0.0",
901
912
  "is-path-inside": "^3.0.3",
902
913
  "json-stable-stringify-without-jsonify": "^1.0.1",
903
- "levn": "^0.4.1",
904
914
  "lodash.merge": "^4.6.2",
905
915
  "minimatch": "^3.1.2",
906
916
  "natural-compare": "^1.4.0",
@@ -1015,35 +1025,35 @@
1015
1025
  }
1016
1026
  },
1017
1027
  "node_modules/express": {
1018
- "version": "4.19.2",
1028
+ "version": "4.21.0",
1019
1029
  "license": "MIT",
1020
1030
  "dependencies": {
1021
1031
  "accepts": "~1.3.8",
1022
1032
  "array-flatten": "1.1.1",
1023
- "body-parser": "1.20.2",
1033
+ "body-parser": "1.20.3",
1024
1034
  "content-disposition": "0.5.4",
1025
1035
  "content-type": "~1.0.4",
1026
1036
  "cookie": "0.6.0",
1027
1037
  "cookie-signature": "1.0.6",
1028
1038
  "debug": "2.6.9",
1029
1039
  "depd": "2.0.0",
1030
- "encodeurl": "~1.0.2",
1040
+ "encodeurl": "~2.0.0",
1031
1041
  "escape-html": "~1.0.3",
1032
1042
  "etag": "~1.8.1",
1033
- "finalhandler": "1.2.0",
1043
+ "finalhandler": "1.3.1",
1034
1044
  "fresh": "0.5.2",
1035
1045
  "http-errors": "2.0.0",
1036
- "merge-descriptors": "1.0.1",
1046
+ "merge-descriptors": "1.0.3",
1037
1047
  "methods": "~1.1.2",
1038
1048
  "on-finished": "2.4.1",
1039
1049
  "parseurl": "~1.3.3",
1040
- "path-to-regexp": "0.1.7",
1050
+ "path-to-regexp": "0.1.10",
1041
1051
  "proxy-addr": "~2.0.7",
1042
- "qs": "6.11.0",
1052
+ "qs": "6.13.0",
1043
1053
  "range-parser": "~1.2.1",
1044
1054
  "safe-buffer": "5.2.1",
1045
- "send": "0.18.0",
1046
- "serve-static": "1.15.0",
1055
+ "send": "0.19.0",
1056
+ "serve-static": "1.16.2",
1047
1057
  "setprototypeof": "1.2.0",
1048
1058
  "statuses": "2.0.1",
1049
1059
  "type-is": "~1.6.18",
@@ -1117,11 +1127,11 @@
1117
1127
  }
1118
1128
  },
1119
1129
  "node_modules/finalhandler": {
1120
- "version": "1.2.0",
1130
+ "version": "1.3.1",
1121
1131
  "license": "MIT",
1122
1132
  "dependencies": {
1123
1133
  "debug": "2.6.9",
1124
- "encodeurl": "~1.0.2",
1134
+ "encodeurl": "~2.0.0",
1125
1135
  "escape-html": "~1.0.3",
1126
1136
  "on-finished": "2.4.1",
1127
1137
  "parseurl": "~1.3.3",
@@ -1173,7 +1183,7 @@
1173
1183
  "license": "ISC"
1174
1184
  },
1175
1185
  "node_modules/follow-redirects": {
1176
- "version": "1.15.6",
1186
+ "version": "1.15.9",
1177
1187
  "funding": [
1178
1188
  {
1179
1189
  "type": "individual",
@@ -1554,8 +1564,11 @@
1554
1564
  }
1555
1565
  },
1556
1566
  "node_modules/merge-descriptors": {
1557
- "version": "1.0.1",
1558
- "license": "MIT"
1567
+ "version": "1.0.3",
1568
+ "license": "MIT",
1569
+ "funding": {
1570
+ "url": "https://github.com/sponsors/sindresorhus"
1571
+ }
1559
1572
  },
1560
1573
  "node_modules/methods": {
1561
1574
  "version": "1.1.2",
@@ -1565,7 +1578,7 @@
1565
1578
  }
1566
1579
  },
1567
1580
  "node_modules/micromatch": {
1568
- "version": "4.0.7",
1581
+ "version": "4.0.8",
1569
1582
  "license": "MIT",
1570
1583
  "dependencies": {
1571
1584
  "braces": "^3.0.3",
@@ -1795,7 +1808,7 @@
1795
1808
  }
1796
1809
  },
1797
1810
  "node_modules/path-to-regexp": {
1798
- "version": "0.1.7",
1811
+ "version": "0.1.10",
1799
1812
  "license": "MIT"
1800
1813
  },
1801
1814
  "node_modules/picomatch": {
@@ -1863,7 +1876,7 @@
1863
1876
  "license": "MIT"
1864
1877
  },
1865
1878
  "node_modules/pump": {
1866
- "version": "3.0.0",
1879
+ "version": "3.0.2",
1867
1880
  "license": "MIT",
1868
1881
  "optional": true,
1869
1882
  "dependencies": {
@@ -1879,10 +1892,10 @@
1879
1892
  }
1880
1893
  },
1881
1894
  "node_modules/qs": {
1882
- "version": "6.11.0",
1895
+ "version": "6.13.0",
1883
1896
  "license": "BSD-3-Clause",
1884
1897
  "dependencies": {
1885
- "side-channel": "^1.0.4"
1898
+ "side-channel": "^1.0.6"
1886
1899
  },
1887
1900
  "engines": {
1888
1901
  "node": ">=0.6"
@@ -2037,7 +2050,7 @@
2037
2050
  }
2038
2051
  },
2039
2052
  "node_modules/send": {
2040
- "version": "0.18.0",
2053
+ "version": "0.19.0",
2041
2054
  "license": "MIT",
2042
2055
  "dependencies": {
2043
2056
  "debug": "2.6.9",
@@ -2069,18 +2082,25 @@
2069
2082
  "version": "2.0.0",
2070
2083
  "license": "MIT"
2071
2084
  },
2085
+ "node_modules/send/node_modules/encodeurl": {
2086
+ "version": "1.0.2",
2087
+ "license": "MIT",
2088
+ "engines": {
2089
+ "node": ">= 0.8"
2090
+ }
2091
+ },
2072
2092
  "node_modules/send/node_modules/ms": {
2073
2093
  "version": "2.1.3",
2074
2094
  "license": "MIT"
2075
2095
  },
2076
2096
  "node_modules/serve-static": {
2077
- "version": "1.15.0",
2097
+ "version": "1.16.2",
2078
2098
  "license": "MIT",
2079
2099
  "dependencies": {
2080
- "encodeurl": "~1.0.2",
2100
+ "encodeurl": "~2.0.0",
2081
2101
  "escape-html": "~1.0.3",
2082
2102
  "parseurl": "~1.3.3",
2083
- "send": "0.18.0"
2103
+ "send": "0.19.0"
2084
2104
  },
2085
2105
  "engines": {
2086
2106
  "node": ">= 0.8.0"
@@ -2434,7 +2454,7 @@
2434
2454
  }
2435
2455
  },
2436
2456
  "node_modules/yaml": {
2437
- "version": "2.5.0",
2457
+ "version": "2.5.1",
2438
2458
  "license": "ISC",
2439
2459
  "bin": {
2440
2460
  "yaml": "bin.mjs"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "description": "Command line client and development toolkit for the SAP Cloud Application Programming Model",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [