@sap/cds-dk 8.5.0 → 8.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 +36 -4
- package/bin/cds.js +48 -28
- package/bin/deploy/index.js +9 -11
- package/bin/import.js +6 -2
- package/bin/repl.js +86 -14
- package/bin/watch.js +1 -1
- package/lib/bind/cfKeyProvider.js +4 -3
- package/lib/bind/index.js +1 -1
- package/lib/build/buildTaskEngine.js +4 -4
- package/lib/build/plugins/helm/files/subcharts/content-deployment/Chart.yaml +3 -1
- package/lib/build/plugins/helm/files/subcharts/content-deployment/templates/_helpers.tpl +3 -5
- package/lib/build/plugins/helm/files/subcharts/content-deployment/values.schema.json +1 -16
- package/lib/build/plugins/helm/files/subcharts/content-deployment/values.yaml +6 -7
- package/lib/build/plugins/helm/files/subcharts/web-application/Chart.yaml +3 -1
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/_helpers.tpl +25 -5
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/api-rule.yaml +13 -4
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/service-binding.yaml +6 -1
- package/lib/build/plugins/helm/files/subcharts/web-application/values.schema.json +55 -48
- package/lib/build/plugins/helm/files/subcharts/web-application/values.yaml +19 -7
- package/lib/cds.js +10 -2
- package/lib/import/common.js +2 -2
- package/lib/init/constants.js +3 -1
- package/lib/init/index.js +10 -0
- package/lib/init/merge.js +1 -1
- package/lib/init/projectReader.js +1 -0
- package/lib/init/registries/mta.js +7 -1
- package/lib/init/template/ams/files/Chart.yaml.hbs +4 -0
- package/lib/init/template/ams/files/containerize.yaml.hbs +20 -0
- package/lib/init/template/ams/files/manifest.yml.hbs +24 -0
- package/lib/init/template/ams/files/mta.yaml.hbs +31 -0
- package/lib/init/template/ams/files/package.json.hbs +10 -0
- package/lib/init/template/ams/files/values.yaml.hbs +13 -0
- package/lib/init/template/ams/index.js +80 -0
- package/lib/init/template/approuter/files/mta.yaml.hbs +6 -4
- package/lib/init/template/approuter/files/package.json +1 -1
- package/lib/init/template/helm/files/values.schema.json +0 -2079
- package/lib/init/template/html5-repo/files/xs-app.json.hbs +1 -0
- package/lib/init/template/html5-repo/index.js +2 -0
- package/lib/init/template/http/index.js +10 -8
- package/lib/init/template/ias/files/Chart.yaml.hbs +4 -0
- package/lib/init/template/ias/files/manifest.yml.hbs +8 -0
- package/lib/init/template/ias/files/mta.yaml.hbs +61 -0
- package/lib/init/template/ias/files/package.json.hbs +22 -0
- package/lib/init/template/ias/files/services-manifest.yml.hbs +6 -0
- package/lib/init/template/ias/files/values.yaml.hbs +52 -0
- package/lib/init/template/ias/index.js +71 -0
- package/lib/init/template/mta/files/mta.yaml.hbs +15 -1
- package/lib/init/template/multitenancy/files/mta.yaml.hbs +38 -5
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +5 -2
- package/lib/init/template/multitenancy/index.js +40 -31
- package/lib/init/template/nodejs/files/package.json.hbs +1 -1
- package/lib/init/template/typescript/files/package.json +1 -1
- package/lib/init/template/xsuaa/index.js +1 -1
- package/lib/util/cf.js +4 -4
- package/lib/util/command.js +1 -9
- package/npm-shrinkwrap.json +140 -96
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,40 @@
|
|
|
3
3
|
|
|
4
4
|
All notable changes to this project will be documented in this file.
|
|
5
5
|
|
|
6
|
-
This project adheres to [Semantic Versioning](
|
|
6
|
+
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
-
The format is based on [Keep a Changelog](
|
|
8
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
9
|
+
|
|
10
|
+
## Version 8.6.0 - 2024-12-17
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `cds repl` got new option `--run` to run a server; also available through `.run` command within the REPL.
|
|
15
|
+
- `cds repl` got new option `--use` to make the features of a `cds` available as globals.
|
|
16
|
+
- `cds repl` got new builtin `.inspect` command to inspect object with configurable depth, e.g. `.inspect cds .depth=1`.
|
|
17
|
+
- `cds watch` now detects a TypeScript project and tries to run with `tsx` if this is installed locally or globally. Otherwise a warning message is emitted. `CDS_TYPESCRIPT=false` can be used to opt out of this behavior.
|
|
18
|
+
- `cds import --group` to allow RFC importer to organize imported modules under a logical name.
|
|
19
|
+
- `cds init/add` for Java projects automatically create a `package-lock.json`.
|
|
20
|
+
- `cds add ias` adds IAS configuration (beta).
|
|
21
|
+
- `cds add ams` adds AMS configuration (beta).
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Running `cds init` in the user's home dir w/o a project name now fails. This is to prevent creation of configuration that would act as global (user) configuration leading to follow-up problems with later projects.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- `cds add html5-repo` adds an `index.html` as `welcomePage` to the `xs-app.json`, if available.
|
|
30
|
+
- `cds bind` fixes the recursive call to `mergeCredentials`.
|
|
31
|
+
- `cds add` won't add a duplicated `SUBSCRIPTION_URL` if it doesn't match the template specification.
|
|
32
|
+
- `cds watch` gives a better error message for TypeScript projects started with if `tsx` isn't installed.
|
|
33
|
+
- `cds build` no longer throws an undefined error when processing build plugin messages.
|
|
34
|
+
|
|
35
|
+
## Version 8.5.1 - 2024-12-05
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- `cds build` now logs existing plugin build messages if a BuildError is thrown.
|
|
9
40
|
|
|
10
41
|
## Version 8.5.0 - 2024-11-26
|
|
11
42
|
|
|
@@ -23,13 +54,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
23
54
|
- The existing `cds watch --debug` is now an alias to `cds watch --inspect`.
|
|
24
55
|
- `cds add cloud-logging` adds cloud-logging as an alternative for application logging in Kyma.
|
|
25
56
|
- `cds add cloud-logging --with-telemetry` or `cds add telemetry` adds cloud-logging as well as support for `cap-js/telemetry` plugin in Kyma.
|
|
26
|
-
- `cds add handler` now also works for Node.js projects. It creates an implementation file for each service with event handlers for all
|
|
27
|
-
- `cds add esm` creates ESM-compatible Node.js projects. Sample code added by `add sample` and `add handler` will respect this setting if added
|
|
57
|
+
- `cds add handler` now also works for Node.js projects. It creates an implementation file for each service with event handlers for all entities and actions.
|
|
58
|
+
- `cds add esm` creates ESM-compatible Node.js projects. Sample code added by `add sample` and `add handler` will respect this setting if added afterwards. Existing code will not be adjusted by `cds add esm`, though.
|
|
28
59
|
|
|
29
60
|
### Fixed
|
|
30
61
|
|
|
31
62
|
- `cds import` throws proper error message if Annotation element doesn't have Term attribute.
|
|
32
63
|
- `cds add approuter` no longer enforces Node.js 22, which is not supporter by current `@sap/approuter` version 17. The previous Node.js version 20 is used again.
|
|
64
|
+
- `cds add -p` with custom options now works if the entry was not in the `package.json` beforehand.
|
|
33
65
|
- `cds add http` works for actions without parameters.
|
|
34
66
|
- `cds add workzone` includes the `updateManifestJson` task on initial generation.
|
|
35
67
|
- `cds build --ws` no longer creates migration tables in shared database or wrong workspace.
|
package/bin/cds.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const path = require('node:path')
|
|
4
|
+
const { sep } = { path }
|
|
5
|
+
const fs = require('node:fs')
|
|
3
6
|
|
|
4
7
|
const cli = {
|
|
5
8
|
|
|
@@ -25,9 +28,6 @@ const cli = {
|
|
|
25
28
|
},
|
|
26
29
|
|
|
27
30
|
async exec (cmd = process.argv[2], ...argv) {
|
|
28
|
-
const path = require('node:path')
|
|
29
|
-
const fs = require('node:fs')
|
|
30
|
-
|
|
31
31
|
if (!argv.length) argv = process.argv.slice(3)
|
|
32
32
|
if (!cmd) cmd = process.stdin.isTTY ? 'help' : 'compile'
|
|
33
33
|
if (cmd in this.Shortcuts) cmd = process.argv[2] = this.Shortcuts[cmd]
|
|
@@ -66,7 +66,10 @@ const cli = {
|
|
|
66
66
|
const p = argv[argv.indexOf('-p') + 1] || argv[argv.indexOf('--package') + 1]
|
|
67
67
|
console.log(`running with --package, adding dependency ${p}`)
|
|
68
68
|
await require('../lib/util/command').spawnCommand(`npm`, ['add', p], { cwd: cds.root })
|
|
69
|
+
delete require.cache[require.resolve(path.join(cds.root,'./package.json'))]
|
|
69
70
|
}
|
|
71
|
+
cds.env.plugins = cds.env.for('cds').plugins // reload plugin env
|
|
72
|
+
cds.add = require('../lib/init/add')
|
|
70
73
|
await cds.plugins
|
|
71
74
|
for (const [, Plugin] of cds.add.registered) {
|
|
72
75
|
const all = Object.entries((new Plugin).options())
|
|
@@ -86,13 +89,8 @@ const cli = {
|
|
|
86
89
|
|
|
87
90
|
if (args[1]?.['resolve-bindings']) await _resolveBindings({ silent: cmd === 'env' })
|
|
88
91
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!process.env.CDS_TYPESCRIPT && cds.cli?.command === 'serve' && fs.existsSync(tsconfig)) {
|
|
92
|
-
// cds.root may for some subcommands not point to the correct directory (e.g. cds w where users can pass a project directory)
|
|
93
|
-
// showing the full detected path should give the user an idea whether this info is relevant for them
|
|
94
|
-
console.error(`Detected ${tsconfig}. If this is a TypeScript project, consider running commands using 'cds-ts' instead of 'cds'.\n`)
|
|
95
|
-
}
|
|
92
|
+
_prepareTsIfNeeded(cds)
|
|
93
|
+
|
|
96
94
|
return await task.apply(this, args)
|
|
97
95
|
}
|
|
98
96
|
} catch (e) {
|
|
@@ -231,24 +229,6 @@ function _dieForUnknownCommand(cmd) {
|
|
|
231
229
|
throw msg;
|
|
232
230
|
}
|
|
233
231
|
|
|
234
|
-
function _require (id,o) {
|
|
235
|
-
try { var resolved = require.resolve(id,o) } catch(e){ DEBUG?.(`[cds] - Command not found: ${id}`); return }
|
|
236
|
-
DEBUG?.(`[cds] - Command resolved: ${resolved}`)
|
|
237
|
-
return require (resolved)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const { sep } = require ('path')
|
|
241
|
-
if (process[Symbol.for('ts-node.register.instance')])
|
|
242
|
-
process.env.CDS_TYPESCRIPT = 'ts-node'
|
|
243
|
-
else if (process._preload_modules?.some(m => m?.includes(`${sep}tsx${sep}`)))
|
|
244
|
-
process.env.CDS_TYPESCRIPT = 'tsx'
|
|
245
|
-
|
|
246
|
-
module.exports = Object.assign ((..._) => cli.exec(..._), cli)
|
|
247
|
-
|
|
248
|
-
if (!module.parent) module.exports()
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
232
|
function getCommands() {
|
|
253
233
|
const fs = require('node:fs');
|
|
254
234
|
const path = require('node:path');
|
|
@@ -267,4 +247,44 @@ function getCommands() {
|
|
|
267
247
|
return Array.from(result).sort()
|
|
268
248
|
}
|
|
269
249
|
|
|
250
|
+
function _require (id,o) {
|
|
251
|
+
try { var resolved = require.resolve(id,o) } catch(e){ DEBUG?.(`[cds] - Command not found: ${id}`); return }
|
|
252
|
+
DEBUG?.(`[cds] - Command resolved: ${resolved}`)
|
|
253
|
+
return require (resolved)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
module.exports = Object.assign ((..._) => cli.exec(..._), cli)
|
|
257
|
+
if (!module.parent) module.exports()
|
|
258
|
+
|
|
259
|
+
// check for an already loaded TS runner
|
|
260
|
+
if (process[Symbol.for('ts-node.register.instance')])
|
|
261
|
+
process.env.CDS_TYPESCRIPT = 'ts-node'
|
|
262
|
+
else if (process._preload_modules?.some(m => m?.includes(`${sep}tsx${sep}`)))
|
|
263
|
+
process.env.CDS_TYPESCRIPT = 'tsx'
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Load tsx if needed in a TS project. Warn users if this fails.
|
|
267
|
+
*/
|
|
268
|
+
function _prepareTsIfNeeded(cds) {
|
|
269
|
+
const tsconfig = path.join(cds.root ?? '.', 'tsconfig.json')
|
|
270
|
+
if (cds.cli?.command === 'serve' && fs.existsSync(tsconfig)) { // for `cds serve` started directly or through watch
|
|
271
|
+
if (/\b(0|no|false)\b/.test(process.env.CDS_TYPESCRIPT)) // opt-out switch to run JS code in a TS project
|
|
272
|
+
return delete process.env.CDS_TYPESCRIPT
|
|
273
|
+
|
|
274
|
+
if (!process.env.CDS_TYPESCRIPT ) {
|
|
275
|
+
try {
|
|
276
|
+
cds._localOrGlobal('tsx/cjs') // cjs is needed as we are in CJS code
|
|
277
|
+
console.log(`Detected ${path.relative(cds.root, tsconfig)}. Running with tsx.\n`)
|
|
278
|
+
process.env.CDS_TYPESCRIPT = 'tsx'
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
if (e.code !== 'MODULE_NOT_FOUND') throw e
|
|
282
|
+
console.error(`Error: detected ${tsconfig}, but could not run with 'tsx'. Enable Typescript with\n npm install -D tsx typescript\n`)
|
|
283
|
+
DEBUG && console.error(e)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
}
|
|
289
|
+
|
|
270
290
|
/* eslint no-console:off */
|
package/bin/deploy/index.js
CHANGED
|
@@ -78,22 +78,20 @@ module.exports = Object.assign(deploy, {
|
|
|
78
78
|
|
|
79
79
|
*--model-only*
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
databases to auto schema evolution.
|
|
81
|
+
Schema evolution: only update the information about the prior cds model.
|
|
82
|
+
In combination with *--dry* it writes the CSN to stdout, so you can store it to a file.
|
|
83
|
+
Use that to migrate existing databases to auto schema evolution.
|
|
85
84
|
|
|
86
85
|
*--delta-from* <filename>
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
generated SQL to stdout.
|
|
87
|
+
Schema evolution: read the information about the prior cds model from the given file,
|
|
88
|
+
which has been created by *cds deploy --model-only --dry*. When used with *--dry* it writes
|
|
89
|
+
the generated SQL to stdout.
|
|
92
90
|
|
|
93
|
-
*--script
|
|
91
|
+
*--script*
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
Schema evolution: together with *--delta-from* generate a script of SQL
|
|
94
|
+
statements to then check and execute manually or for usage with tools such as LiquiBase.
|
|
97
95
|
This script might contain potentially lossy statements!
|
|
98
96
|
|
|
99
97
|
|
package/bin/import.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module.exports = Object.assign(_import, {
|
|
2
2
|
_name: 'import',
|
|
3
|
-
options: ['--out', '--as', '--name', '--include-namespaces', '--from',
|
|
3
|
+
options: ['--out', '--as', '--name', '--include-namespaces', '--from', '--config', '--destination', '--group'],
|
|
4
|
+
shortcuts: ['-o', '-as', '-n', '-ns', undefined, '-c', undefined, undefined, '-', '-f'],
|
|
4
5
|
flags: ['--dry', '--force', '--no-copy', '--no-save', '--keep-namespace', '--beta'],
|
|
5
|
-
shortcuts: ['-o', '-as', '-n', '-ns', undefined, '-c', undefined, '-', '-f'],
|
|
6
6
|
help: `
|
|
7
7
|
# SYNOPSIS
|
|
8
8
|
|
|
@@ -72,6 +72,10 @@ module.exports = Object.assign(_import, {
|
|
|
72
72
|
The name of the module to be imported
|
|
73
73
|
Requires valid system credentials as the import connects to the system to fetch the metadata.
|
|
74
74
|
|
|
75
|
+
*--group*
|
|
76
|
+
Logical group under which the remote service is imported and registered. This could be a
|
|
77
|
+
function group or an application component name. Defaults to the destination name.
|
|
78
|
+
|
|
75
79
|
# EXAMPLES
|
|
76
80
|
|
|
77
81
|
cds import ~/Downloads/API_BUSINESS_PARTNER.edmx
|
package/bin/repl.js
CHANGED
|
@@ -1,13 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
module.exports = Object.assign (repl, {
|
|
2
|
+
options: [ '--run', '--use' ],
|
|
3
|
+
shortcuts: [ '-r', '-u' ],
|
|
4
|
+
help: `
|
|
3
5
|
# SYNOPSIS
|
|
4
6
|
|
|
5
|
-
*cds
|
|
7
|
+
*cds repl* [ <options> ]
|
|
6
8
|
|
|
7
9
|
Launches into a read-eval-print-loop, an interactive playground to
|
|
8
10
|
experiment with cds' JavaScript APIs. See documentation of Node.js'
|
|
9
11
|
REPL for details at _http://nodejs.org/api/repl.html_
|
|
10
12
|
|
|
13
|
+
# OPTIONS
|
|
14
|
+
|
|
15
|
+
*-r | --run* <project>
|
|
16
|
+
|
|
17
|
+
Runs a cds server from a given CAP project folder, or module name.
|
|
18
|
+
You can then access the entities and services of the running server.
|
|
19
|
+
It's the same as using the repl's builtin _.run_ command.
|
|
20
|
+
|
|
21
|
+
*-u | --use* <cds feature>
|
|
22
|
+
|
|
23
|
+
Loads the given cds feature into the repl's global context. For example,
|
|
24
|
+
if you specify _xl_ it makes the _cds.xl_ module's methods available.
|
|
25
|
+
It's the same as doing _{ref,val,xpr,...} = cds.xl_ within the repl.
|
|
26
|
+
|
|
27
|
+
# EXAMPLES
|
|
28
|
+
|
|
29
|
+
*cds repl* --run bookshop
|
|
30
|
+
*cds repl* --run .
|
|
31
|
+
*cds repl* --use cds.ql
|
|
32
|
+
|
|
11
33
|
# SEE ALSO
|
|
12
34
|
|
|
13
35
|
*cds eval* to evaluate and execute JavaScript.
|
|
@@ -15,6 +37,7 @@ module.exports = Object.assign (repl, { options: [], help: `
|
|
|
15
37
|
|
|
16
38
|
async function repl (_, options={}) {
|
|
17
39
|
|
|
40
|
+
const GREEN = '\x1b[32m', RESET = '\x1b[0m'
|
|
18
41
|
const cds = require('../lib/cds')
|
|
19
42
|
console.log('\x1b[32m\x1b[1m'+'Welcome to cds repl v', cds.version, '\x1b[0m')
|
|
20
43
|
|
|
@@ -22,8 +45,12 @@ async function repl (_, options={}) {
|
|
|
22
45
|
inspect.defaultOptions.colors = true
|
|
23
46
|
inspect.defaultOptions.depth = 11
|
|
24
47
|
|
|
48
|
+
Object.defineProperty (cds,'repl',{value:true})
|
|
49
|
+
let context={}, repl = { context, displayPrompt(){} }
|
|
50
|
+
if (options.run) await _run (options.run)
|
|
51
|
+
if (options.use) _export (...options.use.split(','))
|
|
25
52
|
|
|
26
|
-
|
|
53
|
+
repl = require('repl').start ({
|
|
27
54
|
...options,
|
|
28
55
|
ignoreUndefined: true,
|
|
29
56
|
useGlobal: true,
|
|
@@ -33,7 +60,8 @@ async function repl (_, options={}) {
|
|
|
33
60
|
}
|
|
34
61
|
})
|
|
35
62
|
|
|
36
|
-
Object.
|
|
63
|
+
if (Object.keys(context).length) Object.assign (repl.context, context)
|
|
64
|
+
|
|
37
65
|
cds.extend (repl.context) .with ( class {
|
|
38
66
|
get Foo() { return ctx.Foo ??= new cds.entity({ name: 'Foo' }) }; set Foo(v) { ctx.Foo = v }
|
|
39
67
|
get Bar() { return ctx.Bar ??= new cds.entity({ name: 'Bar' }) }; set Bar(v) { ctx.Bar = v }
|
|
@@ -41,15 +69,12 @@ async function repl (_, options={}) {
|
|
|
41
69
|
} .prototype )
|
|
42
70
|
const ctx={}
|
|
43
71
|
|
|
44
|
-
repl.defineCommand ('run', {
|
|
45
|
-
help: 'Runs a cds server
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.log ('- cds.services:', Object.keys(cds.services)); Object.assign (repl.context, cds.services)
|
|
51
|
-
console.log ('- cds.entities:', Object.keys(cds.entities)); Object.assign (repl.context, cds.entities)
|
|
52
|
-
}
|
|
72
|
+
repl.defineCommand ('run', { action: _run,
|
|
73
|
+
help: 'Runs a cds server from a given CAP project folder, or module name like @capire/bookshop.',
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
repl.defineCommand ('inspect', { action: _inspect,
|
|
77
|
+
help: 'Sets options for util.inspect, e.g. `.inspect .depth=1`.',
|
|
53
78
|
})
|
|
54
79
|
|
|
55
80
|
repl.history = new Array(222)
|
|
@@ -62,6 +87,53 @@ async function repl (_, options={}) {
|
|
|
62
87
|
process.on('uncaughtException', console.error)
|
|
63
88
|
process.on('unhandledRejection', console.error)
|
|
64
89
|
|
|
90
|
+
async function _run (project) {
|
|
91
|
+
await cds.test (project) // await cds.exec ('--project', project, '--port', '0')
|
|
92
|
+
_export ('entities', 'services')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _export (...cds_features) {
|
|
96
|
+
console.log()
|
|
97
|
+
console.log ('------------------------------------------------------------------------')
|
|
98
|
+
console.log ('Following variables are made available in your repl\'s global context:')
|
|
99
|
+
console.log()
|
|
100
|
+
for (let each of cds_features) {
|
|
101
|
+
let module = cds[each]
|
|
102
|
+
console.log (`from cds.${each}: {`)
|
|
103
|
+
for (let p in module) {
|
|
104
|
+
if (p in global || p.startsWith('_') || p.includes('.')) continue
|
|
105
|
+
console.log (` ${GREEN}${p}${RESET},`)
|
|
106
|
+
repl.context[p] = module [p]
|
|
107
|
+
}
|
|
108
|
+
console.log (`}`)
|
|
109
|
+
console.log()
|
|
110
|
+
}
|
|
111
|
+
console.log('Simply type e.g.', GREEN+ Object.keys(context).at(-1) +RESET, 'in the prompt to use the respective objects.')
|
|
112
|
+
console.log()
|
|
113
|
+
repl.displayPrompt()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function _inspect (_args) {
|
|
117
|
+
const args = _args.split(' '), subjects={}, options = {}, defaults = inspect.defaultOptions
|
|
118
|
+
for (let each of args) {
|
|
119
|
+
// args of shape .<option>=<value> set inspect options
|
|
120
|
+
if (each[0] === '.') each = eval(`options${each}`)
|
|
121
|
+
// others are subjects to inpsect with given options
|
|
122
|
+
else subjects[each ||= 'defaults'] = each === 'defaults' ? defaults : function _recurse (o,slug) {
|
|
123
|
+
const [ head,...tail ] = slug, x = o[head]
|
|
124
|
+
if (tail.length && x && typeof x === 'object') return _recurse (x,tail)
|
|
125
|
+
else return x
|
|
126
|
+
} (repl.context, each.split('.'))
|
|
127
|
+
}
|
|
128
|
+
// if no subjects were given, just set the options globally
|
|
129
|
+
if (!Object.keys(subjects).length) {
|
|
130
|
+
Object.assign (defaults, options)
|
|
131
|
+
console.log('\n', 'updated node:util.inspect.defaultOptions with:', options)
|
|
132
|
+
} else for (let [each,subject] of Object.entries(subjects))
|
|
133
|
+
console.log ('\n'+each+':', inspect (subject, options))
|
|
134
|
+
console.log()
|
|
135
|
+
repl.displayPrompt()
|
|
136
|
+
}
|
|
65
137
|
}
|
|
66
138
|
|
|
67
139
|
if (!module.parent) repl()
|
package/bin/watch.js
CHANGED
|
@@ -82,7 +82,7 @@ async function watch ([cwd], {
|
|
|
82
82
|
...options
|
|
83
83
|
}={}) {
|
|
84
84
|
if (cwd && !cds.utils.exists(cwd)) try { // try module name like `@capire/bookshop`
|
|
85
|
-
cwd = require.resolve(cwd+'/package.json').slice(0,-13)
|
|
85
|
+
cwd = require.resolve(cwd+'/package.json', {paths:[ process.cwd() ]}).slice(0,-13)
|
|
86
86
|
} catch (err) {
|
|
87
87
|
throw `Error: No such folder or package: '${cwd}'`
|
|
88
88
|
}
|
|
@@ -88,16 +88,17 @@ module.exports = new class CFKeyProvider {
|
|
|
88
88
|
async _resolveManagedService(instanceObj, instance, key, org, space, customCredentials) {
|
|
89
89
|
const create = (cds.cli.command === 'bind' || cds.cli.command === 'deploy') && !cds.cli.options['no-create-service-key']
|
|
90
90
|
const silent = (cds.cli.options.json || cds.cli.command === 'env') && !DEBUG
|
|
91
|
-
const
|
|
91
|
+
const planObj = await this.getPlan(instanceObj.relationships.service_plan.data.guid);
|
|
92
|
+
const offeringObj = await this.getOffering(planObj.relationships.service_offering.data.guid);
|
|
93
|
+
const parameters = offeringObj.name === "identity" ? { "credential-type": "X509_GENERATED", "app-identifier" : "cds_bind" } : {};
|
|
92
94
|
|
|
95
|
+
const credentials = await cfUtil.getOrCreateServiceKey(instanceObj, key, parameters, { create, silent });
|
|
93
96
|
if (!credentials) {
|
|
94
97
|
let message = `No service key ${bold(key)} found for service instance ${bold(instance)}.\n\n`;
|
|
95
98
|
message += `Use ${bold(`cf create-service-key ${instanceObj.name} ${key} [-c ...]`)} to create the required service key.`;
|
|
96
99
|
throw message;
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
const planObj = await this.getPlan(instanceObj.relationships.service_plan.data.guid);
|
|
100
|
-
const offeringObj = await this.getOffering(planObj.relationships.service_offering.data.guid);
|
|
101
102
|
const resolvedBinding = {
|
|
102
103
|
binding: {
|
|
103
104
|
type: "cf",
|
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] =
|
|
121
|
+
credentials[key] = mergeCredentials(credentials[key], customCredentials[key]);
|
|
122
122
|
} else {
|
|
123
123
|
credentials[key] = customCredentials[key];
|
|
124
124
|
}
|
|
@@ -2,7 +2,7 @@ const fs = require('fs')
|
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const cds = require('../cds'), { _log: log } = cds
|
|
4
4
|
const { sortMessagesSeverityAware, deduplicateMessages, CompilationError } = cds.compiler
|
|
5
|
-
const { relativePaths, BuildError, resolveRequiredSapModels, redactCredentials } = require('./util')
|
|
5
|
+
const { relativePaths, BuildError, BuildMessage, resolveRequiredSapModels, redactCredentials } = require('./util')
|
|
6
6
|
const { SEVERITIES, LOG_LEVELS } = require('./constants')
|
|
7
7
|
const BuildTaskFactory = require('./buildTaskFactory')
|
|
8
8
|
const InternalBuildPlugin = require('./provider/internalBuildPlugin')
|
|
@@ -187,8 +187,8 @@ class BuildTaskEngine {
|
|
|
187
187
|
if (errors.length > 0) {
|
|
188
188
|
const error = errors.find(e => e.constructor.name !== COMPILATION_ERROR)
|
|
189
189
|
if (error) {
|
|
190
|
-
// throw original
|
|
191
|
-
|
|
190
|
+
// throw original BuildError including existing BuildMessages
|
|
191
|
+
error.messages = this._sortMessagesUnique(pluginMessages.filter(m => m instanceof BuildMessage), error.messages)
|
|
192
192
|
throw error
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -333,7 +333,7 @@ The higher the value the earlier the plugin is run.`
|
|
|
333
333
|
// flatten
|
|
334
334
|
messages = messages.reduce((acc, m) => acc.concat(m), [])
|
|
335
335
|
// filter according to log-level
|
|
336
|
-
const filteredMessages = messages.filter(message => !message.severity || logLevelIdx >= SEVERITIES.indexOf(message.severity))
|
|
336
|
+
const filteredMessages = messages.filter(message => message && (!message.severity || logLevelIdx >= SEVERITIES.indexOf(message.severity)))
|
|
337
337
|
// remove duplicates
|
|
338
338
|
deduplicateMessages(filteredMessages)
|
|
339
339
|
// sort
|
|
@@ -115,12 +115,10 @@ Name of the imagePullSecret
|
|
|
115
115
|
{{ $ips := (dict "local" .Values.imagePullSecret "global" .Values.global.imagePullSecret) }}
|
|
116
116
|
{{- if $ips.local.name }}
|
|
117
117
|
{{- $ips.local.name }}
|
|
118
|
-
{{- else if $ips.global.
|
|
119
|
-
{{- $ips.global.name }}
|
|
120
|
-
{{- else if or $ips.local.dockerconfigjson $ips.global.dockerconfigjson }}
|
|
118
|
+
{{- else if or (and $ips.local $ips.local.dockerconfigjson) (and $ips.global $ips.global.dockerconfigjson) }}
|
|
121
119
|
{{- include "content-deployment.internal.fullname" . }}
|
|
122
|
-
{{- else }}
|
|
123
|
-
{{-
|
|
120
|
+
{{- else if and $ips.global $ips.global.name }}
|
|
121
|
+
{{- $ips.global.name }}
|
|
124
122
|
{{- end }}
|
|
125
123
|
{{- end }}
|
|
126
124
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://github.tools.sap/unified-runtime/content-deployment/blob/main/values.schema.json",
|
|
3
4
|
"type": "object",
|
|
4
5
|
"required": [
|
|
5
6
|
"image", "bindings"
|
|
@@ -23,22 +24,6 @@
|
|
|
23
24
|
"dockerconfigjson": {
|
|
24
25
|
"type": "string"
|
|
25
26
|
}
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"name": {
|
|
29
|
-
"not": {
|
|
30
|
-
"required": [
|
|
31
|
-
"dockerconfigjson"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"dockerconfigjson": {
|
|
36
|
-
"not": {
|
|
37
|
-
"required": [
|
|
38
|
-
"name"
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
27
|
}
|
|
43
28
|
},
|
|
44
29
|
"image": {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# Helm global values, for more information, see https://helm.sh/docs/chart_template_guide/subcharts_and_globals/#global-chart-values
|
|
2
2
|
global:
|
|
3
3
|
# Image Pull Secret configuration, for more information, see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
|
4
|
-
imagePullSecret:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# Either name or repository is required.
|
|
4
|
+
imagePullSecret:
|
|
5
|
+
# Name of the Kubernetes Secret, used as an image pull secret (must be of type kubernetes.io/dockerconfigjson).
|
|
6
|
+
name: image-pull-secret
|
|
7
|
+
# The content for the dynamically generated Kubernetes Secret, which will be used as an image pull secret.
|
|
8
|
+
# dockerconfigjson: ""
|
|
10
9
|
image: {}
|
|
11
10
|
# registry: gcr.io/my-project
|
|
12
11
|
# tag: latest
|
|
@@ -15,7 +14,7 @@ global:
|
|
|
15
14
|
_internal:
|
|
16
15
|
content-deployment:
|
|
17
16
|
versions:
|
|
18
|
-
1.
|
|
17
|
+
1.7.0: true
|
|
19
18
|
# Will be used instead of the `.Chart.Name`, e.g. when generating the Deployment name.
|
|
20
19
|
# nameOverride: name
|
|
21
20
|
|
|
@@ -29,6 +29,22 @@ Define Host for the APIRule
|
|
|
29
29
|
{{- end }}
|
|
30
30
|
{{- end }}
|
|
31
31
|
|
|
32
|
+
{{/*
|
|
33
|
+
Define Hosts for the APIRule (since v2alpha1)
|
|
34
|
+
*/}}
|
|
35
|
+
{{- define "web-application.internal.exposeHosts" -}}
|
|
36
|
+
{{- if .Values.expose.hosts }}
|
|
37
|
+
{{ .Values.expose.hosts | toYaml }}
|
|
38
|
+
{{- else }}
|
|
39
|
+
{{- $name := (include "web-application.fullname" .) }}
|
|
40
|
+
{{- if hasPrefix $name .Release.Namespace }}
|
|
41
|
+
- {{ .Release.Namespace }}
|
|
42
|
+
{{- else }}
|
|
43
|
+
- {{ printf "%s-%s" $name .Release.Namespace | trunc 63 | trimSuffix "-" }}
|
|
44
|
+
{{- end }}
|
|
45
|
+
{{- end }}
|
|
46
|
+
{{- end }}
|
|
47
|
+
|
|
32
48
|
{{/*
|
|
33
49
|
Returns the TENANT_HOST_PATTERN if defined
|
|
34
50
|
*/}}
|
|
@@ -92,12 +108,10 @@ Name of the imagePullSecret
|
|
|
92
108
|
{{ $ips := (dict "local" .Values.imagePullSecret "global" .Values.global.imagePullSecret) }}
|
|
93
109
|
{{- if $ips.local.name }}
|
|
94
110
|
{{- $ips.local.name }}
|
|
95
|
-
{{- else if $ips.global.
|
|
96
|
-
{{- $ips.global.name }}
|
|
97
|
-
{{- else if or $ips.local.dockerconfigjson $ips.global.dockerconfigjson }}
|
|
111
|
+
{{- else if or (and $ips.local $ips.local.dockerconfigjson) (and $ips.global $ips.global.dockerconfigjson) }}
|
|
98
112
|
{{- include "web-application.fullname" . }}
|
|
99
|
-
{{- else }}
|
|
100
|
-
{{-
|
|
113
|
+
{{- else if and $ips.global $ips.global.name }}
|
|
114
|
+
{{- $ips.global.name }}
|
|
101
115
|
{{- end }}
|
|
102
116
|
{{- end }}
|
|
103
117
|
|
|
@@ -210,5 +224,11 @@ If release name contains chart name it will be used as service instance name.
|
|
|
210
224
|
{{- if .checkValues.failureThreshold }}
|
|
211
225
|
failureThreshold: {{ .checkValues.failureThreshold }}
|
|
212
226
|
{{- end }}
|
|
227
|
+
{{- if .checkValues.successThreshold }}
|
|
228
|
+
successThreshold: {{ .checkValues.successThreshold }}
|
|
229
|
+
{{- end }}
|
|
230
|
+
{{- if .checkValues.timeoutSeconds }}
|
|
231
|
+
timeoutSeconds: {{ .checkValues.timeoutSeconds }}
|
|
232
|
+
{{- end }}
|
|
213
233
|
{{- end }}
|
|
214
234
|
{{- end }}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
{{- if .Values.expose.enabled -}}
|
|
2
|
+
{{- if .Values.expose.APIRule.experimental -}}
|
|
3
|
+
apiVersion: gateway.kyma-project.io/v2alpha1
|
|
4
|
+
{{ else }}
|
|
2
5
|
apiVersion: gateway.kyma-project.io/v1beta1
|
|
6
|
+
{{- end }}
|
|
3
7
|
kind: APIRule
|
|
4
8
|
metadata:
|
|
5
9
|
name: {{ include "web-application.fullname" . }}
|
|
6
10
|
labels: {{- include "web-application.labels" . | nindent 4 }}
|
|
7
11
|
spec:
|
|
8
|
-
gateway: {{tpl .Values.expose.gateway $ }}
|
|
12
|
+
gateway: {{ tpl .Values.expose.gateway $ }}
|
|
13
|
+
{{- if .Values.expose.APIRule.experimental }}
|
|
14
|
+
hosts:
|
|
15
|
+
{{- include "web-application.internal.exposeHosts" . | indent 4 }}
|
|
16
|
+
{{- else }}
|
|
9
17
|
host: {{ include "web-application.internal.exposeHost" . }}
|
|
18
|
+
{{- end }}
|
|
10
19
|
service:
|
|
11
20
|
name: {{ include "web-application.fullname" . }}
|
|
12
21
|
port: {{ .Values.port }}
|
|
13
22
|
rules:
|
|
14
|
-
{{- toYaml .Values.expose.rules | nindent
|
|
15
|
-
{{ if .Values.expose.corsPolicy }}
|
|
23
|
+
{{- toYaml .Values.expose.rules | nindent 4 }}
|
|
24
|
+
{{- if .Values.expose.corsPolicy }}
|
|
16
25
|
corsPolicy:
|
|
17
|
-
{{- toYaml .Values.expose.corsPolicy | nindent
|
|
26
|
+
{{- toYaml .Values.expose.corsPolicy | nindent 4 }}
|
|
18
27
|
{{- end }}
|
|
19
28
|
{{- end }}
|
package/lib/build/plugins/helm/files/subcharts/web-application/templates/service-binding.yaml
CHANGED
|
@@ -11,7 +11,12 @@ metadata:
|
|
|
11
11
|
labels: {{- include "web-application.labels" $ | nindent 4 }}
|
|
12
12
|
spec:
|
|
13
13
|
serviceInstanceName: {{include "web-application.internal.serviceInstanceName" (dict "binding" $mergedParams "root" $) }}
|
|
14
|
-
secretKey
|
|
14
|
+
{{- if $mergedParams.secretKey }}
|
|
15
|
+
secretKey: {{ $mergedParams.secretKey }}
|
|
16
|
+
{{- end }}
|
|
17
|
+
{{- if $mergedParams.serviceInstanceNamespace }}
|
|
18
|
+
serviceInstanceNamespace: {{ $mergedParams.serviceInstanceNamespace }}
|
|
19
|
+
{{- end }}
|
|
15
20
|
{{- if $mergedParams.externalName }}
|
|
16
21
|
externalName: {{ $mergedParams.externalName }}
|
|
17
22
|
{{- end }}
|