@sap/cds-dk 7.0.2 → 7.1.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/bin/add.js +2 -2
- package/bin/bind.js +5 -7
- package/bin/build.js +2 -7
- package/bin/cds.js +6 -8
- package/bin/deploy/to-hana.js +1 -1
- package/bin/init.js +2 -2
- package/bin/subscribe.js +4 -4
- package/bin/unsubscribe.js +4 -4
- package/bin/upgrade.js +4 -4
- package/lib/bind/cfKeyProvider.js +10 -10
- package/lib/bind/index.js +4 -3
- package/lib/bind/userCdsrcJsonStorageProvider.js +2 -10
- package/lib/build/buildTaskEngine.js +9 -22
- package/lib/build/buildTaskFactory.js +18 -27
- package/lib/build/constants.js +16 -14
- package/lib/build/index.js +12 -3
- package/lib/build/provider/buildTaskProviderInternal.js +23 -15
- package/lib/build/provider/mtx/index.js +8 -2
- package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -6
- package/lib/build/provider/mtx-sidecar/index.js +13 -8
- package/lib/build/util.js +13 -0
- package/lib/client/activate.js +7 -7
- package/lib/client/auth_manager.js +5 -5
- package/lib/client/base_command.js +7 -10
- package/lib/client/extend.js +2 -2
- package/lib/client/helper/logging.js +7 -2
- package/lib/client/params.js +2 -3
- package/lib/client/pull.js +3 -3
- package/lib/client/push.js +3 -3
- package/lib/client/settings_manager.js +7 -8
- package/lib/client/tenant_action.js +3 -3
- package/lib/compile/asyncapi/components/messages/index.js +41 -18
- package/lib/compile/asyncapi/index.js +23 -2
- package/lib/deploy/to-hana/hana.js +1 -2
- package/lib/import/common.js +3 -0
- package/lib/import/message.js +2 -1
- package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -0
- package/lib/import/odata/v4parser.js +85 -95
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +78 -73
- package/lib/init/template/approuter/index.js +3 -4
- package/lib/init/template/auditlog/index.js +3 -4
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +15 -23
- package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +22 -17
- package/lib/init/template/cf-manifest/index.js +2 -2
- package/lib/init/template/connectivity/index.js +2 -3
- package/lib/init/template/data/index.js +7 -8
- package/lib/init/template/destination/index.js +3 -5
- package/lib/init/template/enterprise-messaging/index.js +4 -5
- package/lib/init/template/enterprise-messaging-shared/index.js +3 -4
- package/lib/init/template/extensibility/index.js +2 -3
- package/lib/init/template/file-based-messaging/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +1 -1
- package/lib/init/template/hana/index.js +39 -63
- package/lib/init/template/helm/index.js +15 -14
- package/lib/init/template/html5-repo/index.js +3 -7
- package/lib/init/template/java/index.js +3 -3
- package/lib/init/template/kibana/index.js +3 -4
- package/lib/init/template/lint/index.js +13 -13
- package/lib/init/template/mta/index.js +3 -2
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
- package/lib/init/template/multitenancy/index.js +16 -37
- package/lib/init/template/nodejs/index.js +4 -6
- package/lib/init/template/pipeline/index.js +3 -4
- package/lib/init/template/redis-messaging/index.js +3 -4
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +1 -1
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +1 -1
- package/lib/init/template/sample/files/srv/admin-service.cds +1 -1
- package/lib/init/template/sample/files/srv/cat-service.cds +1 -1
- package/lib/init/template/sample/index.js +6 -5
- package/lib/init/template/sqlite/index.js +1 -1
- package/lib/init/template/templateBase.js +9 -19
- package/lib/init/template/tiny-sample/index.js +5 -5
- package/lib/init/template/toggles/index.js +1 -2
- package/lib/init/template/typer/files/xsconfig.json +0 -1
- package/lib/init/template/typer/index.js +1 -1
- package/lib/init/template/xsuaa/index.js +3 -4
- package/lib/init/util/indent.js +57 -0
- package/lib/init/util/merge.js +72 -16
- package/lib/init/util/mvn.js +40 -31
- package/lib/init/util/projectReader.js +52 -168
- package/lib/init/util/template.js +12 -11
- package/lib/init/util/xml.js +6 -6
- package/lib/util/cfUtil.js +1 -2
- package/lib/util/pruneAxiosErrors.js +22 -0
- package/lib/watch/open.js +6 -3
- package/npm-shrinkwrap.json +356 -309
- package/package.json +1 -2
- package/lib/client/helper/errors.js +0 -26
- package/lib/util/version.js +0 -27
package/bin/add.js
CHANGED
|
@@ -91,8 +91,8 @@ module.exports = Object.assign(add, {
|
|
|
91
91
|
|
|
92
92
|
`});
|
|
93
93
|
|
|
94
|
-
async function add(args
|
|
94
|
+
async function add(args) {
|
|
95
95
|
const CDSGenerator = require('../lib/init');
|
|
96
96
|
const generator = new CDSGenerator();
|
|
97
|
-
await generator.addCmd(args[0]
|
|
97
|
+
await generator.addCmd(args[0]);
|
|
98
98
|
}
|
package/bin/bind.js
CHANGED
|
@@ -54,7 +54,6 @@ module.exports = Object.assign(cds_bind, {
|
|
|
54
54
|
const os = require('os');
|
|
55
55
|
const IS_WIN = os.platform() === 'win32';
|
|
56
56
|
|
|
57
|
-
const { CliError } = require('../lib/client/helper/errors');
|
|
58
57
|
const { bind, parseProfile } = require('../lib/bind');
|
|
59
58
|
|
|
60
59
|
|
|
@@ -70,27 +69,26 @@ async function cds_bind(args, options) {
|
|
|
70
69
|
|
|
71
70
|
// Check if cds command was bind. Don't abort in case of deploy
|
|
72
71
|
if (process.env.CDS_ENV && process.argv[2] === 'bind') {
|
|
73
|
-
throw
|
|
72
|
+
throw 'Option --profile is no longer supported. Use --for instead to specify the profile to use when storing connection settings.';
|
|
74
73
|
}
|
|
75
|
-
options.for = options.for ?? 'hybrid';
|
|
76
74
|
|
|
77
75
|
if (!options.to) {
|
|
78
|
-
throw
|
|
76
|
+
throw `Use option --to or -2 to specify the target instance, e.g. cds bind --to myInstance:myService`;
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
if (args.length > 1) {
|
|
82
|
-
throw
|
|
80
|
+
throw `Too many arguments: Please specify only one or no service.`;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
options.serviceArg = args[0]
|
|
86
84
|
options.targets = options.to.split(/,/g);
|
|
87
85
|
|
|
88
86
|
if (options.targets.length >= 2 && options.serviceArg) {
|
|
89
|
-
throw
|
|
87
|
+
throw `Service argument cannot be specified together with multiple targets ('--to') services. Use one service per call or omit the service argument.`;
|
|
90
88
|
}
|
|
91
89
|
|
|
92
90
|
if (options.targets.length >= 2 && options.kind) {
|
|
93
|
-
throw
|
|
91
|
+
throw `The option '--kind' cannot be specified together with multiple targets ('--to') services. Use one service per call or omit the '--kind' option.`;
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
await bind({
|
package/bin/build.js
CHANGED
|
@@ -96,19 +96,14 @@ async function build([project], options = {}) {
|
|
|
96
96
|
cds.env = cds.env.for('cds', cds.root);
|
|
97
97
|
delete options.project // avoid that relative project paths are resolved twice
|
|
98
98
|
|
|
99
|
-
options.cli = true // avoid that errors are logged twice
|
|
100
|
-
|
|
101
|
-
const { CliError } = require('../lib/client/helper/errors')
|
|
102
99
|
const { build } = require('../lib/build')
|
|
103
|
-
|
|
104
100
|
const [major] = cds.version.split('.')
|
|
105
101
|
if (Number(major) < 6) {
|
|
106
|
-
throw
|
|
102
|
+
throw "This application uses @sap/cds version < 6, which is not compatible with the installed @sap/cds-dk version >= 7. Update @sap/cds to version >= 6."
|
|
107
103
|
}
|
|
108
104
|
if (options.clean === "false") {
|
|
109
|
-
throw
|
|
105
|
+
throw "cds build option '--clean' is deprecated - build output folders are always cleaned before build"
|
|
110
106
|
}
|
|
111
|
-
|
|
112
107
|
if (typeof options["options-model"] === "string") {
|
|
113
108
|
options.opts = "model=[" + options["options-model"].split(",").map((entry) => entry.trim()) + "]"
|
|
114
109
|
delete options["options-model"]
|
package/bin/cds.js
CHANGED
|
@@ -54,11 +54,7 @@ const cli = { //NOSONAR
|
|
|
54
54
|
return await task.apply(this, args)
|
|
55
55
|
}
|
|
56
56
|
} catch (e) {
|
|
57
|
-
const { BuildError } = require('../lib/build')
|
|
58
|
-
const { CliError } = require('../lib/client/helper/errors')
|
|
59
57
|
process.exitCode ??= 1
|
|
60
|
-
if (e.messages?.length) return cds._log(e.messages, { 'log-level': cds.env.log.levels.cli })
|
|
61
|
-
else if (e instanceof CliError || e instanceof BuildError) return console.error(e.message)
|
|
62
58
|
if (cds.watched) throw e // bin/watched.js handles errors
|
|
63
59
|
else return console.error(e)
|
|
64
60
|
}
|
|
@@ -152,13 +148,15 @@ function _dieForUnknownCommand(cmd) {
|
|
|
152
148
|
|
|
153
149
|
let bestMatchText = '';
|
|
154
150
|
|
|
155
|
-
const excludeList = ['cds.js', 'cds-ts.js', 'fix-redirects.js'];
|
|
151
|
+
const excludeList = ['cds.js', 'cds-ts.js', 'fix-redirects.js', 'util'];
|
|
156
152
|
const { readdirSync } = require('fs');
|
|
157
153
|
const { resolve } = require('path');
|
|
158
|
-
|
|
154
|
+
let commands = readdirSync(__dirname, { withFileTypes: true })
|
|
159
155
|
.concat(readdirSync(resolve(_local('@sap/cds'), '..', '..', 'bin'), { withFileTypes: true }))
|
|
160
|
-
.filter((f) =>
|
|
161
|
-
.map((f) => f.name.split('.')[0])
|
|
156
|
+
.filter((f) => !excludeList.includes(f.name))
|
|
157
|
+
.map((f) => f.name.split('.')[0])
|
|
158
|
+
commands = [...new Set(commands)] // make unique
|
|
159
|
+
.sort();
|
|
162
160
|
|
|
163
161
|
const bestMatches = fuzzySearch(cmd, commands, DEBUG);
|
|
164
162
|
|
package/bin/deploy/to-hana.js
CHANGED
|
@@ -8,6 +8,6 @@ exports.deploy = (model, serviceName, options) => {
|
|
|
8
8
|
tunnelAddress: options['tunnel-address'],
|
|
9
9
|
vcapFile: options['vcap-file'],
|
|
10
10
|
hdiOptions: { autoUndeploy: options['auto-undeploy'] },
|
|
11
|
-
storeCredentials: options['store-credentials']
|
|
11
|
+
storeCredentials: options['store-credentials'] // TODO: Remove with cds-dk 8
|
|
12
12
|
});
|
|
13
13
|
}
|
package/bin/init.js
CHANGED
|
@@ -98,11 +98,11 @@ module.exports = Object.assign(init, {
|
|
|
98
98
|
|
|
99
99
|
`})
|
|
100
100
|
|
|
101
|
-
async function init (args
|
|
101
|
+
async function init (args) {
|
|
102
102
|
if (process.argv.some(a => legacyOptions.includes(a))) return _showWarningMessage()
|
|
103
103
|
const CDSGenerator = require('../lib/init')
|
|
104
104
|
const generator = new CDSGenerator()
|
|
105
|
-
await generator.initCmd(args[0]
|
|
105
|
+
await generator.initCmd(args[0])
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
|
package/bin/subscribe.js
CHANGED
|
@@ -46,19 +46,19 @@ module.exports = Object.assign(subscribe, {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
async function subscribe([tenant], options = {}) {
|
|
49
|
-
const {
|
|
49
|
+
const { getMessage } = require('../lib/client/helper/logging');
|
|
50
50
|
if (!tenant) {
|
|
51
|
-
throw
|
|
51
|
+
throw getMessage('Tenant not given.', { command: 'subscribe' });
|
|
52
52
|
}
|
|
53
53
|
const libOptions = { tenant };
|
|
54
54
|
if (options.local) {
|
|
55
55
|
libOptions.local = true;
|
|
56
56
|
delete options.local;
|
|
57
57
|
if (options.user) {
|
|
58
|
-
throw
|
|
58
|
+
throw getMessage('Username cannot be specified when running @sap/cds-mtxs locally.', { command: 'subscribe' });
|
|
59
59
|
}
|
|
60
60
|
if (options.to) {
|
|
61
|
-
throw
|
|
61
|
+
throw getMessage('URL cannot be specified when running @sap/cds-mtxs locally.', { command: 'subscribe' });
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
const [username, password] = options.user?.split(':') ?? [];
|
package/bin/unsubscribe.js
CHANGED
|
@@ -47,19 +47,19 @@ module.exports = Object.assign(unsubscribe, {
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
async function unsubscribe([tenant], options = {}) {
|
|
50
|
-
const {
|
|
50
|
+
const { getMessage } = require('../lib/client/helper/logging');
|
|
51
51
|
if (!tenant) {
|
|
52
|
-
throw
|
|
52
|
+
throw getMessage('Tenant not given.', { command: 'unsubscribe' });
|
|
53
53
|
}
|
|
54
54
|
const libOptions = { tenant };
|
|
55
55
|
if (options.local) {
|
|
56
56
|
libOptions.local = true;
|
|
57
57
|
delete options.local;
|
|
58
58
|
if (options.user) {
|
|
59
|
-
throw
|
|
59
|
+
throw getMessage('Username cannot be specified when running @sap/cds-mtxs locally.', { command: 'subscribe' });
|
|
60
60
|
}
|
|
61
61
|
if (options.from) {
|
|
62
|
-
throw
|
|
62
|
+
throw getMessage('URL cannot be specified when running @sap/cds-mtxs locally.', { command: 'unsubscribe' });
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
const [username, password] = options.user?.split(':') ?? [];
|
package/bin/upgrade.js
CHANGED
|
@@ -47,19 +47,19 @@ module.exports = Object.assign(upgrade, {
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
async function upgrade([tenant], options = {}) {
|
|
50
|
-
const {
|
|
50
|
+
const { getMessage } = require('../lib/client/helper/logging');
|
|
51
51
|
if (!tenant) {
|
|
52
|
-
throw
|
|
52
|
+
throw getMessage('Tenant not given.', { command: 'upgrade' });
|
|
53
53
|
}
|
|
54
54
|
const libOptions = { tenant };
|
|
55
55
|
if (options.local) {
|
|
56
56
|
libOptions.local = true;
|
|
57
57
|
delete options.local;
|
|
58
58
|
if (options.user) {
|
|
59
|
-
throw
|
|
59
|
+
throw getMessage('Username cannot be specified when running @sap/cds-mtxs locally.', { command: 'upgrade' });
|
|
60
60
|
}
|
|
61
61
|
if (options.at) {
|
|
62
|
-
throw
|
|
62
|
+
throw getMessage('URL cannot be specified when running @sap/cds-mtxs locally.', { command: 'upgrade' });
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
const [username, password] = options.user?.split(':') ?? [];
|
|
@@ -4,9 +4,9 @@ const DEBUG = cds.debug('cli')
|
|
|
4
4
|
const cfUtil = require('../util/cfUtil');
|
|
5
5
|
|
|
6
6
|
const axios = require('axios');
|
|
7
|
+
require('../util/pruneAxiosErrors');
|
|
7
8
|
const { URL } = require('url');
|
|
8
9
|
const { bold, highlight } = require('../util/term');
|
|
9
|
-
const { CliError } = require('../client/helper/errors');
|
|
10
10
|
|
|
11
11
|
class CFKeyProvider {
|
|
12
12
|
async getCfSpaceInfo() {
|
|
@@ -20,13 +20,13 @@ class CFKeyProvider {
|
|
|
20
20
|
const { org, space } = target;
|
|
21
21
|
const orgs = await BatchRequest.req(targetWithAuth, `/v3/organizations?names=${encodeURIComponent(encodeURIComponent(org))}`);
|
|
22
22
|
if (!(orgs && orgs.resources.length === 1)) {
|
|
23
|
-
throw
|
|
23
|
+
throw `CF org ${org} not found!`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const orgGuid = orgs.resources[0].guid;
|
|
27
27
|
const spaces = await BatchRequest.req(targetWithAuth, `/v3/spaces?names=${encodeURIComponent(encodeURIComponent(space))}&organization_guids=${encodeURIComponent(encodeURIComponent(orgGuid))}`)
|
|
28
28
|
if (!(spaces && spaces.resources.length === 1)) {
|
|
29
|
-
throw
|
|
29
|
+
throw `CF space ${space} not found in org ${org}!`;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const spaceGuid = spaces.resources[0].guid;
|
|
@@ -80,7 +80,7 @@ class CFKeyProvider {
|
|
|
80
80
|
try {
|
|
81
81
|
instanceObj = await this.getInstance({ names: instance, space_guids: spaceGuid });
|
|
82
82
|
} catch (error) {
|
|
83
|
-
throw
|
|
83
|
+
throw `Service instance "${instance}" not found.`;
|
|
84
84
|
}
|
|
85
85
|
switch (instanceObj.type) {
|
|
86
86
|
case 'managed':
|
|
@@ -88,7 +88,7 @@ class CFKeyProvider {
|
|
|
88
88
|
case 'user-provided':
|
|
89
89
|
return this._resolveUserProvidedService(instanceObj, instance, org, space);
|
|
90
90
|
default:
|
|
91
|
-
throw
|
|
91
|
+
throw `Service type ${instanceObj.type} not supported`;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -99,7 +99,7 @@ class CFKeyProvider {
|
|
|
99
99
|
} catch (error) {
|
|
100
100
|
let message = `No service key ${highlight(key)} found for service instance ${highlight(instance)}.\n\n`;
|
|
101
101
|
message += `Use ${bold(`cf create-service-key ${instanceObj.name} ${key} [-c ...]`)} to create the required service key.`;
|
|
102
|
-
throw
|
|
102
|
+
throw message;
|
|
103
103
|
}
|
|
104
104
|
const planObj = await this.getPlans({ guids: instanceObj.relationships.service_plan.data.guid });
|
|
105
105
|
const offeringObj = await this.getOfferings({ guids: planObj.relationships.service_offering.data.guid });
|
|
@@ -150,10 +150,10 @@ class CFKeyProvider {
|
|
|
150
150
|
|
|
151
151
|
// if no api endpoint is configured the currently logged in endpoint will be used
|
|
152
152
|
if (apiEndpoint && apiEndpoint !== this.target.apiEndpoint) {
|
|
153
|
-
name = `${name || instance}:${key || instance + '-key'}
|
|
153
|
+
name = `${name || instance}:${key || instance + '-key'}`;
|
|
154
154
|
let message = `Current Cloud Foundry API endpoint ${highlight(this.target.apiEndpoint)} differs from API endpoint ${highlight(apiEndpoint)} for service binding ${highlight(name)}.\n\n`;
|
|
155
155
|
message += `Use ${bold(`cf login -a ${apiEndpoint}`)} to log in to the target API endpoint.`;
|
|
156
|
-
throw
|
|
156
|
+
throw message;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -223,9 +223,9 @@ class BatchRequest {
|
|
|
223
223
|
if (filteredResources.length === 1) {
|
|
224
224
|
filter.resolve(filteredResources[0]);
|
|
225
225
|
} else if (filteredResources.length === 0) {
|
|
226
|
-
filter.reject(
|
|
226
|
+
filter.reject(`Couldn't find resource for url "${this.url}" with filter "${fmt(filter.filter)}"`);
|
|
227
227
|
} else {
|
|
228
|
-
filter.reject(
|
|
228
|
+
filter.reject(`Found more than one resources for url "${this.url}" with filter "${fmt(filter.filter)}"`);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
}
|
package/lib/bind/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const cds = require('../cds');
|
|
2
2
|
|
|
3
|
-
const { CliError } = require('../client/helper/errors');
|
|
4
|
-
|
|
5
3
|
const BindingResolver = require('./bindingResolver');
|
|
6
4
|
const { determineKinds, getRequiresNameFromKind, checkIsJavaProject, platformText, bindingText, logger } = require('./bindingUtil');
|
|
7
5
|
const { highlight, bold, info } = require('../util/term');
|
|
@@ -15,6 +13,9 @@ module.exports = { bind, parseProfile }
|
|
|
15
13
|
* @param {object} options - command options as defined by build command.
|
|
16
14
|
*/
|
|
17
15
|
async function bind(options) {
|
|
16
|
+
|
|
17
|
+
options.for = options.for || 'hybrid';
|
|
18
|
+
|
|
18
19
|
let on;
|
|
19
20
|
switch(options.on) {
|
|
20
21
|
case 'k8s':
|
|
@@ -28,7 +29,7 @@ async function bind(options) {
|
|
|
28
29
|
on = 'cf';
|
|
29
30
|
break;
|
|
30
31
|
default:
|
|
31
|
-
throw
|
|
32
|
+
throw `Invalid value '${options.on}' for option --on.`;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const onText = { 'cf': 'Cloud Foundry', 'k8s': 'Kubernetes' }[on];
|
|
@@ -58,11 +58,7 @@ class UserCdsrcJsonStorageProvider {
|
|
|
58
58
|
|
|
59
59
|
cdsRoot.requires = cdsRoot.requires || {};
|
|
60
60
|
let section;
|
|
61
|
-
|
|
62
|
-
section = cdsRoot.requires[profileKey] = cdsRoot.requires[profileKey] || {};
|
|
63
|
-
} else {
|
|
64
|
-
section = cdsRoot.requires;
|
|
65
|
-
}
|
|
61
|
+
section = cdsRoot.requires[profileKey] = cdsRoot.requires[profileKey] || {};
|
|
66
62
|
|
|
67
63
|
for (const service of services) {
|
|
68
64
|
const { name, kind, binding, credentials } = service;
|
|
@@ -72,11 +68,7 @@ class UserCdsrcJsonStorageProvider {
|
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
await this.writeJsonFile(jsonPath, jsonObject);
|
|
75
|
-
|
|
76
|
-
logger.log(`Saving bindings to ${highlight(jsonPath)} in profile ${highlight(options.for)}`);
|
|
77
|
-
} else {
|
|
78
|
-
logger.log(`Saving bindings to ${highlight(jsonPath)}`);
|
|
79
|
-
}
|
|
71
|
+
logger.log(`Saving bindings to ${highlight(jsonPath)} in profile ${highlight(options.for)}`);
|
|
80
72
|
}
|
|
81
73
|
|
|
82
74
|
async readJsonSafely(filePath) {
|
|
@@ -27,7 +27,6 @@ class BuildTaskEngine {
|
|
|
27
27
|
|
|
28
28
|
async processTasks(tasks) {
|
|
29
29
|
const startTime = Date.now()
|
|
30
|
-
const messages = []
|
|
31
30
|
|
|
32
31
|
this.logger.log(`building project [${cds.root}], clean [${this.buildOptions.clean}]`)
|
|
33
32
|
this.logger.log(`cds-dk [${require('../../package.json').version}], cds [${cds.version}], compiler [${cds.compiler.version()}], home [${cds.home}]\n`)
|
|
@@ -64,18 +63,12 @@ class BuildTaskEngine {
|
|
|
64
63
|
|
|
65
64
|
await this._writeGenerationLog(handlers)
|
|
66
65
|
this._logBuildOutput(handlers)
|
|
67
|
-
this._logMessages(
|
|
66
|
+
this._logMessages(BuildTaskEngine._getHandlerMessages(handlers))
|
|
68
67
|
this._logTimer(startTime, Date.now())
|
|
69
68
|
|
|
70
69
|
return buildResult
|
|
71
70
|
} catch (error) {
|
|
72
71
|
this._logBuildOutput(handlers)
|
|
73
|
-
|
|
74
|
-
// cds CLI layer logs in case of an exception if invoked from CLI
|
|
75
|
-
if (!this.buildOptions.cli) {
|
|
76
|
-
this._logMessages([...BuildTaskEngine._getErrorMessages([error]), ...messages])
|
|
77
|
-
}
|
|
78
|
-
|
|
79
72
|
throw error
|
|
80
73
|
}
|
|
81
74
|
}
|
|
@@ -215,22 +208,16 @@ class BuildTaskEngine {
|
|
|
215
208
|
}
|
|
216
209
|
|
|
217
210
|
_createHandler(task) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
handler.init()
|
|
211
|
+
const handler = this.providerFactory.createHandler(task)
|
|
212
|
+
handler.init()
|
|
221
213
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
this._logTaskHandler(handler)
|
|
228
|
-
|
|
229
|
-
return handler
|
|
230
|
-
} catch (error) {
|
|
231
|
-
log(error, { log: this.logger.log })
|
|
232
|
-
throw error
|
|
214
|
+
if (!(handler instanceof BuildTaskHandlerInternal) && handler.priority !== 1) {
|
|
215
|
+
// Custom build handlers are executed before internal handlers to ensure
|
|
216
|
+
// that generated content cannot be overwritten by mistake
|
|
217
|
+
throw new Error(`Illegal priority for ${handler.constructor.name} encountered for custom handler - in this version only priority value '1' is allowed`)
|
|
233
218
|
}
|
|
219
|
+
this._logTaskHandler(handler)
|
|
220
|
+
return handler
|
|
234
221
|
}
|
|
235
222
|
|
|
236
223
|
_logBuildOutput(handlers) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
-
const cds = require('../cds')
|
|
3
|
+
const cds = require('../cds')
|
|
4
4
|
const BuildTaskProviderFactory = require('./buildTaskProviderFactory')
|
|
5
5
|
const { hasJavaNature, getProperty, redactCredentials, flatten, getDefaultModelOptions } = require('./util')
|
|
6
6
|
const { FILE_EXT_CDS, BUILD_TASK_JAVA_CF, BUILD_TASK_JAVA } = require("./constants")
|
|
@@ -24,36 +24,27 @@ class BuildTaskFactory {
|
|
|
24
24
|
// 2. read using cds.env.build.tasks
|
|
25
25
|
// 3. create from cds.env.folders config data
|
|
26
26
|
async getTasks() {
|
|
27
|
-
|
|
28
|
-
const tasks = await this._createTasks()
|
|
27
|
+
const tasks = await this._createTasks()
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
// log build tasks
|
|
30
|
+
this.logger.log(`the following build tasks will be executed`)
|
|
31
|
+
let tasksOutput = " {\n \"build\": {\n \"target\": \"" + cds.env.build.target + "\",\n \"tasks\": ["
|
|
32
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
33
|
+
tasksOutput += "\n " + BuildTaskFactory._stringifyTask(tasks[i]) + (i + 1 < tasks.length ? "," : "")
|
|
34
|
+
}
|
|
35
|
+
tasksOutput += "\n ]\n }\n }\n"
|
|
36
|
+
this.logger.log(tasksOutput)
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
// for testing purposes
|
|
39
|
+
this.logger.debug("cds.env used for build:")
|
|
40
|
+
this.logger._debug && this.logger.debug(redactCredentials(cds.env))
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
return tasks
|
|
49
|
-
} catch (e) {
|
|
50
|
-
this.logger.log('')
|
|
51
|
-
// cds CLI layer is doing the logging if invoked using CLI
|
|
52
|
-
if (!this.buildOptions.cli) {
|
|
53
|
-
log(e, { withStack: true, log: (message) => this.logger.log(message) })
|
|
54
|
-
}
|
|
55
|
-
throw e
|
|
42
|
+
// always resolve tasks for input validation
|
|
43
|
+
const resolvedTasks = this.providerFactory.resolveTasks(tasks)
|
|
44
|
+
if (this.buildOptions.resolve) {
|
|
45
|
+
return resolvedTasks
|
|
56
46
|
}
|
|
47
|
+
return tasks
|
|
57
48
|
}
|
|
58
49
|
|
|
59
50
|
async _createTasks() {
|
package/lib/build/constants.js
CHANGED
|
@@ -19,20 +19,22 @@ exports.BUILD_TASKS = [this.BUILD_TASK_JAVA, this.BUILD_TASK_JAVA_CF, this.BUILD
|
|
|
19
19
|
exports.ODATA_VERSION_V2 = "v2"
|
|
20
20
|
exports.ODATA_VERSION_V4 = "v4"
|
|
21
21
|
|
|
22
|
-
exports.CONTENT_LANGUAGE_BUNDLES = "contentLanguageBundles"
|
|
23
|
-
exports.CONTENT_DEFAULT_CSN = "contentDefaultCsn"
|
|
24
|
-
exports.CONTENT_EDMX = "contentEdmx"
|
|
25
|
-
exports.CONTENT_PACKAGE_JSON = "contentPackageJson"
|
|
26
|
-
exports.CONTENT_PACKAGELOCK_JSON = "contentPackageLockJson"
|
|
27
|
-
exports.CONTENT_HDBTABLEDATA = "contentHdbtabledata"
|
|
28
|
-
exports.CONTENT_NPMRC = "contentNpmrc"
|
|
29
|
-
exports.CONTENT_CDSRC_JSON = "contentCdsrcJson"
|
|
30
|
-
exports.CONTENT_NODE_MODULES = "contentNodeModules"
|
|
31
|
-
exports.CONTENT_ENV = "contentEnv"
|
|
32
|
-
exports.CONTENT_DEFAULT_ENV_JSON = "contentDefaultEnvJson"
|
|
33
|
-
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
22
|
+
exports.CONTENT_LANGUAGE_BUNDLES = "contentLanguageBundles" // create i18n.json language bundles - build task specific
|
|
23
|
+
exports.CONTENT_DEFAULT_CSN = "contentDefaultCsn" // create default CSN format flavor: "inferred" - build task specific
|
|
24
|
+
exports.CONTENT_EDMX = "contentEdmx" // create EDMX for required languages - build task specific
|
|
25
|
+
exports.CONTENT_PACKAGE_JSON = "contentPackageJson" // create package.json file if not existing, or modify existing package.json - ENABLED by default
|
|
26
|
+
exports.CONTENT_PACKAGELOCK_JSON = "contentPackageLockJson" // copy package-lock.json file if existing into deployment folder - ENABLED by default
|
|
27
|
+
exports.CONTENT_HDBTABLEDATA = "contentHdbtabledata" // create .hdbtabledata files for .csv files if not existing - ENABLED by default
|
|
28
|
+
exports.CONTENT_NPMRC = "contentNpmrc" // copy .npmrc file if existing into deployment folder - ENABLED by default
|
|
29
|
+
exports.CONTENT_CDSRC_JSON = "contentCdsrcJson" // copy .cdsrc.json file if existing into deployment folder - ENABLED by default
|
|
30
|
+
exports.CONTENT_NODE_MODULES = "contentNodeModules" // copy node_modules folder if existing into deployment folder - DISABLED by default
|
|
31
|
+
exports.CONTENT_ENV = "contentEnv" // copy .env file if existing into deployment folder - DISABLED by default
|
|
32
|
+
exports.CONTENT_DEFAULT_ENV_JSON = "contentDefaultEnvJson" // copy default-env.json file if existing into deployment folder - DISABLED by default
|
|
33
|
+
|
|
34
|
+
exports.CSV_FILE_DETECTION = "csvFileDetection" // detect CSV files based on CDS model location - ENABLED by default
|
|
35
|
+
exports.EXTENSION_POINT_VALIDATION = "extensionPointValidation" // validate extension point restrictions defined by the extended SaaS app - ENABLED by default
|
|
36
|
+
exports.DEFAULT_BUILT_IN_MODELS = "defaultBuiltInModels" // add @sap/cds* built-in models to build tasks - ENABLED by default
|
|
37
|
+
exports.MTX_SIDECAR_DB_VALIDATION = "mtxSidecarDbValidation" // validate consistency of app and sidecar db configuration - ENABLED by default
|
|
36
38
|
|
|
37
39
|
exports.FOLDER_GEN = "gen"
|
|
38
40
|
exports.FILE_EXT_CDS = ".cds"
|
package/lib/build/index.js
CHANGED
|
@@ -14,8 +14,17 @@ module.exports = { build, BuildTaskFactory, BuildTaskEngine, BuildTaskHandler, B
|
|
|
14
14
|
*/
|
|
15
15
|
async function build(options = {}) {
|
|
16
16
|
if (!fs.existsSync(cds.root) || !fs.lstatSync(cds.root).isDirectory()) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
throw `Project folder '${cds.root}' does not exist`
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return await new BuildTaskEngine(options).processTasks()
|
|
21
|
+
} catch (e) {
|
|
22
|
+
if (e instanceof BuildError || e.constructor.name === 'CompilationError') {
|
|
23
|
+
cds._log(e.messages.length ? [...e.messages, ''] : e.message + '\n', { 'log-level': options['log-level'] || cds.env['log-level'] })
|
|
24
|
+
// CompilationError.message also includes the detail messages - do not log twice
|
|
25
|
+
const message = e.constructor.name === 'CompilationError' ? 'CDS compilation failed' : e.messages.length ? e.message : 'CDS build failed'
|
|
26
|
+
throw message
|
|
27
|
+
}
|
|
28
|
+
throw e
|
|
19
29
|
}
|
|
20
|
-
return await new BuildTaskEngine(options).processTasks()
|
|
21
30
|
}
|