@sap/cds-dk 6.6.2 → 6.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/bin/add.js +5 -3
  3. package/bin/build/all.js +1 -1
  4. package/bin/cds.js +10 -8
  5. package/bin/env.js +4 -6
  6. package/bin/login.js +6 -4
  7. package/bin/migrate.js +0 -1
  8. package/bin/repl.js +1 -1
  9. package/bin/serve.js +7 -0
  10. package/bin/subscribe.js +5 -5
  11. package/bin/unsubscribe.js +4 -5
  12. package/bin/upgrade.js +67 -0
  13. package/bin/watch.js +8 -5
  14. package/lib/bind/bindingManager.js +3 -2
  15. package/lib/bind/cfKeyProvider.js +7 -6
  16. package/lib/bind/userCdsrcJsonStorageProvider.js +5 -4
  17. package/lib/cds.js +12 -0
  18. package/lib/client/activate.js +4 -3
  19. package/lib/client/auth_manager.js +4 -3
  20. package/lib/client/base_command.js +7 -2
  21. package/lib/client/helper/cf_helper.js +12 -11
  22. package/lib/client/helper/dependency_helper.js +3 -2
  23. package/lib/client/helper/logging.js +0 -7
  24. package/lib/client/params.js +4 -2
  25. package/lib/client/settings_manager.js +35 -34
  26. package/lib/client/tenant_action.js +78 -0
  27. package/lib/init/constants.js +1 -1
  28. package/lib/init/index.js +4 -4
  29. package/lib/init/template/_merging/registry-mta.js +31 -46
  30. package/lib/init/template/approuter/files/mta.yaml.hbs +12 -8
  31. package/lib/init/template/approuter/files/xs-app.json.hbs +0 -3
  32. package/lib/init/template/approuter/index.js +26 -34
  33. package/lib/init/template/auditlog/files/mta.yaml.hbs +2 -1
  34. package/lib/init/template/auditlog/index.js +8 -21
  35. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +4 -4
  36. package/lib/init/template/cf-manifest/index.js +2 -1
  37. package/lib/init/template/connectivity/index.js +4 -5
  38. package/lib/init/template/data/index.js +19 -22
  39. package/lib/init/template/destinations/index.js +5 -17
  40. package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +2 -1
  41. package/lib/init/template/enterprise-messaging/index.js +7 -19
  42. package/lib/init/template/extensibility/index.js +3 -1
  43. package/lib/init/template/hana/files/mta.yaml.hbs +4 -5
  44. package/lib/init/template/hana/index.js +49 -84
  45. package/lib/init/template/helm/chart/templates/_helpers.tpl +4 -1
  46. package/lib/init/template/helm/files/Chart.yaml.hbs +1 -4
  47. package/lib/init/template/helm/index.js +45 -13
  48. package/lib/init/template/helm/subcharts/web-application/templates/_helpers.tpl +21 -31
  49. package/lib/init/template/helm/subcharts/web-application/templates/api-rule.yaml +3 -12
  50. package/lib/init/template/helm/subcharts/web-application/templates/deployment.yaml +12 -14
  51. package/lib/init/template/helm/subcharts/web-application/templates/network-policy.yaml +27 -4
  52. package/lib/init/template/helm/subcharts/web-application/templates/pod-disruption-budget.yaml +0 -2
  53. package/lib/init/template/helm/subcharts/web-application/templates/secret.yaml +2 -2
  54. package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +2 -2
  55. package/lib/init/template/helm/subcharts/web-application/templates/service-binding.yaml +16 -13
  56. package/lib/init/template/helm/subcharts/web-application/templating.md +16 -9
  57. package/lib/init/template/helm/subcharts/web-application/values.md +317 -379
  58. package/lib/init/template/helm/subcharts/web-application/values.schema.json +87 -107
  59. package/lib/init/template/helm/subcharts/web-application/values.yaml +28 -2
  60. package/lib/init/template/html5-repo/index.js +6 -29
  61. package/lib/init/template/java/index.js +1 -1
  62. package/lib/init/template/kibana-logging/files/mta.yaml.hbs +2 -1
  63. package/lib/init/template/kibana-logging/index.js +5 -8
  64. package/lib/init/template/lint/index.js +8 -8
  65. package/lib/init/template/mta/files/mta.yaml.hbs +3 -2
  66. package/lib/init/template/mta/index.js +3 -2
  67. package/lib/init/template/multitenancy/files/mta.yaml.hbs +25 -31
  68. package/lib/init/template/multitenancy/files/{java/mtxs-configmap.yaml → mtxs-configmap-java.yaml} +1 -1
  69. package/lib/init/template/multitenancy/files/{mtxs-configmap.yaml → mtxs-configmap-nodejs.yaml} +5 -1
  70. package/lib/init/template/multitenancy/files/package.json.hbs +28 -0
  71. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +21 -0
  72. package/lib/init/template/multitenancy/files/values.yaml.hbs +16 -9
  73. package/lib/init/template/multitenancy/index.js +51 -99
  74. package/lib/init/template/nodejs/files/.vscode/extensions.json +1 -2
  75. package/lib/init/template/nodejs/files/.vscode/launch.json +2 -2
  76. package/lib/init/template/nodejs/files/.vscode/tasks.json +2 -2
  77. package/lib/init/template/nodejs/files/package.json.hbs +2 -2
  78. package/lib/init/template/nodejs/index.js +4 -3
  79. package/lib/init/template/pipeline/index.js +3 -2
  80. package/lib/init/template/samples/index.js +5 -4
  81. package/lib/init/template/sqlite/files/package.json.hbs +19 -0
  82. package/lib/init/template/sqlite/index.js +11 -0
  83. package/lib/init/template/toggles/index.js +3 -5
  84. package/lib/init/template/xsuaa/files/mta.yaml.hbs +4 -5
  85. package/lib/init/template/xsuaa/files/values.yaml.hbs +0 -2
  86. package/lib/init/template/xsuaa/index.js +14 -35
  87. package/lib/init/util/commandUtil.js +3 -2
  88. package/lib/init/util/fsUtil.js +19 -2
  89. package/lib/init/util/md5Tracking.js +36 -63
  90. package/lib/init/util/projectReader.js +12 -26
  91. package/lib/lint/Linter.js +0 -3
  92. package/lib/util/exec.js +2 -1
  93. package/lib/util/term.js +1 -1
  94. package/lib/watch/livereload-connect.js +5 -4
  95. package/lib/watch/livereload-server.js +3 -6
  96. package/lib/watch/node-watch.js +1 -1
  97. package/npm-shrinkwrap.json +569 -479
  98. package/package.json +4 -4
  99. package/readme.md +1 -1
  100. package/lib/client/subscription.js +0 -84
  101. package/lib/init/template/approuter/files/chart.yaml +0 -4
  102. package/lib/init/template/auditlog/files/auditlog.yaml +0 -4
  103. package/lib/init/template/destinations/files/destination.yaml +0 -4
  104. package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +0 -4
  105. package/lib/init/template/hana/files/hana-deployer.yaml +0 -4
  106. package/lib/init/template/hana/files/hana.yaml +0 -4
  107. package/lib/init/template/html5-repo/files/html5-apps-deployer.yaml +0 -4
  108. package/lib/init/template/html5-repo/files/html5-apps-repo-host.yaml +0 -4
  109. package/lib/init/template/multitenancy/files/cds.package.json +0 -7
  110. package/lib/init/template/multitenancy/files/cds.package.json.hbs +0 -9
  111. package/lib/init/template/multitenancy/files/dependencies.package.json +0 -5
  112. package/lib/init/template/multitenancy/files/java/.cdsrc.json +0 -22
  113. package/lib/init/template/multitenancy/files/java/package.json +0 -33
  114. package/lib/init/template/multitenancy/files/saas-registry.yaml +0 -4
  115. package/lib/init/template/multitenancy/files/service-manager.yaml +0 -4
  116. package/lib/init/template/multitenancy/files/sidecar.yaml +0 -4
  117. package/lib/init/template/xsuaa/files/xsuaa.yaml +0 -4
