@sap/cds-dk 7.0.1 → 7.0.3
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 +36 -40
- package/bin/bind.js +0 -1
- package/bin/build.js +4 -0
- package/bin/cds.js +14 -8
- package/bin/compile/index.js +3 -3
- package/bin/deploy/to-hana.js +1 -1
- package/bin/help.js +2 -3
- package/bin/init.js +2 -2
- package/lib/bind/cfKeyProvider.js +1 -0
- package/lib/bind/index.js +3 -0
- package/lib/bind/userCdsrcJsonStorageProvider.js +2 -10
- package/lib/build/buildTaskEngine.js +1 -1
- package/lib/build/constants.js +16 -14
- package/lib/build/provider/buildTaskHandlerFeatureToggles.js +2 -1
- package/lib/build/provider/java/index.js +2 -2
- package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -6
- package/lib/build/provider/mtx-sidecar/index.js +15 -11
- package/lib/build/util.js +8 -0
- package/lib/cds.js +2 -2
- package/lib/client/base_command.js +3 -6
- package/lib/compile/asyncapi/components/messages/index.js +41 -18
- package/lib/compile/asyncapi/index.js +23 -2
- package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -0
- package/lib/init/constants.js +5 -5
- package/lib/init/index.js +68 -76
- package/lib/init/template/_merging/registry-mta.js +2 -2
- package/lib/init/template/approuter/index.js +10 -7
- 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 +5 -5
- package/lib/init/template/connectivity/index.js +2 -3
- package/lib/init/template/data/index.js +6 -6
- 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 +6 -6
- package/lib/init/template/kibana/files/mta.yaml.hbs +29 -0
- package/lib/init/template/kibana/index.js +54 -0
- package/lib/init/template/lint/index.js +8 -7
- package/lib/init/template/mta/index.js +3 -2
- package/lib/init/template/multitenancy/files/package.json.hbs +0 -3
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
- package/lib/init/template/multitenancy/index.js +25 -40
- package/lib/init/template/nodejs/index.js +4 -5
- package/lib/init/template/pipeline/index.js +3 -3
- package/lib/init/template/redis-messaging/index.js +3 -4
- package/lib/init/template/sample/files/app/_i18n/i18n.properties +3 -32
- package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +2 -2
- package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +6 -7
- package/lib/init/template/sample/files/app/admin-books/webapp/Component.js +3 -3
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n.properties +3 -11
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +117 -113
- package/lib/init/template/sample/files/app/appconfig/fioriSandboxConfig.json +38 -0
- package/lib/init/template/sample/files/app/browse/fiori-service.cds +56 -0
- package/lib/init/template/sample/files/app/browse/webapp/Component.js +7 -0
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +4 -0
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +139 -0
- package/lib/init/template/sample/files/app/common.cds +78 -81
- package/lib/init/template/sample/files/app/services.cds +1 -0
- 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 +6 -6
- 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 +71 -15
- package/lib/init/util/mvn.js +24 -10
- package/lib/init/util/projectReader.js +53 -169
- package/lib/init/util/template.js +12 -11
- package/lib/init/util/xml.js +6 -6
- package/lib/util/pruneAxiosErrors.js +22 -0
- package/lib/watch/open.js +6 -3
- package/npm-shrinkwrap.json +20 -37
- package/package.json +1 -2
- package/lib/init/template/kibana-logging/files/cds.package.json +0 -7
- package/lib/init/template/kibana-logging/files/mta.yaml.hbs +0 -14
- package/lib/init/template/kibana-logging/index.js +0 -45
- /package/lib/init/template/{kibana-logging → kibana}/files/package.json.hbs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const csnToJSONSchema = require('./components/schemas');
|
|
2
2
|
const getMessageTraits = require('./components/messageTraits');
|
|
3
|
-
const definitionsToMessages = require('./components/messages');
|
|
3
|
+
const { definitionsToMessages, nestedAnnotation } = require('./components/messages');
|
|
4
4
|
const getChannels = require('./channels');
|
|
5
5
|
const cds = require('../../cds');
|
|
6
6
|
const messages = require("./message");
|
|
@@ -75,13 +75,14 @@ function _getAsyncApi(csn, events, serviceName, applicationNamespace, presets) {
|
|
|
75
75
|
const infoObject = getInfoObject(csn.definitions[serviceName]);
|
|
76
76
|
const stateObj = getStateInfo(csn.definitions[serviceName]);
|
|
77
77
|
const shortTextObj = getShortText(csn.definitions[serviceName]);
|
|
78
|
-
|
|
78
|
+
const extensionAnnotationObj = getExtensions(csn.definitions[serviceName], shortTextObj, stateObj);
|
|
79
79
|
return {
|
|
80
80
|
asyncapi: '2.0.0',
|
|
81
81
|
'x-sap-catalog-spec-version': '1.2',
|
|
82
82
|
'x-sap-application-namespace': applicationNamespace,
|
|
83
83
|
...Object.keys(stateObj).length && { 'x-sap-stateInfo': stateObj },
|
|
84
84
|
...Object.keys(shortTextObj).length && { 'x-sap-shortText': shortTextObj },
|
|
85
|
+
...Object.keys(extensionAnnotationObj).length && extensionAnnotationObj,
|
|
85
86
|
info: infoObject,
|
|
86
87
|
defaultContentType: 'application/json',
|
|
87
88
|
channels: getChannels(csn.definitions, events),
|
|
@@ -89,6 +90,26 @@ function _getAsyncApi(csn, events, serviceName, applicationNamespace, presets) {
|
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
function getExtensions(serviceCsn, shortTextObj, stateObj) {
|
|
94
|
+
let extensionObj = {};
|
|
95
|
+
for (const [key, value] of Object.entries(serviceCsn)) {
|
|
96
|
+
if (key.startsWith('@AsyncAPI.Extensions')) {
|
|
97
|
+
const annotationProperties = key.split('@AsyncAPI.Extensions.')[1];
|
|
98
|
+
const keys = annotationProperties.split('.');
|
|
99
|
+
keys[0] = "x-" + keys[0];
|
|
100
|
+
if ((keys[0] === 'x-sap-shortText' && Object.keys(shortTextObj).length > 0) ||
|
|
101
|
+
(keys[0] === 'x-sap-stateInfo' && Object.keys(stateObj).length > 0)
|
|
102
|
+
) continue;
|
|
103
|
+
if (keys.length === 1) {
|
|
104
|
+
extensionObj[keys[0]] = value;
|
|
105
|
+
} else {
|
|
106
|
+
nestedAnnotation(extensionObj, keys[0], keys, value);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return extensionObj;
|
|
111
|
+
}
|
|
112
|
+
|
|
92
113
|
function getShortText(serviceCsn, presetValue = undefined) {
|
|
93
114
|
let shortTextValue = presetValue || serviceCsn["@AsyncAPI.ShortText"];
|
|
94
115
|
if (shortTextValue) {
|
|
@@ -371,6 +371,7 @@ class Expression {
|
|
|
371
371
|
annotate(prefix = '', target, annotationExpressionResult) {
|
|
372
372
|
let _target = target;
|
|
373
373
|
for (const key of Object.keys(annotationExpressionResult)) {
|
|
374
|
+
if (prefix !== '') prefix = prefix + ".";
|
|
374
375
|
_target[prefix + key] = annotationExpressionResult[key];
|
|
375
376
|
}
|
|
376
377
|
return target;
|
package/lib/init/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
|
|
3
|
-
const MAVEN_ARCHETYPE_VERSION = '2.0.
|
|
3
|
+
const MAVEN_ARCHETYPE_VERSION = '2.0.2';
|
|
4
4
|
|
|
5
5
|
const constants = {
|
|
6
6
|
IS_WIN: (os.platform() === 'win32'),
|
|
@@ -15,6 +15,9 @@ const constants = {
|
|
|
15
15
|
JAVA_MVN: 'java:mvn',
|
|
16
16
|
JAVA_PACKAGE: 'java:package',
|
|
17
17
|
NODEJS: 'nodejs',
|
|
18
|
+
SAMPLES: 'samples', // deprecated
|
|
19
|
+
TINY_SAMPLE: 'tiny-sample',
|
|
20
|
+
SAMPLE: 'sample',
|
|
18
21
|
PIPELINE: 'pipeline',
|
|
19
22
|
MTA: 'mta',
|
|
20
23
|
CONNECTIVITY: 'connectivity',
|
|
@@ -33,11 +36,8 @@ const constants = {
|
|
|
33
36
|
REDIS_MESSAGING: 'redis-messaging',
|
|
34
37
|
APPROUTER: 'approuter',
|
|
35
38
|
DESTINATION: 'destination',
|
|
36
|
-
SAMPLES: 'samples', // deprecated
|
|
37
|
-
TINY_SAMPLE: 'tiny-sample',
|
|
38
|
-
SAMPLE: 'sample',
|
|
39
39
|
DATA: 'data',
|
|
40
|
-
|
|
40
|
+
KIBANA: 'kibana',
|
|
41
41
|
LINT: 'lint',
|
|
42
42
|
LINT_GLOBAL: 'lint:global',
|
|
43
43
|
LINT_DEV: 'lint:dev',
|
package/lib/init/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
|
|
3
3
|
const term = require('../util/term');
|
|
4
4
|
|
|
5
|
-
const { OPTIONS,
|
|
5
|
+
const { OPTIONS, COMMAND_INIT, PROJECT_FILES, REGEX_PROJECT_NAME } = require('./constants')
|
|
6
6
|
const { NODEJS, JAVA, HANA, MTA,PIPELINE, SAMPLES, CF_MANIFEST } = OPTIONS
|
|
7
7
|
|
|
8
8
|
const cds = require('../cds'), { exists, readdir } = cds.utils
|
|
@@ -90,67 +90,56 @@ module.exports = class CDSGenerator {
|
|
|
90
90
|
* @param {string} facets, comma separated list of templates, no blanks
|
|
91
91
|
* @param {any} options, additional options
|
|
92
92
|
*/
|
|
93
|
-
async addCmd(facets
|
|
94
|
-
options._cmd = COMMAND_ADD;
|
|
95
|
-
options.add = facets;
|
|
96
|
-
|
|
93
|
+
async addCmd(facets) {
|
|
97
94
|
if (!facets) throw 'You must specify a facet to add to the project.'
|
|
98
95
|
|
|
99
|
-
this._initialize(null
|
|
100
|
-
this._greetings(
|
|
96
|
+
this._initialize(null);
|
|
97
|
+
this._greetings();
|
|
101
98
|
|
|
102
99
|
if (!PROJECT_FILES.find(exists)) {
|
|
103
|
-
throw
|
|
100
|
+
throw `The current folder doesn't seem to contain a project. None of the following files found: ${PROJECT_FILES.join(', ')}.`
|
|
104
101
|
}
|
|
105
102
|
|
|
106
|
-
await this._process(
|
|
107
|
-
await this.stepEnd(
|
|
103
|
+
await this._process();
|
|
104
|
+
await this.stepEnd();
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
/**
|
|
111
108
|
* @param {string} projectName, the project name
|
|
112
|
-
* @param {any} options, additional options
|
|
113
109
|
*/
|
|
114
|
-
async initCmd(projectName
|
|
115
|
-
await this.stepInit(projectName
|
|
110
|
+
async initCmd(projectName) {
|
|
111
|
+
await this.stepInit(projectName);
|
|
116
112
|
await this.stepEnd();
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
async stepInit(projectName
|
|
120
|
-
options._cmd = COMMAND_INIT;
|
|
115
|
+
async stepInit(projectName) {
|
|
121
116
|
|
|
122
|
-
this._initialize(projectName
|
|
123
|
-
this._greetings(
|
|
117
|
+
this._initialize(projectName);
|
|
118
|
+
this._greetings();
|
|
124
119
|
|
|
125
120
|
await this._process();
|
|
126
121
|
}
|
|
127
122
|
|
|
128
|
-
_initialize(projectName
|
|
129
|
-
|
|
130
|
-
if (options.verbose) {
|
|
131
|
-
LOG.warn(`Parameter 'verbose' is no longer supported. Use environment variable 'DEBUG=true' to obtain detailed output.`);
|
|
132
|
-
}
|
|
133
|
-
|
|
123
|
+
_initialize(projectName) {
|
|
124
|
+
const { options } = cds.cli
|
|
134
125
|
this.cwd = options.cwd || process.cwd();
|
|
135
126
|
cds.root = path.resolve(this.cwd, projectName || '.');
|
|
136
127
|
this.projectName = path.basename(cds.root);
|
|
137
128
|
|
|
138
|
-
this.options = options;
|
|
139
129
|
this._cleanupOptions();
|
|
140
130
|
}
|
|
141
131
|
|
|
142
132
|
_greetings() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
LOG.info(`Creating new CAP project in ${term.bold(folderName)}\n`);
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
133
|
+
if (cds.cli.command === COMMAND_INIT) {
|
|
134
|
+
const relativeProjectPath = path.relative(this.cwd, cds.root)
|
|
135
|
+
const folderName = relativeProjectPath ? `.${path.sep}${relativeProjectPath}` : 'current folder'
|
|
136
|
+
LOG.info(`Creating new CAP project in ${term.bold(folderName)}\n`)
|
|
150
137
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
138
|
+
if (cds.cli.options.for && typeof cds.cli.options.for !== 'string') {
|
|
139
|
+
throw 'The --for argument must not be empty.'
|
|
140
|
+
}
|
|
141
|
+
if (cds.cli.options.force) {
|
|
142
|
+
LOG.info(`Using '--force' ... existing files will be overwritten`)
|
|
154
143
|
}
|
|
155
144
|
}
|
|
156
145
|
|
|
@@ -161,9 +150,9 @@ module.exports = class CDSGenerator {
|
|
|
161
150
|
await this._fillTemplateList();
|
|
162
151
|
|
|
163
152
|
for (const template of this.templateList) {
|
|
164
|
-
|
|
165
|
-
LOG.info(msg);
|
|
153
|
+
LOG.info(`Adding feature '${template.name}'...`);
|
|
166
154
|
await template.run();
|
|
155
|
+
await template.runDependentMerging();
|
|
167
156
|
await template.runRelatedMerging();
|
|
168
157
|
}
|
|
169
158
|
|
|
@@ -176,9 +165,6 @@ module.exports = class CDSGenerator {
|
|
|
176
165
|
}
|
|
177
166
|
|
|
178
167
|
async _createTemplate(filename) {
|
|
179
|
-
// Compat
|
|
180
|
-
if (filename === 'sample-tiny') filename = 'tiny-sample'
|
|
181
|
-
|
|
182
168
|
try {
|
|
183
169
|
const TemplateClass = require(`./template/${filename}`);
|
|
184
170
|
return new TemplateClass(this);
|
|
@@ -201,27 +187,30 @@ module.exports = class CDSGenerator {
|
|
|
201
187
|
}
|
|
202
188
|
|
|
203
189
|
async _fillTemplateList() {
|
|
204
|
-
const templates = new Map
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const template = await this._createTemplate(option);
|
|
190
|
+
const templates = new Map
|
|
191
|
+
const { command, options, argv } = cds.cli
|
|
192
|
+
const facets = command === COMMAND_INIT ? options.add : new Set(argv[0].split(','))
|
|
208
193
|
|
|
209
|
-
|
|
210
|
-
|
|
194
|
+
for (let facet of facets) {
|
|
195
|
+
// Compat
|
|
196
|
+
if (facet === 'sample-tiny') facet = 'tiny-sample'
|
|
197
|
+
if (facet === 'kibana-logging') facet = 'kibana'
|
|
211
198
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
199
|
+
if (!templates.has(facet)) {
|
|
200
|
+
const template = await this._createTemplate(facet)
|
|
201
|
+
if (await template.canRun()) {
|
|
202
|
+
DEBUG?.(`Adding feature '${template.name}'`)
|
|
203
|
+
templates.set(facet, template)
|
|
204
|
+
const dependencies = await template.getDependencies()
|
|
205
|
+
dependencies?.forEach(d => facets.add(d))
|
|
217
206
|
}
|
|
218
207
|
}
|
|
219
208
|
}
|
|
220
209
|
|
|
221
|
-
const cmds = Object.values(OPTIONS)
|
|
222
|
-
this.templateList = Array.from(templates.entries())
|
|
223
|
-
|
|
224
|
-
|
|
210
|
+
const cmds = Object.values(OPTIONS)
|
|
211
|
+
this.templateList = Array.from(templates.entries())
|
|
212
|
+
.sort(([a], [b]) => cmds.indexOf(a) - cmds.indexOf(b))
|
|
213
|
+
.map((entry) => entry[1])
|
|
225
214
|
|
|
226
215
|
// check debug to avoid lengthy computation when not in debug mode
|
|
227
216
|
DEBUG?.(`Features: ${this.templateList.map(({name}) => name).join(', ')}`);
|
|
@@ -236,56 +225,59 @@ module.exports = class CDSGenerator {
|
|
|
236
225
|
_cleanupOptions() {
|
|
237
226
|
let tokens = [];
|
|
238
227
|
|
|
239
|
-
|
|
240
|
-
|
|
228
|
+
const { options } = cds.cli
|
|
229
|
+
if (typeof options.add === 'string') {
|
|
230
|
+
tokens = options.add.split(/[,\s+]/g);
|
|
241
231
|
|
|
242
|
-
} else if (Array.isArray(
|
|
243
|
-
tokens =
|
|
232
|
+
} else if (Array.isArray(options.add)) {
|
|
233
|
+
tokens = options.add
|
|
244
234
|
|
|
245
|
-
} else if (
|
|
246
|
-
tokens = [...
|
|
235
|
+
} else if (options.add instanceof Set) {
|
|
236
|
+
tokens = [...options.add];
|
|
247
237
|
}
|
|
248
238
|
|
|
249
239
|
const trimmedTokens = tokens.map((token) => {
|
|
250
240
|
token = token.replace(/\s+/g, '');
|
|
251
241
|
const tokens = token.split(':'), [facet] = tokens
|
|
252
242
|
if (tokens.length > 1) {
|
|
253
|
-
if (
|
|
254
|
-
|
|
243
|
+
if (options[facet]) {
|
|
244
|
+
options[facet].add(token);
|
|
255
245
|
} else {
|
|
256
|
-
|
|
246
|
+
options[facet] = new Set([token]);
|
|
257
247
|
}
|
|
258
248
|
}
|
|
259
249
|
return facet;
|
|
260
250
|
}).filter(Boolean);
|
|
261
251
|
|
|
262
252
|
// set is ordered ... always
|
|
263
|
-
|
|
253
|
+
options.add = new Set(trimmedTokens);
|
|
264
254
|
|
|
265
|
-
if (
|
|
266
|
-
|
|
255
|
+
if (cds.cli.command === COMMAND_INIT && !options.add.has(JAVA)) {
|
|
256
|
+
options.add.add(NODEJS);
|
|
267
257
|
}
|
|
268
258
|
|
|
269
259
|
this._checkAdditionalOptions();
|
|
270
260
|
}
|
|
271
261
|
|
|
272
262
|
_checkAdditionalOptions() {
|
|
273
|
-
|
|
274
|
-
|
|
263
|
+
const { options } = cds.cli
|
|
264
|
+
for (const [key] of Object.entries(options)) {
|
|
265
|
+
const keySplit = key.split(/:/)
|
|
275
266
|
if (keySplit.length === 2) {
|
|
276
|
-
if (!
|
|
277
|
-
|
|
267
|
+
if (!options.add.has(keySplit[0])) {
|
|
268
|
+
console.log(`ignoring option ${key} since ${keySplit[0]} is not part of specified feature list: ${Array.from(options.add).join(', ')}`)
|
|
278
269
|
}
|
|
279
270
|
}
|
|
280
271
|
}
|
|
281
272
|
}
|
|
282
273
|
|
|
283
274
|
async _validateOptions() {
|
|
284
|
-
|
|
275
|
+
const { options, command } = cds.cli
|
|
276
|
+
if (options.force) {
|
|
285
277
|
return;
|
|
286
278
|
}
|
|
287
279
|
|
|
288
|
-
if (
|
|
280
|
+
if (command === COMMAND_INIT) {
|
|
289
281
|
await this._validateProjectName(this.projectName);
|
|
290
282
|
await this._validateProjectFolder(this.cwd);
|
|
291
283
|
}
|
|
@@ -293,7 +285,7 @@ module.exports = class CDSGenerator {
|
|
|
293
285
|
|
|
294
286
|
async _validateProjectName(projectName) {
|
|
295
287
|
if (!projectName) {
|
|
296
|
-
throw
|
|
288
|
+
throw 'Specify a project name.'
|
|
297
289
|
}
|
|
298
290
|
|
|
299
291
|
// remove duplicates by using a set
|
|
@@ -302,9 +294,9 @@ module.exports = class CDSGenerator {
|
|
|
302
294
|
case 0:
|
|
303
295
|
break;
|
|
304
296
|
case 1:
|
|
305
|
-
throw
|
|
297
|
+
throw `Project name ${projectName} contains an invalid character (${[...invalidChars].join(', ')}). Specify a different project name.`
|
|
306
298
|
default:
|
|
307
|
-
throw
|
|
299
|
+
throw `Project name ${projectName} contains invalid characters (${[...invalidChars].join(', ')}). Specify a different project name.`
|
|
308
300
|
}
|
|
309
301
|
}
|
|
310
302
|
|
|
@@ -317,7 +309,7 @@ module.exports = class CDSGenerator {
|
|
|
317
309
|
} else {
|
|
318
310
|
message = `You seem to be trying to initialize an existing project. Use a different project name instead.`;
|
|
319
311
|
}
|
|
320
|
-
throw
|
|
312
|
+
throw `${message}\nDetails: File '${existingProjectFile}' exists in the project folder which indicates an existing project. Use ${term.bold('cds add')} to add more features.`
|
|
321
313
|
}
|
|
322
314
|
}
|
|
323
315
|
}
|
|
@@ -93,7 +93,7 @@ const enterpriseMessaging = {
|
|
|
93
93
|
}]
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
const
|
|
96
|
+
const kibana = {
|
|
97
97
|
in: 'resources',
|
|
98
98
|
where: [{
|
|
99
99
|
property: 'type',
|
|
@@ -278,6 +278,6 @@ module.exports = {
|
|
|
278
278
|
requiredAppApi4,
|
|
279
279
|
providedJavaApprouterApi4,
|
|
280
280
|
providedJavaApprouterApi,
|
|
281
|
-
|
|
281
|
+
kibana,
|
|
282
282
|
approuterExtensibility
|
|
283
283
|
}
|
|
@@ -3,7 +3,7 @@ const { exists } = cds.utils
|
|
|
3
3
|
const { join } = require('path')
|
|
4
4
|
const { readProject } = require('../../util/projectReader')
|
|
5
5
|
const { mergeJSON, mergeYAML, sort } = require('../../util/merge')
|
|
6
|
-
const { XSUAA } = require('../../constants').OPTIONS
|
|
6
|
+
const { XSUAA, KIBANA } = require('../../constants').OPTIONS
|
|
7
7
|
const {
|
|
8
8
|
srvNode4, srvJava4, mtxSidecar4, approuter, // Modules
|
|
9
9
|
xsuaa, // BTP Services
|
|
@@ -23,18 +23,21 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
23
23
|
return [XSUAA]
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
getRelatedFacets() {
|
|
27
|
+
return [KIBANA]
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
async run() {
|
|
27
|
-
const { appPath = 'app' } = await readProject(
|
|
31
|
+
const { appPath = 'app' } = await readProject()
|
|
28
32
|
const appPackageJSONPath = join(appPath, 'package.json')
|
|
29
33
|
await mergeJSON(appPackageJSONPath, join(__dirname, 'files', 'package.json'))
|
|
30
34
|
await sort(appPackageJSONPath, 'dependencies')
|
|
31
35
|
await mergeJSON(join(appPath, 'default-env.json'), join(__dirname, 'files', 'default-env.json'))
|
|
32
|
-
await this.runDependentMerging()
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
async runDependentMerging(context = {}) {
|
|
36
|
-
const project = await readProject(
|
|
37
|
-
const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath } = project
|
|
39
|
+
const project = await readProject()
|
|
40
|
+
const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath, appPath } = project
|
|
38
41
|
|
|
39
42
|
if (hasMta) {
|
|
40
43
|
const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
|
|
@@ -72,7 +75,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
72
75
|
|
|
73
76
|
// add dependency entry in chart.yaml
|
|
74
77
|
const HelmTemplate = require(`../helm`);
|
|
75
|
-
const helmTemplate = new HelmTemplate(
|
|
78
|
+
const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
|
|
76
79
|
await helmTemplate.addDependency('web-application', 'approuter');
|
|
77
80
|
|
|
78
81
|
await mergeYAML(
|
|
@@ -113,7 +116,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
113
116
|
if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
const xsAppPath = join(
|
|
119
|
+
const xsAppPath = join(appPath, 'xs-app.json')
|
|
117
120
|
const additions = isExtensible ? [{ ...approuterExtensibility, at: 0 }] : []
|
|
118
121
|
await mergeJSON(xsAppPath, join(__dirname, 'files', 'xs-app.json.hbs'), project, { additions })
|
|
119
122
|
}
|
|
@@ -13,15 +13,14 @@ module.exports = class AuditlogTemplate extends require('../templateBase') {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async run() {
|
|
16
|
-
const project = await readProject(
|
|
16
|
+
const project = await readProject()
|
|
17
17
|
const { configFile } = project
|
|
18
18
|
project.shortcut = !(await read(configFile)).cds?.requires?.['audit-log']?.kind
|
|
19
19
|
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
20
|
-
await this.runDependentMerging()
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
async runDependentMerging(context = {}) {
|
|
24
|
-
const project = await readProject(
|
|
23
|
+
const project = await readProject()
|
|
25
24
|
const { isNodejs, hasMta, hasHelm, srvPath } = project
|
|
26
25
|
|
|
27
26
|
if (hasMta) {
|
|
@@ -63,7 +62,7 @@ module.exports = class AuditlogTemplate extends require('../templateBase') {
|
|
|
63
62
|
|
|
64
63
|
// copy service instance chart if it is not present
|
|
65
64
|
const HelmTemplate = require(`../helm`);
|
|
66
|
-
const helmTemplate = new HelmTemplate(
|
|
65
|
+
const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
|
|
67
66
|
isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
|
|
68
67
|
|
|
69
68
|
// add dependency entry in chart.yaml
|
|
@@ -7,7 +7,7 @@ applications:
|
|
|
7
7
|
# -----------------------------------------------------------------------------------
|
|
8
8
|
# Backend Service
|
|
9
9
|
# -----------------------------------------------------------------------------------
|
|
10
|
-
- name: {{appName}}-
|
|
10
|
+
- name: {{appName}}-srv
|
|
11
11
|
random-route: true # for development only
|
|
12
12
|
{{#isNodejs}}
|
|
13
13
|
path: {{& srvPath}}
|
|
@@ -15,42 +15,34 @@ applications:
|
|
|
15
15
|
buildpack: nodejs_buildpack
|
|
16
16
|
{{/isNodejs}}
|
|
17
17
|
{{#isJava}}
|
|
18
|
-
path: {{& srvPath}}/target/{{
|
|
18
|
+
path: {{& srvPath}}/target/{{archiveName}}
|
|
19
19
|
memory: 1G
|
|
20
20
|
disk_quota: 512M
|
|
21
21
|
env:
|
|
22
22
|
SPRING_PROFILES_ACTIVE: cloud
|
|
23
23
|
buildpack: java_buildpack
|
|
24
24
|
{{/isJava}}
|
|
25
|
-
{{#hasRequires}}
|
|
26
25
|
services:
|
|
27
|
-
{{#
|
|
28
|
-
{{
|
|
29
|
-
|
|
30
|
-
{{
|
|
31
|
-
{{
|
|
32
|
-
|
|
33
|
-
{{/resource.isXsuaa}}
|
|
34
|
-
{{/requires}}
|
|
35
|
-
{{/hasRequires}}
|
|
26
|
+
{{#hasHana}}
|
|
27
|
+
- {{appName}}-db
|
|
28
|
+
{{/hasHana}}
|
|
29
|
+
{{#hasXsuaa}}
|
|
30
|
+
- {{appNames}}-auth
|
|
31
|
+
{{/hasXsuaa}}
|
|
36
32
|
|
|
37
|
-
{{#
|
|
33
|
+
{{#hasHana}}
|
|
34
|
+
{{^isMultitenant}}
|
|
38
35
|
# -----------------------------------------------------------------------------------
|
|
39
36
|
# HANA Database Content Deployer App
|
|
40
37
|
# -----------------------------------------------------------------------------------
|
|
41
|
-
- name: {{appName}}-{{db.
|
|
42
|
-
path: {{& db.
|
|
38
|
+
- name: {{appName}}-{{db.name}}-deployer
|
|
39
|
+
path: {{& db.path}}
|
|
43
40
|
no-route: true
|
|
44
41
|
health-check-type: process
|
|
45
42
|
memory: 256M
|
|
46
43
|
instances: 1
|
|
47
44
|
buildpack: nodejs_buildpack
|
|
48
|
-
{{#hasRequires}}
|
|
49
45
|
services:
|
|
50
|
-
{{
|
|
51
|
-
{{
|
|
52
|
-
|
|
53
|
-
{{/resource.isHana}}
|
|
54
|
-
{{/requires}}
|
|
55
|
-
{{/hasRequires}}
|
|
56
|
-
{{/needsSidecar}}
|
|
46
|
+
- {{appName}}-db
|
|
47
|
+
{{/isMultitenant}}
|
|
48
|
+
{{/hasHana}}
|
|
@@ -2,21 +2,26 @@
|
|
|
2
2
|
# appName = {{appName}}
|
|
3
3
|
---
|
|
4
4
|
create-services:
|
|
5
|
-
{{#
|
|
6
|
-
#
|
|
7
|
-
- name:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
{{#hasHana}}
|
|
6
|
+
{{#isMultitenant}}
|
|
7
|
+
- name: {{appName}}-db
|
|
8
|
+
broker: service-manager
|
|
9
|
+
plan: container
|
|
10
|
+
{{/isMultitenant}}
|
|
11
|
+
{{^isMultitenant}}
|
|
12
|
+
- name: {{appName}}-db
|
|
13
|
+
broker: hana
|
|
14
|
+
plan: hdi-shared
|
|
15
|
+
{{/isMultitenant}}
|
|
16
|
+
{{/hasHana}}
|
|
17
|
+
{{#hasXsuaa}}
|
|
18
|
+
- name: {{appName}}-auth
|
|
19
|
+
broker: xsuaa
|
|
16
20
|
plan: application
|
|
17
|
-
|
|
18
|
-
{{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
parameters: xs-security.json
|
|
22
|
+
{{/hasXsuaa}}
|
|
23
|
+
{{#hasAuditlog}}
|
|
24
|
+
- name: {{appName}}-auditlog
|
|
25
|
+
broker: auditlog
|
|
26
|
+
plan: application
|
|
27
|
+
{{/hasAuditlog}}
|
|
@@ -9,17 +9,17 @@ const SERVICES_MANIFEST_FILE = 'services-manifest.yml'
|
|
|
9
9
|
module.exports = class CfManifestTemplate extends require('../templateBase') {
|
|
10
10
|
|
|
11
11
|
async canRun() {
|
|
12
|
-
if (
|
|
13
|
-
return true
|
|
12
|
+
if (cds.cli.options.force) {
|
|
13
|
+
return true
|
|
14
14
|
}
|
|
15
15
|
if (exists(MANIFEST_FILE) || exists(SERVICES_MANIFEST_FILE)) {
|
|
16
|
-
throw
|
|
16
|
+
throw `File ${MANIFEST_FILE} or ${SERVICES_MANIFEST_FILE} already exist in current folder. Use --force to overwrite.`
|
|
17
17
|
}
|
|
18
|
-
return true
|
|
18
|
+
return true
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async run() {
|
|
22
22
|
const project = await readProject()
|
|
23
|
-
await copyFiles(join(__dirname, 'files'), cds.root, project,
|
|
23
|
+
await copyFiles(join(__dirname, 'files'), cds.root, project, true)
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -11,14 +11,13 @@ module.exports = class ConnectivityTemplate extends require('../templateBase') {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async run() {
|
|
14
|
-
const project = await readProject(
|
|
14
|
+
const project = await readProject()
|
|
15
15
|
const { configFile } = project
|
|
16
16
|
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
17
|
-
await this.runDependentMerging()
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
async runDependentMerging(context = {}) {
|
|
21
|
-
const project = await readProject(
|
|
20
|
+
const project = await readProject()
|
|
22
21
|
const { isJava, srvPath, hasHelm, hasMta } = project
|
|
23
22
|
|
|
24
23
|
if (hasMta) {
|
|
@@ -8,19 +8,19 @@ const DEBUG = cds.debug('cli')
|
|
|
8
8
|
module.exports = class DataTemplate extends require('../templateBase') {
|
|
9
9
|
|
|
10
10
|
async run() {
|
|
11
|
-
if (
|
|
11
|
+
if (cds.cli.options.for) {
|
|
12
12
|
throw `\nError: Did you mean \`... --data:for\` ?`
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const env = await this.getEnv();
|
|
16
16
|
|
|
17
|
-
let dest = (typeof
|
|
18
|
-
?
|
|
17
|
+
let dest = (typeof cds.cli.options.out === 'string') // target folder
|
|
18
|
+
? cds.cli.options.out
|
|
19
19
|
: getDefaultTargetFolder(env);
|
|
20
20
|
dest = resolve(cds.root, dest);
|
|
21
21
|
|
|
22
|
-
const nameFilter = asRegex(
|
|
23
|
-
const force =
|
|
22
|
+
const nameFilter = asRegex(cds.cli.options['data:for'])
|
|
23
|
+
const { force } = cds.cli.options
|
|
24
24
|
|
|
25
25
|
let csn = await cds.compile.to.csn(cds.env.roots) // normal CSN
|
|
26
26
|
|
|
@@ -63,7 +63,7 @@ function asRegex(spec) {
|
|
|
63
63
|
return new RegExp('^'+spec+'.*')
|
|
64
64
|
}
|
|
65
65
|
} catch (err) {
|
|
66
|
-
throw
|
|
66
|
+
throw err.message // user error, so cut off stack trace
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
return /.*/
|