Skip to content

Commit cc82a70

Browse files
committed
remove registering compile target
1 parent 8a1106b commit cc82a70

File tree

5 files changed

+15
-44
lines changed

5 files changed

+15
-44
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## Version 1.0.0 - 14.05.2024
8+
9+
### Changed
10+
11+
- Removed registering compile target
12+
713
## Version 1.0.0 - 02.05.2024
814

915
### Added

README.md

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ The `@cap-js/asyncapi` is a package that provides support for AsyncAPI document
99
### Table of Contents
1010

1111
- [Requirements and Setup](#requirements-and-setup)
12-
- [Generate AsyncAPI document](#generate-asyncapi-document)
1312
- [Contributing](#contributing)
1413
- [Code of Conduct](#code-of-conduct)
1514
- [Licensing](#licensing)
@@ -25,33 +24,12 @@ $ npm install @cap-js/asyncapi
2524
### Usage
2625

2726
```sh
28-
require("@cap-js/asyncapi").register()
27+
const processor = require('@cap-js/asyncapi')
2928
```
30-
31-
## Generate AsyncAPI document
32-
33-
### 1. Usage of programatic API
34-
35-
To invoke `cds compile --to asyncapi` programatically:
36-
3729
```sh
38-
await cds.compile(<filename>).to.asyncapi()
30+
processor(csn)
3931
```
4032

41-
For more information, visit [capire](https://cap.cloud.sap/docs/node.js/cds-compile#asyncapi)
42-
43-
44-
### 2. Usage from CLI
45-
46-
Run the following command in the CLI to generate the AsyncAPI document.
47-
48-
```sh
49-
$ cds compile <filename> --to asyncapi
50-
```
51-
52-
53-
For more information, visit [capire](https://cap.cloud.sap/docs/advanced/publishing-apis/asyncapi#cli)
54-
5533
## Contributing
5634

5735
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/asyncapi/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).

index.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
const cds = require('@sap/cds')
21

3-
function _lazyRegisterCompileTarget() {
4-
const value = require('./lib/compile/index')
5-
Object.defineProperty(this, "asyncapi", { value })
6-
return value
7-
}
8-
9-
const register = () => {
10-
Object.defineProperty(cds.compile.to, "asyncapi", {
11-
get: _lazyRegisterCompileTarget,
12-
configurable: true
13-
})
14-
}
15-
16-
17-
module.exports = { register }
2+
module.exports = {
3+
compile: require('./lib/compile')
4+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cap-js/asyncapi",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "CAP tool for AsyncAPI",
55
"repository": {
66
"type": "git",
@@ -15,7 +15,7 @@
1515
],
1616
"author": "SAP SE (https://www.sap.com)",
1717
"license": "SEE LICENSE IN LICENSE",
18-
"main": "index.js",
18+
"main": "lib/compile/index.js",
1919
"files": [
2020
"lib/",
2121
"index.js",

test/lib/compile/asyncapiOptions.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const toAsyncAPI = require('../../../lib/compile');
2-
require('../../../').register();
32
const cds = require('@sap/cds');
43
const { readdir, read, path: { resolve } } = cds.utils;
54
const { join } = require('path');
@@ -65,7 +64,8 @@ describe('asyncapi export: options', () => {
6564
});
6665

6766
// generates two files for services set to all
68-
const generatedAsyncAPI = await cds.compile(fileList).to.asyncapi({ service: 'all' });
67+
const csn = await cds.compile(fileList).to.csn();
68+
const generatedAsyncAPI = toAsyncAPI(csn, { service: 'all' });
6969
const filesFound = new Set();
7070
for (const [, metadata] of generatedAsyncAPI) {
7171
filesFound.add(metadata.file);

0 commit comments

Comments
 (0)