@@ -2,7 +2,7 @@ const { join } = require('path')
2
2
  const { readProject } = require('../../util/projectReader')
3
3
  const { mergeJSON, mergeYAML } = require('../../util/merge')
4
4
  const { parseMd5File, writeMd5File } = require('../../util/md5Tracking')
5
- const { srvNode, srvJava, xsuaa, mtxSidecar } = require('../_merging/registry-mta')
5
+ const { srvNode, srvJava, xsuaa, mtxSidecar4 } = require('../_merging/registry-mta')
6
6
  const { PROJECT_TYPE } = require('../../constants')
7
7
 
8
8
  module.exports = class XsuaaTemplate extends require('../templateBase') {
@@ -37,11 +37,11 @@ module.exports = class XsuaaTemplate extends require('../templateBase') {
37
37
 
38
38
  async runDependentMerging( context = {}) {
39
39
  const projectDescriptor = await readProject(this.options)
40
- const { isMultitenant, isExtensible, hasMta, hasHelm, isNodejs, isJava } = projectDescriptor.cap
40
+ const { isMultitenant, isExtensible, hasMta, hasHelm, isJava, srvPath } = projectDescriptor.cap
41
41
 
42
42
  const cds = require('../../../../lib/compile')
43
43
  const xsSecurity = await (async () => { try {
44
- const models = await cds.load(join(this.projectPath, cds.env.folders.srv))
44
+ const models = await cds.load(cds.env.folders.srv)
45
45
  return cds.compile.to.xsuaa(models)
46
46
  } catch (error) { /* ignore */ }
47
47
  })() || { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
@@ -52,33 +52,24 @@ module.exports = class XsuaaTemplate extends require('../templateBase') {
52
52
  isEqualTo: scope.name
53
53
  }],
54
54
  }))}
