Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/apps/cli/commands/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export default class Bundle extends Command {

async run() {
const { argv, flags } = await this.parse(Bundle);
//Guard: building requires at least one AsyncApi file path.
if (!argv.length) {
this.error('At least one AsyncAPI file path is required!');
}
const output = flags.output;
const outputFormat = path.extname(argv[0] as string);
const AsyncAPIFiles = argv as string[];
const AsyncApiFiles = argv as string[];

this.metricsMetadata.files = AsyncAPIFiles.length;
this.metricsMetadata.files = AsyncApiFiles.length;

const document = await bundle(AsyncAPIFiles, {
const document = await bundle(AsyncApiFiles, {
base: flags.base,
baseDir: flags.baseDir,
xOrigin: flags.xOrigin,
Expand All @@ -49,6 +53,7 @@ export default class Bundle extends Command {
} else {
const format = path.extname(output);

//Ensuring only one output format is written and fail fast on unsupported extension.
if (format === '.yml' || format === '.yaml') {
await writeFile(
path.resolve(process.cwd(), output),
Expand All @@ -57,16 +62,16 @@ export default class Bundle extends Command {
encoding: 'utf-8',
},
);
}

if (format === '.json') {
} else if (format === '.json') {
await writeFile(
path.resolve(process.cwd(), output),
document.string() || '',
{
encoding: 'utf-8',
},
);
} else {
this.error('Output file must be .json, .yaml or .yml');
}
this.log(`Check out your shiny new bundled files at ${output}`);
}
Expand Down
72 changes: 72 additions & 0 deletions test/docs/test-output/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# AsyncAPI Sample App

## Overview

This is a sample app.

- **Version:** 1.0.1
- **Server URL:** mqtt://api.streetlights.smartylighting.com:{port}


## Usage

```javascript
const AsyncAPISampleApp = require('./client');
const wsClient = new AsyncAPISampleApp();

async function main() {
try {
await wsClient.connect();
// use wsClient to send/receive messages
await wsClient.close();
} catch (error) {
console.error('Failed to connect:', error);
}
}

main();
```


## API

### `connect()`
Establishes a WebSocket connection.

### `registerMessageHandler(handlerFunction)`
Registers a callback for incoming messages.

### `registerErrorHandler(handlerFunction)`
Registers a callback for connection errors.

### `close()`
Closes the WebSocket connection.


### Available Operations

#### `receiveLightMeasured(payload)`




#### `receiveTurnOn(payload)`




#### `smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.subscribe(payload)`




#### `turnOnOff(payload)`




#### `dimLight(payload)`