@sap/cds-dk 4.5.0 → 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.
- package/CHANGELOG.md +65 -9
- package/bin/bind.js +124 -8
- package/bin/cds-ts.js +1 -1
- package/bin/cds.js +1 -0
- package/bin/deploy/index.js +2 -1
- package/bin/env.js +50 -9
- package/bin/help.js +2 -1
- package/bin/import.js +126 -24
- package/bin/watch.js +45 -9
- package/lib/bind/bindingResolver.js +138 -0
- package/lib/bind/cfKeyProvider.js +353 -0
- package/lib/bind/userCdsrcJsonStorageProvider.js +144 -0
- package/lib/client/auth_manager.js +4 -4
- package/lib/client/settings_manager.js +1 -1
- package/lib/import/common.js +33 -1
- package/lib/import/importapi.js +4 -3
- package/lib/import/index.js +49 -23
- package/lib/import/message.js +11 -6
- package/lib/import/utils/MetadataConverter.js +25 -4
- package/lib/import/utils/MetadataConverterFactory.js +1 -2
- package/lib/import/utils/MultiMap.js +26 -0
- package/lib/import/v2parser.js +142 -24
- package/lib/import/v4parser.js +222 -149
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +2 -0
- package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +36 -52
- package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/rule.test.js +15 -0
- package/lib/init/template/lint/index.js +14 -6
- package/lib/init/template/mta/files/mta.yaml.hbs +0 -7
- package/lib/init/template/mtx/files/xs-security.json.hbs +3 -1
- package/lib/init/template/mtx/package/dependencies.package.json +1 -1
- package/lib/init/template/nodejs/files/.gitignore.hbs +3 -0
- package/lib/init/util/commandUtil.js +5 -0
- package/lib/lint/Linter.js +31 -20
- package/lib/lint/checks.js +5 -1
- package/lib/lint/generators.js +1 -1
- package/lib/lint/io.js +59 -35
- package/lib/util/term.js +2 -0
- package/lib/watch/node-watch.js +38 -19
- package/npm-shrinkwrap.json +1276 -1102
- package/package.json +4 -3
- package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/test.js +0 -10
package/lib/watch/node-watch.js
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
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
|
+
}
|