Skip to content

Commit bc78ac2

Browse files
authored
Merge pull request #22 from cap-js/main
Remove registering compile target
2 parents 8a1106b + 421c0c8 commit bc78ac2

File tree

5 files changed

+19
-45
lines changed

5 files changed

+19
-45
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ 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.1 - 14.05.2024
8+
9+
### Changed
10+
11+
- Removed registering compile target
12+
713
## Version 1.0.0 - 02.05.2024
814

915
### Added
1016

11-
- Initial release
17+
- Initial release

README.md

Lines changed: 6 additions & 25 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)
@@ -24,34 +23,16 @@ $ npm install @cap-js/asyncapi
2423

2524
### Usage
2625

27-
```sh
28-
require("@cap-js/asyncapi").register()
29-
```
30-
31-
## Generate AsyncAPI document
32-
33-
### 1. Usage of programatic API
34-
35-
To invoke `cds compile --to asyncapi` programatically:
36-
37-
```sh
38-
await cds.compile(<filename>).to.asyncapi()
26+
```js
27+
const cds = require('@sap/cds')
28+
const { compile } = require('@cap-js/asyncapi')
3929
```
4030

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
31+
```js
32+
const csn = await cds.load(cds.env.folders.srv)
33+
const asyncapiDocument = compile(csn)
5034
```
5135

52-
53-
For more information, visit [capire](https://cap.cloud.sap/docs/advanced/publishing-apis/asyncapi#cli)
54-
5536
## Contributing
5637

5738
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: 1 addition & 1 deletion
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",

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)