55
- const xsSecurityPath = join(this.projectPath, 'xs-security.json')
56
- await mergeJSON(xsSecurityPath, xsSecurity, projectDescriptor, mergingSemantics)
55
+ await mergeJSON('xs-security.json', xsSecurity, projectDescriptor, mergingSemantics)
57
56
 
58
57
  if (hasMta) {
59
- const srv = isNodejs ? srvNode : srvJava
58
+ const srv = (isJava ? srvJava : srvNode)(srvPath)
60
59
  const additions = [srv, xsuaa]
60
+ const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar')
61
61
  if (isMultitenant && isJava) additions.push(mtxSidecar)
62
62
 
63
- const mtaYAMLPath = join(this.projectPath, 'mta.yaml')
64
- const relationships = [{
63
+ const relationships = [{
65
64
  insert: [xsuaa, 'name'],
66
65
  into: [srv, 'requires', 'name']
67
66
  }]
68
- relationships.push({
67
+ if (isMultitenant) relationships.push({
69
68
  insert: [xsuaa, 'name'],
70
69
  into: [mtxSidecar, 'requires', 'name']
71
70
  })
72
71
 
73
- await mergeYAML(
74
- mtaYAMLPath,
75
- join(__dirname, 'files', 'mta.yaml.hbs'),
76
- projectDescriptor,
77
- {
78
- additions,
79
- relationships
80
- }
81
- )
72
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), projectDescriptor, { additions, relationships })
82
73
  }
83
74
 
84
75
  if (hasHelm) {
@@ -86,35 +77,23 @@ module.exports = class XsuaaTemplate extends require('../templateBase') {
86
77
  let isIndependentCommand = false;
87
78
  if(Object.keys(context).length == 0){
88
79
  isIndependentCommand = true;
89
- context.projectPath = this.projectPath;
90
- context.oldTrackingData = context.newTrackingData = await parseMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'));
80
+ context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'));
91
81
  }
92
-
82
+
93
83
  // copy service-instance chart
94
84
  const HelmTemplate = require(`../helm`);
95
85
  const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
96
86
  isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
97
87
 
98
88
  // add dependency entry in chart.yaml
99
- await mergeYAML(
100
- join(this.projectPath, 'chart', 'Chart.yaml'),
101
- join(__dirname, 'files', 'xsuaa.yaml'),
102
- projectDescriptor,
103
- { additions: [{
104
- in: `dependencies`,
105
- where: [{
106
- property: 'alias',
107
- isEqualTo: 'xsuaa'
108
- }]
109
- }]}
110
- );
89
+ await helmTemplate.addDependency('service-instance', 'xsuaa');
111
90
 
112
91
  await mergeYAML(
113
- join(this.projectPath, 'chart', 'values.yaml'),
92
+ join('chart', 'values.yaml'),
114
93
  join(__dirname, 'files', 'values.yaml.hbs'),
115
94
  projectDescriptor
116
95
  )
117
- if(isIndependentCommand) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData);
96
+ if(isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
118
97
  }
119
98
 
120
99
  // Re-applying the merging part of `cds add mtx` because cds.compile.to.xsuaa
@@ -1,6 +1,7 @@
1
1
  const cp = require('child_process');
2
2
  const os = require('os');
3
- const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) && console.debug
3
+ const cds = require('../../cds');
4
+ const DEBUG = cds.debug('cli');
4
5
 
5
6
 
6
7
  const { IS_WIN } = require('../constants');
@@ -21,7 +22,7 @@ class CommandUtil {
21
22
  async spawnCommand(cmd, args, options = {}, collectResult = false) {
22
23
  args = this._sanitizeArgs(args);
23
24
  return new Promise((resolve, reject) => {
24
- DEBUG && console.debug(`[spawn] ${cmd} ${args.join(' ')}`);
25
+ DEBUG?.(`[spawn] ${cmd} ${args.join(' ')}`);
25
26
 
26
27
  options.env = options.env || process.env;
27
28
 
@@ -2,8 +2,15 @@ const { yaml: YAML } = require('@sap/cds-foss')
2
2
  const JSONC = require('../../util/jsonc');
3
3
  const { read, write } = require('../../cds').utils;
4
4
 
5
+ // REVISIT: Consider merging with template util
6
+
5
7
  module.exports = new class FsUtil {
6
8
 
9
+ constructor() {
10
+ this.copyRenderedJSON = this.copyRenderedJSON.bind(this)
11
+ this.copyRenderedYAML = this.copyRenderedYAML.bind(this)
12
+ }
13
+
7
14
  async readYAML(src, projectDescriptor) {
8
15
  let file
9
16
  try {
@@ -20,9 +27,14 @@ module.exports = new class FsUtil {
20
27
  return YAML.parseDocument(file)
21
28
  }
22
29
 
23
- async writeYAML(filepath, yaml) {
30
+ async writeYAML(dst, yaml) {
24
31
  const content = YAML.stringify(yaml, { collectionStyle: 'block' })
25
- await write(filepath, content)
32
+ await write(content).to(dst)
33
+ }
34
+
35
+ async copyRenderedYAML(src, dst, projectDescriptor) {
36
+ const yaml = await this.readYAML(src, projectDescriptor)
37
+ await write(yaml.toString()).to(dst)
26
38
  }
27
39
 
28
40
  async readJSON(src, projectDescriptor) {
@@ -38,4 +50,9 @@ module.exports = new class FsUtil {
38
50
  async readJSONC(src) {
39
51
  return JSONC.parse(await read(src, 'utf8'))
40
52
  }
53
+
54
+ async copyRenderedJSON(src, dst, projectDescriptor) {
55
+ const json = await this.readJSON(src, projectDescriptor)
56
+ await write(dst, json, { spaces: 2 })
57
+ }
41
58
  }
@@ -1,31 +1,24 @@
1
- const path = require('path'), { dirname, resolve } = path;
2
- const { mkdirp, isdir } = require('../../cds').utils;
3
- const cds = require('../../cds');
1
+ const cds = require('../../cds')
2
+ const { exists, mkdirp, isdir, readdir, read, write, copy, path } = cds.utils;
3
+ const { dirname, join } = path
4
4
 
5
- const fs = require('fs');
6
5
  const crypto = require('crypto');
7
- const LOG = cds.log('k8s');
8
6
  const os = require('os');
7
+ const { copyRenderedYAML } = require('./fsUtil');
9
8
 
10
- async function copyAndTrack(source, dest, context = {}, force = false) {
11
- const sourcePath = resolve(cds.root, source);
12
- const destPath = resolve(cds.root, dest);
13
- //if (fs.promises.cp) return fs.promises.cp(src, dst, { recursive: true });
14
- await mkdirp(dirname(destPath));
15
- if (isdir(sourcePath)) {
16
- const entries = await fs.promises.readdir(sourcePath);
17
- return Promise.all(entries.map(async each => {
18
- const subSourcePath = path.join(sourcePath, each);
19
- const subDestPath = path.join(destPath, each);
20
- return copyAndTrack(subSourcePath, subDestPath, context);
21
- }))
9
+ async function copyAndTrack(source, dest, context = {}, { force = false, projectDescriptor } = {}) {
10
+ await mkdirp(dirname(dest));
11
+ if (isdir(source)) {
12
+ const dirents = await readdir(source);
13
+ return Promise.all(dirents.map(each => copyAndTrack(join(source, each), join(dest, each), context)))
22
14
  } else {
23
- let data = await _readFileIfExists(sourcePath, 'utf-8');
24
- if (!force && await _isChartFileModified(destPath, context)) {
25
- LOG.warn("Chart file " + destPath + " has been modified and will not be updated.");
15
+ const data = exists(source) ? await read(source, 'utf-8') : undefined
16
+ if (!force && await _isChartFileModified(dest, context)) {
17
+ console.log('Chart file ' + dest + ' has been modified and will not be updated.');
26
18
  } else {
27
- _track(destPath, data, context);
28
- return fs.promises.copyFile(sourcePath, destPath);
19
+ _track(dest, data, context);
20
+ if (projectDescriptor) return copyRenderedYAML(source, dest, projectDescriptor)
21
+ return copy(source).to(dest);
29
22
  }
30
23
  }
31
24
  }
@@ -33,56 +26,34 @@ async function copyAndTrack(source, dest, context = {}, force = false) {
33
26
 
34
27
  /**
35
28
  * Takes path of md5 file as an argument and returns a JSON object containing hashes of files stored in MD5 file.
36
- * @param {String} path
29
+ * @param {String} file
37
30
  * @returns {Promise<JSON>}
38
31
  */
39
- async function parseMd5File(path) {
40
- let md5Hashes = {};
41
- const md5FileContent = await _readFileIfExists(path);
42
- if (md5FileContent == undefined) return md5Hashes;
43
- let md5Checksums = md5FileContent.toString().split(os.EOL)
44
- md5Checksums.forEach((checksum) => {
45
- checksum = checksum.split(" ")
46
- md5Hashes[checksum[1]] = checksum[0];
47
- })
48
- return md5Hashes;
32
+ async function parseMd5File(file) {
33
+ const md5 = exists(file) ? await read(file) : undefined
34
+ if (!md5) return {}
35
+ return Object.fromEntries(md5.split(os.EOL).map(line => line.split(' ').reverse()))
49
36
  }
50
37
 
51
38
  /**
52
39
  * Takes json object containing key as filename and value as MD5 hash and generates a md5sum format file.
53
- * @param {String} path
40
+ * @param {String} file
54
41
  * @param {Promise<JSON>} data
55
42
  */
56
- async function writeMd5File(path, data) {
57
- let md5_output;
58
- Object.keys(data).forEach(key => {
59
- var currMd5 = `${data[key]} ${key}`;
60
- if (md5_output === undefined)
61
- md5_output = currMd5;
62
- else
63
- md5_output += os.EOL + currMd5;
64
- })
65
- await fs.promises.writeFile(path, md5_output);
43
+ async function writeMd5File(file, data) {
44
+ await write(Object.entries(data).map(([filename, hash]) =>
45
+ `${hash} ${filename}` + os.EOL
46
+ ).join('')).to(file)
66
47
  }
67
48
 
68
- async function _readFileIfExists(path, encoding) {
69
- try {
70
- return await fs.promises.readFile(path, encoding);
71
- } catch (error) {
72
- if (error.code === 'ENOENT' || error.code === 'EISDIR') return undefined;
73
- else throw error;
74
- }
75
- }
76
-
77
- async function _isChartFileModified(filePath, context = {}) {
78
- const data = await _readFileIfExists(filePath, 'utf-8');
79
- if (data == undefined) {
80
- return false;
81
- }
82
49
 
83
- const key = _pathKey(path.join(context.projectPath, 'chart'), filePath);
84
- const currentHash = _hash(data);
85
- return context.oldTrackingData != undefined && context.oldTrackingData[key] != undefined && context.oldTrackingData[key] != currentHash;
50
+ // REVISIT: Why pass entire 'context' if we're only interested in one key in the old tracking data? -> decrease coupling
51
+ async function _isChartFileModified(file, context = {}) {
52
+ const data = exists(file) ? await read(file, 'utf-8') : undefined
53
+ if (!data) return false;
54
+ const key = _pathKey(join(cds.root, 'chart'), file);
55
+ const hashedContent = _hash(data);
56
+ return context.newTrackingData[key] ? context.newTrackingData[key] !== hashedContent : context.oldTrackingData?.[key] !== hashedContent;
86
57
  }
87
58
 
88
59
  function _hash(data) {
@@ -97,8 +68,9 @@ function _toPosix(path) {
97
68
  return path.replace(/\\/g, '/');
98
69
  }
99
70
 
71
+ // REVISIT: Replace inout parameter 'context' by return value of new tracking data
100
72
  async function _track(filePath, data, context = {}) {
101
- const key = _pathKey(path.join(context.projectPath, 'chart'), filePath);
73
+ const key = _pathKey(path.join(cds.root, 'chart'), filePath);
102
74
  const hashedContent = _hash(data);
103
75
  if (context.oldTrackingData != undefined && context.oldTrackingData[key] != undefined) {
104
76
  context.oldTrackingData[key] = hashedContent;
@@ -106,8 +78,9 @@ async function _track(filePath, data, context = {}) {
106
78
  context.newTrackingData[key] = hashedContent;
107
79
  }
108
80
 
81
+ // REVISIT: Can we make copyAndTrack the only public API?
109
82
  module.exports = {
110
83
  copyAndTrack,
111
84
  parseMd5File,
112
85
  writeMd5File
113
- }
86
+ }
@@ -44,33 +44,23 @@ module.exports = new class ProjectReader {
44
44
  const cap = await this._getCapDescriptor(env, options)
45
45
  const ui = this._getUiDescriptor(env)
46
46
  const projectDescriptor = { cap, ui }
47
- this._validateDbFolders(cap)
48
47
 
49
48
  DEBUG && DEBUG({ projectDescriptor })
50
49
  return projectDescriptor
51
50
  }
52
51
 
53
- _validateDbFolders(cap) {
54
- const { db: dbs, isJava } = cap
55
- if (isJava) {
56
- for (const db of dbs) if (!exists(path.join(db.path, 'package.json'))) {
57
- LOG.error(`Missing 'package.json' in folder ${db.path} - 'cds add hana' adds configuration for SAP HANA`)
58
- }
59
- }
60
- }
61
-
62
52
  async _getCapDescriptor(env, options) {
63
53
  const _hasFacet = template => require(`../template/${template}`).hasFacet(env, options)
64
54
  const cap = {
65
55
  for: options?.for,
66
- pLanguage: DEFAULT_P_LANGUAGE,
56
+ language: DEFAULT_P_LANGUAGE,
67
57
  srv: {},
68
58
  db: [],
69
59
  requires: [],
70
60
  get hasRequires() { return this.requires.length > 0 },
71
61
  get needsSidecar() { return (options?.add.has('hana') || this.db.length > 0) && (this.isJava || !this.isMultitenant) },
72
- get isNodejs() { return this.pLanguage === P_LANGUAGE_NODEJS },
73
- get isJava() { return this.pLanguage === P_LANGUAGE_JAVA },
62
+ get isNodejs() { return this.language === P_LANGUAGE_NODEJS },
63
+ get isJava() { return this.language === P_LANGUAGE_JAVA },
74
64
  get hasSidecar() { return exists('mtx', 'sidecar') },
75
65
  get isMultitenant() { return _hasFacet('multitenancy') },
76
66
  get isExtensible() { return _hasFacet('extensibility') },
@@ -112,20 +102,16 @@ module.exports = new class ProjectReader {
112
102
 
113
103
  case BUILD_TASK_JAVA:
114
104
  case BUILD_TASK_JAVA_CF:
115
- cap.pLanguage = P_LANGUAGE_JAVA
116
- cap.srv = {
117
- path: relDestPath,
118
- name: srcFolder,
119
- ext: await this._getJavaExtDescriptor(srcPath)
120
- }
105
+ cap.language = P_LANGUAGE_JAVA
106
+ cap.srvPath = relDestPath
107
+ cap.srvName = srcFolder
108
+ cap.srvExt = await this._getJavaExtDescriptor(srcPath)
121
109
  break
122
110
 
123
111
  case BUILD_TASK_NODEJS:
124
112
  case BUILD_TASK_NODE_CF:
125
- cap.srv = {
126
- path: relDestPath,
127
- name: srcFolder
128
- }
113
+ cap.srvPath = relDestPath
114
+ cap.srvName = srcFolder
129
115
  break
130
116
 
131
117
  case BUILD_TASK_FIORI:
@@ -177,12 +163,12 @@ module.exports = new class ProjectReader {
177
163
  }
178
164
 
179
165
  async _setAppDetails(cap) {
180
- if (cap.pLanguage !== P_LANGUAGE_JAVA && cap.pLanguage !== P_LANGUAGE_NODEJS) {
181
- throw Error(`${cap.pLanguage} not supported`)
166
+ if (cap.language !== P_LANGUAGE_JAVA && cap.language !== P_LANGUAGE_NODEJS) {
167
+ throw Error(`${cap.language} not supported`)
182
168
  }
183
169
 
184
170
  // 1.1. java - use parent pom.xml
185
- if (cap.pLanguage === P_LANGUAGE_JAVA) {
171
+ if (cap.language === P_LANGUAGE_JAVA) {
186
172
  const pomXmlPath = path.join(cds.root, 'pom.xml')
187
173
  try {
188
174
  if (exists(pomXmlPath)) {
@@ -21,7 +21,6 @@ class Linter {
21
21
  this.flags = [];
22
22
  this.configPath = "";
23
23
  this.configContents = {};
24
- this.projectPath = "";
25
24
  this.cdsdkPath = path.join(__dirname, "../..");
26
25
  this.globalPath = path.join(this.cdsdkPath, "../..");
27
26
  this.extendsPlugin = false;
@@ -282,8 +281,6 @@ class Linter {
282
281
  // CLI will report (no globally installed plugin)
283
282
  }
284
283
  }
285
- // Project path is directory of ESLint config file
286
- this.projectPath = path.dirname(this.configPath);
287
284
  return;
288
285
  }
289
286
 
package/lib/util/exec.js CHANGED
@@ -2,6 +2,7 @@ const { spawn, spawnSync } = require('child_process');
2
2
 
3
3
  const cds = require('../cds');
4
4
  const log = cds.log('exec');
5
+ const DEBUG = cds.debug('exec');
5
6
 
6
7
  function* commandIterator(strs, args) {
7
8
  for (let i=0; i<strs.length; i++) {
@@ -153,7 +154,7 @@ function executeSync(options = {}, command, ...args) {
153
154
  const { acceptStatuses } = options;
154
155
  const execOptions = getExecOptions(options);
155
156
 
156
- log.debug(`exec: ${command} ${args.map( v => v.match(/\s/) ? `"${v}"` : v ).join(' ')}`);
157
+ DEBUG?.(`exec: ${command} ${args.map( v => v.match(/\s/) ? `"${v}"` : v ).join(' ')}`);
157
158
  const result = spawnSync(command, args, execOptions);
158
159
 
159
160
  if (acceptStatuses !== '*' && acceptStatuses.indexOf(result.status) === -1) throw new Error(`Command '${command} ${args.join(' ')}' returned with status code ${result.status}`);
package/lib/util/term.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // FIXME: Nicht gut, das wir das zweimal redundant haben!
2
- const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) && console.debug
2
+ const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) ? console.debug : undefined
3
3
 
4
4
  // https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
5
5
  const t = module.exports.codes = {
@@ -1,4 +1,5 @@
1
- const DEBUG = /\b(y|all|cli|livereload)\b/.test(process.env.DEBUG) && console.debug
1
+ const cds = require('../cds');
2
+ const DEBUG = cds.debug('cli|watch|livereload');
2
3
 
3
4
  module.exports = function livereload(opt) {
4
5
  // options
@@ -86,10 +87,10 @@ module.exports = function livereload(opt) {
86
87
  function acceptContentType(res) {
87
88
  const ha = res.getHeader('content-type');
88
89
  if (ha && ha.indexOf('html') >= 0) {
89
- DEBUG && DEBUG('[livereload] accepting content-type', ha)
90
+ DEBUG?.('[livereload] accepting content-type', ha)
90
91
  return true;
91
92
  }
92
- DEBUG && DEBUG('[livereload] rejecting content-type', ha)
93
+ DEBUG?.('[livereload] rejecting content-type', ha)
93
94
  return false;
94
95
  }
95
96
 
@@ -112,7 +113,7 @@ module.exports = function livereload(opt) {
112
113
  if (!accept(req) || !check(req.url, include) || check(req.url, ignore)) {
113
114
  return next();
114
115
  }
115
- DEBUG && DEBUG('[livereload] accepting URL', req.url)
116
+ DEBUG?.('[livereload] accepting URL', req.url)
116
117
 
117
118
  // Disable G-Zip to enable proper inspecting of HTML
118
119
  if (disableCompression) {
@@ -1,5 +1,5 @@
1
1
  const cds = require('../cds')
2
- const DEBUG = cds.debug('cli|livereload')
2
+ const DEBUG = cds.debug('cli|watch|livereload')
3
3
 
4
4
  const axios = require('axios')
5
5
  const ws = require('ws')
@@ -119,10 +119,7 @@ async function livereloadURL(address, port) {
119
119
  }
120
120
  // Local case. Add effective server address/host to URL.
121
121
  // Make sure IPv6 addresses are properly escaped.
122
- if (require('net').isIPv6(address)) {
123
- // TODO remove as soon as IPv6 support in https://github.com/livereload/livereload-js/pull/103 is fixed
124
- if (address === '::1') address = 'localhost'
125
- // address = `[${address}]`
126
- }
122
+ if (require('net').isIPv6(address)) address = `[${address}]`
123
+
127
124
  return `http://${address}:${port}/livereload.js?snipver=1`
128
125
  }
@@ -108,7 +108,7 @@ function _coalesceEvents(delay, fn) {
108
108
  * Ensures the given child process gets killed in different environments
109
109
  */
110
110
  function _kill (child, cb=()=>{}) {
111
- if (!child) return cb()
111
+ if (!child || !child.connected) return cb()
112
112
  if (child[_pending]) return // safeguard against repeated calls for the same process
113
113
  child[_pending] = true
114
114
  const _done = () => { delete child[_pending]; return cb(); }