Skip to content

Commit 1dd5857

Browse files
authored
Fix: use @sap/cds instead of @sap/cds-dk for build plugin (#324)
* refactor: use @sap/cds instead of @sap/cds-dk for build plugin - Change build plugin to extend cds.build.Plugin from @sap/cds - Remove @sap/cds-dk from peerDependencies - Update tests to mock cds.build.Plugin before requiring build.js - Aligns with other CAP plugins (notifications, captivator) pattern - cds.build.Plugin is injected by cds-dk at build time * remove cds-dk * use npmx * revert removing cds-dk from doc and move cds-dk to devDep
1 parent d858e2c commit 1dd5857

File tree

5 files changed

+27
-34
lines changed

5 files changed

+27
-34
lines changed

__tests__/unit/build.test.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
const cds = require("@sap/cds");
21
const path = require("path");
3-
const OrdBuildPlugin = require("../../lib/build");
42
const { BUILD_DEFAULT_PATH } = require("../../lib/constants");
53
const index = require("../../lib/index");
64

7-
jest.mock("@sap/cds-dk", () => {
8-
return {
9-
build: {
10-
Plugin: class {
11-
constructor() {
12-
this.task = {
13-
dest: undefined,
14-
src: null,
15-
};
16-
}
17-
write() {
18-
return {
19-
to: () => {
20-
return Promise.resolve();
21-
},
22-
};
23-
}
24-
async model() {
25-
return Promise.resolve({});
26-
}
5+
// Setup cds.build.Plugin mock BEFORE requiring build.js
6+
const cds = require("@sap/cds");
7+
cds.build = cds.build || {};
8+
cds.build.Plugin = class {
9+
constructor() {
10+
this.task = {
11+
dest: undefined,
12+
src: null,
13+
};
14+
}
15+
write() {
16+
return {
17+
to: () => {
18+
return Promise.resolve();
2719
},
28-
},
29-
};
30-
});
20+
};
21+
}
22+
async model() {
23+
return Promise.resolve({});
24+
}
25+
};
26+
27+
// Now require the build plugin after the mock is set up
28+
const OrdBuildPlugin = require("../../lib/build");
3129

3230
jest.mock("../../lib/index", () => {
3331
return {

lib/build.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
const cds = require("@sap/cds");
2-
const cds_dk = require("@sap/cds-dk");
32
const path = require("path");
43
const _ = require("lodash");
54
const { ord, getMetadata } = require("./index");
65
const cliProgress = require("cli-progress");
76
const { BUILD_DEFAULT_PATH, ORD_SERVICE_NAME, ORD_DOCUMENT_FILE_NAME } = require("./constants");
87
const { isMCPPluginInPackageJson } = require("./mcpAdapter");
98

10-
module.exports = class OrdBuildPlugin extends cds_dk.build.Plugin {
9+
module.exports = class OrdBuildPlugin extends cds.build.Plugin {
1110
static taskDefaults = { src: cds.env.folders.srv };
1211

1312
init() {

memory-bank/techContext.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ cds compile srv/ --to ord -o ./custom-output/
101101
### CAP Framework Dependencies
102102

103103
- **Minimum CAP Version**: 8.9.4 (peer dependency)
104-
- **Minimum CDS-DK Version**: 8.9.5 (peer dependency)
105104
- **CSN Compatibility**: Must handle all CAP CSN model structures
106105
- **Interop CSN**: Generate interop-compatible CSN format
107106
- **Plugin Architecture**: Must follow CAP plugin conventions

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
"jest": "^30.0.0",
3333
"prettier": "3.7.4",
3434
"supertest": "^7.0.0",
35-
"@cap-js/sqlite": "^2"
35+
"@cap-js/sqlite": "^2",
36+
"@sap/cds-dk": ">=8.9.5"
3637
},
3738
"peerDependencies": {
38-
"@sap/cds": ">=8.9.4",
39-
"@sap/cds-dk": ">=8.9.5"
39+
"@sap/cds": ">=8.9.4"
4040
},
4141
"dependencies": {
4242
"@cap-js/asyncapi": "^1.0.3",

xmpl_java/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@
55
"license": "ISC",
66
"dependencies": {
77
"@cap-js/ord": "file:../../ord"
8-
},
9-
"devDependencies": {
10-
"@sap/cds-dk": "^9.1.3"
118
}
129
}

0 commit comments

Comments
 (0)