@sap/cds-dk 6.6.1 → 6.7.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 (104) hide show
  1. package/CHANGELOG.md +32 -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/client/activate.js +4 -3
  18. package/lib/client/auth_manager.js +4 -3
  19. package/lib/client/base_command.js +7 -2
  20. package/lib/client/helper/cf_helper.js +12 -11
  21. package/lib/client/helper/dependency_helper.js +3 -2
  22. package/lib/client/helper/logging.js +0 -7
  23. package/lib/client/params.js +4 -2
  24. package/lib/client/settings_manager.js +35 -34
  25. package/lib/client/tenant_action.js +78 -0
  26. package/lib/init/constants.js +1 -1
  27. package/lib/init/index.js +6 -4
  28. package/lib/init/template/_merging/registry-mta.js +31 -46
  29. package/lib/init/template/approuter/files/mta.yaml.hbs +12 -8
  30. package/lib/init/template/approuter/files/xs-app.json.hbs +0 -3
  31. package/lib/init/template/approuter/index.js +26 -34
  32. package/lib/init/template/auditlog/files/mta.yaml.hbs +2 -1
  33. package/lib/init/template/auditlog/index.js +8 -21
  34. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +4 -4
  35. package/lib/init/template/cf-manifest/index.js +2 -1
  36. package/lib/init/template/connectivity/index.js +4 -5
  37. package/lib/init/template/data/index.js +19 -22
  38. package/lib/init/template/destinations/index.js +5 -17
  39. package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +2 -1
  40. package/lib/init/template/enterprise-messaging/index.js +7 -19
  41. package/lib/init/template/extensibility/index.js +3 -1
  42. package/lib/init/template/hana/files/mta.yaml.hbs +4 -5
  43. package/lib/init/template/hana/index.js +49 -84
  44. package/lib/init/template/helm/chart/templates/_helpers.tpl +4 -1
  45. package/lib/init/template/helm/files/Chart.yaml.hbs +1 -4
  46. package/lib/init/template/helm/index.js +45 -13
  47. package/lib/init/template/html5-repo/index.js +6 -29
  48. package/lib/init/template/java/index.js +1 -1
  49. package/lib/init/template/kibana-logging/files/mta.yaml.hbs +2 -1
  50. package/lib/init/template/kibana-logging/index.js +5 -8
  51. package/lib/init/template/lint/index.js +8 -8
  52. package/lib/init/template/mta/files/mta.yaml.hbs +3 -2
  53. package/lib/init/template/mta/index.js +3 -2
  54. package/lib/init/template/multitenancy/files/mta.yaml.hbs +25 -31
  55. package/lib/init/template/multitenancy/files/{java/mtxs-configmap.yaml → mtxs-configmap-java.yaml} +1 -1
  56. package/lib/init/template/multitenancy/files/{mtxs-configmap.yaml → mtxs-configmap-nodejs.yaml} +5 -1
  57. package/lib/init/template/multitenancy/files/package.json.hbs +28 -0
  58. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +21 -0
  59. package/lib/init/template/multitenancy/files/values.yaml.hbs +15 -8
  60. package/lib/init/template/multitenancy/index.js +51 -99
  61. package/lib/init/template/nodejs/files/.vscode/extensions.json +1 -2
  62. package/lib/init/template/nodejs/files/.vscode/launch.json +2 -2
  63. package/lib/init/template/nodejs/files/.vscode/tasks.json +2 -2
  64. package/lib/init/template/nodejs/files/package.json.hbs +2 -2
  65. package/lib/init/template/nodejs/index.js +4 -3
  66. package/lib/init/template/pipeline/index.js +3 -2
  67. package/lib/init/template/samples/index.js +5 -4
  68. package/lib/init/template/sqlite/files/package.json.hbs +19 -0
  69. package/lib/init/template/sqlite/index.js +11 -0
  70. package/lib/init/template/toggles/index.js +3 -5
  71. package/lib/init/template/xsuaa/files/mta.yaml.hbs +4 -5
  72. package/lib/init/template/xsuaa/files/values.yaml.hbs +0 -2
  73. package/lib/init/template/xsuaa/index.js +14 -35
  74. package/lib/init/util/commandUtil.js +3 -2
  75. package/lib/init/util/fsUtil.js +19 -2
  76. package/lib/init/util/md5Tracking.js +36 -63
  77. package/lib/init/util/projectReader.js +13 -27
  78. package/lib/lint/Linter.js +0 -3
  79. package/lib/util/exec.js +2 -1
  80. package/lib/util/term.js +1 -1
  81. package/lib/watch/livereload-connect.js +5 -4
  82. package/lib/watch/livereload-server.js +3 -6
  83. package/lib/watch/node-watch.js +1 -1
  84. package/npm-shrinkwrap.json +91 -105
  85. package/package.json +4 -4
  86. package/readme.md +1 -1
  87. package/lib/client/subscription.js +0 -84
  88. package/lib/init/template/approuter/files/chart.yaml +0 -4
  89. package/lib/init/template/auditlog/files/auditlog.yaml +0 -4
  90. package/lib/init/template/destinations/files/destination.yaml +0 -4
  91. package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +0 -4
  92. package/lib/init/template/hana/files/hana-deployer.yaml +0 -4
  93. package/lib/init/template/hana/files/hana.yaml +0 -4
  94. package/lib/init/template/html5-repo/files/html5-apps-deployer.yaml +0 -4
  95. package/lib/init/template/html5-repo/files/html5-apps-repo-host.yaml +0 -4
  96. package/lib/init/template/multitenancy/files/cds.package.json +0 -7
  97. package/lib/init/template/multitenancy/files/cds.package.json.hbs +0 -9
  98. package/lib/init/template/multitenancy/files/dependencies.package.json +0 -5
  99. package/lib/init/template/multitenancy/files/java/.cdsrc.json +0 -22
  100. package/lib/init/template/multitenancy/files/java/package.json +0 -33
  101. package/lib/init/template/multitenancy/files/saas-registry.yaml +0 -4
  102. package/lib/init/template/multitenancy/files/service-manager.yaml +0 -4
  103. package/lib/init/template/multitenancy/files/sidecar.yaml +0 -4
  104. package/lib/init/template/xsuaa/files/xsuaa.yaml +0 -4
