@sap/cds-dk 6.2.3 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/bin/bind.js +4 -4
- package/bin/deploy/to-h2.js +4 -0
- package/bin/deploy/to-sqlite.js +6 -4
- package/bin/help.js +1 -1
- package/bin/login.js +1 -0
- package/bin/push.js +29 -7
- package/lib/bind/userCdsrcJsonStorageProvider.js +4 -4
- package/lib/client/activate.js +1 -1
- package/lib/client/base_command.js +10 -10
- package/lib/client/helper/dependency_helper.js +10 -1
- package/lib/client/helper/logging.js +6 -2
- package/lib/client/pull.js +6 -6
- package/lib/client/push.js +33 -14
- package/lib/client/settings_manager.js +52 -21
- package/lib/compile/openapi/csdl2openapi.js +1 -1
- package/lib/compile/to-xsuaa.js +1 -1
- package/lib/import/odata/v2parser.js +37 -1
- package/lib/import/odata/v4parser.js +101 -23
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +23 -45
- package/lib/init/template/approuter/index.js +44 -48
- package/lib/init/template/auditlog/index.js +14 -10
- package/lib/init/template/cf-manifest/index.js +9 -11
- package/lib/init/template/connectivity/index.js +10 -10
- package/lib/init/template/data/index.js +20 -19
- package/lib/init/template/destinations/index.js +14 -9
- package/lib/init/template/enterprise-messaging/index.js +14 -9
- package/lib/init/template/extensibility/index.js +14 -9
- package/lib/init/template/hana/index.js +51 -57
- package/lib/init/template/helm/index.js +27 -59
- package/lib/init/template/helm/subchart/templates/_helpers.tpl +38 -0
- package/lib/init/template/helm/subchart/templates/deployment.yaml +12 -12
- package/lib/init/template/helm/subchart/values.md +565 -194
- package/lib/init/template/helm/subchart/values.schema.json +163 -8
- package/lib/init/template/helm/subchart/values.yaml +17 -1
- package/lib/init/template/html5-repo/index.js +15 -11
- package/lib/init/template/java/index.js +15 -11
- package/lib/init/template/kibana-logging/index.js +30 -31
- package/lib/init/template/lint/index.js +17 -18
- package/lib/init/template/mta/index.js +18 -40
- package/lib/init/template/mtx/index.js +2 -3
- package/lib/init/template/multitenancy/index.js +27 -20
- package/lib/init/template/nodejs/index.js +18 -20
- package/lib/init/template/notebook/index.js +5 -434
- package/lib/init/template/pipeline/index.js +10 -10
- package/lib/init/template/samples/index.js +7 -16
- package/lib/init/template/templateBase.js +17 -18
- package/lib/init/template/toggles/files/cdsrc.json +5 -0
- package/lib/init/template/toggles/files/cdsrc.json.hbs +7 -0
- package/lib/init/template/toggles/index.js +12 -6
- package/lib/init/template/xsuaa/index.js +44 -41
- package/lib/init/types.d.ts +0 -59
- package/lib/init/util/commandUtil.js +6 -7
- package/lib/init/util/fsUtil.js +23 -109
- package/lib/init/util/merge.js +319 -0
- package/lib/init/util/mvnArchetypeUtil.js +6 -5
- package/lib/init/util/projectReader.js +125 -300
- package/lib/init/util/spinner.js +10 -8
- package/lib/init/util/templateUtil.js +25 -368
- package/lib/lint/Linter.js +2 -3
- package/lib/lint/checks.js +0 -1
- package/lib/lint/io.js +18 -34
- package/npm-shrinkwrap.json +102 -239
- package/package.json +3 -3
- package/lib/init/template/notebook/cap_magic.py +0 -118
- package/lib/init/template/notebook/files/{{{name}}}.ipynb.hbs +0 -90
- package/lib/init/template/notebook/files/{{{name}}}.json +0 -102
- package/lib/init/template/notebook/notebook.js +0 -394
- package/lib/init/util/logger.js +0 -42
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { Parser } = require('htmlparser2');
|
|
3
|
-
const codeTypes = ['language-sh', 'language-bash', 'language-js', 'language-javascript', 'language-swift', 'language-sql'];
|
|
4
|
-
const codeStartTags = ['%%writefile ', '!'];
|
|
5
|
-
const displays = { 'welcome': "<iframe src='http://localhost:4004' width=1000 height=600 style='background-color:white'></iframe>" }
|
|
6
|
-
let baseURL;
|
|
7
|
-
let route;
|
|
8
|
-
|
|
9
|
-
function tag2Element(tag, attribs) {
|
|
10
|
-
const element = {};
|
|
11
|
-
if (attribs) {
|
|
12
|
-
if (attribs.href) {
|
|
13
|
-
const routes = route.split('/');
|
|
14
|
-
routes.pop();
|
|
15
|
-
const routeDot = routes.join('/');
|
|
16
|
-
routes.pop();
|
|
17
|
-
const routeDots = routes.join('/');
|
|
18
|
-
element.href = attribs.href.replace(/^\.\./g, `${baseURL}${routeDots}`)
|
|
19
|
-
.replace(/^\./g, `${baseURL}${routeDot}`)
|
|
20
|
-
.replace(/^#/g, `${baseURL}${route}#`)
|
|
21
|
-
.replace(/^\/pages\/cap/g, `${baseURL}/docs`)
|
|
22
|
-
.replace(/^\/cap/g, `${baseURL}/docs`)
|
|
23
|
-
.replace(/^\/docs/g, `${baseURL}/docs`);
|
|
24
|
-
}
|
|
25
|
-
if (attribs.src) {
|
|
26
|
-
const routes = route.split('/');
|
|
27
|
-
routes.pop();
|
|
28
|
-
const routeDot = routes.join('/');
|
|
29
|
-
routes.pop();
|
|
30
|
-
const routeDots = routes.join('/');
|
|
31
|
-
element.src = attribs.src.replace(/^\.\./g, `${baseURL}${routeDots}`)
|
|
32
|
-
.replace(/^\./g, `${baseURL}${routeDot}`)
|
|
33
|
-
.replace(/^#/g, `${baseURL}${route}#`)
|
|
34
|
-
.replace(/^\/pages\/cap/g, `${baseURL}/docs`)
|
|
35
|
-
.replace(/^\/cap/g, `${baseURL}/docs`)
|
|
36
|
-
.replace(/^\/docs/g, `${baseURL}/docs`);
|
|
37
|
-
}
|
|
38
|
-
if (attribs.class) {
|
|
39
|
-
element.class = attribs.class;
|
|
40
|
-
}
|
|
41
|
-
if (attribs.id) {
|
|
42
|
-
element.id = attribs.id;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (tag) {
|
|
46
|
-
element.tag = tag;
|
|
47
|
-
}
|
|
48
|
-
return element;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function tags2Markdown(tag, element) {
|
|
52
|
-
let mdTags = ['', ''];
|
|
53
|
-
let mdType = 'markdown';
|
|
54
|
-
switch (tag) {
|
|
55
|
-
case 'a':
|
|
56
|
-
if (element.class && element.class.includes('learn-more')) {
|
|
57
|
-
mdTags = ['\n ⮡ [', `](${element.href})\n\n`];
|
|
58
|
-
} else {
|
|
59
|
-
mdTags = ['[', `](${element.href})`];
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
case 'blockquote':
|
|
63
|
-
mdTags = ['\n> ', '\n'];
|
|
64
|
-
break;
|
|
65
|
-
case 'br':
|
|
66
|
-
mdTags = ['', '\n\n'];
|
|
67
|
-
break;
|
|
68
|
-
case 'code':
|
|
69
|
-
mdType = 'markdown';
|
|
70
|
-
if (element.class) {
|
|
71
|
-
if (element.class.includes('language-plaintext')) {
|
|
72
|
-
mdTags = ['`', '`'];
|
|
73
|
-
mdType = 'markdown';
|
|
74
|
-
} else {
|
|
75
|
-
mdType = 'code';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case 'del':
|
|
80
|
-
mdTags = ['~~', '~~'];
|
|
81
|
-
break;
|
|
82
|
-
case 'div':
|
|
83
|
-
if (element.class) {
|
|
84
|
-
if (codeTypes.some(codeType => element.class.includes(codeType))) {
|
|
85
|
-
mdType = 'code';
|
|
86
|
-
if (element.class.includes('language-sh') ||
|
|
87
|
-
element.class.includes('language-bash')) {
|
|
88
|
-
mdTags = ['!', ''];
|
|
89
|
-
}
|
|
90
|
-
} else if (element.class.includes('language-json')) {
|
|
91
|
-
mdTags = ['```json', '```'];
|
|
92
|
-
mdType = 'markdown';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
case 'em':
|
|
97
|
-
mdTags = ['*', '*'];
|
|
98
|
-
break;
|
|
99
|
-
case 'h1':
|
|
100
|
-
mdTags = ['\n# ', '\n'];
|
|
101
|
-
break;
|
|
102
|
-
case 'h2':
|
|
103
|
-
if (element.id) {
|
|
104
|
-
mdTags = ['## ', `<a id="${element.id}"></a>\n`];
|
|
105
|
-
} else {
|
|
106
|
-
mdTags = ['## ', `\n`];
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
case 'h3':
|
|
110
|
-
mdTags = ['### ', '\n'];
|
|
111
|
-
break;
|
|
112
|
-
case 'h4':
|
|
113
|
-
mdTags = ['#### ', '\n'];
|
|
114
|
-
break;
|
|
115
|
-
case 'h5':
|
|
116
|
-
mdTags = ['##### ', '\n'];
|
|
117
|
-
break;
|
|
118
|
-
case 'h6':
|
|
119
|
-
mdTags = ['###### ', '\n'];
|
|
120
|
-
break;
|
|
121
|
-
case 'hr':
|
|
122
|
-
mdTags = ['---', '\n'];
|
|
123
|
-
break;
|
|
124
|
-
case 'iframe':
|
|
125
|
-
mdType = 'code';
|
|
126
|
-
mdTags = [`%%html\n<iframe src=${element.src} width=1000 height=600 style="background-color:white"></iframe>`, '\n'];
|
|
127
|
-
break;
|
|
128
|
-
case 'img':
|
|
129
|
-
mdTags = ['!', `[IMAGE](${element.src})\n`];
|
|
130
|
-
break;
|
|
131
|
-
case 'li':
|
|
132
|
-
mdTags = ['\n- ', '\n'];
|
|
133
|
-
break;
|
|
134
|
-
case 'p':
|
|
135
|
-
if (element.class === 'subtitle') {
|
|
136
|
-
mdTags = ['## ', '\n'];
|
|
137
|
-
} else if (element.class === 'sample-label') {
|
|
138
|
-
mdTags = ['%%writefile ', '\n'];
|
|
139
|
-
} else {
|
|
140
|
-
mdTags = ['', '\n'];
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
143
|
-
case 'pre':
|
|
144
|
-
if (element.class) {
|
|
145
|
-
if (element.class.includes('log')) {
|
|
146
|
-
mdTags = ['<pre><code>', '</pre></code>\n'];
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
mdTags = ['<pre>', '</pre>\n'];
|
|
150
|
-
}
|
|
151
|
-
break;
|
|
152
|
-
case 'strong':
|
|
153
|
-
mdTags = ['**', '**'];
|
|
154
|
-
break;
|
|
155
|
-
case 'style':
|
|
156
|
-
mdTags = ['<style>', '</style>\n'];
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
return { tags: mdTags, type: mdType };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function checkHtmlComments(comment, inContent, inExclusion, showHtml) {
|
|
165
|
-
comment = comment.trim();
|
|
166
|
-
if (['CONTENT START'].includes(comment)) {
|
|
167
|
-
inContent = true;
|
|
168
|
-
} else if (inContent && ['CONTENT END'].includes(comment)) {
|
|
169
|
-
inContent = false;
|
|
170
|
-
} else if (inContent && ['EXCLUDE IN NOTEBOOK START'].includes(comment)) {
|
|
171
|
-
inExclusion = true;
|
|
172
|
-
} else if (inContent && inExclusion && ['EXCLUDE IN NOTEBOOK END'].includes(comment)) {
|
|
173
|
-
inExclusion = false;
|
|
174
|
-
} else if (inContent && !inExclusion && ['INCLUDE IN NOTEBOOK [welcome]'].includes(comment)) {
|
|
175
|
-
const name = comment.split('INCLUDE IN NOTEBOOK [')[1].split(']')[0].trim();
|
|
176
|
-
showHtml = displays[name];
|
|
177
|
-
}
|
|
178
|
-
return { inContent: inContent, inExclusion: inExclusion, showHtml };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
module.exports = class Notebook {
|
|
182
|
-
constructor(args) {
|
|
183
|
-
this.name = args.name;
|
|
184
|
-
this.nb = args.nb;
|
|
185
|
-
this.html = args.html;
|
|
186
|
-
baseURL = args.url;
|
|
187
|
-
route = args.route;
|
|
188
|
-
this.cells = [];
|
|
189
|
-
return this.html2Notebook();
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Adjust capire content to notebook flow
|
|
193
|
-
sanitizeNotebook(content, type) {
|
|
194
|
-
if (content.includes('%%writefile ')) {
|
|
195
|
-
content = content.split(']')[0].replace('[', '"') + '"';
|
|
196
|
-
}
|
|
197
|
-
if (content.includes('!cds init ')) {
|
|
198
|
-
content = '';
|
|
199
|
-
}
|
|
200
|
-
if (content.includes('cf push ')) {
|
|
201
|
-
content = content.replace('cf push ', '!cf push ');
|
|
202
|
-
}
|
|
203
|
-
if (content.includes('!cds watch ')) {
|
|
204
|
-
content = '!cds watch';
|
|
205
|
-
}
|
|
206
|
-
if (content.includes('create a project with minimal defaults as follows:')) {
|
|
207
|
-
content = ', `cds init` has already created a project with minimal defaults for us.'
|
|
208
|
-
}
|
|
209
|
-
if (content.includes('%%writefile "db/data/sap.capire.bookshop-Books.csv"')) {
|
|
210
|
-
this.openCell('code', '%cd db\n%mkdir data\n%cd ..');
|
|
211
|
-
}
|
|
212
|
-
if (content.includes('> ') && !content.includes('> filling') && type === 'markdown') {
|
|
213
|
-
content = content.replace(/[\s]+>[\s\n]+/, '> ');
|
|
214
|
-
}
|
|
215
|
-
return content;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Convert capire html to notebook
|
|
219
|
-
html2Notebook() {
|
|
220
|
-
let md = '';
|
|
221
|
-
const mdArray = [];
|
|
222
|
-
const tagsActive = []
|
|
223
|
-
const typesActive = [];
|
|
224
|
-
let inContent = false;
|
|
225
|
-
let inExclusion = false;
|
|
226
|
-
let showHtml;
|
|
227
|
-
let markAsCode = false;
|
|
228
|
-
let element = { tags: [] };
|
|
229
|
-
const parser = new Parser({
|
|
230
|
-
oncomment(comment) {
|
|
231
|
-
const commentChecks = checkHtmlComments(comment, inContent, inExclusion, showHtml);
|
|
232
|
-
inContent = commentChecks.inContent;
|
|
233
|
-
inExclusion = commentChecks.inExclusion;
|
|
234
|
-
showHtml = commentChecks.showHtml;
|
|
235
|
-
},
|
|
236
|
-
onopentag(name, attribs) {
|
|
237
|
-
if (inContent && !inExclusion) {
|
|
238
|
-
element = tag2Element(name, attribs);
|
|
239
|
-
const mdResults = tags2Markdown(name, element);
|
|
240
|
-
if (markAsCode) {
|
|
241
|
-
mdResults.type = 'code';
|
|
242
|
-
}
|
|
243
|
-
// Mark start of code block
|
|
244
|
-
if (codeStartTags.some(codeTag => md.includes(codeTag))) {
|
|
245
|
-
if (!mdResults.tags[1].includes('[IMAGE]')) {
|
|
246
|
-
markAsCode = true;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// Start markdown element
|
|
250
|
-
if (mdArray.length > 0 && !markAsCode) {
|
|
251
|
-
if (mdArray[mdArray.length - 1].type !== mdResults.type && mdResults.type === 'code') {
|
|
252
|
-
mdArray[mdArray.length - 1].text += md;
|
|
253
|
-
md = '';
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
md += mdResults.tags[0];
|
|
257
|
-
// Store info for closing tag
|
|
258
|
-
tagsActive.push(mdResults.tags);
|
|
259
|
-
typesActive.push(mdResults.type);
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
ontext(text) {
|
|
263
|
-
if (text) {
|
|
264
|
-
if (inContent && !inExclusion) {
|
|
265
|
-
if (element) {
|
|
266
|
-
md += text;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
onclosetag() {
|
|
272
|
-
if (inContent && !inExclusion) {
|
|
273
|
-
if (tagsActive.length > 0) {
|
|
274
|
-
// End markdown element
|
|
275
|
-
md += tagsActive[tagsActive.length - 1][1];
|
|
276
|
-
tagsActive.pop();
|
|
277
|
-
typesActive.pop();
|
|
278
|
-
if (md) {
|
|
279
|
-
const type = typesActive[typesActive.length - 1];
|
|
280
|
-
if (type === 'code' || markAsCode) {
|
|
281
|
-
// Mark end of code block
|
|
282
|
-
if (type === 'code' && markAsCode) {
|
|
283
|
-
markAsCode = false;
|
|
284
|
-
}
|
|
285
|
-
md = md.replace(/>/g, '>').replace(/</g, '<');
|
|
286
|
-
mdArray.push({ text: md, type: 'code' });
|
|
287
|
-
} else {
|
|
288
|
-
md = md.replace(/\$/g, '\\$');
|
|
289
|
-
mdArray.push({ text: md, type: 'markdown' });
|
|
290
|
-
}
|
|
291
|
-
md = '';
|
|
292
|
-
}
|
|
293
|
-
if (showHtml) {
|
|
294
|
-
mdArray.push({ text: '%%html\n' + showHtml, type: 'code' });
|
|
295
|
-
showHtml = '';
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
element = {};
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
parser.write(this.html);
|
|
303
|
-
parser.done();
|
|
304
|
-
|
|
305
|
-
// Add notebook dependencies (if any)
|
|
306
|
-
if (this.name.includes('-mta')) {
|
|
307
|
-
const name = this.name.replace('-mta', '')
|
|
308
|
-
this.openCell('code', `%run ${name}.ipynb`)
|
|
309
|
-
} else if (this.name.includes('-mtx')) {
|
|
310
|
-
const name = this.name.replace('-mtx', '')
|
|
311
|
-
this.openCell('code', `%run ${name}-mta.ipynb\n`)
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Write out notebook cells
|
|
315
|
-
mdArray.forEach((cell, i) => {
|
|
316
|
-
if (i === 0) {
|
|
317
|
-
this.openCell(cell.type, cell.text);
|
|
318
|
-
} else {
|
|
319
|
-
cell.text = this.sanitizeNotebook(cell.text, cell.type);
|
|
320
|
-
if (cell.text) {
|
|
321
|
-
// If same type as last cell
|
|
322
|
-
if (cell.type === mdArray[i - 1].type) {
|
|
323
|
-
if (cell.text.includes('%%writefile ')) {
|
|
324
|
-
this.openCell(cell.type, cell.text);
|
|
325
|
-
} else {
|
|
326
|
-
this.addToCell(cell.type, cell.text);
|
|
327
|
-
}
|
|
328
|
-
} else {
|
|
329
|
-
if (cell.type === 'code') {
|
|
330
|
-
this.openCell(cell.type, cell.text);
|
|
331
|
-
} else {
|
|
332
|
-
this.addToCell(cell.type, cell.text);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
})
|
|
338
|
-
this.closeCell();
|
|
339
|
-
return this;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
openCell(type, content) {
|
|
343
|
-
this.closeCell();
|
|
344
|
-
let cell;
|
|
345
|
-
content = content.trim().replace(/^[\n]+/, '');
|
|
346
|
-
if (type === 'code') {
|
|
347
|
-
content = content.replace(/^![\s]+/, '!')
|
|
348
|
-
cell = {
|
|
349
|
-
"cell_type": "code",
|
|
350
|
-
"execution_count": null,
|
|
351
|
-
"metadata": {},
|
|
352
|
-
"outputs": [],
|
|
353
|
-
"source": [content]
|
|
354
|
-
}
|
|
355
|
-
} else {
|
|
356
|
-
cell = {
|
|
357
|
-
"cell_type": "markdown",
|
|
358
|
-
"metadata": {},
|
|
359
|
-
"source": [content]
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
this.cells.push(cell);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
addToCell(type, content) {
|
|
366
|
-
if (this.cells.length > 0) {
|
|
367
|
-
// Can only append content to cell if previous cell content exists
|
|
368
|
-
// (i.e. an open cell exists) and if the cell_type matches
|
|
369
|
-
if (this.cells[this.cells.length - 1]['source'].length > 0 &&
|
|
370
|
-
this.cells[this.cells.length - 1]['cell_type'] === type) {
|
|
371
|
-
const source = this.cells[this.cells.length - 1]['source'];
|
|
372
|
-
this.cells[this.cells.length - 1]['source'][source.length - 1] += content;
|
|
373
|
-
} else {
|
|
374
|
-
this.openCell(type, content);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
closeCell() {
|
|
380
|
-
if (this.cells.length > 0) {
|
|
381
|
-
if (this.cells[this.cells.length - 1]['source'].length > 0) {
|
|
382
|
-
const cell = this.cells[this.cells.length - 1];
|
|
383
|
-
const source = cell['source']
|
|
384
|
-
if (cell.cell_type === 'code') {
|
|
385
|
-
cell['source'][source.length - 1] = source[source.length - 1].trim().replace(/[\n]+$/g, '');
|
|
386
|
-
}
|
|
387
|
-
this.nb['cells'].push(cell);
|
|
388
|
-
// Push empty cell to register closing of a cell
|
|
389
|
-
this.cells.push({ "source": [] });
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
}
|
package/lib/init/util/logger.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint no-console: 0 */
|
|
2
|
-
|
|
3
|
-
const term = require('../../util/term');
|
|
4
|
-
const cds = require('../../cds');
|
|
5
|
-
const LOG = cds.log ? cds.log('init') : console;
|
|
6
|
-
|
|
7
|
-
const defaultLogger = {
|
|
8
|
-
isDebug: LOG._debug,
|
|
9
|
-
|
|
10
|
-
debug: (message = '') => {
|
|
11
|
-
LOG.debug(message);
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
log: (message = '') => {
|
|
15
|
-
if (typeof LOG.level !== 'number' || LOG.level > 0) {
|
|
16
|
-
console.log(message);
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
warn: (message = '') => {
|
|
21
|
-
LOG.warn(term.warn(message));
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
error: (message = '') => {
|
|
25
|
-
LOG.error(term.error(message));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
defaultLogger.isTTY = process.stdout.isTTY;
|
|
30
|
-
|
|
31
|
-
const nullLogger = {
|
|
32
|
-
debug: () => { },
|
|
33
|
-
log: () => { },
|
|
34
|
-
warn: () => { },
|
|
35
|
-
error: () => { },
|
|
36
|
-
write: () => { }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
defaultLogger,
|
|
41
|
-
nullLogger
|
|
42
|
-
}
|