Skip to content

Commit 4357131

Browse files
authored
Merge pull request #16 from cap-js/plugin-to-package
Plugin to reuse library
2 parents feaaa4e + 683d878 commit 4357131

File tree

12 files changed

+21
-122
lines changed

12 files changed

+21
-122
lines changed

README.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,15 @@
22

33
# AsyncAPI Plugin
44

5-
The `@cap-js/asyncapi` package is a [CDS plugin](https://cap.cloud.sap/docs/node.js/cds-plugins#cds-plugin-packages) that provides support for AsyncAPI document compilation.
5+
The `@cap-js/asyncapi` is a package that provides support for AsyncAPI document compilation.
66

77
### Table of Contents
88

9-
- [Setup](#setup)
109
- [Generate AsyncAPI document](#generate-asyncapi-document)
1110
- [Contributing](#contributing)
1211
- [Code of Conduct](#code-of-conduct)
1312
- [Licensing](#licensing)
1413

15-
## Setup
16-
17-
To use `cds compile --to asyncapi` functionality, simply add this self-configuring plugin package to your project:
18-
19-
```sh
20-
npm add @cap-js/asyncapi
21-
```
22-
23-
In this guide, we use the [Incidents Management reference sample app](https://github.com/cap-js/incidents-app) as the base, to generate the AsyncAPI document for the `services.cds` file.
24-
2514
## Generate AsyncAPI document
2615

2716
### 1. Usage of programatic API

cds-plugin.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const cds = require('@sap/cds')
2+
3+
function _lazyRegisterCompileTarget() {
4+
const value = require('./lib/compile/index')
5+
Object.defineProperty(this, "asyncapi", { value })
6+
return value
7+
}
8+
9+
const registerAsyncapiCompileTarget = () => {
10+
Object.defineProperty(cds.compile.to, "asyncapi", {
11+
get: _lazyRegisterCompileTarget,
12+
configurable: true
13+
})
14+
}
15+
16+
17+
module.exports = { registerAsyncapiCompileTarget }

lib/compile/api.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@cap-js/asyncapi",
33
"version": "1.0.0",
4-
"description": "CAP Plugin for AsyncAPI",
4+
"description": "CAP tool for AsyncAPI",
55
"repository": {
66
"type": "git",
77
"url": "git+https://github.com/cap-js/asyncapi.git"
@@ -15,9 +15,8 @@
1515
],
1616
"author": "SAP SE (https://www.sap.com)",
1717
"license": "SEE LICENSE IN LICENSE",
18-
"main": "cds-plugin.js",
18+
"main": "index.js",
1919
"files": [
20-
"cds-plugin.js",
2120
"lib/"
2221
],
2322
"scripts": {

test/lib/compile/asyncapiOptions.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const toAsyncAPI = require('../../../lib/compile');
2-
require('../../../cds-plugin')
2+
require('../../../').registerAsyncapiCompileTarget();
33
const cds = require('@sap/cds');
44
const { readdir, read, path: { resolve } } = cds.utils;
55
const { join } = require('path');

xmpl/.cdsrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

xmpl/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

xmpl/README.md

Whitespace-only changes.

xmpl/package.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)