@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.
Files changed (90) hide show
  1. package/bin/add.js +2 -2
  2. package/bin/bind.js +5 -7
  3. package/bin/build.js +2 -7
  4. package/bin/cds.js +6 -8
  5. package/bin/deploy/to-hana.js +1 -1
  6. package/bin/init.js +2 -2
  7. package/bin/subscribe.js +4 -4
  8. package/bin/unsubscribe.js +4 -4
  9. package/bin/upgrade.js +4 -4
  10. package/lib/bind/cfKeyProvider.js +10 -10
  11. package/lib/bind/index.js +4 -3
  12. package/lib/bind/userCdsrcJsonStorageProvider.js +2 -10
  13. package/lib/build/buildTaskEngine.js +9 -22
  14. package/lib/build/buildTaskFactory.js +18 -27
  15. package/lib/build/constants.js +16 -14
  16. package/lib/build/index.js +12 -3
  17. package/lib/build/provider/buildTaskProviderInternal.js +23 -15
  18. package/lib/build/provider/mtx/index.js +8 -2
  19. package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -6
  20. package/lib/build/provider/mtx-sidecar/index.js +13 -8
  21. package/lib/build/util.js +13 -0
  22. package/lib/client/activate.js +7 -7
  23. package/lib/client/auth_manager.js +5 -5
  24. package/lib/client/base_command.js +7 -10
  25. package/lib/client/extend.js +2 -2
  26. package/lib/client/helper/logging.js +7 -2
  27. package/lib/client/params.js +2 -3
  28. package/lib/client/pull.js +3 -3
  29. package/lib/client/push.js +3 -3
  30. package/lib/client/settings_manager.js +7 -8
  31. package/lib/client/tenant_action.js +3 -3
  32. package/lib/compile/asyncapi/components/messages/index.js +41 -18
  33. package/lib/compile/asyncapi/index.js +23 -2
  34. package/lib/deploy/to-hana/hana.js +1 -2
  35. package/lib/import/common.js +3 -0
  36. package/lib/import/message.js +2 -1
  37. package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -0
  38. package/lib/import/odata/v4parser.js +85 -95
  39. package/lib/init/constants.js +1 -1
  40. package/lib/init/index.js +78 -73
  41. package/lib/init/template/approuter/index.js +3 -4
  42. package/lib/init/template/auditlog/index.js +3 -4
  43. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +15 -23
  44. package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +22 -17
  45. package/lib/init/template/cf-manifest/index.js +2 -2
  46. package/lib/init/template/connectivity/index.js +2 -3
  47. package/lib/init/template/data/index.js +7 -8
  48. package/lib/init/template/destination/index.js +3 -5
  49. package/lib/init/template/enterprise-messaging/index.js +4 -5
  50. package/lib/init/template/enterprise-messaging-shared/index.js +3 -4
  51. package/lib/init/template/extensibility/index.js +2 -3
  52. package/lib/init/template/file-based-messaging/index.js +2 -2
  53. package/lib/init/template/hana/files/mta.yaml.hbs +1 -1
  54. package/lib/init/template/hana/index.js +39 -63
  55. package/lib/init/template/helm/index.js +15 -14
  56. package/lib/init/template/html5-repo/index.js +3 -7
  57. package/lib/init/template/java/index.js +3 -3
  58. package/lib/init/template/kibana/index.js +3 -4
  59. package/lib/init/template/lint/index.js +13 -13
  60. package/lib/init/template/mta/index.js +3 -2
  61. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
  62. package/lib/init/template/multitenancy/index.js +16 -37
  63. package/lib/init/template/nodejs/index.js +4 -6
  64. package/lib/init/template/pipeline/index.js +3 -4
  65. package/lib/init/template/redis-messaging/index.js +3 -4
  66. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +1 -1
  67. package/lib/init/template/sample/files/app/browse/webapp/manifest.json +1 -1
  68. package/lib/init/template/sample/files/srv/admin-service.cds +1 -1
  69. package/lib/init/template/sample/files/srv/cat-service.cds +1 -1
  70. package/lib/init/template/sample/index.js +6 -5
  71. package/lib/init/template/sqlite/index.js +1 -1
  72. package/lib/init/template/templateBase.js +9 -19
  73. package/lib/init/template/tiny-sample/index.js +5 -5
  74. package/lib/init/template/toggles/index.js +1 -2
  75. package/lib/init/template/typer/files/xsconfig.json +0 -1
  76. package/lib/init/template/typer/index.js +1 -1
  77. package/lib/init/template/xsuaa/index.js +3 -4
  78. package/lib/init/util/indent.js +57 -0
  79. package/lib/init/util/merge.js +72 -16
  80. package/lib/init/util/mvn.js +40 -31
  81. package/lib/init/util/projectReader.js +52 -168
  82. package/lib/init/util/template.js +12 -11
  83. package/lib/init/util/xml.js +6 -6
  84. package/lib/util/cfUtil.js +1 -2
  85. package/lib/util/pruneAxiosErrors.js +22 -0
  86. package/lib/watch/open.js +6 -3
  87. package/npm-shrinkwrap.json +356 -309
  88. package/package.json +1 -2
  89. package/lib/client/helper/errors.js +0 -26
  90. package/lib/util/version.js +0 -27
