@sap/cds-dk 6.0.2 → 6.1.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 (105) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/bin/add.js +29 -16
  3. package/bin/cds.js +7 -3
  4. package/bin/compile/index.js +6 -1
  5. package/bin/deploy/index.js +7 -1
  6. package/bin/fix-redirects.js +4 -2
  7. package/bin/init.js +5 -0
  8. package/bin/login.js +8 -2
  9. package/bin/pull.js +58 -0
  10. package/bin/push.js +52 -0
  11. package/bin/subscribe.js +45 -0
  12. package/lib/bind/bindingResolver.js +1 -2
  13. package/lib/bind/bindingUtil.js +1 -2
  14. package/lib/bind/cfKeyProvider.js +3 -3
  15. package/lib/client/activate.js +1 -1
  16. package/lib/client/auth_manager.js +7 -3
  17. package/lib/client/extend.js +1 -1
  18. package/lib/client/helper/cf_helper.js +1 -0
  19. package/lib/client/helper/url_helper.js +7 -3
  20. package/lib/client/index.js +1 -1
  21. package/lib/client/params.js +4 -2
  22. package/lib/client/pull.js +51 -0
  23. package/lib/client/push.js +49 -0
  24. package/lib/client/settings_manager.js +74 -21
  25. package/lib/compile/openapi/csdl2openapi.js +135 -163
  26. package/lib/compile/openapi/index.js +0 -1
  27. package/lib/import/common.js +9 -1
  28. package/lib/import/odata/metadataconverter/MetadataConverter.js +17 -4
  29. package/lib/import/odata/v2parser.js +0 -1
  30. package/lib/import/odata/v4parser.js +103 -29
  31. package/lib/import/openapi/importOpenAPI.js +3 -3
  32. package/lib/init/constants.js +9 -3
  33. package/lib/init/template/_merging/registry-mta.js +290 -0
  34. package/lib/init/template/approuter/index.js +22 -32
  35. package/lib/init/template/auditlog/index.js +7 -9
  36. package/lib/init/template/extensibility/files/cds.package.json +7 -0
  37. package/lib/init/template/extensibility/files/cds.package.json.hbs +9 -0
  38. package/lib/init/template/extensibility/files/xs-security.json.hbs +26 -0
  39. package/lib/init/template/extensibility/index.js +48 -0
  40. package/lib/init/template/hana/files/java/cdsrc.json.hbs +1 -1
  41. package/lib/init/template/hana/files/java/profile.cdsrc.json.hbs +2 -2
  42. package/lib/init/template/hana/files/mta.yaml.hbs +10 -0
  43. package/lib/init/template/hana/files/nodejs/cds.package.json.hbs +1 -1
  44. package/lib/init/template/hana/files/nodejs/cds.profile.package.json.hbs +2 -2
  45. package/lib/init/template/hana/index.js +76 -63
  46. package/lib/init/template/kibana-logging/index.js +31 -37
  47. package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +14 -14
  48. package/lib/init/template/lint/index.js +1 -1
  49. package/lib/init/template/mta/files/mta.yaml.hbs +1 -1
  50. package/lib/init/template/mta/index.js +13 -7
  51. package/lib/init/template/mtx/index.js +2 -142
  52. package/lib/init/template/multitenancy/files/cds.package.json +7 -0
  53. package/lib/init/template/multitenancy/files/cds.package.json.hbs +9 -0
  54. package/lib/init/template/{mtx → multitenancy}/files/dependencies.package.json +1 -1
  55. package/lib/init/template/multitenancy/files/java/.cdsrc.json +19 -0
  56. package/lib/init/template/multitenancy/files/java/package.json +31 -0
  57. package/lib/init/template/{mtx → multitenancy}/files/mta.yaml.hbs +13 -6
  58. package/lib/init/template/multitenancy/files/xs-security.json.hbs +18 -0
  59. package/lib/init/template/multitenancy/index.js +109 -0
  60. package/lib/init/template/nodejs/files/package.json.hbs +3 -0
  61. package/lib/init/template/templateBase.js +4 -3
  62. package/lib/init/template/toggles/files/cds.package.json +7 -0
  63. package/lib/init/template/toggles/files/cds.package.json.hbs +9 -0
  64. package/lib/init/template/toggles/index.js +24 -0
  65. package/lib/init/template/xsuaa/files/mta.yaml.hbs +10 -0
  66. package/lib/init/template/xsuaa/index.js +44 -33
  67. package/lib/init/util/projectReader.js +13 -8
  68. package/lib/init/util/templateUtil.js +112 -110
  69. package/lib/k8s/ChartAdder.js +11 -3
  70. package/lib/k8s/ChartBuilder.js +6 -0
  71. package/lib/k8s/buildModel.js +1 -3
  72. package/lib/k8s/connectivity/index.js +11 -5
  73. package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +7 -3
  74. package/lib/k8s/deployment/index.js +2 -4
  75. package/lib/k8s/deployment/subchart/Chart.yaml +1 -1
  76. package/lib/k8s/deployment/subchart/templates/_helpers.tpl +22 -11
  77. package/lib/k8s/deployment/subchart/templates/deployment.yaml +12 -5
  78. package/lib/k8s/deployment/subchart/templates/network-policy.yaml +3 -1
  79. package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +1 -1
  80. package/lib/k8s/deployment/subchart/values.md +812 -0
  81. package/lib/k8s/deployment/subchart/values.schema.json +125 -30
  82. package/lib/k8s/deployment/subchart/values.yaml +7 -3
  83. package/lib/k8s/hana-deployer/index.js +10 -0
  84. package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +8 -0
  85. package/lib/k8s/html5-apps-deployer/index.js +10 -0
  86. package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +8 -0
  87. package/lib/k8s/index.js +2 -2
  88. package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +1 -159
  89. package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +0 -33
  90. package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +1 -1
  91. package/lib/k8s/resources/helm/chart/values.schema.json +449 -0
  92. package/lib/k8s/xsuaa/lib.js +10 -7
  93. package/lib/lint/Linter.js +155 -158
  94. package/lib/lint/generators.js +1 -1
  95. package/lib/lint/io.js +13 -5
  96. package/npm-shrinkwrap.json +1053 -136
  97. package/package.json +5 -4
  98. package/lib/init/template/_merging/existences.js +0 -297
  99. package/lib/init/template/mtx/files/cds.package.json +0 -12
  100. package/lib/init/template/mtx/files/cds.package.json.hbs +0 -14
  101. package/lib/init/template/mtx/files/java/.cdsrc.json +0 -17
  102. package/lib/init/template/mtx/files/java/package.json +0 -43
  103. package/lib/init/template/mtx/files/java/server.js +0 -30
  104. package/lib/init/template/mtx/files/xs-security.json.hbs +0 -48
  105. package/lib/lint/.eslintrc.js +0 -3