@@ -21,7 +21,7 @@ const VSCODE_FILE_ASSOCIATIONS = {
21
21
  module.exports = class LintTemplate extends require('../templateBase') {
22
22
  constructor(generator) {
23
23
  super(generator);
24
- this.customPath = path.join(this.projectPath, ".eslint");
24
+ this.customPath = path.join(cds.root, ".eslint");
25
25
  this.docsPath = path.join(this.customPath, "docs");
26
26
  this.rulesPath = path.join(this.customPath, "rules");
27
27
  this.testsPath = path.join(this.customPath, "tests");
@@ -81,8 +81,8 @@ module.exports = class LintTemplate extends require('../templateBase') {
81
81
  }
82
82
  });
83
83
  await io.sanitizeVscodeSettings(
84
- this.projectPath,
85
- path.join(this.projectPath, ".vscode/settings.json"),
84
+ cds.root,
85
+ path.join(cds.root, ".vscode/settings.json"),
86
86
  this.lintType,
87
87
  extensions,
88
88
  this.customRuleExample
@@ -123,7 +123,7 @@ module.exports = class LintTemplate extends require('../templateBase') {
123
123
  }
124
124
 
125
125
  _checkEslint() {
126
- const eslintCmd = checks.resolveEslint(this.projectPath, '');
126
+ const eslintCmd = checks.resolveEslint(cds.root, '');
127
127
  if (!eslintCmd) {
128
128
  this.missingNpmDependencies["names"].push("eslint");
129
129
  this.missingNpmDependencies["msgs"].push("ESLint v>=7.0.0");
@@ -134,7 +134,7 @@ module.exports = class LintTemplate extends require('../templateBase') {
134
134
  _checkEslintPlugin() {
135
135
  const eslintPluginLocal = checks.resolvePlugin(
136
136
  "@sap/eslint-plugin-cds",
137
- this.projectPath
137
+ cds.root
138
138
  );
139
139
  // Require locally installed ESLint CDS plugin
140
140
  if (!eslintPluginLocal) {
@@ -155,9 +155,9 @@ module.exports = class LintTemplate extends require('../templateBase') {
155
155
  }
156
156
 
157
157
  async _addEslintPluginConfig() {
158
- let configPath = getConfigPath(this.projectPath);
158
+ let configPath = getConfigPath(cds.root);
159
159
  if (!configPath) {
160
- configPath = path.join(this.projectPath, ".eslintrc.json");
160
+ configPath = path.join(cds.root, ".eslintrc.json");
161
161
  }
162
162
  await io.sanitizeEslintConfig(configPath, this.customRuleExample);
163
163
  return;
@@ -207,7 +207,7 @@ module.exports = class LintTemplate extends require('../templateBase') {
207
207
  let doneTask = true;
208
208
  try {
209
209
  cp.execSync(task, {
210
- cwd: this.projectPath,
210
+ cwd: cds.root,
211
211
  shell: IS_WIN,
212
212
  stdio: "inherit",
213
213
  });
@@ -14,8 +14,8 @@ build-parameters:
14
14
  {{/cap.isNodejs}}
15
15
  modules:
16
16
  - name: {{cap.appName}}-srv
17
- type: {{cap.pLanguage}}
18
- path: {{& cap.srv.path}}
17
+ type: {{cap.language}}
18
+ path: {{& cap.srvPath}}
19
19
  {{#cap.isNodejs}}
20
20
  parameters:
21
21
  buildpack: nodejs_buildpack
@@ -39,3 +39,4 @@ modules:
39
39
  - name: srv-api # required by consumers of CAP services (e.g. approuter)
40
40
  properties:
41
41
  srv-url: ${default-url}
42
+ requires: []
@@ -1,5 +1,6 @@
1
1
  const { join } = require('path');
2
- const { exists } = require('../../../cds').utils
2
+ const cds = require('../../../cds')
3
+ const { exists } = cds.utils
3
4
  const { copyFiles } = require('../../util/templateUtil')
4
5
  const { readProject } = require('../../util/projectReader');
5
6
 
@@ -13,7 +14,7 @@ module.exports = class MtaTemplate extends require('../templateBase') {
13
14
  async run() {
14
15
  const projectDescriptor = await readProject()
15
16
  if (!exists('mta.yaml')) {
16
- await copyFiles(join(__dirname, 'files'), this.projectPath, projectDescriptor);
17
+ await copyFiles(join(__dirname, 'files'), cds.root, projectDescriptor);
17
18
  }
18
19
 
19
20
  // Re-applying the dependent merging part of other facets if necessary.
@@ -1,63 +1,57 @@
1
1
  ---
2
2
  modules:
3
3
  - name: {{cap.appName}}-srv
4
- type: {{cap.pLanguage}}
5
- path: {{& cap.srv.path}}
4
+ type: {{cap.language}}
5
+ path: {{& cap.srvPath}}
6
6
  requires:
7
7
  - name: {{cap.appName}}-registry
8
- {{#cap.isJava}}
9
- - name: mtx-sidecar
8
+ {{#cap.isJava}}
9
+ - name: mtx-api
10
10
  properties:
11
11
  CDS_MULTITENANCY_MTXS_ENABLED: true
12
- CDS_MULTITENANCY_SIDECAR_URL: ~{url}
13
- {{/cap.isJava}}
12
+ CDS_MULTITENANCY_SIDECAR_URL: ~{mtx-url}
13
+ {{/cap.isJava}}
14
14
  provides:
15
15
  - name: srv-api # required by consumers of CAP services (e.g. approuter)
16
16
  properties:
17
17
  srv-url: ${default-url}
18
- {{#cap.isNodejs}}
19
- - name: mtx-api # potentially required by approuter
20
- properties:
21
- mtx-url: ${default-url}
22
- {{/cap.isNodejs}}
23
18
 
24
- {{#cap.isJava}}
25
- - name: {{cap.appName}}-mtx-sidecar
19
+ - name: {{cap.appName}}-mtx
26
20
  type: nodejs
27
- path: mtx/sidecar
21
+ path: {{#cap.isNodejs}}gen/{{/cap.isNodejs}}mtx/sidecar
22
+ {{#cap.isNodejs}}
23
+ build-parameters:
24
+ builder: npm-ci
25
+ {{/cap.isNodejs}}
26
+ {{#cap.isJava}}
28
27
  build-parameters:
29
28
  builder: custom
30
29
  build-result: gen
31
30
  commands:
32
31
  - npm run build
32
+ {{/cap.isJava}}
33
33
  parameters:
34
34
  memory: 256M
35
35
  disk-quota: 512M
36
36
  provides:
37
- - name: mtx-sidecar
38
- properties:
39
- url: ${default-url}
40
- {{#cap.isJava}}
41
- - name: mtx-api # potentially required by approuter
37
+ - name: mtx-api
42
38
  properties:
43
39
  mtx-url: ${default-url}
44
- {{/cap.isJava}}
45
- {{#cap.hasXsuaa}}
40
+ {{#cap.hasXsuaa}}
46
41
  requires:
47
42
  - name: {{cap.appName}}-auth
48
- {{/cap.hasXsuaa}}
49
- {{/cap.isJava}}
43
+ {{/cap.hasXsuaa}}
50
44
 
51
45
  resources:
52
46
  - name: {{cap.appName}}-registry
53
47
  type: org.cloudfoundry.managed-service
54
48
  requires:
55
- {{#cap.isNodejs}}
49
+ {{#cap.isNodejs}}
56
50
  - name: mtx-api
57
- {{/cap.isNodejs}}
58
- {{#cap.isJava}}
51
+ {{/cap.isNodejs}}
52
+ {{#cap.isJava}}
59
53
  - name: srv-api
60
- {{/cap.isJava}}
54
+ {{/cap.isJava}}
61
55
  parameters:
62
56
  service: saas-registry
63
57
  service-plan: application
@@ -68,14 +62,14 @@ resources:
68
62
  description: A simple CAP project.
69
63
  category: 'Category'
70
64
  appUrls:
71
- {{#cap.isNodejs}}
65
+ {{#cap.isNodejs}}
72
66
  getDependencies: ~{mtx-api/mtx-url}/-/cds/saas-provisioning/dependencies
73
67
  onSubscription: ~{mtx-api/mtx-url}/-/cds/saas-provisioning/tenant/{tenantId}
74
- {{/cap.isNodejs}}
75
- {{#cap.isJava}}
68
+ {{/cap.isNodejs}}
69
+ {{#cap.isJava}}
76
70
  getDependencies: ~{srv-api/srv-url}/mt/v1.0/subscriptions/dependencies
77
71
  onSubscription: ~{srv-api/srv-url}/mt/v1.0/subscriptions/tenants/{tenantId}
78
- {{/cap.isJava}}
72
+ {{/cap.isJava}}
79
73
  onSubscriptionAsync: true
80
74
  onUnSubscriptionAsync: true
81
75
  onUpdateDependenciesAsync: true
@@ -17,4 +17,4 @@ data:
17
17
  CDS_MULTITENANCY_APPUI_TENANTSEPARATOR: "-"
18
18
  CDS_MULTITENANCY_MTXS_ENABLED: "true"
19
19
  CDS_MULTITENANCY_APPUI_URL: {{ printf "https://%s" $approuterUrl }}
20
- CDS_MULTITENANCY_SIDECAR_URL: {{ printf "https://%s" $sidecarUrl }}
20
+ CDS_MULTITENANCY_SIDECAR_URL: {{ printf "https://%s" $sidecarUrl }}
@@ -4,6 +4,10 @@
4
4
  {{- $ := merge (dict "name" "approuter" "deployment" .Values.approuter ) . }}
5
5
  {{- $approuterUrl := (include "cap.deploymentHostFull" $ )}}
6
6
 
7
+ {{- $sidecarDeployment := .Values.sidecar }}
8
+ {{- $ = merge (dict "name" "sidecar" "deployment" .Values.sidecar ) . }}
9
+ {{- $sidecarUrl := (include "cap.deploymentHostFull" $ )}}
10
+
7
11
  apiVersion: v1
8
12
  kind: ConfigMap
9
13
  metadata:
@@ -12,4 +16,4 @@ metadata:
12
16
  data:
13
17
  CDS_MULTITENANCY_APPUI_TENANTSEPARATOR: "-"
14
18
  CDS_MULTITENANCY_APPUI_URL: {{ printf "https://%s" $approuterUrl }}
15
- SUBSCRIPTION_URL: {{ printf "https://${tenant_subdomain}-%s" $approuterUrl }}
19
+ SUBSCRIPTION_URL: {{ printf "https://${tenant_subdomain}-%s" $approuterUrl }}
@@ -0,0 +1,28 @@
1
+ {
2
+ {{#cap.isNodejs}}
3
+ "dependencies": {
4
+ "@sap/cds-mtxs": "^1"
5
+ },
6
+ {{/cap.isNodejs}}
7
+ "cds": {
8
+ {{#cap.isJava}}
9
+ "profiles": ["with-mtx-sidecar", "java"],
10
+ "build": {
11
+ "target": "."
12
+ },
13
+ {{/cap.isJava}}
14
+ {{#cap.isNodejs}}
15
+ "profile": "with-mtx-sidecar",
16
+ {{/cap.isNodejs}}
17
+ "requires": {
18
+ {{#cap.for}}
19
+ "[{{cap.for}}]": {
20
+ "multitenancy": true
21
+ }
22
+ {{/cap.for}}
23
+ {{^cap.for}}
24
+ "multitenancy": true
25
+ {{/cap.for}}
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "{{cap.appName}}-mtx",
3
+ "dependencies": {
4
+ "@sap/cds": "^6",
5
+ "@sap/cds-mtxs": "^1",
6
+ "@sap/xssec": "^3",
7
+ "express": "^4",
8
+ "hdb": "^0",
9
+ "passport": "^0.6.0"
10
+ },
11
+ "devDependencies": {
12
+ "sqlite3": "^5"
13
+ },
14
+ "scripts": {
15
+ "start": "cds-serve"{{#cap.isJava}},
16
+ "build": "npm ci && npx -p @sap/cds-dk@^6 cds build ../.. --for mtx-sidecar --production && cd gen && npm ci"{{/cap.isJava}}
17
+ },
18
+ "cds": {
19
+ "profile": "mtx-sidecar"
20
+ }
21
+ }
@@ -1,8 +1,10 @@
1
1
  ---
2
2
  srv:
3
3
  bindings:
4
+ {{#cap.isJava}}
4
5
  saas-registry:
5
6
  serviceInstanceName: saas-registry
7
+ {{/cap.isJava}}
6
8
  service-manager:
7
9
  serviceInstanceName: service-manager
8
10
  {{#cap.hasXsuaa}}
@@ -22,26 +24,32 @@ saasRegistryParameters:
22
24
  displayName: {{cap.appName}}
23
25
  description: {{cap.appDescription}}
24
26
  category: "CAP Application"
25
- appUrls:
26
27
  {{#cap.isNodejs}}
28
+ bindSidecar: true
29
+ {{/cap.isNodejs}}
30
+ appUrls:
31
+ {{#cap.isNodejs}}
27
32
  getDependencies: "/-/cds/saas-provisioning/dependencies"
28
33
  onSubscription: "/-/cds/saas-provisioning/tenant/{tenantId}"
29
- {{/cap.isNodejs}}
30
- {{#cap.isJava}}
34
+ {{/cap.isNodejs}}
35
+ {{#cap.isJava}}
31
36
  getDependencies: "/mt/v1.0/subscriptions/dependencies"
32
37
  onSubscription: "/mt/v1.0/subscriptions/tenants/{tenantId}"
33
- {{/cap.isJava}}
38
+ {{/cap.isJava}}
34
39
  onSubscriptionAsync: true
35
40
  onUnSubscriptionAsync: true
36
41
  onUpdateDependenciesAsync: true
37
42
  callbackTimeoutMillis: 300000
38
- {{#cap.isJava}}
39
43
  sidecar:
40
44
  bindings:
41
- {{#cap.hasXsuaa}}
45
+ {{#cap.hasXsuaa}}
42
46
  auth:
43
47
  serviceInstanceName: xsuaa
44
- {{/cap.hasXsuaa}}
48
+ {{/cap.hasXsuaa}}
49
+ {{#cap.isNodejs}}
50
+ saas-registry:
51
+ serviceInstanceName: saas-registry
52
+ {{/cap.isNodejs}}
45
53
  service-manager:
46
54
  serviceInstanceName: service-manager
47
55
  image:
@@ -60,4 +68,3 @@ sidecar:
60
68
  path: /
61
69
  readiness:
62
70
  path: /
63
- {{/cap.isJava}}
@@ -1,15 +1,16 @@
1
1
  const { join } = require('path')
2
2
  const cds = require('../../../cds')
3
- const { copy, exists } = cds.utils
3
+ const { exists } = cds.utils
4
4
  const { readProject } = require('../../util/projectReader')
5
5
  const { mergeJSON, mergeYAML, sortDependencies } = require('../../util/merge')
6
6
  const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5Tracking')
7
+ const { copyRenderedJSON } = require('../../util/fsUtil')
7
8
  const {
8
9
  srvNode, srvJava, // Server
9
- mtxSidecar, // Additional Modules
10
+ mtxSidecar4, // Additional Modules
10
11
  saasRegistry, serviceManager, xsuaa, // BTP Services
11
- providedMtxAPISrv, providedMtxAPISidecar, srvAPI, providedMtxSidecarAPI, requiredMtxSidecarAPI // APIs
12
- } = require('../_merging/registry-mta');
12
+ srvAPI, providedMtxAPISidecar4, requiredMtxSidecarAPI // APIs
13
+ } = require('../_merging/registry-mta')
13
14
 
14
15
  module.exports = class MultitenancyTemplate extends require('../templateBase') {
15
16
 
@@ -17,82 +18,73 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
17
18
  // REVISIT: Check if this can be simplified
18
19
  return options?.add?.has('mtx') || options?.add?.has('multitenancy') ||
19
20
  !!env.requires?.multitenancy || !!env.requires?.db?.multiTenant ||
20
- this.isJava && exists(join('mtx', 'sidecar')) || false
21
+ exists(join('mtx', 'sidecar')) || false
21
22
  }
22
23
 
23
24
  async run() {
24
25
  const projectDescriptor = await readProject(this.options)
25
- const { for: forProfile, isNodejs, isJava } = projectDescriptor.cap
26
- if (isNodejs) {
27
- const packageJSONPath = join(this.projectPath, 'package.json')
28
- const cdsTemplateFile = forProfile ? 'cds.package.json.hbs' : 'cds.package.json'
29
- await mergeJSON(packageJSONPath, join(__dirname, 'files', cdsTemplateFile), projectDescriptor)
30
- await mergeJSON(packageJSONPath, join(__dirname, 'files', 'dependencies.package.json'))
31
- await sortDependencies(packageJSONPath)
32
- } else if (isJava) {
33
- const cdsrcJSONPath = join(this.projectPath, '.cdsrc.json')
34
- await mergeJSON(cdsrcJSONPath, join(__dirname, 'files', 'java', '.cdsrc.json'))
35
- await copy(join(__dirname, 'files', 'java', 'package.json'), join(this.projectPath, 'mtx', 'sidecar', 'package.json'))
36
- }
26
+ const { isNodejs } = projectDescriptor.cap
27
+ await mergeJSON('package.json', join(__dirname, 'files', `package.json.hbs`), projectDescriptor)
28
+ if (isNodejs) await sortDependencies('package.json')
29
+ await copyRenderedJSON(join(__dirname, 'files', 'package.sidecar.json.hbs'), join('mtx', 'sidecar', 'package.json'), projectDescriptor)
37
30
  await this.runDependentMerging()
38
31
  }
39
32
 
40
33
  async runDependentMerging(context = {}) {
41
34
  const projectDescriptor = await readProject()
42
- const { isNodejs, isJava, hasMta, hasHelm, hasApprouter, hasXsuaa, hasHana } = projectDescriptor.cap
35
+ const { isNodejs, isJava, hasMta, hasHelm, hasApprouter, hasXsuaa, hasHana, srvPath } = projectDescriptor.cap
43
36
 
44
37
  if (hasMta) {
45
- const modules = isNodejs ? [srvNode] : [srvJava, mtxSidecar]
46
- const srv = isNodejs ? srvNode : srvJava
38
+ const srv = (isNodejs ? srvNode : srvJava)(srvPath)
39
+ const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar')
40
+ const modules = [srv, mtxSidecar]
47
41
  const services = [saasRegistry]
48
42
  if (hasXsuaa) services.push(xsuaa)
49
- const apis = isNodejs ? [providedMtxAPISrv] : [srvAPI, providedMtxAPISidecar, providedMtxSidecarAPI, requiredMtxSidecarAPI]
43
+ const apis = [srvAPI(srv), providedMtxAPISidecar4(mtxSidecar)]
44
+ if (isJava) apis.push(requiredMtxSidecarAPI(srv))
50
45
  const additions = [...modules, ...services, ...apis]
51
46
 
52
- const overwrites = hasXsuaa ? [{ item: [xsuaa, 'parameters.config.tenant-mode'], withValue: 'shared'}] : []
47
+ const overwrites = hasXsuaa ? [{ item: [xsuaa, 'parameters.config.tenant-mode'], withValue: 'shared' }] : []
53
48
 
54
49
  const relationships = [{
55
50
  insert: [saasRegistry, 'name'],
56
- into: [srv, 'requires', 'name']
51
+ into: [isJava ? srv : mtxSidecar, 'requires', 'name']
57
52
  }]
58
- if (isJava) {
59
- if (hasXsuaa) {
60
- relationships.push({
61
- insert: [xsuaa, 'name'],
62
- into: [mtxSidecar, 'requires', 'name']
63
- })
64
- }
65
- if (hasHana) {
66
- relationships.push({
67
- insert: [serviceManager, 'name'],
68
- into: [mtxSidecar, 'requires', 'name'],
69
- })
70
- }
53
+ if (hasXsuaa) {
54
+ relationships.push({
55
+ insert: [xsuaa, 'name'],
56
+ into: [mtxSidecar, 'requires', 'name']
57
+ })
58
+ }
59
+ if (hasHana) {
60
+ relationships.push({
61
+ insert: [serviceManager, 'name'],
62
+ into: [mtxSidecar, 'requires', 'name'],
63
+ })
71
64
  }
72
65
 
73
- const templateMtaPath = join(__dirname, `files`, `mta.yaml.hbs`)
74
- const mtaPath = join(this.projectPath, 'mta.yaml')
66
+ const templateMtaPath = join(__dirname, 'files', 'mta.yaml.hbs')
75
67
  const mergingRules = { additions, overwrites, relationships }
76
- await mergeYAML(mtaPath, templateMtaPath, projectDescriptor, mergingRules)
68
+ await mergeYAML('mta.yaml', templateMtaPath, projectDescriptor, mergingRules)
77
69
  }
78
70
 
71
+ // REVISIT: Why not just pass a Boolean from run() to indicate the merging isn't run transitively?
79
72
  let isIndependentCommand = false
80
73
  if (hasHelm) {
81
- //in case facet is being added to the already exisiting charts folder
74
+ // in case facet is being added to the already existing charts folder
82
75
  if (Object.keys(context).length == 0) {
83
76
  isIndependentCommand = true
84
- context.projectPath = this.projectPath
85
- context.oldTrackingData = context.newTrackingData = await parseMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'))
77
+ context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'))
86
78
  }
87
79
 
88
80
  await mergeYAML(
89
- join(this.projectPath, 'chart', 'values.yaml'),
81
+ join('chart', 'values.yaml'),
90
82
  join(__dirname, 'files', 'values.yaml.hbs'),
91
83
  projectDescriptor
92
84
  )
93
85
 
94
86
  await mergeYAML(
95
- join(this.projectPath, 'chart', 'values.yaml'),
87
+ join('chart', 'values.yaml'),
96
88
  {
97
89
  srv: {
98
90
  envFrom: [
@@ -117,74 +109,34 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
117
109
  projectDescriptor
118
110
  )
119
111
 
120
- if (isJava) {
121
- await mergeYAML(
122
- join(this.projectPath, 'chart', 'Chart.yaml'),
123
- join(__dirname, 'files', 'sidecar.yaml'),
124
- projectDescriptor,
125
- {
126
- additions: [{
127
- in: `dependencies`,
128
- where: [{
129
- property: 'alias',
130
- isEqualTo: 'sidecar'
131
- }]
132
- }]
133
- }
134
- )
135
- }
136
-
137
- // copy service-instance chart
112
+ // REVISIT: Don't reference other templates except for the safe `runDependentMerging` -> low coupling, high cohesion
138
113
  const HelmTemplate = require(`../helm`);
139
114
  const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
140
- isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
141
115
 
142
- // add dependency entry in chart.yaml
143
- await mergeYAML(
144
- join(this.projectPath, 'chart', 'Chart.yaml'),
145
- join(__dirname, 'files', 'saas-registry.yaml'),
146
- projectDescriptor,
147
- { additions: [{
148
- in: `dependencies`,
149
- where: [{
150
- property: 'alias',
151
- isEqualTo: 'saas-registry'
152
- }]
153
- }]}
154
- );
116
+ await helmTemplate.addDependency('web-application', 'sidecar');
155
117
 
156
- await mergeYAML(
157
- join(this.projectPath, 'chart', 'Chart.yaml'),
158
- join(__dirname, 'files', 'service-manager.yaml'),
159
- projectDescriptor,
160
- { additions: [{
161
- in: `dependencies`,
162
- where: [{
163
- property: 'alias',
164
- isEqualTo: 'service-manager'
165
- }]
166
- }]}
167
- );
118
+ // copy service-instance chart
119
+ isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
168
120
 
169
- const mtxsConfigmapPath = isNodejs
170
- ? join(__dirname, 'files', 'mtxs-configmap.yaml')
171
- : join(__dirname, 'files', 'java', 'mtxs-configmap.yaml');
121
+ // add dependency entry in chart.yaml
122
+ await helmTemplate.addDependency('service-instance', 'saas-registry');
123
+ await helmTemplate.addDependency('service-instance', 'service-manager');
172
124
 
173
125
  // add mtxs configmap
174
126
  await copyAndTrack(
175
- mtxsConfigmapPath,
176
- join(this.projectPath, 'chart', 'templates', 'mtxs-configmap.yaml'),
177
- context
127
+ join(__dirname, 'files', `mtxs-configmap-${isJava ? 'java' : 'nodejs'}.yaml`),
128
+ join('chart', 'templates', 'mtxs-configmap.yaml'),
129
+ context,
178
130
  )
179
131
 
180
132
  // add saas registry secret
181
133
  await copyAndTrack(
182
134
  join(__dirname, 'files', 'saas-registry-secret.yaml'),
183
- join(this.projectPath, 'chart', 'templates', 'saas-registry-secret.yaml'),
135
+ join('chart', 'templates', 'saas-registry-secret.yaml'),
184
136
  context
185
137
  );
186
138
 
187
- if (isIndependentCommand) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData)
139
+ if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
188
140
  }
189
141
 
190
142
  if (hasApprouter) {
@@ -201,7 +153,7 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
201
153
 
202
154
  if (hasXsuaa) {
203
155
  await mergeJSON(
204
- join(this.projectPath, 'xs-security.json'),
156
+ 'xs-security.json',
205
157
  join(__dirname, 'files', 'xs-security.json.hbs'),
206
158
  projectDescriptor,
207
159
  {
@@ -215,7 +167,7 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
215
167
 
216
168
  if (hasXsuaa && hasHelm) {
217
169
  await mergeYAML(
218
- join(this.projectPath, 'chart', 'values.yaml'),
170
+ join('chart', 'values.yaml'),
219
171
  {
220
172
  xsuaa: {
221
173
  parameters: {
@@ -226,7 +178,7 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
226
178
  null,
227
179
  { forceOverwrite: true }
228
180
  )
229
- if (isIndependentCommand) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData)
181
+ if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
230
182
  }
231
183
  }
232
184
  }
@@ -8,9 +8,8 @@
8
8
  "dbaeumer.vscode-eslint",
9
9
  "esbenp.prettier-vscode",
10
10
  "mechatroner.rainbow-csv",
11
+ "qwtel.sqlite-viewer",
11
12
  "humao.rest-client",
12
- "alexcvzz.vscode-sqlite",
13
- "hbenl.vscode-mocha-test-adapter",
14
13
  "sdras.night-owl"
15
14
  ],
16
15
  // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
@@ -5,8 +5,8 @@
5
5
  "version": "0.2.0",
6
6
  "configurations": [
7
7
  {
8
- "command": "cds run --with-mocks --in-memory?",
9
- "name": "cds run",
8
+ "command": "cds serve --with-mocks --in-memory?",
9
+ "name": "cds serve",
10
10
  "request": "launch",
11
11
  "type": "node-terminal",
12
12
  "skipFiles": [ "<node_internals>/**" ]
@@ -16,9 +16,9 @@
16
16
  },
17
17
  {
18
18
  "type": "shell",
19
- "label": "cds run",
19
+ "label": "cds serve",
20
20
  "command": "cds",
21
- "args": ["run", "--with-mocks", "--in-memory?"],
21
+ "args": ["serve", "--with-mocks", "--in-memory?"],
22
22
  "problemMatcher": []
23
23
  }
24
24
  ]
@@ -10,9 +10,9 @@
10
10
  "express": "^4"
11
11
  },
12
12
  "devDependencies": {
13
- "sqlite3": "^5.0.4"
13
+ "sqlite3": "^5"
14
14
  },
15
15
  "scripts": {
16
- "start": "cds run"
16
+ "start": "cds-serve"
17
17
  }
18
18
  }
@@ -1,5 +1,6 @@
1
1
  const { join, relative } = require('path');
2
- const { mkdirp } = require('../../../cds').utils
2
+ const cds = require('../../../cds')
3
+ const { mkdirp } = cds.utils
3
4
  const { COMMAND_ADD, OPTION_JAVA, OPTION_NODEJS, URLS } = require('../../constants')
4
5
  const { copyFiles } = require('../../util/templateUtil')
5
6
  const LOG = console
@@ -8,7 +9,7 @@ module.exports = class NodejsTemplate extends require('../templateBase') {
8
9
 
9
10
  static hasFacet() {
10
11
  // TODO: Implement
11
- //return this.pLanguage === P_LANGUAGE_NODEJS
12
+ //return this.language === P_LANGUAGE_NODEJS
12
13
  }
13
14
 
14
15
  async canRun() {
@@ -34,7 +35,7 @@ module.exports = class NodejsTemplate extends require('../templateBase') {
34
35
  }
35
36
 
36
37
  async finalize() {
37
- const relativeProjectPath = relative(this.cwd, this.projectPath);
38
+ const relativeProjectPath = relative(this.cwd, cds.root);
38
39
  if (relativeProjectPath && relativeProjectPath !== '.') {
39
40
  LOG.info(`Continue with 'cd ${relativeProjectPath}'`);
40
41
  }