@sap/cds-dk 9.7.2 → 9.8.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 +42 -2
  2. package/bin/bind.js +7 -2
  3. package/bin/build.js +14 -4
  4. package/bin/cds.js +2 -2
  5. package/bin/completion/completionFs.js +1 -1
  6. package/bin/completion/index.js +2 -2
  7. package/bin/data-products/get-csn-via-dp-cli.js +1 -1
  8. package/bin/debug.js +1 -1
  9. package/bin/deploy/index.js +3 -2
  10. package/bin/gen.js +1 -1
  11. package/bin/help.js +1 -1
  12. package/bin/import.js +3 -0
  13. package/bin/minify.js +1 -1
  14. package/bin/mock.js +1 -1
  15. package/bin/repl.js +212 -39
  16. package/bin/test.js +0 -2
  17. package/bin/up.js +27 -3
  18. package/bin/util/containerize.js +1 -3
  19. package/bin/version.js +30 -9
  20. package/bin/watch.js +20 -4
  21. package/lib/bind/cf.js +2 -2
  22. package/lib/bind/k8s.js +0 -1
  23. package/lib/bind/plugin.js +2 -0
  24. package/lib/bind/shared.js +6 -1
  25. package/lib/build/constants.js +0 -8
  26. package/lib/build/index.js +569 -25
  27. package/lib/build/{provider/edmxBuildPlugin.js → plugins/edmx.js} +6 -15
  28. package/lib/build/{provider/featureToggleBuildPlugin.js → plugins/featureToggles.js} +8 -27
  29. package/lib/build/{provider → plugins}/fiori/index.js +27 -40
  30. package/lib/build/{provider → plugins}/hana/index.js +67 -85
  31. package/lib/build/{provider → plugins}/hana/migrationtable.js +4 -3
  32. package/lib/build/plugins/helm/index.js +6 -6
  33. package/lib/build/{provider/internalBuildPlugin.js → plugins/internal.js} +7 -31
  34. package/lib/build/{provider → plugins}/java/index.js +18 -26
  35. package/lib/build/plugins/mtx/index.js +41 -0
  36. package/lib/build/plugins/mtx/resourcesTarBuilder.js +41 -0
  37. package/lib/build/{provider → plugins}/mtx-extension/extensionCompilation.js +1 -1
  38. package/lib/build/{provider → plugins}/mtx-extension/index.js +35 -44
  39. package/lib/build/{provider → plugins}/mtx-sidecar/index.js +17 -3
  40. package/lib/build/{provider → plugins}/nodejs/index.js +29 -28
  41. package/lib/build/{plugin.js → plugins/plugin.js} +57 -60
  42. package/lib/build/plugins.js +11 -8
  43. package/lib/build/util.js +0 -8
  44. package/lib/compile/to-xsuaa.js +2 -2
  45. package/lib/deploy/to-hana/hana.js +64 -56
  46. package/lib/import/common.js +1 -1
  47. package/lib/import/odata/metadataconverter/MetadataConverter.js +4 -3
  48. package/lib/import/odata/v2parser.js +28 -28
  49. package/lib/import/odata/v4parser.js +37 -2
  50. package/lib/import/openapi/index.js +1 -1
  51. package/lib/init/constants.js +1 -2
  52. package/lib/init/template/app-frontend/index.js +1 -1
  53. package/lib/init/template/approuter/files/package.json +1 -1
  54. package/lib/init/template/completion/completionSetup.js +1 -1
  55. package/lib/init/template/data/as-csv.js +1 -1
  56. package/lib/init/template/github-actions/index.js +1 -1
  57. package/lib/init/template/handler/index.js +1 -1
  58. package/lib/init/template/helm/index.js +4 -4
  59. package/lib/init/template/kyma/index.js +3 -3
  60. package/lib/init/template/lint/index.js +7 -21
  61. package/lib/init/template/multitenancy/files/package.json.hbs +0 -5
  62. package/lib/init/template/postgres/files/containerize.yaml.hbs +15 -0
  63. package/lib/init/template/postgres/files/package.json.hbs +35 -0
  64. package/lib/init/template/postgres/files/values.yaml.hbs +23 -0
  65. package/lib/init/template/postgres/index.js +34 -9
  66. package/lib/init/template/test/files/package.json +1 -1
  67. package/lib/init/template/typescript/files/package.json +1 -1
  68. package/lib/init/template/workzone-standard/files/mta.yaml.hbs +1 -0
  69. package/lib/lint/eslintHelp.json +1 -1
  70. package/lib/lint/io.js +9 -13
  71. package/lib/mtx/pull.js +1 -1
  72. package/lib/mtx/settings_manager.js +11 -5
  73. package/lib/mtx/tenant_action.js +1 -1
  74. package/lib/mtx/util/fs.js +2 -2
  75. package/lib/util/fs.js +3 -3
  76. package/lib/util/git.js +1 -1
  77. package/lib/util/glob.js +1 -1
  78. package/lib/watch/hot-reload.js +202 -0
  79. package/lib/watch/livereload-server.js +6 -4
  80. package/lib/watch/node-watch.js +5 -1
  81. package/lib/watch/watched.js +7 -3
  82. package/lib/watch/watcher.js +41 -3
  83. package/npm-shrinkwrap.json +46 -31
  84. package/package.json +1 -1
  85. package/lib/build/buildTaskEngine.js +0 -377
  86. package/lib/build/buildTaskFactory.js +0 -198
  87. package/lib/build/buildTaskProvider.js +0 -38
  88. package/lib/build/buildTaskProviderFactory.js +0 -233
  89. package/lib/build/provider/internalBuildTaskProvider.js +0 -227
  90. package/lib/build/provider/java-cf/index.js +0 -1
  91. package/lib/build/provider/mtx/index.js +0 -36
  92. package/lib/build/provider/mtx/resourcesTarBuilder.js +0 -102
  93. package/lib/build/provider/node-cf/index.js +0 -1
  94. package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +0 -40
  95. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/fixed/schema.cds +0 -4
  96. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/invalid/schema.cds +0 -4
  97. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/rule.test.js +0 -15
  98. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/valid/schema.cds +0 -6
  99. package/lib/init/types.d.ts +0 -23
  100. /package/lib/build/{provider → plugins}/hana/2migration.js +0 -0
  101. /package/lib/build/{provider → plugins}/hana/template/.hdiconfig-all +0 -0
  102. /package/lib/build/{provider → plugins}/hana/template/.hdiconfig-cloud +0 -0
  103. /package/lib/build/{provider → plugins}/hana/template/.hdinamespace +0 -0
  104. /package/lib/build/{provider → plugins}/hana/template/package.json +0 -0
  105. /package/lib/build/{provider → plugins}/hana/template/undeploy.json +0 -0