@@ -6,7 +6,7 @@ const { mergeJSON } = require('../../util/merge')
6
6
  module.exports = class FileBasedMessagingTemplate extends require('../templateBase') {
7
7
 
8
8
  async canRun() {
9
- const { isJava } = await readProject(this.options)
9
+ const { isJava } = await readProject()
10
10
  if (isJava) throw `'cds add file-based-messaging' is not available for Java yet`
11
11
  return true
12
12
  }
@@ -16,7 +16,7 @@ module.exports = class FileBasedMessagingTemplate extends require('../templateBa
16
16
  }
17
17
 
18
18
  async run() {
19
- const project = await readProject(this.options)
19
+ const project = await readProject()
20
20
  const { configFile } = project
21
21
  project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
22
22
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
@@ -9,7 +9,7 @@ modules:
9
9
  {{^isMultitenant}}
10
10
  - name: {{appName}}-db-deployer
11
11
  type: hdb
12
- path: {{& db.0.path}}
12
+ path: {{& db.path}}
13
13
  parameters:
14
14
  buildpack: nodejs_buildpack
15
15
  {{#isJava}}
@@ -1,17 +1,15 @@
1
- const { join } = require('path');
1
+ const { join } = require('path')
2
2
  const cds = require('../../../cds')
3
3
  const { read, write, exists, rmdir } = cds.utils
4
- const commandUtil = require('../../../util/command');
5
- const mvnArchetypes = require('../../util/mvn');
6
- const term = require('../../../util/term');
4
+ const { readProject } = require('../../util/projectReader')
7
5
  const { mergeJSON, mergeYAML, removeFromYAML, removeFromYAMLArray } = require('../../util/merge')
6
+ const mvn = require('../../util/mvn')
8
7
  const { parseMd5File, writeMd5File } = require('../../util/md5')
9
8
  const { copyFiles } = require('../../util/template')
10
- const { readProject } = require('../../util/projectReader');
11
9
 
12
- const { OPTIONS: { JAVA }, URLS } = require('../../constants');
10
+ const { OPTIONS: { JAVA } } = require('../../constants')
13
11
 
14
- const { srvNode4, srvJava4, hdbDeployer, serviceManager, hdiContainer, mtxSidecar4 } = require('../_merging/registry-mta');
12
+ const { srvNode4, srvJava4, hdbDeployer, serviceManager, hdiContainer, mtxSidecar4 } = require('../_merging/registry-mta')
15
13
 
16
14
  module.exports = class HanaTemplate extends require('../templateBase') {
17
15
 
@@ -20,56 +18,40 @@ module.exports = class HanaTemplate extends require('../templateBase') {
20
18
  }
21
19
 
22
20
  async run() {
23
- const project = await readProject(this.options)
24
- const { isJava, configFile } = project
21
+ const project = await readProject()
22
+ const { isJava, configFile, db } = project
25
23
  project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
26
24
 
27
- const env = await this.getEnv() // REVISIT: Get info from project
28
-
29
25
  // REVISIT: Let cds build generate by default
30
- const hdiConfigPath = join(env.folders.db, 'src', '.hdiconfig')
26
+ const hdiConfigPath = join(db.folder, 'src', '.hdiconfig')
31
27
  const hdiConfigTemplatePath = join(__dirname, 'files', 'src', '.hdiconfig')
32
28
  await mergeJSON(hdiConfigPath, hdiConfigTemplatePath)
33
29
 
34
30
  // REVISIT: Let csd build generate by default
35
- const undeployJSONPath = join(env.folders.db, 'undeploy.json')
31
+ const undeployJSONPath = join(db.folder, 'undeploy.json')
36
32
  const undeployJSONTemplatePath = join(__dirname, 'files', 'undeploy.json')
37
33
  await mergeJSON(undeployJSONPath, undeployJSONTemplatePath)
38
34
 
39
35
  if (isJava) {
40
- await copyFiles(join(__dirname, 'files', 'db'), env.folders.db, {}, this.options.force)
41
- await this._updatePomXml()
36
+ await copyFiles(join(__dirname, 'files', 'db'), db.folder, {}, cds.cli.options.force)
37
+ // REVISIT: shouldn't behave differently during cds init
38
+ // if called during cds init the project generation call to AT will add settings
39
+ if (!cds.cli.options.add.has(JAVA)) await mvn.execMvn(mvn.getAddHanaCmdArgs())
42
40
  }
43
41
 
44
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project, { forceOverwrite: true })
42
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project, { forceOverwrite: true }) // REVISIT: forceOverwrite: true as default?
45
43
 
46
- const packageJson = exists('package.json') ? await read('package.json') : undefined
44
+ const packageJson = exists('package.json') ? await read('package.json') : null
47
45
  if (packageJson?.dependencies) {
48
46
  delete packageJson.dependencies['@sap/hana-client']
49
47
  await write('package.json', packageJson, { spaces: 2 })
50
48
  }
51
- await this.runDependentMerging()
52
- }
53
-
54
- async removeEntriesFromContext(context, key) {
55
- Object.keys(context.oldTrackingData).forEach(fileName => {
56
- if (fileName.startsWith(key)) {
57
- delete context.oldTrackingData[fileName];
58
- }
59
- });
60
-
61
- Object.keys(context.newTrackingData).forEach(fileName => {
62
- if (fileName.startsWith(key)) {
63
- delete context.newTrackingData[fileName];
64
- }
65
- });
66
49
  }
67
50
 
68
51
  async runDependentMerging(context = {}) {
69
- const project = await readProject(this.options)
52
+ const project = await readProject()
70
53
  const { hasMta, hasHelm, hasHtml5Repo, isJava, isMultitenant, srvPath } = project
71
54
 
72
-
73
55
  if (hasMta) {
74
56
  const srv = (isJava ? srvJava4 : srvNode4)(srvPath)
75
57
  const db = isMultitenant ? serviceManager : hdiContainer
@@ -92,26 +74,23 @@ module.exports = class HanaTemplate extends require('../templateBase') {
92
74
  into: [srv, 'requires', 'name']
93
75
  }]
94
76
 
95
- if (!isMultitenant) {
77
+ if (isMultitenant) {
96
78
  relationships.push({
97
- insert: [hdiContainer, 'name'],
98
- into: [hdbDeployer, 'requires', 'name']
79
+ insert: [serviceManager, 'name'],
80
+ into: [mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar'), 'requires', 'name']
99
81
  })
100
82
  } else {
101
83
  relationships.push({
102
- insert: [serviceManager, 'name'],
103
- into: [mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar'), 'requires', 'name']
84
+ insert: [hdiContainer, 'name'],
85
+ into: [hdbDeployer, 'requires', 'name']
104
86
  })
105
87
  }
106
88
 
107
- const modules = !isMultitenant ? [srv, hdbDeployer] : [srv]
89
+ const modules = isMultitenant ? [srv] : [srv, hdbDeployer]
108
90
 
109
- await mergeYAML(
110
- 'mta.yaml',
111
- join(__dirname, 'files', 'mta.yaml.hbs'),
112
- project,
113
- { additions: [...modules, db].filter(a => a), deletions, relationships }
114
- )
91
+ await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, {
92
+ additions: [...modules, db].filter(a => a), deletions, relationships
93
+ })
115
94
  }
116
95
 
117
96
  if (hasHelm) {
@@ -123,7 +102,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
123
102
  }
124
103
 
125
104
  const HelmTemplate = require(`../helm`);
126
- const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
105
+ const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
127
106
 
128
107
  if(isMultitenant){
129
108
  shouldUpdateTrackingFile = true;
@@ -137,7 +116,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
137
116
  // remove content-deployment subchart if html5Repo doesn't exist
138
117
  if(!hasHtml5Repo) {
139
118
  const contentDeploymentEntriesPattern = "charts/content-deployment/"
140
- await this.removeEntriesFromContext(context, contentDeploymentEntriesPattern);
119
+ this.removeEntriesFromContext(context, contentDeploymentEntriesPattern);
141
120
 
142
121
  const contentDeploymentSubchartPath = join('chart', 'charts', 'content-deployment');
143
122
  if(exists(contentDeploymentSubchartPath)) {
@@ -193,21 +172,18 @@ module.exports = class HanaTemplate extends require('../templateBase') {
193
172
  }
194
173
  }
195
174
 
196
- async _updatePomXml() {
197
- // if called during cds init the project generation call to AT will add settings
198
- if (!this.options.add.has(JAVA)) {
199
- const mvnAddHanaArgs = mvnArchetypes.getAddHanaCmdArgs(this.options);
200
- try {
201
- await commandUtil.spawnCommand('mvn', mvnAddHanaArgs, {
202
- cwd: cds.root
203
- });
204
- } catch (err) {
205
- // REVISIT: This should not have to be checked and tested in a facet implementation, move to Maven util
206
- if (err.code === 'ENOENT' && err.path === 'mvn') {
207
- throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
208
- }
209
- throw err;
175
+ // REVISIT: tracking data massaging is getting too much -> revisit md5 tracking
176
+ removeEntriesFromContext(context, key) {
177
+ Object.keys(context.oldTrackingData).forEach(fileName => {
178
+ if (fileName.startsWith(key)) {
179
+ delete context.oldTrackingData[fileName]
210
180
  }
211
- }
181
+ })
182
+
183
+ Object.keys(context.newTrackingData).forEach(fileName => {
184
+ if (fileName.startsWith(key)) {
185
+ delete context.newTrackingData[fileName]
186
+ }
187
+ })
212
188
  }
213
189
  }
@@ -1,13 +1,14 @@
1
1
  const { join } = require('path');
2
- const { exists, rimraf } = require('../../../cds').utils;
2
+ const cds = require('../../../cds')
3
+ const { exists, rimraf } = cds.utils
3
4
  const { readProject } = require('../../util/projectReader');
4
5
  const { mergeYAML } = require('../../util/merge')
5
6
  const { parseMd5File, writeMd5File, copyAndTrack } = require('../../util/md5')
6
7
 
7
8
  module.exports = class HelmTemplate extends require('../templateBase') {
8
9
 
9
- constructor(generator, oldTrackingData = undefined, newTrackingData = {}) {
10
- super(generator)
10
+ constructor(oldTrackingData = undefined, newTrackingData = {}) {
11
+ super()
11
12
  this.oldTrackingData = oldTrackingData;
12
13
  this.newTrackingData = newTrackingData;
13
14
  }
@@ -16,18 +17,19 @@ module.exports = class HelmTemplate extends require('../templateBase') {
16
17
  return ['hana', 'xsuaa', 'auditlog', 'enterprise-messaging', 'destination' , 'multitenancy', 'extensibility', 'approuter', 'connectivity']
17
18
  }
18
19
 
19
- static hasFacet(_, options) {
20
+ static hasFacet() {
20
21
  // REVISIT: this works, but could be semantically nicer with a 'shouldRunDependentMerging' or the like
21
- if (options?.add.has('mta') && !options?.add.has('helm')) return false
22
+ const { add } = cds.cli.options
23
+ if (add.has('mta') && !add.has('helm')) return false
22
24
  return exists(join('chart', 'values.yaml'))
23
25
  }
24
26
 
25
27
  async canRun() {
26
- if (this.options.force) {
28
+ if (cds.cli.options.force) {
27
29
  await rimraf(join('chart'))
28
- return true;
30
+ return true
29
31
  }
30
- return true;
32
+ return true
31
33
  }
32
34
 
33
35
  async addSubChart(subchart, force = false) {
@@ -47,11 +49,11 @@ module.exports = class HelmTemplate extends require('../templateBase') {
47
49
  }
48
50
 
49
51
  async isInternal() {
50
- return !exists(join('chart', 'charts', 'web-application')) || this.options['internal-unified-runtime-charts'];
52
+ return !exists(join('chart', 'charts', 'web-application')) || cds.cli.options['internal-unified-runtime-charts'];
51
53
  }
52
54
 
53
55
  async addDependency(name, alias){
54
- const project = await readProject(this.options);
56
+ const project = await readProject();
55
57
  const isInternal = await this.isInternal();
56
58
  await mergeYAML(
57
59
  join('chart', 'Chart.yaml'),
@@ -77,8 +79,8 @@ module.exports = class HelmTemplate extends require('../templateBase') {
77
79
  }
78
80
 
79
81
  async run() {
80
- const project = await readProject(this.options)
81
- const isInternal = this.options['internal-unified-runtime-charts'] !== undefined && this.options['internal-unified-runtime-charts'];
82
+ const project = await readProject()
83
+ const isInternal = cds.cli.options['internal-unified-runtime-charts'] !== undefined && cds.cli.options['internal-unified-runtime-charts'];
82
84
  this.oldTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'));
83
85
  await this.addSubChart('web-application', !isInternal);
84
86
  await copyAndTrack(
@@ -100,7 +102,6 @@ module.exports = class HelmTemplate extends require('../templateBase') {
100
102
  join(__dirname, 'files', 'values.yaml.hbs'),
101
103
  project
102
104
  )
103
- await this.runDependentMerging();
104
105
  await writeMd5File(join('chart', '.cds-add-helm-files.md5'), this.newTrackingData);
105
106
  }
106
- };
107
+ }
@@ -13,7 +13,7 @@ module.exports = class Html5RepoTemplate extends require('../templateBase') {
13
13
  }
14
14
 
15
15
  async canRun() {
16
- const project = await readProject(this.options)
16
+ const project = await readProject()
17
17
  const { hasMta, hasHelm } = project
18
18
  if (!hasHelm && hasMta) {
19
19
  throw `'cds add html5-repo' is not available for Cloud Foundry yet`
@@ -26,12 +26,8 @@ module.exports = class Html5RepoTemplate extends require('../templateBase') {
26
26
  return exists(join('chart', 'templates', 'html5-apps-deployer-configmap.yaml'))
27
27
  }
28
28
 
29
- async run() {
30
- await this.runDependentMerging()
31
- }
32
-
33
29
  async runDependentMerging(context = {}) {
34
- const { appName, hasHelm } = await readProject(this.options)
30
+ const { appName, hasHelm } = await readProject()
35
31
 
36
32
  if (hasHelm) {
37
33
  //in case facet is being added to the already exisiting charts folder
@@ -78,7 +74,7 @@ module.exports = class Html5RepoTemplate extends require('../templateBase') {
78
74
 
79
75
  // copy content deployment chart if it is not present
80
76
  const HelmTemplate = require(`../helm`);
81
- const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
77
+ const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
82
78
  isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('content-deployment');
83
79
 
84
80
  // add dependency entry in chart.yaml
@@ -23,13 +23,13 @@ module.exports = class JavaTemplate extends require('../templateBase') {
23
23
  }
24
24
 
25
25
  async run() {
26
- const { cmdLine, artifactId, archetypeVersion } = await mvn.getGenerateCmdArgs(this.projectName, this.options)
26
+ const { cmdLine, artifactId, archetypeVersion } = await mvn.getGenerateCmdArgs(path.basename(cds.root))
27
27
  console.log(`Using Maven archetype version ${archetypeVersion}`)
28
28
 
29
- const temp = await fs.promises.mkdtemp(join(os.tmpdir(), `${this.projectName}_`))
29
+ const temp = await fs.promises.mkdtemp(join(os.tmpdir(), `${path.basename(cds.root)}_`))
30
30
  try {
31
31
  await cmd.spawnCommand('mvn', cmdLine, { cwd: temp })
32
- await copy(join(temp, artifactId), this.projectPath);
32
+ await copy(join(temp, artifactId), cds.root);
33
33
  } catch (err) {
34
34
  if (err.code === 'ENOENT' && err.path === 'mvn') {
35
35
  throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
@@ -10,21 +10,20 @@ module.exports = class KibanaTemplate extends require('../templateBase') {
10
10
  }
11
11
 
12
12
  async canRun() {
13
- const { hasMta, hasHelm, isJava } = await readProject(this.options)
13
+ const { hasMta, hasHelm, isJava } = await readProject()
14
14
  if (hasHelm && !hasMta) throw `'cds add kibana' is not available for Kyma yet`
15
15
  if (isJava) throw `'cds add kibana' is not available for Java yet`
16
16
  return true
17
17
  }
18
18
 
19
19
  async run() {
20
- const project = await readProject(this.options)
20
+ const project = await readProject()
21
21
  const { configFile } = project
22
22
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
23
- await this.runDependentMerging()
24
23
  }
25
24
 
26
25
  async runDependentMerging() {
27
- const project = await readProject(this.options)
26
+ const project = await readProject()
28
27
  const { hasMta, hasApprouter, isJava, isMultitenant, srvPath } = project
29
28
 
30
29
  if (hasMta) {
@@ -10,7 +10,6 @@ const { LINT_DEV, LINT_GLOBAL } = require("../../constants").OPTIONS;
10
10
  const { getConfigPath, getFileExtensions } = require("@sap/eslint-plugin-cds/lib/api");
11
11
  const cds = require("../../../cds");
12
12
  const { mkdirp, exists } = cds.utils;
13
- const LOG = console;
14
13
 
15
14
  const IS_WIN = os.platform() === "win32";
16
15
  const ALLOWED_FILE_EXTENSIONS = getFileExtensions();
@@ -19,8 +18,8 @@ const VSCODE_FILE_ASSOCIATIONS = {
19
18
  }
20
19
 
21
20
  module.exports = class LintTemplate extends require('../templateBase') {
22
- constructor(generator) {
23
- super(generator);
21
+ constructor() {
22
+ super();
24
23
  this.customPath = path.join(cds.root, ".eslint");
25
24
  this.docsPath = path.join(this.customPath, "docs");
26
25
  this.rulesPath = path.join(this.customPath, "rules");
@@ -32,13 +31,14 @@ module.exports = class LintTemplate extends require('../templateBase') {
32
31
  }
33
32
 
34
33
  async canRun() {
35
- if (this.options.lint) {
34
+ const { lint } = cds.cli.options
35
+ if (lint) {
36
36
  // If custom rule example is requested, also trigger
37
37
  // "custom" rule type of setup
38
- if (this.options.lint.has(LINT_DEV)) {
38
+ if (lint.has(LINT_DEV)) {
39
39
  this.customRuleExample = true;
40
40
  }
41
- if (this.options.lint.has(LINT_GLOBAL)) {
41
+ if (lint.has(LINT_GLOBAL)) {
42
42
  this.lintType = "global";
43
43
  }
44
44
  }
@@ -98,21 +98,21 @@ module.exports = class LintTemplate extends require('../templateBase') {
98
98
  "names"
99
99
  ].join(" ")}`;
100
100
 
101
- if (this.options.force) {
102
- LOG.info(
101
+ if (cds.cli.options.force) {
102
+ console.log(
103
103
  `\n\nAlmost done - installing ${this.missingNpmDependencies["names"].length} npm dependencies:\n${task}`
104
104
  );
105
105
  this._runTask(task);
106
106
  } else {
107
- LOG.info(
107
+ console.log(
108
108
  `\n\nAlmost done - ${term.warn(
109
109
  `you are missing ${this.missingNpmDependencies["names"].length} npm dependencies`
110
110
  )}:\n`
111
111
  );
112
112
  this.missingNpmDependencies["msgs"].forEach((msg, i) => {
113
- LOG.info(`(${i + 1}) ${msg}`);
113
+ console.log(`(${i + 1}) ${msg}`);
114
114
  if (i === this.missingNpmDependencies["msgs"].length - 1) {
115
- LOG.info("\n");
115
+ console.log("\n");
116
116
  }
117
117
  });
118
118
  await this._promptInstallDependencies(task);
@@ -187,11 +187,11 @@ module.exports = class LintTemplate extends require('../templateBase') {
187
187
  clearTimeout(timerID);
188
188
  received = answer.trim().toLowerCase();
189
189
  // If user confirms or force flag is set, install dependencies
190
- if (["y", "yes"].includes(received) || this.options.force) {
190
+ if (["y", "yes"].includes(received) || cds.cli.options.force) {
191
191
  resolve(this._runTask(task));
192
192
  // If use declines or question timeout is reached, print todos
193
193
  } else if (["n", "no"].includes(received.toLowerCase())) {
194
- LOG.info(todos);
194
+ console.log(todos);
195
195
  resolve();
196
196
  } else {
197
197
  // Close and restart question (with new timeout)
@@ -7,7 +7,8 @@ const { mergeJSON, sort } = require('../../util/merge')
7
7
 
8
8
  module.exports = class MtaTemplate extends require('../templateBase') {
9
9
 
10
- static hasFacet(_, options) {
10
+ static hasFacet() {
11
+ const { options } = cds.cli
11
12
  if (!options?.add.has('mta') && options?.add.has('helm')) return false
12
13
  return exists('mta.yaml')
13
14
  }
@@ -17,7 +18,7 @@ module.exports = class MtaTemplate extends require('../templateBase') {
17
18
  }
18
19
 
19
20
  async run() {
20
- const project = await readProject(this.options)
21
+ const project = await readProject()
21
22
  if (!exists('mta.yaml')) {
22
23
  await copyRenderedYAML(join(__dirname, 'files', 'mta.yaml.hbs'), 'mta.yaml', project)
23
24
  }
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "scripts": {
15
15
  "start": "cds-serve"{{#isJava}},
16
- "build": "cds build ../.. --for mtx-sidecar --production && cd gen && npm ci"{{/isJava}}
16
+ "build": "cds build ../.. --for mtx-sidecar --production && npm ci --prefix gen"{{/isJava}}
17
17
  },
18
18
  "cds": {
19
19
  "profile": "mtx-sidecar"
@@ -15,8 +15,9 @@ const {
15
15
 
16
16
  module.exports = class MultitenancyTemplate extends require('../templateBase') {
17
17
 
18
- static hasFacet(env, options) {
18
+ static hasFacet(env) {
19
19
  // REVISIT: Check if this can be simplified
20
+ const { options } = cds.cli.options
20
21
  return options?.add?.has('mtx') || options?.add?.has('multitenancy') ||
21
22
  !!env.requires?.multitenancy || !!env.requires?.db?.multiTenant ||
22
23
  exists(join('mtx', 'sidecar')) || false
@@ -27,7 +28,7 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
27
28
  }
28
29
 
29
30
  async run() {
30
- const project = await readProject(this.options)
31
+ const project = await readProject()
31
32
  const { isNodejs, isJava, configFile } = project
32
33
  await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), project)
33
34
  if (isJava) {
@@ -37,11 +38,10 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
37
38
  }
38
39
  if (isNodejs) await sort('package.json', 'dependencies')
39
40
  await copyRenderedJSON(join(__dirname, 'files', 'package.sidecar.json.hbs'), join('mtx', 'sidecar', 'package.json'), project)
40
- await this.runDependentMerging()
41
41
  }
42
42
 
43
43
  async runDependentMerging(context = {}) {
44
- const project = await readProject(this.options)
44
+ const project = await readProject()
45
45
  const { isNodejs, isJava, hasMta, hasHelm, hasXsuaa, hasHana, srvPath } = project
46
46
 
47
47
  if (hasMta) {
@@ -93,11 +93,7 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
93
93
  context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'))
94
94
  }
95
95
 
96
- await mergeYAML(
97
- join('chart', 'values.yaml'),
98
- join(__dirname, 'files', 'values.yaml.hbs'),
99
- project
100
- )
96
+ await mergeYAML(join('chart', 'values.yaml'), join(__dirname, 'files', 'values.yaml.hbs'), project)
101
97
 
102
98
  const envFromObject = {
103
99
  envFrom: [
@@ -130,7 +126,7 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
130
126
 
131
127
  // REVISIT: Don't reference other templates except for the safe `runDependentMerging` -> low coupling, high cohesion
132
128
  const HelmTemplate = require(`../helm`);
133
- const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
129
+ const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
134
130
 
135
131
  await helmTemplate.addDependency('web-application', 'sidecar');
136
132
 
@@ -159,33 +155,16 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
159
155
  }
160
156
 
161
157
  if (hasXsuaa) {
162
- await mergeJSON(
163
- 'xs-security.json',
164
- join(__dirname, 'files', 'xs-security.json.hbs'),
165
- project,
166
- {
167
- additions: [{
168
- in: 'scopes',
169
- where: [{ property: 'name', isEqualTo: '$XSAPPNAME.mtcallback' }],
170
- }]
171
- }
172
- )
173
- }
174
-
175
- if (hasXsuaa && hasHelm) {
176
- await mergeYAML(
177
- join('chart', 'values.yaml'),
178
- {
179
- xsuaa: {
180
- parameters: {
181
- 'tenant-mode': 'shared'
182
- }
183
- }
184
- },
185
- null,
186
- { forceOverwrite: true }
187
- )
188
- if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
158
+ await mergeJSON('xs-security.json',join(__dirname, 'files', 'xs-security.json.hbs'), project, {
159
+ additions: [{
160
+ in: 'scopes',
161
+ where: [{ property: 'name', isEqualTo: '$XSAPPNAME.mtcallback' }],
162
+ }]
163
+ })
164
+ if (hasHelm) {
165
+ await mergeYAML(join('chart', 'values.yaml'), { xsuaa: { parameters: { 'tenant-mode': 'shared' }}}, null, { forceOverwrite: true })
166
+ if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
167
+ }
189
168
  }
190
169
  }
191
170
  }
@@ -1,10 +1,9 @@
1
1
  const { join } = require('path')
2
2
  const cds = require('../../../cds')
3
- const { exists, mkdirp } = cds.utils
3
+ const { exists, mkdirp, path } = cds.utils
4
4
  const { URLS, OPTIONS: { NODEJS, JAVA }, COMMAND_ADD } = require('../../constants')
5
5
  const term = require('../../../util/term')
6
6
  const { copyFiles } = require('../../util/template')
7
- const LOG = console
8
7
 
9
8
  module.exports = class NodejsTemplate extends require('../templateBase') {
10
9
 
@@ -24,13 +23,12 @@ module.exports = class NodejsTemplate extends require('../templateBase') {
24
23
 
25
24
  async run() {
26
25
  const { db, srv, app } = (await this.getEnv()).folders
27
- const { projectPath, projectName } = this
28
- await copyFiles(join(__dirname, 'files'), projectPath, { projectName }, this.options.force)
26
+ await copyFiles(join(__dirname, 'files'), cds.root, { projectName: path.basename(cds.root) }, cds.cli.options.force)
29
27
  await Promise.all([db, srv, app].map(p => mkdirp(p)))
30
28
  }
31
29
 
32
30
  async finalize() {
33
- LOG.info(`Find samples on ${term.link(URLS.SAMPLES)}`)
34
- LOG.info(`Learn about next steps at ${term.link(URLS.CAPIRE)}`)
31
+ console.log(`Find samples on ${term.link(URLS.SAMPLES)}`)
32
+ console.log(`Learn about next steps at ${term.link(URLS.CAPIRE)}`)
35
33
  }
36
34
  }
@@ -3,13 +3,12 @@ const cds = require('../../../cds')
3
3
  const { exists } = cds.utils
4
4
  const { copyFiles } = require('../../util/template')
5
5
  const { URLS } = require('../../constants')
6
- const LOG = console
7
6
 
8
7
  module.exports = class PipelineTemplate extends require('../templateBase') {
9
8
 
10
9
 
11
10
  async canRun() {
12
- if (this.options.force) {
11
+ if (cds.cli.options.force) {
13
12
  return true;
14
13
  }
15
14
 
@@ -21,10 +20,10 @@ module.exports = class PipelineTemplate extends require('../templateBase') {
21
20
  }
22
21
 
23
22
  async run() {
24
- await copyFiles(join(__dirname, 'files'), cds.root, {}, this.options.force);
23
+ await copyFiles(join(__dirname, 'files'), cds.root, {}, true);
25
24
  }
26
25
 
27
26
  async finalize() {
28
- LOG.info(`For information on project "Piper" and its pipelines see ${URLS.PIPELINE_HELP}`);
27
+ console.log(`For information on project "Piper" and its pipelines see ${URLS.PIPELINE_HELP}`);
29
28
  }
30
29
  }
@@ -8,7 +8,7 @@ const { srvNode4, srvJava4, redis } = require('../_merging/registry-mta')
8
8
  module.exports = class RedisMessagingTemplate extends require('../templateBase') {
9
9
 
10
10
  async canRun() {
11
- const { hasMta, hasHelm, isJava } = await readProject(this.options)
11
+ const { hasMta, hasHelm, isJava } = await readProject()
12
12
  if (isJava) throw `'cds add redis-messaging' is not available for Java yet`
13
13
  if (hasHelm && !hasMta) throw `'cds add redis-messaging' is not available for Kyma yet`
14
14
  return true
@@ -19,15 +19,14 @@ module.exports = class RedisMessagingTemplate extends require('../templateBase')
19
19
  }
20
20
 
21
21
  async run() {
22
- const project = await readProject(this.options)
22
+ const project = await readProject()
23
23
  const { configFile } = project
24
24
  project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
25
25
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
26
- await this.runDependentMerging()
27
26
  }
28
27
 
29
28
  async runDependentMerging() {
30
- const project = await readProject(this.options)
29
+ const project = await readProject()
31
30
  const { hasMta, isNodejs, srvPath } = project
32
31
 
33
32
  if (hasMta) {