@sap/cds-dk 6.6.2 → 6.7.1
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 -1
- package/bin/add.js +5 -3
- package/bin/build/all.js +1 -1
- package/bin/cds.js +10 -8
- package/bin/env.js +4 -6
- package/bin/login.js +6 -4
- package/bin/migrate.js +0 -1
- package/bin/repl.js +1 -1
- package/bin/serve.js +7 -0
- package/bin/subscribe.js +5 -5
- package/bin/unsubscribe.js +4 -5
- package/bin/upgrade.js +67 -0
- package/bin/watch.js +8 -5
- package/lib/bind/bindingManager.js +3 -2
- package/lib/bind/cfKeyProvider.js +7 -6
- package/lib/bind/userCdsrcJsonStorageProvider.js +5 -4
- package/lib/cds.js +12 -0
- package/lib/client/activate.js +4 -3
- package/lib/client/auth_manager.js +4 -3
- package/lib/client/base_command.js +7 -2
- package/lib/client/helper/cf_helper.js +12 -11
- package/lib/client/helper/dependency_helper.js +3 -2
- package/lib/client/helper/logging.js +0 -7
- package/lib/client/params.js +4 -2
- package/lib/client/settings_manager.js +35 -34
- package/lib/client/tenant_action.js +78 -0
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +4 -4
- package/lib/init/template/_merging/registry-mta.js +31 -46
- package/lib/init/template/approuter/files/mta.yaml.hbs +12 -8
- package/lib/init/template/approuter/files/xs-app.json.hbs +0 -3
- package/lib/init/template/approuter/index.js +26 -34
- package/lib/init/template/auditlog/files/mta.yaml.hbs +2 -1
- package/lib/init/template/auditlog/index.js +8 -21
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +4 -4
- package/lib/init/template/cf-manifest/index.js +2 -1
- package/lib/init/template/connectivity/index.js +4 -5
- package/lib/init/template/data/index.js +19 -22
- package/lib/init/template/destinations/index.js +5 -17
- package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +2 -1
- package/lib/init/template/enterprise-messaging/index.js +7 -19
- package/lib/init/template/extensibility/index.js +3 -1
- package/lib/init/template/hana/files/mta.yaml.hbs +4 -5
- package/lib/init/template/hana/index.js +49 -84
- package/lib/init/template/helm/chart/templates/_helpers.tpl +4 -1
- package/lib/init/template/helm/files/Chart.yaml.hbs +1 -4
- package/lib/init/template/helm/index.js +45 -13
- package/lib/init/template/helm/subcharts/web-application/templates/_helpers.tpl +21 -31
- package/lib/init/template/helm/subcharts/web-application/templates/api-rule.yaml +3 -12
- package/lib/init/template/helm/subcharts/web-application/templates/deployment.yaml +12 -14
- package/lib/init/template/helm/subcharts/web-application/templates/network-policy.yaml +27 -4
- package/lib/init/template/helm/subcharts/web-application/templates/pod-disruption-budget.yaml +0 -2
- package/lib/init/template/helm/subcharts/web-application/templates/secret.yaml +2 -2
- package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +2 -2
- package/lib/init/template/helm/subcharts/web-application/templates/service-binding.yaml +16 -13
- package/lib/init/template/helm/subcharts/web-application/templating.md +16 -9
- package/lib/init/template/helm/subcharts/web-application/values.md +317 -379
- package/lib/init/template/helm/subcharts/web-application/values.schema.json +87 -107
- package/lib/init/template/helm/subcharts/web-application/values.yaml +28 -2
- package/lib/init/template/html5-repo/index.js +6 -29
- package/lib/init/template/java/index.js +1 -1
- package/lib/init/template/kibana-logging/files/mta.yaml.hbs +2 -1
- package/lib/init/template/kibana-logging/index.js +5 -8
- package/lib/init/template/lint/index.js +8 -8
- package/lib/init/template/mta/files/mta.yaml.hbs +3 -2
- package/lib/init/template/mta/index.js +3 -2
- package/lib/init/template/multitenancy/files/mta.yaml.hbs +25 -31
- package/lib/init/template/multitenancy/files/{java/mtxs-configmap.yaml → mtxs-configmap-java.yaml} +1 -1
- package/lib/init/template/multitenancy/files/{mtxs-configmap.yaml → mtxs-configmap-nodejs.yaml} +5 -1
- package/lib/init/template/multitenancy/files/package.json.hbs +28 -0
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +21 -0
- package/lib/init/template/multitenancy/files/values.yaml.hbs +16 -9
- package/lib/init/template/multitenancy/index.js +51 -99
- package/lib/init/template/nodejs/files/.vscode/extensions.json +1 -2
- package/lib/init/template/nodejs/files/.vscode/launch.json +2 -2
- package/lib/init/template/nodejs/files/.vscode/tasks.json +2 -2
- package/lib/init/template/nodejs/files/package.json.hbs +2 -2
- package/lib/init/template/nodejs/index.js +4 -3
- package/lib/init/template/pipeline/index.js +3 -2
- package/lib/init/template/samples/index.js +5 -4
- package/lib/init/template/sqlite/files/package.json.hbs +19 -0
- package/lib/init/template/sqlite/index.js +11 -0
- package/lib/init/template/toggles/index.js +3 -5
- package/lib/init/template/xsuaa/files/mta.yaml.hbs +4 -5
- package/lib/init/template/xsuaa/files/values.yaml.hbs +0 -2
- package/lib/init/template/xsuaa/index.js +14 -35
- package/lib/init/util/commandUtil.js +3 -2
- package/lib/init/util/fsUtil.js +19 -2
- package/lib/init/util/md5Tracking.js +36 -63
- package/lib/init/util/projectReader.js +12 -26
- package/lib/lint/Linter.js +0 -3
- package/lib/util/exec.js +2 -1
- package/lib/util/term.js +1 -1
- package/lib/watch/livereload-connect.js +5 -4
- package/lib/watch/livereload-server.js +3 -6
- package/lib/watch/node-watch.js +1 -1
- package/npm-shrinkwrap.json +569 -479
- package/package.json +4 -4
- package/readme.md +1 -1
- package/lib/client/subscription.js +0 -84
- package/lib/init/template/approuter/files/chart.yaml +0 -4
- package/lib/init/template/auditlog/files/auditlog.yaml +0 -4
- package/lib/init/template/destinations/files/destination.yaml +0 -4
- package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +0 -4
- package/lib/init/template/hana/files/hana-deployer.yaml +0 -4
- package/lib/init/template/hana/files/hana.yaml +0 -4
- package/lib/init/template/html5-repo/files/html5-apps-deployer.yaml +0 -4
- package/lib/init/template/html5-repo/files/html5-apps-repo-host.yaml +0 -4
- package/lib/init/template/multitenancy/files/cds.package.json +0 -7
- package/lib/init/template/multitenancy/files/cds.package.json.hbs +0 -9
- package/lib/init/template/multitenancy/files/dependencies.package.json +0 -5
- package/lib/init/template/multitenancy/files/java/.cdsrc.json +0 -22
- package/lib/init/template/multitenancy/files/java/package.json +0 -33
- package/lib/init/template/multitenancy/files/saas-registry.yaml +0 -4
- package/lib/init/template/multitenancy/files/service-manager.yaml +0 -4
- package/lib/init/template/multitenancy/files/sidecar.yaml +0 -4
- package/lib/init/template/xsuaa/files/xsuaa.yaml +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,41 @@ 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 6.7.1 - 2023-04-19
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `cds init` uses latest Maven Java archetype version 1.33.1 for creating Java projects.
|
|
15
|
+
- Bump `@sap/cds` to 6.7.1
|
|
16
|
+
- Bump `@sap/cds-mtxs` to 1.7.2
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Compatibility with @sap/cds versions >= 4.5 and < 6.2: avoid runtime errors with debugging disabled.
|
|
21
|
+
|
|
22
|
+
## Version 6.7.0 - 2023-03-28
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- `cds upgrade` enables upgrading a tenant subscribed to a multitenant SaaS app to the latest base model.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- `cds env --for` is now used to specify profiles; before it specified project paths, but never worked correctly.
|
|
31
|
+
- `cds add data` now uses comma as CSV separator by default instead of semicolon. This allows using GitHub tabular display.
|
|
32
|
+
- `cds add approuter` doesn't create entries for `authenticationMethod` and `authenticationType` any more, but uses the equivalent `@sap/approuter` defaults.
|
|
33
|
+
- `cds add multitenancy` will now create a sidecar MTX project for Node.js as well.
|
|
34
|
+
- `cds subscribe` and `cds unsubscribe` no longer require a username in case @sap/cds-mtxs is configured with dummy auth.
|
|
35
|
+
- `cds subscribe` and `cds unsubscribe` now rely on @sap/cds-mtxs (version 1.7.0 or higher).
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- `cds watch`'s livereload feature may now use a local IPv6 address (`::1`) instead of always `localhost`. This is usually the case on Node.js 17 or higher.
|
|
40
|
+
- In all but `cds compile` errors where not handled correctly, especially compiler errors not displayed in human readable format.
|
|
41
|
+
- `cds init` creates project sample files correctly.
|
|
42
|
+
- CLI commands w/ unknown arguments (`cds --foo`) clearly fail again with a proper error message
|
|
43
|
+
- Reduce console output in case of multitenancy-related command failures.
|
|
44
|
+
|
|
10
45
|
## Version 6.6.2 - 2023-03-22
|
|
11
46
|
|
|
12
47
|
### Fixed
|
|
@@ -24,7 +59,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
24
59
|
### Fixed
|
|
25
60
|
|
|
26
61
|
- `cds add helm` fixed html5 cloud service is now read properly.
|
|
27
|
-
- `cds import` now flattens the `@Capabilities`
|
|
62
|
+
- `cds import` now flattens the `@Capabilities` annotation in the CSN for OData V4 files.
|
|
28
63
|
- `cds import` for OData V4 files now captures the `EnumTypes` information in the CSN according to `UnderlyingType`.
|
|
29
64
|
- `cds import` now captures the `@Common.Text` annotation value properly in the CSN for OData V4 files.
|
|
30
65
|
- `cds init --add java` now uses local Java version when creating new Java project.
|
package/bin/add.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
module.exports = Object.assign(add, {
|
|
3
3
|
options: ['--for', '--out', '--data:for'],
|
|
4
4
|
shortcuts: ['-4', '-o'],
|
|
5
|
-
flags: ['--force', '--verbose'],
|
|
5
|
+
flags: ['--force', '--verbose', '--internal-unified-runtime-charts'],
|
|
6
6
|
help: `
|
|
7
7
|
# SYNOPSIS
|
|
8
8
|
|
|
@@ -13,7 +13,9 @@ module.exports = Object.assign(add, {
|
|
|
13
13
|
|
|
14
14
|
The following <features> are supported so far:
|
|
15
15
|
|
|
16
|
-
*hana* - adds configuration for SAP HANA
|
|
16
|
+
*hana* - adds configuration for SAP HANA databases
|
|
17
|
+
|
|
18
|
+
*sqlite* - adds configuration for SQLite databases
|
|
17
19
|
|
|
18
20
|
*xsuaa* - adds configuration for authentication via XSUAA
|
|
19
21
|
|
|
@@ -66,7 +68,7 @@ module.exports = Object.assign(add, {
|
|
|
66
68
|
# EXAMPLES
|
|
67
69
|
|
|
68
70
|
*cds add* mta,pipeline
|
|
69
|
-
*cds add*
|
|
71
|
+
*cds add* multitenancy
|
|
70
72
|
*cds add* hana,xsuaa --for production
|
|
71
73
|
*cds add* cf-manifest
|
|
72
74
|
*cds add* data --for my.namspace.MyEntity
|
package/bin/build/all.js
CHANGED
|
@@ -78,7 +78,7 @@ async function build([project], options = {}) {
|
|
|
78
78
|
return await cds.build.build(options)
|
|
79
79
|
} catch (e) {
|
|
80
80
|
process.exitCode = 1
|
|
81
|
-
cds._log(e.errors
|
|
81
|
+
cds._log(e.errors?.length ? e.errors : e, { 'log-level': cds.env.log.levels.cli })
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
}
|
package/bin/cds.js
CHANGED
|
@@ -32,7 +32,7 @@ const cli = { //NOSONAR
|
|
|
32
32
|
if (argv.some(a => this.Shortcuts[a]==='help')) return this.help (cmd)
|
|
33
33
|
|
|
34
34
|
const cds_cli = require (_local('@sap/cds/bin/cds'))
|
|
35
|
-
DEBUG
|
|
35
|
+
DEBUG?.(`[cds] - @sap/cds ${require('../lib/cds').version} loaded: ${require('../lib/cds').home}`)
|
|
36
36
|
|
|
37
37
|
const task = this.load (cmd, /*else*/ (f)=> argv.unshift(cmd) && _defaultCompile (argv,f))
|
|
38
38
|
if (task) {
|
|
@@ -47,16 +47,18 @@ const cli = { //NOSONAR
|
|
|
47
47
|
const args = cds_cli.args(task,argv)
|
|
48
48
|
args[0].push(...appendArgs)
|
|
49
49
|
if (args[1]?.['resolve-bindings']) await _resolveBindings()
|
|
50
|
-
return task.apply(this, args)
|
|
50
|
+
return await task.apply(this, args)
|
|
51
51
|
} catch (e) {
|
|
52
52
|
process.exitCode = 1
|
|
53
|
-
|
|
53
|
+
if (e.messages) require('../lib/cds')._log (e.messages)
|
|
54
|
+
else console.error(e)
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
},
|
|
57
58
|
|
|
58
59
|
load (cmd,_default) {
|
|
59
|
-
|
|
60
|
+
if (cmd === 'build/all') return _require ('./'+cmd) // TODO: remove with CDS 7
|
|
61
|
+
return /[\\/.-@]/.test(cmd) && _default && _default(true) // like `cds ./srv` or `cds @capire/bookshop`
|
|
60
62
|
|| /cds/i.test(cmd) && _dieForUnknownCommand (cmd) // cds cds
|
|
61
63
|
|| _require ('./'+cmd) // cds-dk commands
|
|
62
64
|
|| _require ('@sap/cds/bin/'+cmd, {paths:[process.cwd(), __dirname]}) // prefer local cds for the rest
|
|
@@ -67,7 +69,7 @@ const cli = { //NOSONAR
|
|
|
67
69
|
help (cmd) { return this.exec ('help', cmd) }
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG)
|
|
72
|
+
const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) ? console.debug : undefined
|
|
71
73
|
|
|
72
74
|
async function _resolveBindings() {
|
|
73
75
|
const cds = require('../lib/cds')
|
|
@@ -90,7 +92,7 @@ function _defaultCompile (argv, _force) {
|
|
|
90
92
|
// Try all arguments if one resolves to a model. If yes, we assume 'compile' is intended.
|
|
91
93
|
const model = _force || _is_model(argv)
|
|
92
94
|
if (model) return _require ('./compile')
|
|
93
|
-
DEBUG
|
|
95
|
+
DEBUG?.(`[cds] - Command is not a model to compile: ${argv}`)
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
function _is_model (argv) {
|
|
@@ -142,8 +144,8 @@ function _dieForUnknownCommand(cmd) {
|
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
function _require (id,o) {
|
|
145
|
-
try { var resolved = require.resolve(id,o) } catch(e){ DEBUG
|
|
146
|
-
DEBUG
|
|
147
|
+
try { var resolved = require.resolve(id,o) } catch(e){ DEBUG?.(`[cds] - Command not found: ${id}`); return }
|
|
148
|
+
DEBUG?.(`[cds] - Command resolved: ${resolved}`)
|
|
147
149
|
return require (resolved)
|
|
148
150
|
}
|
|
149
151
|
|
package/bin/env.js
CHANGED
|
@@ -16,11 +16,7 @@ module.exports = Object.assign (env, {
|
|
|
16
16
|
|
|
17
17
|
# OPTIONS
|
|
18
18
|
|
|
19
|
-
*-4* | *--for* <
|
|
20
|
-
|
|
21
|
-
Load configuration from path instead of the current working directory.
|
|
22
|
-
|
|
23
|
-
*--profile* <profile,...>
|
|
19
|
+
*-4* | *--for* | *--profile* <profile,...>
|
|
24
20
|
|
|
25
21
|
Load configuration for the specified profile(s).
|
|
26
22
|
|
|
@@ -41,13 +37,15 @@ const info = (s) => process.stdout.isTTY ? term.info (s) : s
|
|
|
41
37
|
|
|
42
38
|
async function env ([cmd, key, value], options={}) {
|
|
43
39
|
|
|
40
|
+
if (options.for) process.env.CDS_ENV = options.for
|
|
41
|
+
|
|
44
42
|
const cds = require('../lib/cds')
|
|
45
43
|
const fn = (
|
|
46
44
|
options["process-env"] ? processEnvCommands[cmd] :
|
|
47
45
|
commands[cmd] || ((key = cmd), commands.get)
|
|
48
46
|
)
|
|
49
47
|
|
|
50
|
-
let env =
|
|
48
|
+
let env = cds.env
|
|
51
49
|
if (options["resolve-bindings"]) {
|
|
52
50
|
const BindingManager = require('../lib/bind/bindingManager')
|
|
53
51
|
const bindingManager = new BindingManager({ env, silent: true })
|
package/bin/login.js
CHANGED
|
@@ -9,9 +9,10 @@ module.exports = Object.assign(login, {
|
|
|
9
9
|
|
|
10
10
|
*cds login* [ <app-url> ]
|
|
11
11
|
|
|
12
|
-
Simplifies usage of *cds
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Simplifies usage of multitenancy-related commands (e.g. *cds subscribe* and *cds push*)
|
|
13
|
+
by providing them with automatic authentication: fetches and saves authentication
|
|
14
|
+
tokens and provides relevant tokens to those commands. Alternatively saves username
|
|
15
|
+
for apps running locally.
|
|
15
16
|
|
|
16
17
|
Saves further settings for the current project (<app-url>, <tenant-subdomain>, and
|
|
17
18
|
URLs for passcodes and tokens).
|
|
@@ -110,7 +111,8 @@ module.exports = Object.assign(login, {
|
|
|
110
111
|
|
|
111
112
|
# SEE ALSO
|
|
112
113
|
|
|
113
|
-
*cds
|
|
114
|
+
Supported commands: *cds subscribe*, *cds upgrade*, *cds pull*, *cds push*, and *cds unsubscribe*.
|
|
115
|
+
*cds logout* to remove any authentication data.
|
|
114
116
|
https://cap.cloud.sap/docs/guides/extensibility/customization?q=mock#mock-users for information on suitable mock users.
|
|
115
117
|
|
|
116
118
|
`}});
|
package/bin/migrate.js
CHANGED
package/bin/repl.js
CHANGED
package/bin/serve.js
ADDED
package/bin/subscribe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module.exports = Object.assign(subscribe, {
|
|
2
|
-
init:
|
|
2
|
+
init: cmd => new (require('../lib/client/tenant_action'))(cmd),
|
|
3
3
|
options: ['--to', '--user'],
|
|
4
4
|
flags: ['--local'],
|
|
5
5
|
shortcuts: ['-2', '-u', '-l'],
|
|
@@ -23,8 +23,8 @@ module.exports = Object.assign(subscribe, {
|
|
|
23
23
|
*-u* | *--user* <name>[:[<password>]]
|
|
24
24
|
|
|
25
25
|
Username and optionally password for authentication with Basic Auth in test scenarios.
|
|
26
|
-
|
|
27
|
-
are
|
|
26
|
+
Only relevant if <url> is given. May be omitted in case of dummy authentication.
|
|
27
|
+
Tokens saved with *cds login* are not used for this command.
|
|
28
28
|
|
|
29
29
|
*-l* | *--local*
|
|
30
30
|
|
|
@@ -35,7 +35,7 @@ module.exports = Object.assign(subscribe, {
|
|
|
35
35
|
# SEE ALSO
|
|
36
36
|
|
|
37
37
|
*cds login* for more information on authentication options.
|
|
38
|
-
*cds login* to save project settings, simplifying multiple runs of this command.
|
|
38
|
+
*cds login* to save project settings and Basic-Auth data, simplifying multiple runs of this command.
|
|
39
39
|
|
|
40
40
|
`});
|
|
41
41
|
|
|
@@ -59,7 +59,7 @@ async function subscribe([tenant], options = {}) {
|
|
|
59
59
|
const [username, password] = options.user?.split(':') ?? [];
|
|
60
60
|
delete options.user;
|
|
61
61
|
|
|
62
|
-
await subscribe.init(
|
|
62
|
+
await subscribe.init('subscribe').run({
|
|
63
63
|
...options,
|
|
64
64
|
username,
|
|
65
65
|
password
|
package/bin/unsubscribe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module.exports = Object.assign(unsubscribe, {
|
|
2
|
-
init:
|
|
2
|
+
init: cmd => new (require('../lib/client/tenant_action'))(cmd),
|
|
3
3
|
options: ['--from', '--user'],
|
|
4
4
|
flags: ['--local'],
|
|
5
5
|
shortcuts: ['-f', '-u', '-l'],
|
|
@@ -23,8 +23,7 @@ module.exports = Object.assign(unsubscribe, {
|
|
|
23
23
|
*-u* | *--user* <name>[:[<password>]]
|
|
24
24
|
|
|
25
25
|
Username and optionally password for authentication with Basic Auth in test scenarios.
|
|
26
|
-
|
|
27
|
-
are unsuitable for this command.)
|
|
26
|
+
Only relevant if <url> is given. Tokens saved with *cds login* are not used for this command.
|
|
28
27
|
|
|
29
28
|
*-l* | *--local*
|
|
30
29
|
|
|
@@ -35,7 +34,7 @@ module.exports = Object.assign(unsubscribe, {
|
|
|
35
34
|
# SEE ALSO
|
|
36
35
|
|
|
37
36
|
*cds login* for more information on authentication options.
|
|
38
|
-
*cds login* to save project settings, simplifying multiple runs of this command.
|
|
37
|
+
*cds login* to save project settings and Basic-Auth data, simplifying multiple runs of this command.
|
|
39
38
|
|
|
40
39
|
`});
|
|
41
40
|
|
|
@@ -59,7 +58,7 @@ async function unsubscribe([tenant], options = {}) {
|
|
|
59
58
|
const [username, password] = options.user?.split(':') ?? [];
|
|
60
59
|
delete options.user;
|
|
61
60
|
|
|
62
|
-
await unsubscribe.init(
|
|
61
|
+
await unsubscribe.init('unsubscribe').run({
|
|
63
62
|
...options,
|
|
64
63
|
username,
|
|
65
64
|
password
|
package/bin/upgrade.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module.exports = Object.assign(upgrade, {
|
|
2
|
+
init: cmd => new (require('../lib/client/tenant_action'))(cmd),
|
|
3
|
+
options: ['--at', '--user'],
|
|
4
|
+
flags: ['--local'],
|
|
5
|
+
shortcuts: ['-a', '-u', '-l'],
|
|
6
|
+
help: `
|
|
7
|
+
# SYNOPSIS
|
|
8
|
+
|
|
9
|
+
*cds upgrade* <tenant>
|
|
10
|
+
|
|
11
|
+
Upgrade a tenant subscribed to a multitenant SaaS app to its latest base model.
|
|
12
|
+
|
|
13
|
+
Running *cds upgrade* with a URL is intended for non-productive use only, including against
|
|
14
|
+
SaaS apps running on localhost with mock authentication.
|
|
15
|
+
|
|
16
|
+
# OPTIONS
|
|
17
|
+
|
|
18
|
+
*-a* | *--at* <url>
|
|
19
|
+
|
|
20
|
+
Specify the URL of the SaaS app. Determined from the current user's active CDS or
|
|
21
|
+
Cloud Foundry login by default.
|
|
22
|
+
|
|
23
|
+
*-u* | *--user* <name>[:[<password>]]
|
|
24
|
+
|
|
25
|
+
Username and optionally password for authentication with Basic Auth in test scenarios.
|
|
26
|
+
Only relevant if <url> is given. May be omitted in case of dummy authentication.
|
|
27
|
+
Tokens saved with *cds login* are not used for this command.
|
|
28
|
+
|
|
29
|
+
*-l* | *--local*
|
|
30
|
+
|
|
31
|
+
Run a locally-installed @sap/cds-mtxs and connect to it instead of a URL. Ignore settings
|
|
32
|
+
saved with *cds login*.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# SEE ALSO
|
|
36
|
+
|
|
37
|
+
*cds login* for more information on authentication options.
|
|
38
|
+
*cds login* to save project settings and Basic-Auth data, simplifying multiple runs of this command.
|
|
39
|
+
|
|
40
|
+
`});
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
async function upgrade([tenant], options = {}) {
|
|
44
|
+
const { CliError } = require('../lib/client/helper/errors');
|
|
45
|
+
if (!tenant) {
|
|
46
|
+
throw new CliError('Tenant not given.', { command: 'upgrade' });
|
|
47
|
+
}
|
|
48
|
+
const libOptions = { tenant };
|
|
49
|
+
if (options.local) {
|
|
50
|
+
libOptions.local = true;
|
|
51
|
+
delete options.local;
|
|
52
|
+
if (options.user) {
|
|
53
|
+
throw new CliError('Username cannot be specified when running @sap/cds-mtxs locally.', { command: 'upgrade' });
|
|
54
|
+
}
|
|
55
|
+
if (options.at) {
|
|
56
|
+
throw new CliError('URL cannot be specified when running @sap/cds-mtxs locally.', { command: 'upgrade' });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const [username, password] = options.user?.split(':') ?? [];
|
|
60
|
+
delete options.user;
|
|
61
|
+
|
|
62
|
+
await upgrade.init('upgrade').run({
|
|
63
|
+
...options,
|
|
64
|
+
username,
|
|
65
|
+
password
|
|
66
|
+
}, libOptions);
|
|
67
|
+
}
|
package/bin/watch.js
CHANGED
|
@@ -39,11 +39,12 @@ module.exports = Object.assign ( watch, {
|
|
|
39
39
|
|
|
40
40
|
# SEE ALSO
|
|
41
41
|
|
|
42
|
-
*cds serve --help* for the different start options
|
|
42
|
+
*cds serve --help* for the different start options.
|
|
43
43
|
|
|
44
44
|
`})
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const cds = require('../lib/cds')
|
|
47
|
+
const DEBUG = cds.debug('cli|watch')
|
|
47
48
|
const {delimiter,dirname,relative,resolve,sep} = require ('path')
|
|
48
49
|
const fs = require ('fs')
|
|
49
50
|
|
|
@@ -109,7 +110,7 @@ async function watch ([cwd], {
|
|
|
109
110
|
}
|
|
110
111
|
log ()
|
|
111
112
|
log (`${t.bold}cds ${args.join(' ')}`)
|
|
112
|
-
log (process.pid, 'watching:', ext, '...')
|
|
113
|
+
DEBUG && log (process.pid, 'watching:', ext, '...')
|
|
113
114
|
if (includes) DEBUG && log (`also watching: ${includes.source}`)
|
|
114
115
|
if (liveReload) log (`live reload enabled for browsers`)
|
|
115
116
|
|
|
@@ -124,7 +125,7 @@ async function watch ([cwd], {
|
|
|
124
125
|
delay: parseInt(process.env.CDS_WATCH_DELAY) || 200,
|
|
125
126
|
options
|
|
126
127
|
}).on('restart', (files)=>{
|
|
127
|
-
log (`\n${t.bold} ___________________________\n
|
|
128
|
+
log (`\n${t.bold} ___________________________\n`)
|
|
128
129
|
if (liveReload) liveReload.markPending(files)
|
|
129
130
|
if (this.delayed) clearTimeout (this.delayed)
|
|
130
131
|
this.delayed = setTimeout(()=>{
|
|
@@ -209,7 +210,9 @@ if (!module.parent) (async()=>{ // launched by nodemon
|
|
|
209
210
|
case 'NO_SERVICES_FOUND': return _no_services_found(e)
|
|
210
211
|
case 'MODEL_NOT_FOUND': return _no_models_found(e)
|
|
211
212
|
case 'EADDRINUSE': return process.send(e) //> tell cds watch
|
|
212
|
-
default:
|
|
213
|
+
default: if (!e.messages) { // compiler messages have been written by cli already
|
|
214
|
+
console.error('\n❗️ ERROR on server start: ❗️\n\n', e)
|
|
215
|
+
}
|
|
213
216
|
}}
|
|
214
217
|
function _no_models_found(e) { console.log (`
|
|
215
218
|
No models found in ${cds.resolve(e.model||'*',false)}.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const bindingResolver = require('./bindingResolver')
|
|
2
2
|
const { logger } = require('./bindingUtil')
|
|
3
|
-
const
|
|
3
|
+
const cds = require('../cds')
|
|
4
|
+
const DEBUG = cds.debug('cli')
|
|
4
5
|
|
|
5
6
|
class BindingManager {
|
|
6
7
|
constructor(options = {}) {
|
|
@@ -85,4 +86,4 @@ class BindingManager {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
module.exports = BindingManager
|
|
89
|
+
module.exports = BindingManager
|
|
@@ -3,7 +3,8 @@ const fsp = require('fs').promises;
|
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const util = require('util');
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const cds = require('../cds');
|
|
7
|
+
const DEBUG = cds.debug('cli')
|
|
7
8
|
|
|
8
9
|
const axios = require('axios');
|
|
9
10
|
const { URL } = require('url');
|
|
@@ -16,7 +17,7 @@ const IS_WIN = os.platform() === 'win32';
|
|
|
16
17
|
|
|
17
18
|
class CFKeyProvider {
|
|
18
19
|
async _cfRead(...args) {
|
|
19
|
-
DEBUG
|
|
20
|
+
DEBUG?.(`_cfRead: cf ${args}`);
|
|
20
21
|
|
|
21
22
|
const result = await execAsync(`cf ${args}`, {
|
|
22
23
|
shell: IS_WIN,
|
|
@@ -47,7 +48,7 @@ class CFKeyProvider {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
} catch (err) {
|
|
50
|
-
DEBUG
|
|
51
|
+
DEBUG?.(`getCfTargetFromConfigFile: ${err}`);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -66,7 +67,7 @@ class CFKeyProvider {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
async getCfSpaceInfo() {
|
|
69
|
-
DEBUG
|
|
70
|
+
DEBUG?.('getting space info');
|
|
70
71
|
|
|
71
72
|
const target = await this.getCfTarget();
|
|
72
73
|
const authorization = await this.getCfAuthorization();
|
|
@@ -91,7 +92,7 @@ class CFKeyProvider {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
async getCfAuthorization() {
|
|
94
|
-
DEBUG
|
|
95
|
+
DEBUG?.('getting authorization');
|
|
95
96
|
return this._cfRead('oauth-token');
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -297,7 +298,7 @@ class BatchRequest {
|
|
|
297
298
|
|
|
298
299
|
static async req(target, urlPath) {
|
|
299
300
|
const url = new URL(urlPath, target.apiEndpoint);
|
|
300
|
-
DEBUG
|
|
301
|
+
DEBUG?.(`_req: ${url.toString()}`);
|
|
301
302
|
|
|
302
303
|
const result = await axios.get(url.toString(), {
|
|
303
304
|
headers: {
|
|
@@ -2,11 +2,12 @@ const os = require('os');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const readline = require('readline');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const cds = require('../cds');
|
|
6
|
+
const DEBUG = cds.debug('cli');
|
|
6
7
|
|
|
7
8
|
const fs = require('fs').promises;
|
|
8
9
|
const { highlight } = require('../util/term');
|
|
9
|
-
const { logger } = require('./bindingUtil')
|
|
10
|
+
const { logger } = require('./bindingUtil');
|
|
10
11
|
|
|
11
12
|
const commandUtil = require('../init/util/commandUtil');
|
|
12
13
|
|
|
@@ -39,12 +40,12 @@ class UserCdsrcJsonStorageProvider {
|
|
|
39
40
|
return; // file is git ignored
|
|
40
41
|
} catch (err) {
|
|
41
42
|
if (err.code === 'ENOENT') { // git command not found
|
|
42
|
-
DEBUG
|
|
43
|
+
DEBUG?.('git command not found');
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
if (!err.stdLog.match(/::/)) { // included or not a git repo
|
|
47
|
-
DEBUG
|
|
48
|
+
DEBUG?.(err);
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
}
|
package/lib/cds.js
CHANGED
|
@@ -7,6 +7,18 @@ const cds = module.exports = _local ('@sap/cds')
|
|
|
7
7
|
cds._log = _local ('@sap/cds/bin/utils/log')
|
|
8
8
|
cds._local = _local
|
|
9
9
|
|
|
10
|
+
if (/^(4\.[56]|5|6\.[01])\b/.test(cds.version)) {
|
|
11
|
+
// cds.debug may return false as of @sap/cds@(>=4.5 && < 6.2).
|
|
12
|
+
// Patch this to be able to call `cds.debug(label)?.(message)`.
|
|
13
|
+
// REVISIT remove once we no longer support these versions
|
|
14
|
+
Object.defineProperty(cds, 'debug', {
|
|
15
|
+
value: function cds_debug_patched (module, options) {
|
|
16
|
+
const L = cds.log (module, options)
|
|
17
|
+
if (L._debug) return L.debug
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
function _resolve (id) {
|
|
11
23
|
return require.resolve (id, {paths:[
|
|
12
24
|
process.cwd(), // project-local module is preferred
|
package/lib/client/activate.js
CHANGED
|
@@ -2,7 +2,8 @@ const fs = require('fs').promises;
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const axios = require('axios');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const cds = require('../cds');
|
|
6
|
+
const DEBUG = cds.debug('cli');
|
|
6
7
|
const { collectFileContent, collectFiles, toUnixPath } = require('./helper/fs_helper');
|
|
7
8
|
const { CliError } = require('./helper/errors');
|
|
8
9
|
|
|
@@ -102,7 +103,7 @@ module.exports = class Activate extends BaseCommand {
|
|
|
102
103
|
if (! entry.startsWith(projectFolder)) {
|
|
103
104
|
/* Current file might be below the base model's node_modules, in which case compilation on server should succeed.
|
|
104
105
|
Otherwise, compilation will probably fail, with this message giving a hint. */
|
|
105
|
-
|
|
106
|
+
DEBUG?.(`Source file outside project folder will not be uploaded: ${entry}`);
|
|
106
107
|
return false;
|
|
107
108
|
}
|
|
108
109
|
const unixFilename = toUnixPath(entry);
|
|
@@ -188,7 +189,7 @@ module.exports = class Activate extends BaseCommand {
|
|
|
188
189
|
throw new CliError(`Job ${jobId} failed: did not receive job-status path`);
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
DEBUG?.(`Job ID: ${jobId}`);
|
|
192
193
|
|
|
193
194
|
return new Promise((resolve, reject) => {
|
|
194
195
|
const statusUrl = this.concatUrls(params.get('appUrl'), statusPath);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const cds = require('../cds');
|
|
4
|
+
const DEBUG = cds.debug('cli');
|
|
4
5
|
const { SettingsManager } = require('./settings_manager');
|
|
5
6
|
const { ParamCollection } = require('./params');
|
|
6
7
|
const { CliError } = require('./helper/errors');
|
|
@@ -39,7 +40,7 @@ function getTokenUrl(params) {
|
|
|
39
40
|
async function retrieveTokenOrPasscodeUrl(params) {
|
|
40
41
|
if (params.has('token')) {
|
|
41
42
|
if (params.get('renewLogin') || params.get('tokenExpirationDate') <= Date.now()) {
|
|
42
|
-
|
|
43
|
+
DEBUG?.((params.get('renewLogin') ? 'Renewing' : 'Refreshing expired') + ' authentication token');
|
|
43
44
|
params.delete('token');
|
|
44
45
|
params.delete('tokenExpirationDate');
|
|
45
46
|
} else {
|
|
@@ -54,7 +55,7 @@ async function retrieveTokenOrPasscodeUrl(params) {
|
|
|
54
55
|
let authData;
|
|
55
56
|
do {
|
|
56
57
|
const tokenUrl = getTokenUrl(params);
|
|
57
|
-
|
|
58
|
+
DEBUG?.(`Getting authentication token or passcode URL from ${(params.obfuscateQueryParams(tokenUrl))}`);
|
|
58
59
|
|
|
59
60
|
let response;
|
|
60
61
|
try {
|
|
@@ -20,9 +20,9 @@ module.exports = class BaseCommand {
|
|
|
20
20
|
const prefix = `Request to ${url} failed`;
|
|
21
21
|
switch (error.response?.status) {
|
|
22
22
|
case 401:
|
|
23
|
-
throw new CliError(`${prefix}: invalid authentication
|
|
23
|
+
throw new CliError(`${prefix}: invalid authentication.\nRetry with valid passcode${
|
|
24
24
|
params.has('passcodeUrl') ? ` from ${params.get('passcodeUrl')}` : ''
|
|
25
|
-
}.`, { error, command });
|
|
25
|
+
} or username/password (required if SaaS app is configured with mocked-auth).`, { error, command });
|
|
26
26
|
case 403:
|
|
27
27
|
throw new CliError(prefix + ': insufficient authorization. Ensure client has all necessary roles.', { error, command });
|
|
28
28
|
case 404:
|
|
@@ -32,6 +32,11 @@ module.exports = class BaseCommand {
|
|
|
32
32
|
throw new CliError(prefix + '.', { error, command });
|
|
33
33
|
default:
|
|
34
34
|
// Unexpected error should be transparent to user.
|
|
35
|
+
if (!require('..').debug('axios')) {
|
|
36
|
+
error.config?.auth && (error.config.auth = '...'); // TODO use &&= with Node > 14
|
|
37
|
+
delete error.request;
|
|
38
|
+
delete error.response;
|
|
39
|
+
}
|
|
35
40
|
throw error;
|
|
36
41
|
}
|
|
37
42
|
}
|