@@ -1,36 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const cds = require('../../../cds')
4
- const EdmxBuildPlugin = require('../edmxBuildPlugin')
5
- const ResourcesTarBuilder = require('./resourcesTarBuilder')
6
- const { FOLDER_GEN } = require('../../constants')
7
-
8
- class MtxBuildPlugin extends EdmxBuildPlugin {
9
- get priority() {
10
- // must run after 'hana' build task
11
- return super.priority - 10
12
- }
13
-
14
- init() {
15
- super.init()
16
- }
17
-
18
- async build() {
19
- // Only create resources TAR, compiled CSN(s) are created by the Nodejs app build task.
20
- const dest = cds.env.build.target !== '.' ? this.task.dest : path.join(this.task.dest, FOLDER_GEN)
21
- const model = await this.model()
22
- if (!model) {
23
- return
24
- }
25
- return new ResourcesTarBuilder(this).createTar(dest, model)
26
- }
27
-
28
- async clean() {
29
- // staging build content is deleted by BuildTaskEngine
30
- if (cds.env.build.target === '.') {
31
- // remove 'gen' folder
32
- return fs.promises.rm(path.join(this.task.dest, FOLDER_GEN), { force: true, recursive: true })
33
- }
34
- }
35
- }
36
- module.exports = MtxBuildPlugin
@@ -1,102 +0,0 @@
1
- const path = require('path')
2
- const cds = require('../../../cds')
3
- const InternalBuildPlugin = require('../internalBuildPlugin')
4
-
5
- const { BUILD_TASK_HANA } = require('../../constants')
6
- const fs = require('fs')
7
- const { WARNING } = InternalBuildPlugin
8
- const DEFAULT_TAR_NAME = "resources.tgz"
9
-
10
- class ResourcesTarBuilder {
11
- constructor(plugin) {
12
- this._plugin = plugin
13
- }
14
-
15
- get plugin() { return this._plugin }
16
-
17
- async createTar(dest, model) {
18
- const { root, resources } = await this._getResources(model)
19
- if (resources.length === 0) {
20
- // packTarArchive fails otherwise
21
- this.plugin.pushMessage("No deployment resources found - skip resources.tgz", WARNING)
22
- return
23
- }
24
- await this.writeTarFile(path.join(dest, DEFAULT_TAR_NAME), root, resources)
25
- }
26
-
27
- /**
28
- * Creates a TAR file at the given absolute tarPath. An optional resources list holds the files and folders
29
- * that will be added to the TAR. Paths are relative to the passed root directory. If omitted, the entire
30
- * root directory contents will be added.
31
- * @param {*} tarFile Absolute TAR file name.
32
- * @param {*} root The root directory the passed resources are relative to.
33
- * @param {*} resources Optional list of absolute or relative resource paths - relative to the given root directory.
34
- * If omitted all resources contained in the root directory are added to the TAR file.
35
- */
36
- async writeTarFile(tarFile, root, resources) {
37
- const { tar } = require('../../..').utils
38
- await tar.czfd(tarFile, root, resources)
39
- this.plugin.pushFile(tarFile)
40
- }
41
-
42
- async _getResources(model) {
43
- // distinguish HANA and SQLITE deployment
44
- let root = this._getHanaTenantDbPath()
45
- let resources
46
- if (root) {
47
- resources = this._getHanaResources(root)
48
- } else {
49
- root = cds.root
50
- resources = await this._getSqliteResources(model)
51
- }
52
- return { root, resources }
53
- }
54
-
55
- /**
56
- * Reads a list of files and folders required for HANA deployment.
57
- * This is a subset of all files contained in the directory.
58
- * - 'db/src', 'db/cfg', 'db/undeploy.json'...
59
- * See '../../../../lib.deploy'
60
- * Note: the hana build task has already been executed
61
- * @param {string} root
62
- * @returns an array containing all resources
63
- */
64
- _getHanaResources(root) {
65
- return ['src', 'cfg', 'undeploy.json', '.hdiignore'].reduce((acc, res) => {
66
- const resPath = path.join(root, res)
67
- if (fs.existsSync(resPath)) {
68
- acc.push(resPath)
69
- }
70
- return acc
71
- }, [])
72
- }
73
-
74
- /**
75
- * Reads all resources for Sqlite deployment - see '../../../../lib.deploy'
76
- *
77
- * @param {object} model
78
- * @returns
79
- */
80
- async _getSqliteResources(model) {
81
- const { resources } = cds.deploy
82
- return Object.keys(await resources(model))
83
- }
84
-
85
- _getHanaTenantDbPath() {
86
- return ResourcesTarBuilder.getHanaTenantDbTask(this.plugin.context.tasks, this.plugin.task)?.dest
87
- }
88
-
89
- static getHanaTenantDbTask(tasks, mtxTask) {
90
- const hanaTasks = tasks.filter(task => task.for === BUILD_TASK_HANA)
91
- if (hanaTasks.length === 1) return hanaTasks[0]
92
-
93
- return hanaTasks.find(hanaTask => {
94
- // if called from internalBuildTaskProvider, the src folder for the tenant db task might still not set
95
- // while an existing second shared db always requires src to be set
96
- if (!hanaTask.src) return true
97
- const srcFolder = path.isAbsolute(hanaTask.src) ? path.relative(cds.root, hanaTask.src) : hanaTask.src
98
- return mtxTask.options?.model?.includes(srcFolder) || srcFolder === cds.env.folders.db.replace('/', '')
99
- })
100
- }
101
- }
102
- module.exports = ResourcesTarBuilder
@@ -1 +0,0 @@
1
- module.exports = require('../nodejs')
@@ -1,40 +0,0 @@
1
- module.exports = require("@sap/eslint-plugin-cds").createRule({
2
- meta: {
3
- docs: {
4
- description: `Demonstrates how to implement a model validation check.
5
-
6
- __________________-_______
7
- < Entity 'Moo' not allowed! >
8
- --------------------------
9
- \ ^__^
10
- \ (oo)\_______
11
- (__)\ )\/\
12
- ||----w |
13
- || ||`,
14
- version: "1.0.0"
15
- },
16
- fixable: "code"
17
- },
18
- create: function (context) {
19
- return { entity: checkForMoo };
20
-
21
- function checkForMoo(e) {
22
- const entityName = e.name.split(".").pop();
23
- if (entityName === "Moo") {
24
- const loc = context.getLocation(entityName, e);
25
- const fix = (fixer) => {
26
- const rangeEnd = context.getSourceCode().getIndexFromLoc({
27
- line: loc.end.line,
28
- column: loc.end.column
29
- });
30
- return fixer.insertTextAfterRange([0, rangeEnd], "n");
31
- };
32
- context.report({
33
- message: "Entity 'Moo' not allowed!",
34
- node: context.getNode(e),
35
- fix
36
- });
37
- }
38
- }
39
- }
40
- })
@@ -1,4 +0,0 @@
1
- namespace my.bookshop;
2
- entity Moon {
3
- key ID : Integer;
4
- }
@@ -1,4 +0,0 @@
1
- namespace my.bookshop;
2
- entity Moo {
3
- key ID : Integer;
4
- }
@@ -1,15 +0,0 @@
1
- const { runRuleTester } = require("@sap/eslint-plugin-cds/lib/api");
2
-
3
- runRuleTester({
4
- root: __dirname,
5
- filename: "schema.cds",
6
- errors: [
7
- {
8
- message: "Entity 'Moo' not allowed!",
9
- line: 2,
10
- column: 8,
11
- endLine: 2,
12
- endColumn: 11,
13
- },
14
- ],
15
- });
@@ -1,6 +0,0 @@
1
- namespace my.bookshop;
2
- entity Books {
3
- key ID : Integer;
4
- title : String;
5
- stock : Integer;
6
- }
@@ -1,23 +0,0 @@
1
-
2
-
3
- /**
4
- * Called from wrapper modules
5
- */
6
- export interface CDSGenerator {
7
- /**
8
- * Initializes the generator and starts generation
9
- * @param projectName the new project name or null
10
- * @param options the current options
11
- */
12
- stepInit(projectName: string, options: any): Promise<void>;
13
-
14
- /**
15
- * Displays a final message
16
- */
17
- stepEnd(): Promise<void>;
18
-
19
- /**
20
- * Contains the parameter description
21
- */
22
- uiConfig?: any;
23
- }