@sap/cds-dk 4.5.4 → 4.6.0

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/bin/bind.js +124 -8
  3. package/bin/cds-ts.js +1 -1
  4. package/bin/cds.js +1 -0
  5. package/bin/env.js +50 -9
  6. package/bin/help.js +1 -0
  7. package/bin/import.js +34 -14
  8. package/bin/watch.js +25 -4
  9. package/lib/bind/bindingResolver.js +138 -0
  10. package/lib/bind/cfKeyProvider.js +353 -0
  11. package/lib/bind/userCdsrcJsonStorageProvider.js +144 -0
  12. package/lib/client/auth_manager.js +4 -4
  13. package/lib/client/settings_manager.js +1 -1
  14. package/lib/import/common.js +10 -1
  15. package/lib/import/importapi.js +4 -3
  16. package/lib/import/index.js +34 -5
  17. package/lib/import/message.js +1 -0
  18. package/lib/import/utils/MetadataConverter.js +25 -4
  19. package/lib/import/utils/MetadataConverterFactory.js +1 -2
  20. package/lib/import/utils/MultiMap.js +26 -0
  21. package/lib/import/v2parser.js +131 -12
  22. package/lib/import/v4parser.js +212 -172
  23. package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +36 -52
  24. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/rule.test.js +15 -0
  25. package/lib/init/template/lint/index.js +14 -6
  26. package/lib/init/template/mta/files/mta.yaml.hbs +0 -7
  27. package/lib/init/template/mtx/files/xs-security.json.hbs +3 -1
  28. package/lib/init/template/mtx/package/dependencies.package.json +1 -1
  29. package/lib/init/template/nodejs/files/.gitignore.hbs +3 -0
  30. package/lib/init/util/commandUtil.js +5 -0
  31. package/lib/lint/Linter.js +31 -20
  32. package/lib/lint/checks.js +5 -1
  33. package/lib/lint/io.js +59 -35
  34. package/lib/util/term.js +2 -0
  35. package/lib/watch/node-watch.js +38 -19
  36. package/npm-shrinkwrap.json +1782 -1138
  37. package/package.json +3 -3
  38. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/test.js +0 -10
@@ -5,28 +5,26 @@ module.exports = ({ cwd, script, ext, ignore=RegExp(), env={}, delay=200, option
5
5
  // Phoning home...
6
6
  const EventEmitter = require('events')
7
7
  const emitter = new EventEmitter
8
- process.on('exit', () => {
9
- if (child) child.kill() // propagate exit to child
10
- emitter.emit('quit') // listener might exit(), so expect this to be the last statement here
11
- })
8
+ process.on('exit', () => { gracefullyKill (child); emitter.emit('quit') })
12
9
 
13
10
  // Re-starting child process...
14
11
  const { fork } = require('child_process')
15
12
  const restart = (evt, name)=>{
16
- const execArgv = [...process.execArgv]
17
- if (child) child.kill()
18
- if (evt && evt.startsWith('--')) execArgv.push(evt)
19
- if (name && name.startsWith('--')) execArgv.push(name)
20
- if (options.debug) execArgv.push('--inspect')
21
- if (options['debug-brk']) execArgv.push('--inspect-brk')
22
- const files = evt === "update" ? [ name ] : undefined
23
- emitter.emit ('restart', files)
24
- child = fork (script, { cwd, env, stdio:'inherit', execArgv }, (err)=>{
25
- if (err) console.error (err)
26
- })
27
- child.on('message', msg => {
28
- if (msg === 'restart') return restart()
29
- emitter.emit('message', msg)
13
+ gracefullyKill (child, () => {
14
+ const execArgv = [...process.execArgv]
15
+ if (evt && evt.startsWith('--')) execArgv.push(evt)
16
+ if (name && name.startsWith('--')) execArgv.push(name)
17
+ if (options.debug) execArgv.push('--inspect')
18
+ if (options['debug-brk']) execArgv.push('--inspect-brk')
19
+ const files = evt === "update" ? [ name ] : undefined
20
+ emitter.emit ('restart', files)
21
+ child = fork (script, { cwd, env, stdio:'inherit', execArgv }, (err)=>{
22
+ if (err) console.error (err)
23
+ })
24
+ child.on('message', msg => {
25
+ if (msg === 'restart') return restart()
26
+ emitter.emit('message', msg)
27
+ })
30
28
  })
31
29
  }
32
30
  restart()
@@ -46,10 +44,19 @@ module.exports = ({ cwd, script, ext, ignore=RegExp(), env={}, delay=200, option
46
44
  else if (input === 'break' || input === 'brk') restart('--inspect-brk')
47
45
  else if (input === 'debug-brk') restart('--inspect-brk')
48
46
  else if (input === 'ps') ps(child,env)
49
- else if (input === 'bye' || input.match(/^n$/i)) { child.kill(); process.exit() }
47
+ else if (input === 'bye' || input.match(/^n$/i)) { gracefullyKill (child, () => process.exit()) }
50
48
  else console.log ('?\n')
51
49
  })
52
50
 
51
+ emitter.restart = restart
52
+ emitter.stop = () => { gracefullyKill(child, () => false); child = undefined; }
53
+ emitter.setEnv = (name, value) => {
54
+ if (typeof value === "undefined") {
55
+ delete env[name]
56
+ } else {
57
+ env[name]
58
+ }
59
+ }
53
60
  return emitter
54
61
  }
55
62
 
@@ -59,3 +66,15 @@ const ps = (child,env) => console.log (`\x1b[32m
59
66
  ${ child.pid} child cds ${JSON.parse(env._args).join(' ')}
60
67
  \x1b[0m`
61
68
  )
69
+
70
+ // On Windows, kill() abruptly kills the child process (https://nodejs.org/api/child_process.html#subprocesskillsignal)
71
+ // Send a custom message an wait a bit to give cleanup code a chance to execute.
72
+ const isWindows = (process.platform === 'win32')
73
+ const waitTime = parseInt(process.env.CDS_WATCH_KILL_DELAY) || (isWindows ? 500 : 0)
74
+ function gracefullyKill (proc, fn=()=>{}) {
75
+ if (proc) {
76
+ proc.send({ exit: true })
77
+ setTimeout(()=> { proc.kill(); fn()}, waitTime)
78
+ }
79
+ else fn()
80
+ }