@sap/cds-dk 4.9.5 → 6.0.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 +73 -0
- package/bin/activate.js +4 -4
- package/bin/add.js +11 -5
- package/bin/bind.js +16 -28
- package/bin/build/all.js +2 -2
- package/bin/build/index.js +12 -19
- package/bin/cds.js +16 -17
- package/bin/compile/index.js +12 -3
- package/bin/deploy/index.js +14 -14
- package/bin/deploy/to-hana.js +4 -4
- package/bin/deploy/to-sqlite.js +1 -1
- package/bin/env.js +13 -4
- package/bin/eval.js +1 -1
- package/bin/fix-redirects.js +1 -1
- package/bin/import.js +44 -179
- package/bin/repl.js +1 -1
- package/bin/watch.js +10 -15
- package/lib/bind/BindingManager.js +87 -0
- package/lib/bind/bindingResolver.js +14 -85
- package/lib/bind/bindingUtil.js +18 -11
- package/lib/bind/cfKeyProvider.js +58 -29
- package/lib/bind/kubernetesCredentialsProvider.js +44 -21
- package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
- package/lib/cds.js +13 -0
- package/lib/client/base_command.js +3 -2
- package/lib/client/extend.js +6 -7
- package/lib/client/helper/fs_helper.js +7 -8
- package/lib/client/helper/string_helper.js +6 -1
- package/lib/client/settings_manager.js +38 -45
- package/lib/compile/index.js +9 -10
- package/lib/compile/openapi/csdl2openapi.js +151 -43
- package/lib/compile/openapi/index.js +2 -2
- package/lib/compile/to-xsuaa.js +3 -2
- package/lib/import/common.js +342 -27
- package/lib/import/importapi.js +81 -13
- package/lib/import/message.js +4 -4
- package/lib/import/odata/index.js +141 -0
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverter.js +2 -2
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverterFactory.js +1 -1
- package/lib/import/{utils → odata/util}/MultiMap.js +0 -0
- package/lib/import/{v2parser.js → odata/v2parser.js} +405 -468
- package/lib/import/{v4parser.js → odata/v4parser.js} +311 -322
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Aggregation.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Authorization.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Capabilities.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Core.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Measures.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Validation.V1.json +0 -0
- package/lib/import/openapi/importOpenAPI.js +521 -0
- package/lib/import/openapi/index.js +19 -0
- package/lib/import/openapi/utilities.js +38 -0
- package/lib/index.js +1 -1
- package/lib/init/constants.js +7 -2
- package/lib/init/index.js +10 -3
- package/lib/init/template/_merging/existences.js +79 -19
- package/lib/init/template/approuter/files/mta.yaml.hbs +25 -11
- package/lib/init/template/approuter/files/package.json +1 -1
- package/lib/init/template/approuter/files/xs-app.json.hbs +7 -0
- package/lib/init/template/approuter/index.js +61 -54
- package/lib/init/template/auditlog/index.js +2 -2
- package/lib/init/template/data/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +17 -17
- package/lib/init/template/hana/index.js +8 -4
- package/lib/init/template/helm/index.js +39 -0
- package/lib/init/template/helm/update/index.js +28 -0
- package/lib/init/template/java/index.js +7 -9
- package/lib/init/template/kibana-logging/index.js +5 -6
- package/lib/init/template/mta/index.js +4 -4
- package/lib/init/template/mtx/files/java/package.json +9 -9
- package/lib/init/template/mtx/files/mta.yaml.hbs +0 -7
- package/lib/init/template/mtx/files/xs-security.json.hbs +11 -20
- package/lib/init/template/mtx/index.js +50 -57
- package/lib/init/template/nodejs/files/package.json.hbs +2 -2
- package/lib/init/template/notebook/index.js +2 -0
- package/lib/init/template/templateBase.js +6 -4
- package/lib/init/template/xsuaa/index.js +9 -5
- package/lib/init/util/fsUtil.js +25 -10
- package/lib/init/util/logger.js +1 -1
- package/lib/init/util/mvnArchetypeUtil.js +4 -10
- package/lib/init/util/projectReader.js +16 -8
- package/lib/init/util/templateUtil.js +30 -34
- package/lib/k8s/ChartAdder.js +65 -0
- package/lib/k8s/ChartBuilder.js +186 -0
- package/lib/k8s/Context.js +71 -0
- package/lib/k8s/ImageUtil.js +21 -0
- package/lib/k8s/Model.d.ts +53 -0
- package/lib/k8s/auditlog/index.js +29 -0
- package/lib/k8s/auditlog/templates/auditlog.yaml +1 -0
- package/lib/k8s/buildModel.js +70 -0
- package/lib/k8s/connectivity/index.js +74 -0
- package/lib/k8s/connectivity/templates/connectivity-binding.yaml +9 -0
- package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +16 -0
- package/lib/k8s/connectivity/templates/connectivity.yaml +1 -0
- package/lib/k8s/deployment/index.js +81 -0
- package/lib/k8s/deployment/subchart/Chart.yaml +6 -0
- package/lib/k8s/deployment/subchart/templates/_helpers.tpl +156 -0
- package/lib/k8s/deployment/subchart/templates/api-rule.yaml +24 -0
- package/lib/k8s/deployment/subchart/templates/deployment.yaml +110 -0
- package/lib/k8s/deployment/subchart/templates/network-policy.yaml +16 -0
- package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +11 -0
- package/lib/k8s/deployment/subchart/templates/secret.yaml +10 -0
- package/lib/k8s/deployment/subchart/templates/service-binding.yaml +27 -0
- package/lib/k8s/deployment/subchart/templates/service.yaml +11 -0
- package/lib/k8s/deployment/subchart/values-lint.yaml +8 -0
- package/lib/k8s/deployment/subchart/values.schema.json +449 -0
- package/lib/k8s/deployment/subchart/values.yaml +76 -0
- package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +81 -0
- package/lib/k8s/destinations/index.js +40 -0
- package/lib/k8s/destinations/lib.js +16 -0
- package/lib/k8s/destinations/templates/destinations.yaml +1 -0
- package/lib/k8s/docker/push.js +8 -0
- package/lib/k8s/event-mesh/index.js +53 -0
- package/lib/k8s/event-mesh/lib.js +9 -0
- package/lib/k8s/event-mesh/templates/event-mesh.yaml +1 -0
- package/lib/k8s/hana-deployer/index.js +38 -0
- package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +41 -0
- package/lib/k8s/helm/Release.js +80 -0
- package/lib/k8s/html5-apps-deployer/index.js +43 -0
- package/lib/k8s/html5-apps-deployer/templates/_html5_deployment_helpers.tpl +16 -0
- package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +53 -0
- package/lib/k8s/html5-apps-repo-host/index.js +26 -0
- package/lib/k8s/html5-apps-repo-host/lib.js +16 -0
- package/lib/k8s/html5-apps-repo-host/templates/html5-apps-repo-host.yaml +1 -0
- package/lib/k8s/index.js +153 -0
- package/lib/k8s/modules.js +36 -0
- package/lib/k8s/multitenancy/index.js +24 -0
- package/lib/k8s/multitenancy/lib.js +25 -0
- package/lib/k8s/multitenancy/templates/saas-registry.yaml +19 -0
- package/lib/k8s/readProject.js +14 -0
- package/lib/k8s/resources/helm/chart/templates/NOTES.txt +11 -0
- package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +221 -0
- package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +167 -0
- package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +103 -0
- package/lib/k8s/util.js +186 -0
- package/lib/k8s/wrapFeature.js +55 -0
- package/lib/k8s/xsuaa/index.js +64 -0
- package/lib/k8s/xsuaa/lib.js +14 -0
- package/lib/k8s/xsuaa/templates/xsuaa.yaml +1 -0
- package/lib/util/exec.js +1 -1
- package/lib/util/write.js +1 -1
- package/lib/watch/node-watch.js +43 -14
- package/npm-shrinkwrap.json +1272 -2792
- package/package.json +5 -5
- package/lib/import/index.js +0 -235
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,79 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
8
8
|
|
|
9
|
+
## Version 6.0.1 - 2022-07-05
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Deprecated the `--for <filterPattern>` parameter of `cds add data` in favor of the new `--data:for`. The former is still supported, but will eventually be removed, as it collides with the general `--for <profile>` parameter of `cds add`.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `cds bind` api endpoint regex for cli now ignores trailing version info in url
|
|
18
|
+
|
|
19
|
+
## Version 6.0.0 - 2022-07-01
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `cds import` now supports importing external openapi specification file into CSN.
|
|
24
|
+
- `cds import` now supports the `--from` option to specify the protocol for importing an external file.
|
|
25
|
+
- `cds import` can be programmatically accessed using APIs `cds.import()`, `cds.import.from.edmx()` and `cds.import.from.openapi()`.
|
|
26
|
+
- `cds compile --to openapi` allows describing custom headers and custom query options.
|
|
27
|
+
- `cds import` now supports `HasStream="true"` for both OData V4 and V2.
|
|
28
|
+
- `cds compile --to openapi` now adds properties with `@mandatory` to the required field.
|
|
29
|
+
- Added a link to VS Code CAP Notebooks documentation to `cds init --add notebooks` and `cds add notebooks`.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- `cds import` now uses `@odata.Type` and `@odata.Precision` for edm to cds type mapping.
|
|
34
|
+
- `cds compile --to openapi` now has better description for `$expand` query option.
|
|
35
|
+
- The original package `sqlite3` is now used again in its latest version.
|
|
36
|
+
- `cds import` now deprecated `cds.DecimalFloat` type.
|
|
37
|
+
- `cds import` now allows OData version 4.01 edmx files and supports `Scale="floating"`.
|
|
38
|
+
- `cds import` now adds `@odata.Type` annotation for `Edm.Byte` and `Edm.SByte`.
|
|
39
|
+
- `cds import` now has improved tests to check `--as`option with `force` flag file overwriting.
|
|
40
|
+
- `cds init` uses latest Maven Java archetype version 1.25.0 for creating Java projects.
|
|
41
|
+
- `cds import` now imports edmx file without any entities containing only unbounded action/function.
|
|
42
|
+
- `cds import` API now supports includeNamespaces option.
|
|
43
|
+
- `cds compile --to openapi` now adds `format`, `multipleOf`, `maximum` and `minimum` to anyOf.
|
|
44
|
+
- `cds import` will now mark an association as a composition when `OnDelete Action="Cascade"` is present.
|
|
45
|
+
- `cds import` has deprecated `--into` option.
|
|
46
|
+
- `cds bind` reads Cloud Foundry file `config.json` to get org and space information.
|
|
47
|
+
- `cds deploy` now stores connection information without credentials by default in `.cdsrc-private.json`.
|
|
48
|
+
- `cds deploy` has a new option `--store-credentials` to enforce the former behavior of storing credentials in `default-env.json`.
|
|
49
|
+
- If a `@sap/cds` is installed locally in a project, it must be version 4 or higher for CLI commands to run.
|
|
50
|
+
- `cds import` now doesn't trim the bound action/function name in the csn if the format of the name is A_B.
|
|
51
|
+
- `@sap/cds` version 6 is now required in new projects added by `cds init` and `cds add`.
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- `cds compile --to openapi` fixes annotations on bound action overloads.
|
|
56
|
+
- `cds add cf-manifest` now uses the correct `application` plan for the `xsuaa` service
|
|
57
|
+
- A combination of `cds add approuter`, `cds add mtx`, and `cds add mta` will now use a safer approach to determine the subscription URL.
|
|
58
|
+
- `cds init` and `cds add` output the feature names correctly in case the names contain a dash
|
|
59
|
+
- `cds compile --to openapi` fix for type error when entity/action is not specified in the service definition.
|
|
60
|
+
- `cds import` API fix for race condition issue.
|
|
61
|
+
- `cds somecdsfile --profile ...` (without the `compile` command) no longer ignores the given profile
|
|
62
|
+
- `cds watch` got more robust against unlucky timing and no longer runs into port conflicts
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## Version 4.9.7 - 2022-06-08
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
|
|
69
|
+
- Update `@sap/xsenv` to 3.3.1
|
|
70
|
+
|
|
71
|
+
## Version 4.9.6 - 2022-06-08
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
|
|
75
|
+
- Include `@sap/cds` 5.9.6
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- `cds login` (and `cds extend`, `cds activate` if previously logged in) now properly renew token URL
|
|
80
|
+
- Improved logging during those commands
|
|
81
|
+
|
|
9
82
|
## Version 4.9.5 - 2022-05-17
|
|
10
83
|
|
|
11
84
|
### Changed
|
package/bin/activate.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = Object.assign(activate, {
|
|
|
9
9
|
|
|
10
10
|
Activate an extension project.
|
|
11
11
|
By default, the current working directory is used as project directory.
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
To facilitate running this multiple times against the same app, refer to the *cds login* command.
|
|
14
14
|
|
|
15
15
|
|
|
@@ -25,14 +25,14 @@ module.exports = Object.assign(activate, {
|
|
|
25
25
|
|
|
26
26
|
*-p* | *--passcode* <passcode>
|
|
27
27
|
|
|
28
|
-
Tenant-specific passcode for authentication.
|
|
28
|
+
Tenant-specific passcode for authentication.
|
|
29
29
|
Also see cds login --help or https://cap.cloud.sap/docs/guides/extensibility/#save-an-authentication-token-for-a-simplified-workflow
|
|
30
30
|
|
|
31
31
|
*-u* | *--username* <name>
|
|
32
32
|
|
|
33
33
|
Deprecated. Use the passcode parameter.
|
|
34
34
|
|
|
35
|
-
*-c* | *--clientid* <clientid>
|
|
35
|
+
*-c* | *--clientid* <clientid>
|
|
36
36
|
|
|
37
37
|
Client ID for authentication. This will override the default Client ID from environment.
|
|
38
38
|
|
|
@@ -49,7 +49,7 @@ module.exports = Object.assign(activate, {
|
|
|
49
49
|
|
|
50
50
|
async function activate ([projectFolder], options = {}) {
|
|
51
51
|
const injection = {
|
|
52
|
-
cds: require('
|
|
52
|
+
cds: require('../lib/cds')
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
Object.assign(options, { projectFolder })
|
package/bin/add.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
module.exports = Object.assign(add, {
|
|
3
|
-
options: ['--for', '--out'],
|
|
3
|
+
options: ['--for', '--out', '--data:for'],
|
|
4
4
|
shortcuts: ['-4', '-o'],
|
|
5
5
|
flags: ['--force', '--verbose'],
|
|
6
6
|
help: `
|
|
@@ -15,7 +15,13 @@ module.exports = Object.assign(add, {
|
|
|
15
15
|
|
|
16
16
|
*hana* - adds configuration for SAP HANA deployment
|
|
17
17
|
|
|
18
|
-
*
|
|
18
|
+
*xsuaa* - adds configuration for authentication via XSUAA
|
|
19
|
+
|
|
20
|
+
*mtx* - adds configuration for multitenancy and extensibility
|
|
21
|
+
|
|
22
|
+
*approuter* - adds configuration for the Cloud Foundry approuter
|
|
23
|
+
|
|
24
|
+
*mta* - adds an _mta.yaml_ file for MTA-based SAP Business Technology Platform deployment
|
|
19
25
|
|
|
20
26
|
*cf-manifest* - adds _manifest.yml_ and _services-manifest.yml_ files for Cloud Foundry native deployment
|
|
21
27
|
|
|
@@ -34,9 +40,9 @@ module.exports = Object.assign(add, {
|
|
|
34
40
|
|
|
35
41
|
# OPTIONS
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
*--data:for* <entity name or prefix>
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
Adds data content for entities matching the given pattern. If it contains meta characters like
|
|
40
46
|
'^' or '*', it is treated like a regular expression, otherwise as a prefix.
|
|
41
47
|
|
|
42
48
|
*-o* | *--out* <target folder>
|
|
@@ -51,7 +57,7 @@ module.exports = Object.assign(add, {
|
|
|
51
57
|
# EXAMPLES
|
|
52
58
|
|
|
53
59
|
*cds add* hana,mta,pipeline
|
|
54
|
-
*cds add*
|
|
60
|
+
*cds add* mtx --for production
|
|
55
61
|
*cds add* cf-manifest
|
|
56
62
|
*cds add* data --for my.namspace.MyEntity
|
|
57
63
|
|
package/bin/bind.js
CHANGED
|
@@ -46,31 +46,28 @@ module.exports = Object.assign(cds_bind, {
|
|
|
46
46
|
`
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
const cds = require('
|
|
49
|
+
const cds = require('../lib/cds');
|
|
50
50
|
const LOG = cds.log('bind');
|
|
51
51
|
// required for spinner
|
|
52
52
|
LOG.isDebug = LOG._debug;
|
|
53
53
|
LOG.isTTY = process.stdout.isTTY;
|
|
54
|
+
const resolveBinding = require('../lib/bind/bindingResolver').resolver(LOG);
|
|
54
55
|
|
|
55
56
|
const { highlight, bold, info } = require('../lib/util/term');
|
|
56
57
|
|
|
57
58
|
const Spinner = require('../lib/init/util/spinner');
|
|
58
|
-
const resolveBinding = require('../lib/bind/bindingResolver').resolver(LOG);
|
|
59
59
|
const { determineKinds, getRequiresNameFromKind, execAndExit, checkIsJavaProject, throwError, platformText, bindingText } = require('../lib/bind/bindingUtil');
|
|
60
60
|
|
|
61
|
-
const VCAP_LABEL_PLACEHOLDER = '<replace with service label>';
|
|
62
|
-
|
|
63
61
|
async function cds_bind(args, options, logger = LOG) {
|
|
62
|
+
|
|
64
63
|
options.profile = parseProfile(options.profile);
|
|
65
64
|
setProfile(options.profile);
|
|
66
65
|
|
|
67
66
|
if (options.exec) {
|
|
68
|
-
cds_bind_exec(args, options)
|
|
67
|
+
await cds_bind_exec(args, options)
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
const env = cds.env.for('cds', process.cwd());
|
|
73
|
-
|
|
74
71
|
if (!options.to) {
|
|
75
72
|
throw new Error(`use option --to or -2 to specify the target instance, e.g. cds bind --to myInstance:myService`);
|
|
76
73
|
}
|
|
@@ -138,25 +135,16 @@ async function cds_bind(args, options, logger = LOG) {
|
|
|
138
135
|
resolvedService.name = getRequiresNameFromKind(resolvedService.binding.instance, resolvedService.kind);
|
|
139
136
|
}
|
|
140
137
|
|
|
141
|
-
if (!resolvedService.name) {
|
|
142
|
-
if (isJavaProject) {
|
|
143
|
-
const { binding } = resolvedService;
|
|
144
|
-
// Generate a custom service entry for Java projects w/o the need to specify a name manually
|
|
145
|
-
resolvedService.name = `custom-service:${binding.instance || binding.secret}`
|
|
146
|
-
} else {
|
|
147
|
-
throw new Error(`Unknown CDS service name for service "${resolvedService._target}". Please specify as argument for "cds bind".`)
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
138
|
const { kind, name, binding } = resolvedService;
|
|
152
139
|
const kindText = kind && `with kind ${highlight(kind)}`;
|
|
153
|
-
const nameText = !isJavaProject && highlight(name);
|
|
140
|
+
const nameText = !isJavaProject && name && highlight(name);
|
|
154
141
|
|
|
155
142
|
logger.log(['Binding', nameText, 'to', platformText(binding), bindingText(binding, highlight), kindText].filter(t => t).join(' '));
|
|
156
143
|
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
if (!resolvedService.name) {
|
|
145
|
+
const { binding } = resolvedService;
|
|
146
|
+
// Generate a custom service entry for Java projects w/o the need to specify a name manually
|
|
147
|
+
resolvedService.name = `custom-service:${binding.instance || binding.secret}`
|
|
160
148
|
}
|
|
161
149
|
}
|
|
162
150
|
|
|
@@ -173,15 +161,15 @@ async function cds_bind(args, options, logger = LOG) {
|
|
|
173
161
|
}
|
|
174
162
|
|
|
175
163
|
async function cds_bind_exec(command) { // eslint-disable-lint
|
|
176
|
-
const cds = require('
|
|
164
|
+
const cds = require('../lib/cds');
|
|
177
165
|
const env = cds.env.for('cds', process.cwd());
|
|
178
|
-
env._emulate_vcap_services();
|
|
179
|
-
await require('../lib/bind/bindingResolver').applyTo({ env, output: 'info' });
|
|
180
|
-
execAndExit(...command);
|
|
181
|
-
}
|
|
182
166
|
|
|
183
|
-
|
|
184
|
-
|
|
167
|
+
const BindingManager = require('../lib/bind/BindingManager')
|
|
168
|
+
const bindingManager = new BindingManager({ env, output: 'info' })
|
|
169
|
+
const bindingEnv = await bindingManager.bindingEnv()
|
|
170
|
+
const processEnv = Object.assign(process.env, bindingEnv)
|
|
171
|
+
|
|
172
|
+
execAndExit({ env: processEnv }, ...command);
|
|
185
173
|
}
|
|
186
174
|
|
|
187
175
|
function runCmd({ profile }, isJavaProject) {
|
package/bin/build/all.js
CHANGED
|
@@ -48,7 +48,7 @@ module.exports = Object.assign(build, {
|
|
|
48
48
|
`
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
function build([project], options = {}
|
|
51
|
+
function build([project], options = {}) {
|
|
52
52
|
options.project = options.project || project
|
|
53
53
|
// switch-off error logging as CLI is logging any exceptions by default
|
|
54
54
|
// otherwise errors are logged twice
|
|
@@ -66,7 +66,7 @@ function build([project], options = {}, /* for unit tests only: */ _env = null)
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
|
-
return require('
|
|
69
|
+
return require('../../lib/cds').build(options)
|
|
70
70
|
} catch (error) {
|
|
71
71
|
return Promise.reject(error.message)
|
|
72
72
|
}
|
package/bin/build/index.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = Object.assign(build, {
|
|
|
4
4
|
help: `
|
|
5
5
|
# SYNOPSIS
|
|
6
6
|
|
|
7
|
-
*cds build* [<options>]
|
|
7
|
+
*cds build* [<project>] [<options>]
|
|
8
8
|
|
|
9
9
|
Builds all modules in the current project by compiling contained CDS sources.
|
|
10
10
|
The modules are folders in the project root directory. All well known modules (db, srv, app)
|
|
@@ -12,28 +12,22 @@ module.exports = Object.assign(build, {
|
|
|
12
12
|
|
|
13
13
|
# OPTIONS
|
|
14
14
|
|
|
15
|
-
*-4
|
|
15
|
+
*-4 | --for* hana | java | nodejs | mtx
|
|
16
16
|
|
|
17
17
|
Name of the build task that is applied to the source folder, either explicitly configured in
|
|
18
18
|
the build task list or generated out of the project setup
|
|
19
19
|
For example, the "hana" build task will create SAP HANA artefacts.
|
|
20
20
|
The module folder can be defined using option "--src", a default is used otherwise.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
*-s | --src* <folder>
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
For example, "@sap/cds/build/hana" represents the fully qualified name of the "hana" build task.
|
|
26
|
-
The module folder can be defined using option "--src", a default is used otherwise.
|
|
27
|
-
|
|
28
|
-
*-s* | *--src* <folder>
|
|
29
|
-
|
|
30
|
-
The module folder to build using the build task defined by option "--for" or "--use".
|
|
24
|
+
The module folder to build using the build task defined by option "--for".
|
|
31
25
|
This option is only supported when building an individual module of the project.
|
|
32
26
|
The folder is resolved based on "<project>/<cds.env.build.target>".
|
|
33
27
|
A default is used based on the type of the build task, for example, the folder "db" is used for a
|
|
34
|
-
"hana" build task, "srv" for "
|
|
28
|
+
"hana" build task, "srv" for "nodejs" or "java" build task.
|
|
35
29
|
|
|
36
|
-
*-o
|
|
30
|
+
*-o | --dest* <folder>
|
|
37
31
|
|
|
38
32
|
Output folder of the build task. The type of build task is defined by option "--for".
|
|
39
33
|
The folder is resolved based on "<project>/<cds.env.build.target>".
|
|
@@ -56,12 +50,11 @@ module.exports = Object.assign(build, {
|
|
|
56
50
|
Builds the project using the "production" profile - same when NODE_ENV environment variable is set to "production".
|
|
57
51
|
E.g. HANA deployment artefacts will be created if "sql" has been set as database kind in cds configuration.
|
|
58
52
|
|
|
59
|
-
*-in
|
|
53
|
+
*-in | --project* [<project>]
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
Default - current working directory.
|
|
55
|
+
Runs _cds build_ for the specified project, default is current working directory.
|
|
63
56
|
|
|
64
|
-
*-c
|
|
57
|
+
*-c | --clean* deprecated
|
|
65
58
|
|
|
66
59
|
Incremental builds are not supported.
|
|
67
60
|
Build output folders are always cleaned before build.
|
|
@@ -73,17 +66,17 @@ module.exports = Object.assign(build, {
|
|
|
73
66
|
*cds* build --production
|
|
74
67
|
*cds* build --log-level info
|
|
75
68
|
*cds* build --for hana
|
|
76
|
-
*cds* build --for java
|
|
69
|
+
*cds* build --for java --dest ../srv/target --opts model=[db/model,srv,schema]
|
|
77
70
|
`})
|
|
78
71
|
|
|
79
72
|
/**
|
|
80
73
|
* Redirect to modular build system.
|
|
81
74
|
*/
|
|
82
|
-
function build(project, options = {}
|
|
75
|
+
function build(project, options = {}) {
|
|
83
76
|
if (options.dry) {
|
|
84
77
|
// eslint-disable-next-line no-console
|
|
85
78
|
console.warn("[cds] - CLI option 'dry' is no longer supported.\n")
|
|
86
79
|
delete options.dry
|
|
87
80
|
}
|
|
88
|
-
return require('./all')(project, options
|
|
81
|
+
return require('./all')(project, options)
|
|
89
82
|
}
|
package/bin/cds.js
CHANGED
|
@@ -34,9 +34,9 @@ const cli = { //NOSONAR
|
|
|
34
34
|
if (cmd in this.Shortcuts) cmd = process.argv[2] = this.Shortcuts[cmd]
|
|
35
35
|
if (argv.some(a => this.Shortcuts[a]==='help')) return this.help (cmd)
|
|
36
36
|
|
|
37
|
-
const cds_cli = require (_local('@sap/cds/bin/cds'))
|
|
38
|
-
DEBUG && DEBUG (`[cds] - @sap/cds ${global.cds.version} loaded: ${global.cds.home}`)
|
|
37
|
+
const cds_cli = require (_local('@sap/cds/bin/cds'))
|
|
39
38
|
if (cmd !== 'repl' && process.env.NODE_ENV !== 'test') cds_cli.errorHandlers()
|
|
39
|
+
DEBUG && DEBUG (`[cds] - @sap/cds ${require('../lib/cds').version} loaded: ${require('../lib/cds').home}`)
|
|
40
40
|
|
|
41
41
|
const task = this.load (cmd, /*else*/ (f)=> argv.unshift(cmd) && _defaultCompile (argv,f))
|
|
42
42
|
if (task) {
|
|
@@ -73,11 +73,18 @@ function _local (id) {
|
|
|
73
73
|
|
|
74
74
|
function _defaultCompile (argv, _force) {
|
|
75
75
|
// Try all arguments if one resolves to a model. If yes, we assume 'compile' is intended.
|
|
76
|
-
const model = _force ||
|
|
76
|
+
const model = _force || _is_model(argv)
|
|
77
77
|
if (model) return _require ('./compile')
|
|
78
78
|
DEBUG && DEBUG (`[cds] - Command is not a model to compile: ${argv}`)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
function _is_model (argv) {
|
|
82
|
+
// IMPORTANT: have a separate env here, so that the normal one is not initialized before `cds_cli.args` above
|
|
83
|
+
const env = require (_local('@sap/cds/lib/env')).for('cds')
|
|
84
|
+
const cds = require (_local('@sap/cds'))
|
|
85
|
+
return !!cds.resolve(argv,{env,cache:{}})
|
|
86
|
+
}
|
|
87
|
+
|
|
81
88
|
function _dieForUnknownCommand(cmd) {
|
|
82
89
|
const term = require('../lib/util/term');
|
|
83
90
|
const fuzzySearch = _require('./util/fuzzySearch');
|
|
@@ -92,19 +99,20 @@ function _dieForUnknownCommand(cmd) {
|
|
|
92
99
|
bestMatchText = '';
|
|
93
100
|
break;
|
|
94
101
|
case 1:
|
|
95
|
-
bestMatchText = `A similar command is \n\n
|
|
102
|
+
bestMatchText = `A similar command is \n\n ${term.bold("cds " + bestMatches[0])}`;
|
|
96
103
|
break;
|
|
97
104
|
default:
|
|
98
|
-
bestMatchText = `Similar commands are \n\n
|
|
105
|
+
bestMatchText = `Similar commands are \n\n ${term.bold("cds " + bestMatches.join('\n cds '))}`;
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
const msg = `
|
|
102
109
|
Unknown command '${term.bold(cmd)}'. ${bestMatchText}
|
|
103
110
|
|
|
104
111
|
Haven't found the proper command yet? Here are all supported commands:
|
|
105
|
-
${term.bold(commands.join(', '))}
|
|
106
112
|
|
|
107
|
-
|
|
113
|
+
${term.bold(commands.join('\n '))}
|
|
114
|
+
|
|
115
|
+
You can use ${term.bold("cds help [command]")} to get more information on the command.
|
|
108
116
|
`
|
|
109
117
|
console.error(msg)
|
|
110
118
|
|
|
@@ -117,17 +125,8 @@ function _require (id,o) {
|
|
|
117
125
|
return require (resolved)
|
|
118
126
|
}
|
|
119
127
|
|
|
120
|
-
|
|
121
|
-
const { version } = require (_local (id+'/package.json'))
|
|
122
|
-
return version.split('.')[0] >= minVersion
|
|
123
|
-
}
|
|
128
|
+
module.exports = Object.assign ((..._) => cli.exec(..._), cli)
|
|
124
129
|
|
|
125
|
-
if (_minVersion ('@sap/cds', 4)) {
|
|
126
|
-
module.exports = Object.assign ((..._) => cli.exec(..._), cli)
|
|
127
|
-
}
|
|
128
|
-
else { // TODO compat to cds 3 remove after a while.
|
|
129
|
-
module.exports = require (_local('@sap/cds/bin/cds'))
|
|
130
|
-
}
|
|
131
130
|
if (!module.parent) module.exports()
|
|
132
131
|
|
|
133
132
|
/* eslint no-console:off */
|
package/bin/compile/index.js
CHANGED
|
@@ -120,7 +120,7 @@ module.exports = Object.assign ( compile, {
|
|
|
120
120
|
function compile_all (root='.') {
|
|
121
121
|
|
|
122
122
|
const {exec} = require ('child_process')
|
|
123
|
-
const cds = require
|
|
123
|
+
const cds = require('../../lib/compile') // get the enhanced cds w/ additional compile processors
|
|
124
124
|
|
|
125
125
|
exec(`find ${root} -name *.cds ! -path '*/node_modules/*'`, (_,stdout)=>{
|
|
126
126
|
const all = stdout.split('\n').slice(0,-1)
|
|
@@ -142,7 +142,7 @@ function compile (models, options={}) {
|
|
|
142
142
|
if (options.all) return compile_all (models[0])
|
|
143
143
|
|
|
144
144
|
const { inspect } = require('util')
|
|
145
|
-
const cds = require
|
|
145
|
+
const cds = require('../../lib/compile') // get the enhanced cds w/ additional compile processors
|
|
146
146
|
|
|
147
147
|
let model, src, _suffix; //> be filled in below
|
|
148
148
|
if (!options.as && !/,/.test(options.to)) options.as = 'str'
|
|
@@ -202,7 +202,7 @@ function compile (models, options={}) {
|
|
|
202
202
|
}))
|
|
203
203
|
|
|
204
204
|
// add processor for logging compiler messages and errors
|
|
205
|
-
const log = this.log ||
|
|
205
|
+
const log = this.log || _log
|
|
206
206
|
chain = chain.then ((results)=>{
|
|
207
207
|
if (messages.length) log (messages, options)
|
|
208
208
|
return results
|
|
@@ -272,4 +272,13 @@ function compile (models, options={}) {
|
|
|
272
272
|
}[x] || '.'+x) }
|
|
273
273
|
|
|
274
274
|
}
|
|
275
|
+
|
|
276
|
+
function _log (messages, options) {
|
|
277
|
+
const cds = require('../../lib/cds')
|
|
278
|
+
const { sortMessagesSeverityAware, deduplicateMessages } = cds.compiler
|
|
279
|
+
deduplicateMessages(messages)
|
|
280
|
+
messages = sortMessagesSeverityAware (messages)
|
|
281
|
+
cds.utils._log (messages, options)
|
|
282
|
+
}
|
|
283
|
+
|
|
275
284
|
/* eslint no-console:0 */
|
package/bin/deploy/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module.exports = Object.assign(deploy, {
|
|
2
|
-
options: ['--to', '--tunnel-address'
|
|
2
|
+
options: ['--to', '--tunnel-address'],
|
|
3
|
+
flags: [ '--no-save', '--auto-undeploy', '--dry', '--with-mocks', '--store-credentials', '--bind' ],
|
|
3
4
|
shortcuts: ['-2'],
|
|
4
5
|
help: `
|
|
5
6
|
# SYNOPSIS
|
|
@@ -41,29 +42,28 @@ module.exports = Object.assign(deploy, {
|
|
|
41
42
|
Deploy through the given address (host:port) rather than the original
|
|
42
43
|
database address. The tunnel must have been opened before, e.g. using 'cf ssh'.
|
|
43
44
|
|
|
44
|
-
*--
|
|
45
|
+
*--store-credentials* (only in combination with *--to hana*)
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
Stores credentials in *default-env.json file*. This is the former default behavior
|
|
48
|
+
which has been replaced by creating and storing connection information in file
|
|
49
|
+
*.cdsrc-private.json*.
|
|
49
50
|
|
|
50
|
-
*--bind* (beta feature, only in combination with *--to hana*)
|
|
51
|
-
|
|
52
|
-
Use *cds bind* to connect the created service after deployment.
|
|
53
|
-
This will no longer create default-env.json files. Instead, cds bind is used to
|
|
54
|
-
create and store connection information in file *.cdsrc-private.json*.
|
|
55
51
|
|
|
56
52
|
# EXAMPLES
|
|
57
53
|
cds deploy --to sqlite:db
|
|
54
|
+
cds deploy --to hana
|
|
58
55
|
cds deploy --to hana:myService --auto-undeploy
|
|
59
|
-
cds deploy --to hana --vcap-file ./secret/default-env.json
|
|
60
56
|
|
|
61
57
|
`})
|
|
62
58
|
|
|
63
|
-
const cds = require('
|
|
59
|
+
const cds = require('../../lib/cds')
|
|
64
60
|
|
|
65
61
|
async function deploy (_model, options) { // NOSONAR
|
|
66
62
|
|
|
63
|
+
if (options.bind) {
|
|
64
|
+
console.log (`Option '--bind' is now active by default and can therefore be omitted.`)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
67
|
if (_model && _model.length === 0) _model = undefined // empty array (no model args) means default models
|
|
68
68
|
const { 'to':url, 'no-save':no_save = cds.env.deploy.no_save } = options
|
|
69
69
|
if (!options.mocked) { options.mocked = options['with-mocks'] }
|
|
@@ -90,7 +90,7 @@ async function deploy (_model, options) { // NOSONAR
|
|
|
90
90
|
await deployer.deploy (_model, _db, options)
|
|
91
91
|
if (options.dry) return
|
|
92
92
|
if (kind === 'hana') return // REVISIT: the hana deployer is a bit special
|
|
93
|
-
if (url && !no_save) await
|
|
93
|
+
if (url && !no_save) await update_package_json (_kind, _model, _db)
|
|
94
94
|
} catch (e) {
|
|
95
95
|
if (e.code === 'MODEL_NOT_FOUND') {
|
|
96
96
|
if (!_model) throw new Error ('No .cds models found, please specify one as an argument')
|
|
@@ -100,7 +100,7 @@ async function deploy (_model, options) { // NOSONAR
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
async function
|
|
103
|
+
async function update_package_json (kind, model, database) {
|
|
104
104
|
const { fs, path, isfile } = cds.utils
|
|
105
105
|
const { readFile, writeFile } = fs.promises
|
|
106
106
|
const package_json = path.resolve ('package.json'), exists = isfile (package_json)
|
package/bin/deploy/to-hana.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const { join } = require('path');
|
|
2
2
|
|
|
3
3
|
exports.deploy = (_model, _db, options) => {
|
|
4
|
-
// locate deployer relative to
|
|
5
|
-
const cdsHome = require('
|
|
4
|
+
// locate deployer relative to sap/cds
|
|
5
|
+
const cdsHome = require('../../lib/cds').home;
|
|
6
6
|
const deployer = require(join(cdsHome, 'bin/deploy/to-hana'));
|
|
7
7
|
|
|
8
|
-
const bind = require('../bind');
|
|
9
|
-
return deployer.deploy(_model, _db, options,
|
|
8
|
+
const bind = !options['store-credentials'] ? require('../bind') : undefined;
|
|
9
|
+
return deployer.deploy(_model, _db, options, bind);
|
|
10
10
|
}
|
package/bin/deploy/to-sqlite.js
CHANGED
package/bin/env.js
CHANGED
|
@@ -44,22 +44,31 @@ const info = (s) => process.stdout.isTTY ? term.info (s) : s
|
|
|
44
44
|
|
|
45
45
|
async function env ([cmd, key, value], options={}) {
|
|
46
46
|
|
|
47
|
-
const cds = require('
|
|
47
|
+
const cds = require('../lib/cds')
|
|
48
48
|
const fn = (options["process-env"] ? processEnvCommands[cmd] : commands[cmd]) || (()=>{
|
|
49
49
|
this.help ('env')
|
|
50
50
|
throw new Error (`Don't understand '${cmd}' here...`)
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
let env = options.for ? cds.env.for(options.for) : cds.env
|
|
54
|
+
|
|
55
|
+
if (options["resolve-bindings"]) {
|
|
56
|
+
const BindingManager = require('../lib/bind/BindingManager')
|
|
57
|
+
const bindingManager = new BindingManager({env, output: "debug"})
|
|
58
|
+
const bindingEnv = await bindingManager.bindingEnv()
|
|
59
|
+
Object.assign(process.env, bindingEnv)
|
|
60
|
+
env = cds.env.for(options.for || 'cds') // reload env
|
|
61
|
+
}
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
|
|
64
|
+
env['_home_cds-dk'] = path.resolve(__dirname, '..') // to help tools find the DK
|
|
57
65
|
|
|
58
66
|
if (!options.for && options.mocked) await cds.service.bindings
|
|
59
67
|
|
|
60
68
|
fn (env, key, value)
|
|
61
69
|
}
|
|
62
70
|
|
|
71
|
+
|
|
63
72
|
const commands = {
|
|
64
73
|
|
|
65
74
|
get [undefined]() { return commands.list },
|
package/bin/eval.js
CHANGED
|
@@ -21,7 +21,7 @@ module.exports = Object.assign ( run, { help: `
|
|
|
21
21
|
function run ([code]) {
|
|
22
22
|
if (!code) return console.error (`Please specify the code to execute, like\n\n cds -e "cds.compile('my-model').to.json()"\n`)
|
|
23
23
|
// eslint-disable-next-line no-unused-vars
|
|
24
|
-
const cds = require('
|
|
24
|
+
const cds = require('../lib/cds')
|
|
25
25
|
if (code[0] === '.') code = 'cds' + code
|
|
26
26
|
const outcome = eval(code) //NOSONAR
|
|
27
27
|
console.log (outcome)
|
package/bin/fix-redirects.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const [arg0, arg1, _, ...args] = process.argv // eslint-disable-line no-unused-vars
|
|
2
|
-
const files = require('
|
|
2
|
+
const files = require('../lib/cds').resolve(args.length ? args : '*')
|
|
3
3
|
process.argv = [ arg0, arg1, 'ria', ...files ]
|
|
4
4
|
|
|
5
5
|
console.log ('[cds] - searching for ambiguous redirects in', files)
|