@sap/cds-dk 7.8.2 → 7.9.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/bin/add.js +28 -7
- package/bin/bind.js +64 -21
- package/bin/build.js +35 -3
- package/bin/cds.js +31 -13
- package/bin/compile/index.js +44 -3
- package/bin/completion/completionFs.js +61 -0
- package/bin/completion/index.js +212 -0
- package/bin/completion/scripts/cds-bash.sh +17 -0
- package/bin/completion/scripts/cds-ps.ps1 +18 -0
- package/bin/completion/scripts/cds-zsh.sh +12 -0
- package/bin/help.js +8 -2
- package/bin/init.js +34 -4
- package/bin/subscribe.js +5 -1
- package/bin/watch.js +4 -2
- package/lib/bind/KubernetesApiAccessor.js +3 -2
- package/lib/bind/bindingResolver.js +8 -4
- package/lib/bind/bindingUtil.js +10 -8
- package/lib/bind/cfKeyProvider.js +58 -153
- package/lib/bind/index.js +49 -36
- package/lib/bind/kubernetesCredentialsProvider.js +6 -5
- package/lib/bind/userCdsrcJsonStorageProvider.js +25 -3
- package/lib/build/buildTaskEngine.js +1 -1
- package/lib/build/provider/hana/index.js +1 -1
- package/lib/build/provider/hana/template/undeploy.json +3 -1
- package/lib/build/provider/nodejs/index.js +1 -1
- package/lib/compile/openapi/index.js +5 -0
- package/lib/deploy/to-hana/hana.js +25 -7
- package/lib/env/schemas/cds-rc.js +29 -2
- package/lib/import/odata/v4parser.js +78 -25
- package/lib/init/constants.js +2 -1
- package/lib/init/index.js +18 -13
- package/lib/init/merge.js +1 -0
- package/lib/init/mvn.js +8 -47
- package/lib/init/plugin.js +0 -4
- package/lib/init/projectReader.js +17 -10
- package/lib/init/template/approuter/files/values.yaml.hbs +0 -12
- package/lib/init/template/completion/completionSetup.js +184 -0
- package/lib/init/template/completion/index.js +22 -0
- package/lib/init/template/data/as-csv.js +25 -17
- package/lib/init/template/data/as-json.js +148 -44
- package/lib/init/template/data/index.js +28 -15
- package/lib/init/template/hana/files/undeploy.json +2 -1
- package/lib/init/template/helm/files/chart/values.schema.json +1 -1
- package/lib/init/template/helm/files/content-deployment/Chart.yaml +0 -2
- package/lib/init/template/helm/files/content-deployment/values.schema.json +0 -1
- package/lib/init/template/helm/files/service-instance/Chart.yaml +0 -2
- package/lib/init/template/helm/files/service-instance/values.schema.json +0 -1
- package/lib/init/template/helm/files/web-application/Chart.yaml +0 -2
- package/lib/init/template/helm/files/web-application/values.schema.json +0 -1
- package/lib/init/template/helm-unified-runtime/files/values.schema.json +1 -1
- package/lib/init/template/http/index.js +150 -104
- package/lib/init/template/kafka/index.js +6 -0
- package/lib/init/template/lint/index.js +12 -13
- package/lib/init/template/mta/files/mta.yaml.hbs +2 -2
- package/lib/init/template/multitenancy/files/values.yaml.hbs +0 -5
- package/lib/init/template/multitenancy/index.js +13 -5
- package/lib/init/template/nodejs/files/.vscode/settings.json +11 -0
- package/lib/init/template/nodejs/files/eslint.config.js +13 -0
- package/lib/init/template/nodejs/files/package.json.hbs +3 -1
- package/lib/init/template/sample/index.js +18 -20
- package/lib/init/template/tiny-sample/index.js +1 -2
- package/lib/init/template/typer/index.js +2 -2
- package/lib/lint/Linter.js +133 -55
- package/lib/lint/checks.js +5 -6
- package/lib/lint/io.js +119 -10
- package/lib/mtx/auth_manager.js +5 -5
- package/lib/mtx/params.js +4 -2
- package/lib/mtx/settings_manager.js +1 -1
- package/lib/mtx/tenant_action.js +12 -2
- package/lib/mtx/util/logging.js +10 -4
- package/lib/util/axios.js +2 -1
- package/lib/util/cf.js +32 -37
- package/lib/util/git.js +1 -1
- package/lib/util/term.js +1 -1
- package/{bin → lib/watch}/watched.js +2 -2
- package/npm-shrinkwrap.json +35 -52
- package/package.json +2 -2
- package/lib/init/template/nodejs/files/.eslintrc +0 -26
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const path = require('node:path');
|
|
2
|
+
|
|
3
|
+
const cds = require('../../bin/cds');
|
|
4
|
+
const { bold } = require('../../lib/util/term');
|
|
5
|
+
|
|
6
|
+
const SUPPORTED_SHELLS = ['bash', 'gitbash', 'zsh', 'ps']
|
|
7
|
+
|
|
8
|
+
module.exports = Object.assign(completion, {
|
|
9
|
+
handleCompletion,
|
|
10
|
+
options: ['--shell', '--curr', '--line', '--prev'],
|
|
11
|
+
shortcuts: ['-s'],
|
|
12
|
+
flags: ['--add', '--profile', '--remove'],
|
|
13
|
+
help: `
|
|
14
|
+
# SYNOPSIS
|
|
15
|
+
|
|
16
|
+
-- beta feature --
|
|
17
|
+
|
|
18
|
+
*cds completion* <options>
|
|
19
|
+
|
|
20
|
+
Adds or removes shell completion for cds commands. Currently supported shells:
|
|
21
|
+
bash, Git Bash, zsh, and PowerShell.
|
|
22
|
+
|
|
23
|
+
Depending on the operating system and the shell type, the following files will be changed:
|
|
24
|
+
Linux, WSL
|
|
25
|
+
bash: ~/.bashrc
|
|
26
|
+
zsh: ~/.zshrc
|
|
27
|
+
macOS
|
|
28
|
+
bash: ~/.bash_profile
|
|
29
|
+
zsh: ~/.zshrc
|
|
30
|
+
Windows
|
|
31
|
+
PowerShell: $PROFILE
|
|
32
|
+
Git Bash: ~/.bash_profile
|
|
33
|
+
|
|
34
|
+
This command also acts as an internal completion handler for the shell completion scripts.
|
|
35
|
+
|
|
36
|
+
# OPTIONS
|
|
37
|
+
|
|
38
|
+
*--add*
|
|
39
|
+
Add shell completion for cds commands (see examples).
|
|
40
|
+
|
|
41
|
+
*--remove*
|
|
42
|
+
Remove shell completion for cds commands (see examples).
|
|
43
|
+
|
|
44
|
+
*--shell* <bash | gitbash | ps | zsh>
|
|
45
|
+
Force the shell completion code to be added to the correct shell profile file.
|
|
46
|
+
bash: macOS, Linux, WSL
|
|
47
|
+
zsh: macOS, Linux, WSL
|
|
48
|
+
gitbash: Git Bash for Windows
|
|
49
|
+
ps: PowerShell
|
|
50
|
+
|
|
51
|
+
# EXAMPLES
|
|
52
|
+
|
|
53
|
+
*cds* completion --add # Add shell completion for cds commands
|
|
54
|
+
*cds* completion --remove # Remove shell completion for cds commands
|
|
55
|
+
*cds* completion --add --shell bash # Add shell completion for cds commands and enforce using bash shell
|
|
56
|
+
|
|
57
|
+
# ALIASES
|
|
58
|
+
|
|
59
|
+
*cds* add completion # Add shell completion for cds commands
|
|
60
|
+
*cds* add completion --shell bash # Add shell completion for cds commands and enforce using bash shell
|
|
61
|
+
|
|
62
|
+
`});
|
|
63
|
+
|
|
64
|
+
function getScriptFile(shell) {
|
|
65
|
+
switch (shell) {
|
|
66
|
+
case 'bash':
|
|
67
|
+
case 'gitbash':
|
|
68
|
+
return 'cds-bash.sh'
|
|
69
|
+
case 'ps':
|
|
70
|
+
return 'cds-ps.ps1'
|
|
71
|
+
case 'zsh':
|
|
72
|
+
return 'cds-zsh.sh'
|
|
73
|
+
case '':
|
|
74
|
+
case undefined:
|
|
75
|
+
case null:
|
|
76
|
+
throw 'Internal error: option --shell is missing';
|
|
77
|
+
default:
|
|
78
|
+
throw `Internal error: unsupported shell: ${shell}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function completion(_argv, options) {
|
|
83
|
+
if (options.profile) {
|
|
84
|
+
const scriptFile = getScriptFile(options.shell);
|
|
85
|
+
return console.log(path.join(__dirname, 'scripts', scriptFile));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (options.add || options.remove) {
|
|
89
|
+
const completionSetup = require('../../lib/init/template/completion/completionSetup');
|
|
90
|
+
await completionSetup.setup(options.add, options);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// workaround to parse complex clis containing -- as part of value,
|
|
95
|
+
// e.g. cds completion --line "cds add --"
|
|
96
|
+
const localArgv = process.argv.slice(3);
|
|
97
|
+
const localOptions = {}
|
|
98
|
+
for (let i = 0; i < localArgv.length; i++) {
|
|
99
|
+
localOptions[localArgv[i].replaceAll('-', '')] = localArgv[++i];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (localOptions.curr === undefined || localOptions.prev === undefined || localOptions.line === undefined) {
|
|
103
|
+
throw `Some information is missing. Please run ${bold('cds help completion')} for details on how to call this command.`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const shell = localOptions.shell;
|
|
107
|
+
if (!SUPPORTED_SHELLS.includes(shell)) {
|
|
108
|
+
throw `internal Error: no completion handler found for type: ${shell}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const currentWord = localOptions.curr;
|
|
112
|
+
const previousWord = localOptions.prev;
|
|
113
|
+
const line = localOptions.line;
|
|
114
|
+
const segments = getSegments(line);
|
|
115
|
+
const cdsCmd = segments[1] || '';
|
|
116
|
+
|
|
117
|
+
let completions = await getCompletions(cdsCmd, previousWord, currentWord, segments);
|
|
118
|
+
if (currentWord && shell === 'ps') {
|
|
119
|
+
completions = completions.filter(v => v?.startsWith(currentWord));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
reply(completions);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function handleCompletion(currentWord, previousWord, argv, _util) {
|
|
126
|
+
const allOptionsFlags = ['--add', '--remove', '--shell']
|
|
127
|
+
.filter(e => !argv.includes(e));
|
|
128
|
+
|
|
129
|
+
if (currentWord?.startsWith('-')) {
|
|
130
|
+
return allOptionsFlags;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (previousWord === '--shell') {
|
|
134
|
+
return ['bash', 'gitbash', 'ps', 'zsh'];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return allOptionsFlags;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function reply(values) {
|
|
141
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
values = values.filter(e => !!(typeof e === 'string' && e.trim()));
|
|
146
|
+
values = [...new Set(values)];
|
|
147
|
+
values.sort((a, b) => {
|
|
148
|
+
if (a.startsWith('-') && !b.startsWith('-')) { return 1; }
|
|
149
|
+
if (!a.startsWith('-') && b.startsWith('-')) { return -1; }
|
|
150
|
+
return a.localeCompare(b);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
console.log(values.join('\n'));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function getSegments(line) {
|
|
157
|
+
const cliSplit = /'(.*?)'|"(.*?)"|(\\,|\\ |[^, ])+/gs;
|
|
158
|
+
const result = line.match(cliSplit);
|
|
159
|
+
return result.map(s =>
|
|
160
|
+
s.trim()
|
|
161
|
+
.replace(/(\\ )/g, ' ')
|
|
162
|
+
.replace(/^["']|["']$/g, '')
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function getCdsCmd(cdsCmd) {
|
|
167
|
+
cdsCmd = cds.Shortcuts?.[cdsCmd] ?? cdsCmd;
|
|
168
|
+
return cds.load(cdsCmd);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function getAllOptions(cdsCmdObj, segments) {
|
|
172
|
+
return [
|
|
173
|
+
...cdsCmdObj.options ?? [],
|
|
174
|
+
...cdsCmdObj.flags?.filter(o => !segments.includes(o)) ?? []
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function getUtil() {
|
|
179
|
+
const completionFs = require('./completionFs');
|
|
180
|
+
return {
|
|
181
|
+
cds,
|
|
182
|
+
completionFs
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function getCompletions(cdsCmd, previousWord, currentWord, segments) {
|
|
187
|
+
if (cdsCmd === currentWord) {
|
|
188
|
+
return cds.cmds;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
const cdsCmdObj = getCdsCmd(cdsCmd);
|
|
193
|
+
if (typeof cdsCmdObj.handleCompletion === 'function') {
|
|
194
|
+
return await cdsCmdObj.handleCompletion(currentWord, previousWord, segments, getUtil());
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (currentWord?.startsWith('-')) {
|
|
198
|
+
return getAllOptions(cdsCmdObj, segments);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const completionFs = require('./completionFs');
|
|
202
|
+
const all = await completionFs.readdir(currentWord);
|
|
203
|
+
if (!(cdsCmdObj.options?.includes(previousWord) || cdsCmdObj.shortcuts?.includes(previousWord))) {
|
|
204
|
+
const allOptions = getAllOptions(cdsCmdObj, segments);
|
|
205
|
+
all.push(...allOptions);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return all;
|
|
209
|
+
} catch (err) {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
CDS_COMMAND="cds"
|
|
4
|
+
|
|
5
|
+
_completeCds()
|
|
6
|
+
{
|
|
7
|
+
local current options previous
|
|
8
|
+
COMPREPLY=()
|
|
9
|
+
current="${COMP_WORDS[COMP_CWORD]}"
|
|
10
|
+
previous="${COMP_WORDS[COMP_CWORD - 1]}"
|
|
11
|
+
options=$($CDS_COMMAND completion --shell bash --prev "$previous" --curr "$current" --line "${COMP_WORDS[*]}")
|
|
12
|
+
COMPREPLY=( $(compgen -W "${options}" -- ${current}) )
|
|
13
|
+
compopt -o nosort -o nospace
|
|
14
|
+
return 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
complete -F _completeCds $CDS_COMMAND
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
$COMMAND = "cds"
|
|
2
|
+
|
|
3
|
+
Register-ArgumentCompleter -Native -CommandName $COMMAND -ScriptBlock {
|
|
4
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
5
|
+
|
|
6
|
+
$cmdSegments = $commandAst.CommandElements
|
|
7
|
+
$idx = $cmdSegments.IndexOf(($cmdSegments | Where-Object { $_.Extent.Text -eq $wordToComplete }))
|
|
8
|
+
if ($idx -gt 0) {
|
|
9
|
+
$previousWord = $cmdSegments[$idx - 1].Extent.Text
|
|
10
|
+
} else {
|
|
11
|
+
$previousWord = $cmdSegments[$cmdSegments.Count - 1].Extent.Text
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
$options = & $COMMAND completion --shell ps --prev "$previousWord" --curr "$wordToComplete" --line "$commandAst"
|
|
15
|
+
foreach ($option in $options) {
|
|
16
|
+
[System.Management.Automation.CompletionResult]::new($option, $option, 'ParameterValue', $option)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/zsh
|
|
2
|
+
|
|
3
|
+
# compinit is required but added to ~/.zshrc so user can remove it if it is already loaded
|
|
4
|
+
# autoload -Uz compinit && compinit
|
|
5
|
+
|
|
6
|
+
CDS_COMMAND="cds"
|
|
7
|
+
|
|
8
|
+
_completeCds() {
|
|
9
|
+
compadd -S '' -V 'force no sort' -- `${CDS_COMMAND} completion --shell zsh --prev "${words[CURRENT-1]}" --curr "${words[CURRENT]}" --line "${words}"`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
compdef _completeCds ${CDS_COMMAND}
|
package/bin/help.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const cds = require('../lib/cds')
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-console */
|
|
4
|
-
module.exports = exports = Object.assign (help, {formatHelp, help:`
|
|
4
|
+
module.exports = exports = Object.assign (help, {formatHelp, handleCompletion, help:`
|
|
5
5
|
# USAGE
|
|
6
6
|
|
|
7
7
|
*cds* <command> [<args>]
|
|
@@ -32,13 +32,19 @@ module.exports = exports = Object.assign (help, {formatHelp, help:`
|
|
|
32
32
|
* * | *push* push extension to extensible SaaS app
|
|
33
33
|
*t* | *lint* run linter for env or model checks [beta]
|
|
34
34
|
*v* | *version* get detailed version information
|
|
35
|
+
* * | *completion* add/remove cli completion for cds commands
|
|
35
36
|
*?* | *help* get detailed usage information
|
|
36
37
|
|
|
37
38
|
Learn more about each command using:
|
|
38
39
|
*cds help* <command> or
|
|
39
40
|
*cds* <command> *--help*
|
|
40
41
|
|
|
41
|
-
`})
|
|
42
|
+
`});
|
|
43
|
+
|
|
44
|
+
async function handleCompletion(_currentWord, _previousWord, _argv, _util) {
|
|
45
|
+
const cds = require('./cds');
|
|
46
|
+
return Object.values(cds.cmds);
|
|
47
|
+
}
|
|
42
48
|
|
|
43
49
|
async function help (topic) {
|
|
44
50
|
await cds.plugins
|
package/bin/init.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
const { URLS } = require('../lib/init/constants')
|
|
1
|
+
const { URLS } = require('../lib/init/constants');
|
|
2
|
+
|
|
3
|
+
const currentOptions = ['--add', '--java:mvn', '--java:package', '--lint:custom', '--lint:custom:example'];
|
|
2
4
|
const legacyOptions = ['--db-technology', '--insecure', '--java-package', '--modules',
|
|
3
5
|
'--mta', '--odata-version', '--pipeline', '--skip-install', '--skip-sample-models',
|
|
4
6
|
'--srv-memory', '--srv-technology']
|
|
5
7
|
|
|
6
8
|
module.exports = Object.assign(init, {
|
|
7
|
-
|
|
9
|
+
handleCompletion,
|
|
10
|
+
options: [...currentOptions, ...legacyOptions],
|
|
8
11
|
shortcuts: [],
|
|
9
12
|
flags: ['--force', '--verbose'],
|
|
10
13
|
help: `
|
|
@@ -96,7 +99,34 @@ module.exports = Object.assign(init, {
|
|
|
96
99
|
|
|
97
100
|
`})
|
|
98
101
|
|
|
99
|
-
async function
|
|
102
|
+
async function handleCompletion(currentWord, previousWord, argv, util) {
|
|
103
|
+
const allOptionsFlags = [
|
|
104
|
+
...currentOptions ?? [],
|
|
105
|
+
...init.flags ?? []
|
|
106
|
+
].filter(e => !argv.includes(e));
|
|
107
|
+
|
|
108
|
+
if (currentWord?.startsWith('-')) {
|
|
109
|
+
return allOptionsFlags;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (previousWord === '--add') {
|
|
113
|
+
return util.completionFs.readTemplates(argv);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (previousWord === '--java:package') {
|
|
117
|
+
const excludes = ['_merging'];
|
|
118
|
+
return (await util.completionFs.readdir(currentWord, { files: false }))
|
|
119
|
+
.filter(e => !excludes.includes(e));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!currentWord && init.options?.includes(previousWord)) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return allOptionsFlags;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function init(args) {
|
|
100
130
|
if (process.argv.some(a => legacyOptions.includes(a))) return _showWarningMessage()
|
|
101
131
|
const CDSGenerator = require('../lib/init')
|
|
102
132
|
const generator = new CDSGenerator()
|
|
@@ -104,7 +134,7 @@ async function init (args) {
|
|
|
104
134
|
}
|
|
105
135
|
|
|
106
136
|
|
|
107
|
-
function _showWarningMessage
|
|
137
|
+
function _showWarningMessage() {
|
|
108
138
|
|
|
109
139
|
const message = `
|
|
110
140
|
************************************************
|
package/bin/subscribe.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = Object.assign(subscribe, {
|
|
2
2
|
init: cmd => new (require('../lib/mtx/tenant_action'))(cmd),
|
|
3
|
-
options: ['--to', '--user'],
|
|
3
|
+
options: ['--to', '--user', '--body'],
|
|
4
4
|
flags: ['--local', '--resolve-bindings'],
|
|
5
5
|
shortcuts: ['-2', '-u', '-l', '-b'],
|
|
6
6
|
help: `
|
|
@@ -39,6 +39,10 @@ module.exports = Object.assign(subscribe, {
|
|
|
39
39
|
|
|
40
40
|
Resolve remote service bindings configured via *cds bind*.
|
|
41
41
|
|
|
42
|
+
--body
|
|
43
|
+
|
|
44
|
+
JSON object to be sent as the body of the subscription request.
|
|
45
|
+
|
|
42
46
|
|
|
43
47
|
# SEE ALSO
|
|
44
48
|
|
package/bin/watch.js
CHANGED
|
@@ -70,7 +70,9 @@ const ignore = RegExp(
|
|
|
70
70
|
`(webapp|dist|target)\\${sep}|` +
|
|
71
71
|
`tsconfig\\.json$|` +
|
|
72
72
|
`.*\\.tsbuildinfo$` +
|
|
73
|
-
')'
|
|
73
|
+
')' +
|
|
74
|
+
`|package-lock\\.json$` +
|
|
75
|
+
`|\\${sep}gen\\${sep}`
|
|
74
76
|
)
|
|
75
77
|
|
|
76
78
|
async function watch ([cwd], {
|
|
@@ -138,7 +140,7 @@ async function watch ([cwd], {
|
|
|
138
140
|
|
|
139
141
|
const nodemon = require('../lib/watch/node-watch')
|
|
140
142
|
const watcher = nodemon ({
|
|
141
|
-
script: resolve(__dirname,'watched'), cwd, env, ext, ignore,
|
|
143
|
+
script: resolve(__dirname,'../lib/watch/watched'), cwd, env, ext, ignore,
|
|
142
144
|
delay,
|
|
143
145
|
options
|
|
144
146
|
}).on('restart', (files)=>{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const yaml = require('@sap/cds-foss')('yaml');
|
|
2
2
|
const { exec } = require('../util/exec');
|
|
3
|
+
const { bold } = require('../util/term');
|
|
3
4
|
|
|
4
5
|
class KubernetesApiAccessor {
|
|
5
6
|
|
|
@@ -15,7 +16,7 @@ class KubernetesApiAccessor {
|
|
|
15
16
|
if (!currentContextEntry) throw new Error(`Current context not found in kubectl config.`);
|
|
16
17
|
const currentContext = currentContextEntry.context;
|
|
17
18
|
const clusterEntry = config.clusters && config.clusters.find( entry => entry.name === currentContext.cluster && entry.cluster && entry.cluster.server );
|
|
18
|
-
if (!currentContextEntry) throw new Error(`Cluster ${currentContext.cluster} not found in kubectl config.`);
|
|
19
|
+
if (!currentContextEntry) throw new Error(`Cluster ${bold(currentContext.cluster)} not found in kubectl config.`);
|
|
19
20
|
const { cluster } = clusterEntry;
|
|
20
21
|
|
|
21
22
|
const serverToContext = {};
|
|
@@ -41,7 +42,7 @@ class KubernetesApiAccessor {
|
|
|
41
42
|
let contextEntry;
|
|
42
43
|
|
|
43
44
|
if (cluster && cluster !== config.cluster.server) {
|
|
44
|
-
contextEntry = config.serverToContext[cluster] || throwError(`Cluster ${cluster} not found in kubectl configuration`);
|
|
45
|
+
contextEntry = config.serverToContext[cluster] || throwError(`Cluster ${bold(cluster)} not found in kubectl configuration`);
|
|
45
46
|
} else {
|
|
46
47
|
contextEntry = config.context;
|
|
47
48
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const cds = require('../cds');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { platformText, bindingText, logger } = require('./bindingUtil');
|
|
4
|
+
const { bold } = require('../util/term');
|
|
4
5
|
|
|
5
6
|
class BindingResolver {
|
|
6
7
|
getUnresolvedBindings({ cwd = process.cwd(), env } = {}) {
|
|
@@ -25,18 +26,21 @@ class BindingResolver {
|
|
|
25
26
|
|
|
26
27
|
const resolvedBindings = {}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
// Serialized because of parallelization issues in the cf CLI,
|
|
30
|
+
// see https://github.com/cloudfoundry/cli/issues/2232
|
|
31
|
+
// await Promise.all(Object.keys(bindings).map(async name => {
|
|
32
|
+
for (const name of Object.keys(bindings)) {
|
|
29
33
|
const binding = bindings[name]
|
|
30
34
|
const cacheKey = JSON.stringify(binding)
|
|
31
35
|
let resolvedBinding
|
|
32
36
|
if (!cache[cacheKey]) {
|
|
33
37
|
resolvedBinding = cache[cacheKey] = await this.resolveBinding(name, binding)
|
|
34
|
-
logger.log(`bound ${name} to ${platformText(binding)} ${bindingText(binding)}`)
|
|
38
|
+
logger.log(`bound ${bold(name)} to ${platformText(binding)} ${bindingText(binding)}`)
|
|
35
39
|
} else {
|
|
36
40
|
resolvedBinding = cache[cacheKey]
|
|
37
41
|
}
|
|
38
42
|
resolvedBindings[name] = resolvedBinding
|
|
39
|
-
}
|
|
43
|
+
}
|
|
40
44
|
return Object.keys(resolvedBindings).length > 0 ? resolvedBindings : undefined
|
|
41
45
|
}
|
|
42
46
|
|
|
@@ -44,7 +48,7 @@ class BindingResolver {
|
|
|
44
48
|
switch (binding.type) {
|
|
45
49
|
case 'cf': return require('./cfKeyProvider').resolve(name, binding)
|
|
46
50
|
case 'k8s': return require('./kubernetesCredentialsProvider').resolve(name, binding)
|
|
47
|
-
default: throw new Error(`Unsupported binding type
|
|
51
|
+
default: throw new Error(`Unsupported binding type ${bold(binding.type)} for service ${bold(name)}.`)
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
}
|
package/lib/bind/bindingUtil.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { bold } = require('../util/term');
|
|
1
2
|
|
|
2
3
|
const KindToRequiresNameMap = {
|
|
3
4
|
xsuaa: 'auth', // REVISIT: remove with ^8
|
|
@@ -15,11 +16,12 @@ const KindToRequiresNameMap = {
|
|
|
15
16
|
'enterprise-messaging-amqp': 'messaging',
|
|
16
17
|
'enterprise-messaging-http': 'messaging',
|
|
17
18
|
'enterprise-messaging-shared': 'messaging',
|
|
19
|
+
'redis-messaging': 'messaging',
|
|
18
20
|
'multitenancy': 'multitenancy'
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
const PreferredKinds = {
|
|
22
|
-
multitenancy:1, 'hana-cloud':1, xsuaa:1, 'xsuaa-auth':1, 'ias-auth':1, 'saas-registry':1
|
|
24
|
+
multitenancy: 1, 'hana-cloud': 1, xsuaa: 1, 'xsuaa-auth': 1, 'ias-auth': 1, 'saas-registry': 1
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
const PLATFORM_TYPES = {
|
|
@@ -30,7 +32,7 @@ const PLATFORM_TYPES = {
|
|
|
30
32
|
class BindingUtil {
|
|
31
33
|
static getRequiresNameFromKind(service, kind) {
|
|
32
34
|
const requiresName = KindToRequiresNameMap[kind];
|
|
33
|
-
if (!requiresName) throw new Error(`Unknown CDS service name for service
|
|
35
|
+
if (!requiresName) throw new Error(`Unknown CDS service name for service ${bold(service)}. Please specify as argument for ${bold('cds bind')}.`)
|
|
34
36
|
return requiresName;
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -98,23 +100,23 @@ class BindingUtil {
|
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
static platformText(binding) {
|
|
101
|
-
if (!PLATFORM_TYPES[binding.type]) throw new Error(`Unexpected binding type
|
|
103
|
+
if (!PLATFORM_TYPES[binding.type]) throw new Error(`Unexpected binding type ${bold(binding.type)}.`);
|
|
102
104
|
return PLATFORM_TYPES[binding.type]
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
static bindingText(binding
|
|
107
|
+
static bindingText(binding) {
|
|
106
108
|
switch (binding.type) {
|
|
107
109
|
case 'cf':
|
|
108
110
|
if (binding.key) {
|
|
109
|
-
return `managed service ${
|
|
111
|
+
return `managed service ${bold(binding.instance + ':' + binding.key)}`
|
|
110
112
|
} else {
|
|
111
|
-
return `user provided service ${
|
|
113
|
+
return `user provided service ${bold(binding.instance)}`
|
|
112
114
|
}
|
|
113
115
|
case 'k8s':
|
|
114
116
|
if (binding.name) {
|
|
115
|
-
return `service binding ${
|
|
117
|
+
return `service binding ${bold(binding.name)}`
|
|
116
118
|
} else {
|
|
117
|
-
return `secret ${
|
|
119
|
+
return `secret ${bold(binding.secret)}`
|
|
118
120
|
}
|
|
119
121
|
default:
|
|
120
122
|
throw new Error('Internal Error');
|