@@ -0,0 +1,9 @@
1
+ {
2
+ "cds": {
3
+ "requires": {
4
+ "[{{cap.for}}]": {
5
+ "extensibility": true
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "scopes": [
3
+ {
4
+ "name": "$XSAPPNAME.cds.ExtensionDeveloper",
5
+ "description": "Extend CAP applications via extension projects"
6
+ },
7
+ {
8
+ "name": "$XSAPPNAME.cds.UIFlexDeveloper",
9
+ "description": "Extend CAP applications via UIFlex extensibility"
10
+ }
11
+ ],
12
+ "role-templates": [
13
+ {
14
+ "name": "ExtensionDeveloper",
15
+ "description": "Extension development including UIFlex extensibility",
16
+ "scope-references": [
17
+ "$XSAPPNAME.cds.ExtensionDeveloper",
18
+ "$XSAPPNAME.cds.UIFlexDeveloper"
19
+ ]
20
+ }
21
+ ],
22
+ "authorities": [
23
+ "$XSAPPNAME.cds.ExtensionDeveloper",
24
+ "$XSAPPNAME.cds.UIFlexDeveloper"
25
+ ]
26
+ }
@@ -0,0 +1,48 @@
1
+ const cds = require('../../../cds'), { path } = cds.utils
2
+ const TemplateBase = require('../templateBase')
3
+ const ProjectReader = require('../../util/projectReader')
4
+
5
+ module.exports = class ExtensibilityTemplate extends TemplateBase {
6
+ constructor(projectPath, generator) {
7
+ super(projectPath, generator, __dirname)
8
+ this.projectReader = new ProjectReader(this)
9
+ }
10
+
11
+ async runDependentMerging() {
12
+ const projectDescriptor = await this.projectReader.read()
13
+ const { hasXsuaa } = projectDescriptor.cap
14
+ if (hasXsuaa) {
15
+ await this.templateUtil.mergeJSON(
16
+ path.join(this.projectPath, 'xs-security.json'),
17
+ path.join(__dirname, 'files', 'xs-security.json.hbs'),
18
+ projectDescriptor,
19
+ {
20
+ additions: [{
21
+ ref: 'scope-extension-developer',
22
+ in: 'scopes',
23
+ where: [{ property: 'name', isEqualTo: '$XSAPPNAME.cds.ExtensionDeveloper' }],
24
+ }, {
25
+ ref: 'scope-uiflex',
26
+ in: 'scopes',
27
+ where: [{ property: 'name', isEqualTo: '$XSAPPNAME.cds.UIFlexDeveloper' }],
28
+ }, {
29
+ ref: 'template-extension-developer',
30
+ in: 'role-templates',
31
+ where: [{ property: 'name', isEqualTo: 'ExtensionDeveloper' }],
32
+ }]
33
+ }
34
+ )
35
+ }
36
+ }
37
+
38
+ async run() {
39
+ const projectDescriptor = await this.projectReader.read(this.options)
40
+ const { for: forProfile, isJava } = projectDescriptor.cap
41
+ const basePath = isJava ? path.join(this.projectPath, 'mtx', 'sidecar') : this.projectPath
42
+ const packageJSONPath = path.join(basePath, 'package.json')
43
+ const cdsTemplateFile = forProfile ? 'cds.package.json.hbs' : 'cds.package.json'
44
+ await this.templateUtil.mergeJSON(packageJSONPath, path.join(__dirname, 'files', cdsTemplateFile), projectDescriptor)
45
+ await this.templateUtil.sortDependencies(packageJSONPath)
46
+ await this.runDependentMerging()
47
+ }
48
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "requires": {
3
3
  "db": {
4
- "kind": { "#overwrite": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}" }
4
+ "kind": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
5
5
  }
6
6
  }
7
7
  }
@@ -2,11 +2,11 @@
2
2
  "requires": {
3
3
  "[{{cap.for}}]": {
4
4
  "db": {
5
- "kind": { "#overwrite": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}" }
5
+ "kind": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
6
6
  }
7
7
  },
8
8
  "db": {
9
- "kind": "sql"
9
+ "kind": "{{#cap.isMultitenant}}sqlite{{/cap.isMultitenant}}{{^cap.isMultitenant}}sql{{/cap.isMultitenant}}"
10
10
  }
11
11
  }
12
12
  }
@@ -15,6 +15,16 @@ modules:
15
15
  - name: {{cap.appName}}-db
16
16
  {{/cap.isMultitenant}}
17
17
 
18
+ {{#cap.isJava}}
19
+ {{#cap.isMultitenant}}
20
+ - name: {{cap.appName}}-mtx-sidecar
21
+ type: nodejs
22
+ path: mtx/sidecar
23
+ requires:
24
+ - name: {{cap.appName}}-db
25
+ {{/cap.isMultitenant}}
26
+ {{/cap.isJava}}
27
+
18
28
  resources:
19
29
  - name: {{cap.appName}}-db
20
30
  {{^cap.isMultitenant}}
@@ -2,7 +2,7 @@
2
2
  "cds": {
3
3
  "requires": {
4
4
  "db": {
5
- "kind": { "#overwrite": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}" }
5
+ "kind": "{{#cap.isMultitenant}}sql-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
6
6
  }
7
7
  }
8
8
  }
@@ -3,11 +3,11 @@
3
3
  "requires": {
4
4
  "[{{cap.for}}]": {
5
5
  "db": {
6
- "kind": { "#overwrite": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}" }
6
+ "kind": "{{#cap.isMultitenant}}hana-mt{{/cap.isMultitenant}}{{^cap.isMultitenant}}hana-cloud{{/cap.isMultitenant}}"
7
7
  }
8
8
  },
9
9
  "db": {
10
- "kind": "sql"
10
+ "kind": "{{#cap.isMultitenant}}sqlite{{/cap.isMultitenant}}{{^cap.isMultitenant}}sql{{/cap.isMultitenant}}"
11
11
  }
12
12
  }
13
13
  }
@@ -7,10 +7,11 @@ const term = require('../../../util/term');
7
7
  const ProjectReader = require('../../util/projectReader');
8
8
 
9
9
  const TemplateBase = require('../templateBase');
10
+ const versionCompare = require('../../util/versionCompare');
10
11
 
11
12
  const { PROJECT_TYPE, OPTION_JAVA, URLS, OPTION_HELM_UPDATE } = require('../../constants');
12
13
  const { nullLogger } = require('../../util/logger');
13
- const { srvNode, srvJava, hdbDeployer, serviceManager, hdiContainer } = require('../_merging/existences');
14
+ const { srvNode, srvJava, hdbDeployer, serviceManager, hdiContainer, mtxSidecar } = require('../_merging/registry-mta');
14
15
 
15
16
  module.exports = class HanaTemplate extends TemplateBase {
16
17
  constructor(projectPath, generator) {
@@ -34,66 +35,70 @@ module.exports = class HanaTemplate extends TemplateBase {
34
35
  }
35
36
 
36
37
  async checkEnabled() {
37
- const { lt } = require('semver')
38
38
  const cds = require('../../../cds')
39
- if (lt(cds.version, '5.9.0')) {
39
+ if (versionCompare(cds.version, '5.9.0') < 0) {
40
40
  cds.error('The added configuration requires @sap/cds 5.9.0 or higher. Please update @sap/cds to the latest version and run \x1b[1mcds add hana\x1b[0m again.')
41
41
  }
42
42
  return true
43
43
  }
44
44
 
45
45
  async runDependentMerging() {
46
- const projectDescriptor = await this.projectReader.read(this.options);
46
+ const projectDescriptor = await this.projectReader.read(this.options)
47
+ const { hasMtaDeployment, isNodejs, isJava, isMultitenant, hasHana } = projectDescriptor.cap
48
+
49
+ if (isNodejs && isMultitenant) {
50
+ await this._updateCdsConfiguration()
51
+ } else if (isJava && isMultitenant) {
52
+ await this._updateCdsrcJson()
53
+ }
47
54
 
48
- const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
55
+ if (hasMtaDeployment) {
56
+ const srv = isNodejs ? srvNode : srvJava
57
+ const db = isMultitenant ? serviceManager : hdiContainer
58
+ const deletions = isMultitenant ? [{
59
+ item: hdbDeployer,
60
+ relationships: [{
61
+ removeProperty: 'name',
62
+ allWithin: ['modules', 'requires', 'name'],
63
+ }]
64
+ }, {
65
+ item: hdiContainer,
66
+ relationships: [{
67
+ removeProperty: 'name',
68
+ allWithin: ['modules', 'requires', 'name'],
69
+ }]
70
+ }] : []
49
71
 
50
- if (!fs.existsSync(mtaYAMLPath)) return
72
+ const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
51
73
 
52
- const srv = projectDescriptor.cap.isNodejs ? srvNode : srvJava
53
- const deployer = projectDescriptor.cap.isMultitenant ? null : hdbDeployer
54
- const db = projectDescriptor.cap.isMultitenant ? serviceManager : hdiContainer
55
- const deletions = projectDescriptor.cap.isMultitenant ? [{
56
- existence: hdbDeployer,
57
- relationships: [{
58
- allWithinKeyPath: ["modules"],
59
- inKeyPath: ["requires"],
60
- into: "name",
61
- existenceKeyPath: ["name"],
62
- }]
63
- }, {
64
- existence: hdiContainer,
65
- relationships: [{
66
- allWithinKeyPath: ["modules"],
67
- inKeyPath: ["requires"],
68
- into: "name",
69
- existenceKeyPath: ["name"],
74
+ const relationships = [{
75
+ insert: [db, 'name'],
76
+ into: [srv, 'requires', 'name']
70
77
  }]
71
- }] : []
72
-
73
- await this.templateUtil.mergeYAML(
74
- mtaYAMLPath,
75
- `${__dirname}/files/mta.yaml.hbs`,
76
- projectDescriptor,
77
- {
78
- existences: [srv, deployer, db],
79
- relationships: [{
80
- in: srv,
81
- inKeyPath: ["requires"],
82
- into: "name",
83
- existences: [db],
84
- existenceKeyPath: ["name"],
85
- },
86
- !projectDescriptor.cap.isMultitenant && projectDescriptor.cap.isNodejs ?
87
- {
88
- in: deployer,
89
- inKeyPath: ["requires"],
90
- into: "name",
91
- existences: [db],
92
- existenceKeyPath: ["name"],
93
- } : null],
94
- deletions
78
+
79
+ if (!isMultitenant) {
80
+ relationships.push({
81
+ insert: [hdiContainer, 'name'],
82
+ into: [hdbDeployer, 'requires', 'name']
83
+ })
84
+ }
85
+
86
+ if (isJava && isMultitenant) {
87
+ relationships.push({
88
+ insert: [serviceManager, 'name'],
89
+ into: [mtxSidecar, 'requires', 'name']
90
+ })
95
91
  }
96
- );
92
+
93
+ const modules = !isMultitenant ? [srv, hdbDeployer] : [srv]
94
+
95
+ await this.templateUtil.mergeYAML(
96
+ mtaYAMLPath,
97
+ `${__dirname}/files/mta.yaml.hbs`,
98
+ projectDescriptor,
99
+ { additions: [...modules, db].filter(a => a), deletions, relationships }
100
+ )
101
+ }
97
102
  }
98
103
 
99
104
  async run() {
@@ -112,14 +117,13 @@ module.exports = class HanaTemplate extends TemplateBase {
112
117
  case PROJECT_TYPE.java: {
113
118
  await this.templateUtil.copyFiles(path.join('java', 'db'), path.join(this.projectPath, env.folders.db), {}, this.options.force);
114
119
  await this._updatePomXml();
115
- const cdsrcJsonPath = path.join(this.projectPath, '.cdsrc.json');
116
- await this._updateCdsrcJson(cdsrcJsonPath, env.folders.db, env);
120
+ await this._updateCdsrcJson();
117
121
  break;
118
122
  }
119
- case PROJECT_TYPE.nodejs:
120
- await this._updatePackageJson(path.join(this.projectPath, 'package.json'));
123
+ case PROJECT_TYPE.nodejs: {
124
+ await this._updatePackageJson()
121
125
  break;
122
-
126
+ }
123
127
  default: break;
124
128
  }
125
129
  await this.runDependentMerging()
@@ -142,29 +146,38 @@ module.exports = class HanaTemplate extends TemplateBase {
142
146
  }
143
147
  }
144
148
 
145
- async _updatePackageJson(packageJsonPath) {
146
- const projectDescriptor = await this.projectReader.read(this.options);
149
+ async _updatePackageJson() {
150
+ const packageJsonPath = path.join(this.projectPath, 'package.json')
147
151
  const dependenciesTemplatePath = path.join(__dirname, 'files', 'nodejs', 'dependencies.package.json');
148
152
  await this.templateUtil.mergeJSON(packageJsonPath, dependenciesTemplatePath);
149
153
 
150
- const cdsTemplateFile = projectDescriptor.cap.for ? 'cds.profile.package.json.hbs' : 'cds.package.json.hbs';
151
- const cdsTemplatePath = path.join(__dirname, 'files', 'nodejs', cdsTemplateFile);
152
- await this.templateUtil.mergeJSON(packageJsonPath, cdsTemplatePath, projectDescriptor);
153
-
154
154
  const packageJson = await this.fsUtil.readJSON(packageJsonPath);
155
155
  if (packageJson.dependencies['@sap/hana-client']) {
156
156
  delete packageJson.dependencies['@sap/hana-client'];
157
157
  await this.fsUtil.writeJSON(packageJsonPath, packageJson);
158
158
  }
159
+
160
+ await this._updateCdsConfiguration(packageJsonPath)
161
+ }
162
+
163
+ async _updateCdsConfiguration() {
164
+ const packageJsonPath = path.join(this.projectPath, 'package.json')
165
+ const projectDescriptor = await this.projectReader.read(this.options);
166
+ const { for: forProfile } = projectDescriptor.cap;
167
+ const cdsTemplateFile = forProfile ? 'cds.profile.package.json.hbs' : 'cds.package.json.hbs';
168
+ const cdsTemplatePath = path.join(__dirname, 'files', 'nodejs', cdsTemplateFile);
169
+ await this.templateUtil.mergeJSON(packageJsonPath, cdsTemplatePath, projectDescriptor, { forceOverwrite: true })
159
170
  }
160
171
 
161
- async _updateCdsrcJson(cdsrcJsonPath) {
172
+ async _updateCdsrcJson() {
173
+ const cdsrcJsonPath = path.join(this.projectPath, '.cdsrc.json');
162
174
  const projectDescriptor = await this.projectReader.read(this.options);
163
- const cdsTemplateFile = projectDescriptor.cap.for ? 'profile.cdsrc.json.hbs' : 'cdsrc.json.hbs';
175
+ const { for: forProfile } = projectDescriptor.cap;
176
+ const cdsTemplateFile = forProfile ? 'profile.cdsrc.json.hbs' : 'cdsrc.json.hbs';
164
177
  const cdsTemplatePath = path.join(__dirname, 'files', 'java', cdsTemplateFile);
165
178
  if (!fs.existsSync(cdsrcJsonPath)) {
166
179
  this.fsUtil.writeJSON(cdsrcJsonPath, {})
167
180
  }
168
- await this.templateUtil.mergeJSON(cdsrcJsonPath, cdsTemplatePath, projectDescriptor);
181
+ await this.templateUtil.mergeJSON(cdsrcJsonPath, cdsTemplatePath, projectDescriptor, { forceOverwrite: true });
169
182
  }
170
183
  }
@@ -1,59 +1,53 @@
1
1
  const cds = require('../../../cds')
2
- const fs = require('fs');
3
- const path = require('path');
2
+ const path = require('path')
4
3
 
5
- const ProjectReader = require('../../util/projectReader');
6
-
7
- const TemplateBase = require('../templateBase');
8
-
9
- const { PROJECT_TYPE, } = require('../../constants');
10
- const { srvNode, srvJava, kibanaLogging } = require('../_merging/existences');
4
+ const ProjectReader = require('../../util/projectReader')
5
+ const TemplateBase = require('../templateBase')
6
+ const { PROJECT_TYPE, } = require('../../constants')
7
+ const { srvNode, srvJava, kibanaLogging } = require('../_merging/registry-mta')
11
8
 
12
9
  module.exports = class KibanaTemplate extends TemplateBase {
13
10
  constructor(projectPath, generator) {
14
- super(projectPath, generator, __dirname);
15
- this.projectReader = new ProjectReader(this);
11
+ super(projectPath, generator, __dirname)
12
+ this.projectReader = new ProjectReader(this)
16
13
  }
17
14
 
18
15
  async runDependentMerging() {
19
- const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
20
-
21
- if (!fs.existsSync(mtaYAMLPath)) {
22
- return;
16
+ const projectDescriptor = await this.projectReader.read(this.options)
17
+ const { hasMtaDeployment, isNodejs } = projectDescriptor.cap
18
+
19
+ if (hasMtaDeployment) {
20
+ const srv = isNodejs ? srvNode : srvJava
21
+
22
+ const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml')
23
+ await this.templateUtil.mergeYAML(
24
+ mtaYAMLPath,
25
+ `${__dirname}/files/mta.yaml.hbs`,
26
+ projectDescriptor,
27
+ {
28
+ additions: [srv, kibanaLogging],
29
+ relationships: [{
30
+ insert: [kibanaLogging, 'name'],
31
+ into: [srv, 'requires', 'name']
32
+ }],
33
+ }
34
+ )
23
35
  }
24
-
25
- const projectDescriptor = await this.projectReader.read(this.options);
26
- const srv = projectDescriptor.cap.isNodejs ? srvNode : srvJava
27
-
28
- await this.templateUtil.mergeYAML(
29
- mtaYAMLPath,
30
- `${__dirname}/files/mta.yaml.hbs`,
31
- projectDescriptor,
32
- {
33
- existences: [srv, kibanaLogging],
34
- relationships: [{
35
- in: srv,
36
- inKeyPath: ["requires"],
37
- into: "name",
38
- existences: [kibanaLogging],
39
- existenceKeyPath: ["name"],
40
- }],
41
- }
42
- );
43
36
  }
44
37
 
45
38
  async run() {
46
- const projectType = await this.getProjectType();
39
+ const projectType = await this.getProjectType()
47
40
 
48
41
  switch (projectType) {
49
42
  case PROJECT_TYPE.java:
50
43
  default:
51
- cds.error(`kibana-logging is not implemented for project type '${projectType}' yet`);
44
+ cds.error(`kibana-logging is not implemented for project type '${projectType}' yet`)
52
45
  // TODO: implement
53
- break;
46
+ break
54
47
  case PROJECT_TYPE.nodejs: {
55
48
  const projectDescriptor = await this.projectReader.read(this.options);
56
- const cdsTemplateFile = projectDescriptor.cap.for ? 'cds.profile.package.json.hbs' : 'cds.package.json'
49
+ const { for: forProfile } = projectDescriptor.cap
50
+ const cdsTemplateFile = forProfile ? 'cds.profile.package.json.hbs' : 'cds.package.json'
57
51
  const cdsTemplatePath = path.join(__dirname, 'files', cdsTemplateFile)
58
52
  await this.templateUtil.mergeJSON(path.join(this.projectPath, 'package.json'), cdsTemplatePath, projectDescriptor)
59
53
  }
@@ -1,4 +1,4 @@
1
- module.exports = require("@sap/eslint-plugin-cds/lib/api").createRule({
1
+ module.exports = require("@sap/eslint-plugin-cds").createRule({
2
2
  meta: {
3
3
  docs: {
4
4
  description: `Demonstrates how to implement a model validation check.
@@ -11,30 +11,30 @@ module.exports = require("@sap/eslint-plugin-cds/lib/api").createRule({
11
11
  (__)\ )\/\
12
12
  ||----w |
13
13
  || ||`,
14
- version: "1.0.0",
14
+ version: "1.0.0"
15
15
  },
16
- fixable: "code",
16
+ fixable: "code"
17
17
  },
18
18
  create: function (context) {
19
- const m = context.cds.model;
20
- m.forall("entity", (d) => {
21
- const entityName = d.name.split(".").pop();
19
+ return { entity: checkForMoo };
20
+
21
+ function checkForMoo(e) {
22
+ const entityName = e.name.split(".").pop();
22
23
  if (entityName === "Moo") {
23
- const loc = context.cds.getLocation(entityName, d);
24
+ const loc = context.getLocation(entityName, e);
24
25
  const fix = (fixer) => {
25
- const rangeEnd = context.sourcecode.getIndexFromLoc({
26
+ const rangeEnd = context.getSourceCode().getIndexFromLoc({
26
27
  line: loc.end.line,
27
- column: loc.end.column,
28
+ column: loc.end.column
28
29
  });
29
30
  return fixer.insertTextAfterRange([0, rangeEnd], "n");
30
31
  };
31
32
  context.report({
32
33
  message: "Entity 'Moo' not allowed!",
33
- loc,
34
- fix,
35
- file: d.$location.file,
34
+ node: context.getNode(e),
35
+ fix
36
36
  });
37
37
  }
38
- });
39
- },
38
+ }
39
+ }
40
40
  })
@@ -8,7 +8,7 @@ const io = require("../../../lint/io");
8
8
  const readline = require("readline");
9
9
 
10
10
  const { OPTION_LINT_DEV, OPTION_LINT_GLOBAL } = require("../../constants");
11
- const { mkdirp, fs } = require("@sap/cds/lib/utils");
11
+ const { mkdirp, fs } = require("@sap/cds").utils;
12
12
  const { getConfigPath, getFileExtensions } = require("@sap/eslint-plugin-cds/lib/api");
13
13
  const generators = require("../../../lint/generators");
14
14
 
@@ -9,7 +9,7 @@ build-parameters:
9
9
  before-all:
10
10
  - builder: custom
11
11
  commands:
12
- - npx -p @sap/cds-dk cds build --production
12
+ - npx -p @sap/cds-dk{{#cap.isJava}}@^6{{/cap.isJava}} cds build --production
13
13
 
14
14
  modules:
15
15
  - name: {{cap.appName}}-srv
@@ -11,6 +11,7 @@ module.exports = class MtaTemplate extends TemplateBase {
11
11
 
12
12
  async run() {
13
13
  const projectDescriptor = await this.projectReader.read();
14
+ const { hasApprouter, hasHana, hasXsuaa, isMultitenant, isExtensible } = projectDescriptor.cap;
14
15
  if (!existsSync(join(this.projectPath, 'mta.yaml'))) {
15
16
  await this.templateUtil.copyFiles('.', this.projectPath, projectDescriptor);
16
17
  }
@@ -18,25 +19,30 @@ module.exports = class MtaTemplate extends TemplateBase {
18
19
  // Re-applying the merging part of `cds add xsuaa`, `cds add hana`, and `cds add mtx`, if necessary.
19
20
  // TODO: Find a generic solution for situation like these. Probably involves some restructuring in the
20
21
  // project reader, so that there's a logical mapping from hasX to XTemplate.
21
- if (projectDescriptor.cap.hasApprouter) {
22
+ if (hasApprouter) {
22
23
  const ApprouterTemplate = require(`../approuter`)
23
24
  const template = new ApprouterTemplate(this.projectPath, this.generator)
24
25
  await template.runDependentMerging()
25
26
  }
26
- if (projectDescriptor.cap.hasHana) {
27
+ if (hasHana) {
27
28
  const HanaTemplate = require(`../hana`)
28
29
  const template = new HanaTemplate(this.projectPath, this.generator)
29
30
  await template.runDependentMerging()
30
31
  }
31
- if (projectDescriptor.cap.hasXsuaa) {
32
+ if (hasXsuaa) {
32
33
  const XsuaaTemplate = require(`../xsuaa`)
33
34
  const template = new XsuaaTemplate(this.projectPath, this.generator)
34
35
  await template.runDependentMerging()
35
36
  }
36
- if (projectDescriptor.cap.isMultitenant) {
37
- const MtxTemplate = require(`../mtx`)
38
- const template = new MtxTemplate(this.projectPath, this.generator)
37
+ if (isMultitenant) {
38
+ const MultitenancyTemplate = require(`../multitenancy`)
39
+ const template = new MultitenancyTemplate(this.projectPath, this.generator)
40
+ await template.runDependentMerging()
41
+ }
42
+ if (isExtensible) {
43
+ const ExtensibilityTemplate = require(`../extensibility`)
44
+ const template = new ExtensibilityTemplate(this.projectPath, this.generator)
39
45
  await template.runDependentMerging()
40
46
  }
41
47
  }
42
- };
48
+ }