Skip to content

Commit

Permalink
remove registering compile target
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevitha011 committed May 14, 2024
1 parent 8a1106b commit cc82a70
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Version 1.0.0 - 14.05.2024

### Changed

- Removed registering compile target

## Version 1.0.0 - 02.05.2024

### Added
Expand Down
26 changes: 2 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ The `@cap-js/asyncapi` is a package that provides support for AsyncAPI document
### Table of Contents

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

```sh
require("@cap-js/asyncapi").register()
const processor = require('@cap-js/asyncapi')
```

## Generate AsyncAPI document

### 1. Usage of programatic API

To invoke `cds compile --to asyncapi` programatically:

```sh
await cds.compile(<filename>).to.asyncapi()
processor(csn)
```

For more information, visit [capire](https://cap.cloud.sap/docs/node.js/cds-compile#asyncapi)


### 2. Usage from CLI

Run the following command in the CLI to generate the AsyncAPI document.

```sh
$ cds compile <filename> --to asyncapi
```


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

## Contributing

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).
Expand Down
19 changes: 3 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
const cds = require('@sap/cds')

function _lazyRegisterCompileTarget() {
const value = require('./lib/compile/index')
Object.defineProperty(this, "asyncapi", { value })
return value
}

const register = () => {
Object.defineProperty(cds.compile.to, "asyncapi", {
get: _lazyRegisterCompileTarget,
configurable: true
})
}


module.exports = { register }
module.exports = {
compile: require('./lib/compile')
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cap-js/asyncapi",
"version": "1.0.0",
"version": "1.0.1",
"description": "CAP tool for AsyncAPI",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,7 @@
],
"author": "SAP SE (https://www.sap.com)",
"license": "SEE LICENSE IN LICENSE",
"main": "index.js",
"main": "lib/compile/index.js",
"files": [
"lib/",
"index.js",
Expand Down
4 changes: 2 additions & 2 deletions test/lib/compile/asyncapiOptions.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const toAsyncAPI = require('../../../lib/compile');
require('../../../').register();
const cds = require('@sap/cds');
const { readdir, read, path: { resolve } } = cds.utils;
const { join } = require('path');
Expand Down Expand Up @@ -65,7 +64,8 @@ describe('asyncapi export: options', () => {
});

// generates two files for services set to all
const generatedAsyncAPI = await cds.compile(fileList).to.asyncapi({ service: 'all' });
const csn = await cds.compile(fileList).to.csn();
const generatedAsyncAPI = toAsyncAPI(csn, { service: 'all' });
const filesFound = new Set();
for (const [, metadata] of generatedAsyncAPI) {
filesFound.add(metadata.file);
Expand Down

0 comments on commit cc82a70

Please sign in to comment.