Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add installation guide #818

Merged
merged 84 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
542889e
add asyncapiDocument and asyncapiString documentation
Florence-Njeri Jul 20, 2022
e7536f6
add CLi installation and upgrade guide
Florence-Njeri Aug 19, 2022
7f3c42a
remove asyncapi-file
Florence-Njeri Aug 19, 2022
58a02a3
revert asyncapi file
Florence-Njeri Aug 19, 2022
1d9beae
run grammarly
Florence-Njeri Aug 19, 2022
b559824
add installation using docker
Florence-Njeri Aug 29, 2022
676c0cf
final
Florence-Njeri Aug 29, 2022
cddf86b
update the installation guide
Florence-Njeri Sep 4, 2022
c6192bf
add versioning to the installation guide
Florence-Njeri Sep 7, 2022
7f8f7a8
remove note saying we've tested till node version 14
Florence-Njeri Sep 8, 2022
df024c8
Merge branch 'master' into installation-guide
Florence-Njeri Sep 8, 2022
dd916e2
add uninstall section
Florence-Njeri Sep 8, 2022
b2ab66d
merge
Florence-Njeri Sep 8, 2022
2b95411
refine the intsllation and generator/template versioning docs
Florence-Njeri Sep 19, 2022
31c182f
refine the docs
Florence-Njeri Sep 19, 2022
86a6c98
revise the versioning file
Florence-Njeri Sep 19, 2022
eb8842c
restructure the installation guide
Florence-Njeri Sep 22, 2022
6c5400d
restructure the installation guide
Florence-Njeri Sep 22, 2022
772f6ac
refactor the docs to be more reader friendly
Florence-Njeri Sep 22, 2022
1e9dbf0
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
dfe0a05
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
f8a8506
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
020b715
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
96d0c22
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
f11ff11
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
f8a5fd9
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
a29d203
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
1d74d84
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
200765b
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
af3c23f
Update docs/installation-guide.md
Florence-Njeri Sep 23, 2022
a0fee82
Update docs/installation-guide.md
Florence-Njeri Sep 26, 2022
59b79ed
Update docs/installation-guide.md
Florence-Njeri Sep 26, 2022
23c6244
Update docs/installation-guide.md
Florence-Njeri Sep 26, 2022
42580d6
Update docs/versioning.md
Florence-Njeri Sep 26, 2022
ee474f8
Update docs/installation-guide.md
Florence-Njeri Sep 26, 2022
d5a1c6c
Update docs/installation-guide.md
Florence-Njeri Sep 26, 2022
53a2d98
Update docs/installation-guide.md
Florence-Njeri Sep 26, 2022
a47327d
Update docs/versioning.md
Florence-Njeri Sep 26, 2022
4be4940
Update docs/versioning.md
Florence-Njeri Sep 26, 2022
5c08c02
Update docs/versioning.md
Florence-Njeri Sep 26, 2022
c50c2b8
Update docs/versioning.md
Florence-Njeri Sep 26, 2022
96db1ed
improvements
Florence-Njeri Sep 26, 2022
7df9ca5
accept incoming changes
Florence-Njeri Sep 26, 2022
2636f6f
minor fix
Florence-Njeri Sep 26, 2022
b17c810
fix doc weight
Florence-Njeri Sep 26, 2022
b080218
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
bc2a1df
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
0b209b3
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
579cc3e
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
603912e
Update docs/versioning.md
Florence-Njeri Sep 29, 2022
f24bf67
Update docs/versioning.md
Florence-Njeri Sep 29, 2022
ca9c036
Update docs/versioning.md
Florence-Njeri Sep 29, 2022
502b14f
Update docs/versioning.md
Florence-Njeri Sep 29, 2022
68d8ca1
Update docs/versioning.md
Florence-Njeri Sep 29, 2022
4a6aa61
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
ccbd461
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
768ea93
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
2b83768
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
25f7b26
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
fd4d4a3
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
310b8ab
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
2e3c143
Update docs/versioning.md
Florence-Njeri Sep 29, 2022
94dc393
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
3399808
Update docs/versioning.md
Florence-Njeri Sep 29, 2022
bb33b23
Update docs/installation-guide.md
Florence-Njeri Sep 29, 2022
06ab5f0
use AsyncAPI document reference
Florence-Njeri Oct 4, 2022
6bd7ce0
Apply suggestions from code review
Florence-Njeri Oct 4, 2022
21aa62d
Update docs/installation-guide.md
Florence-Njeri Oct 18, 2022
50885e8
replace the installation section from read.md
Florence-Njeri Oct 19, 2022
ffad150
remove versioning dection from the Readme
Florence-Njeri Oct 19, 2022
8413c72
cli installation
Florence-Njeri Oct 19, 2022
cea05ed
grammarly
Florence-Njeri Oct 19, 2022
a1efab0
rename asyncapi-file to asyncapi-document
Florence-Njeri Oct 19, 2022
edfda3f
Update README.md
Florence-Njeri Oct 21, 2022
95e9ae3
Update docs/versioning.md
Florence-Njeri Oct 21, 2022
d776eff
add versioning and installation files to the TOC
Florence-Njeri Oct 21, 2022
b6fc03a
remove reference to asyncapi generator CLI
Florence-Njeri Oct 21, 2022
502d2f2
Merge branch 'master' into installation-guide
derberg Oct 25, 2022
114b814
add installation instructions for MacOs and Linux
Florence-Njeri Nov 8, 2022
cdbb76e
Merge branch 'installation-guide' of https://github.com/Florence-Njer…
Florence-Njeri Nov 8, 2022
83747bf
Merge branch 'master' into installation-guide
derberg Nov 8, 2022
0c1d269
Update docs/installation-guide.md
Florence-Njeri Nov 8, 2022
a6962c6
Merge branch 'master' into installation-guide
Florence-Njeri Nov 10, 2022
71b823a
Merge branch 'master' into installation-guide
Florence-Njeri Nov 14, 2022
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
60 changes: 3 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,8 @@ Install both packages using [official installer](https://nodejs.org/en/download/

## Using from the command-line interface (CLI)

### Install the CLI

To use it as CLI, install generator globally:

```bash
npm install -g @asyncapi/generator
```

### Update the CLI

You might want to update your local installation of generator for different reasons:

* You want the latest generator to have its latest features. Perform usual installation and in case you had generator installed already, it will upgrade to latest available:
```bash
npm install -g @asyncapi/generator
```
* You want a specific version of the generator because your template might not be compatible with the latest generator. Check [what version you need](https://github.com/asyncapi/generator/releases) and perform installation, specifying the exact version with the `@` character:
```bash
npm install -g @asyncapi/generator@0.50.0
```

> Sometimes you have to force additional npm installation like this: `npm install -g --force @asyncapi/generator`
### CLI installation
Learn to install the AsyncAPI CLI from the [installation guide](installation-guide.md).

### CLI usage

Expand Down Expand Up @@ -247,41 +227,7 @@ See [API documentation](docs/api.md) for more example and full API reference inf

## Generator version vs Template version

The Generator is a tool that you can use to generate whatever you want, taking an AsyncAPI specification file as the input. A template is a tool that uses Generator features and helpers to specify what should be generated.

In other words, a template depends on the Generator and its features. For example, it might work with the latest version of the Generator but not the previous ones.

The owner of the template specifies in the configuration what version of the Generator it is compatible with:
```bash
"generator": ">=0.50.0 <2.0.0",
```

The Generator doesn't work in case the template is not compatible:
```bash
Something went wrong:
Error: This template is not compatible with the current version of the generator (0.50.0). This template is compatible with the following version range: >=0.60.0 <2.0.0.
at Generator.validateTemplateConfig (/Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/lib/generator.js:678:13)
at Generator.loadTemplateConfig (/Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/lib/generator.js:663:16)
at Generator.generate (/Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/lib/generator.js:146:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/cli.js:135:7
```

In case you use Generator CLI and a specific template on production, it is safer to lock to a specific version of the template and the Generator.

Instead of generating HTML with latest `html-template` and the generator CLI:
```bash
npm install -g @asyncapi/generator
ag asyncapi.yaml @asyncapi/html-template -o ./docs
```

Generate HTML with the version of the `html-template` and the Generator CLI that you are happy with:
```bash
npm install -g @asyncapi/generator@0.50.0
ag asyncapi.yaml @asyncapi/html-template@0.7.0 -o ./docs
```

Before using newer versions of the template, always look at the [changelog](https://github.com/asyncapi/html-template/releases) first. Generator features are not important for you, just make sure to use a version compatible with the template.
Learn more about versioning from the [versioning document](versioning.md).

## How to create a template

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Table of Contents
- [Configuration File](configuration-file.md)
- [Templates](template.md)
- [Authoring Templates](authoring-templates.md)
- [Generator Version vs Template Version](versioning.md)
- [React Render Engine](react-render-engine.md)
- [Nunjucks Render Engine](nunjucks-render-engine.md)
- [AsyncAPI Context](asyncapi-context.md)
Expand Down
81 changes: 81 additions & 0 deletions docs/installation-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
Florence-Njeri marked this conversation as resolved.
Show resolved Hide resolved
title: "Installation Guide"
weight: 20
---

You can use the generator library to generate whatever you want in your event-driven architecture apps. Find your preferred method below:
- [AsyncAPI CLI](#asyncapi-cli)
- [Use the Generator Library in Node.js Apps](#2-use-the-generator-library-in-your-nodejs-apps)

## Prerequisites
Florence-Njeri marked this conversation as resolved.
Show resolved Hide resolved
Before you install and use the AsyncAPI CLI and the generator library, ensure you meet the prerequisites below, then [install the CLI](#installation).
1. Node.js v12.16 and higher
2. Npm v6.13.7 and higher

To verify the versions of Node and Npm you have, run the following command on your terminal:
```
npm -v
```
```
node -v
```

If you don't have either Node or Npm installed, use the [official node.js installer](https://nodejs.org/en/download/).

If you have the correct versions installed, proceed to the CLI installation guide below. Otherwise, upgrading the Npm or Node version is lower than the recommended versions specified above.

## AsyncAPI CLI
The AsyncAPI CLI tool allows you to do many different things with the [AsyncAPI document](asyncapi-document.md). You can generate message-based API boilerplate code, documentation, or anything else you need as long as you specify it in your [template](template.md) or the existing template already supports it. To use the generator via the AsyncAPI CLI, you need to install the AsyncAPI CLI tool.

### Installation
Florence-Njeri marked this conversation as resolved.
Show resolved Hide resolved

#### Install AsyncAPI CLI using NPM

The AsyncAPI CLI is a NodeJS project, so the easiest way to install it is by using the following `npm` command:
```
npm install -g @asyncapi/cli
```

To install a specific version of the generator tool, pass the version during installation:
```
npm install -g @asyncapi/cli@{version}
```

derberg marked this conversation as resolved.
Show resolved Hide resolved
#### MacOS
You can install in MacOS by using brew: `brew install asyncapi`.

#### Linux
You can install in Linux by using `dpkg`, a package manager for debian:
1. 'curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.deb`
2. `sudo dpkg -i asyncapi.deb`

#### Other Operating Systems
For further installation instructions for different operating systems, read the [AsyncAPI CLI documentation](https://github.com/asyncapi/cli#installation).

> **Remember:**
> Each [community-developed template](https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate) is dependent on a certain version of the generator for it to work correctly. Before you install the generator CLI, check the template's `package.json` for the version of the generator CLI your template is compatible with. Read the [versioning docs](versioning.md) to learn why it's important to use certain generator versions with your templates.

### Update AsyncAPI CLI
There are several reasons why you might want to update your generator version:
* You have the generator tool installed but want to use the latest released features. To upgrade to the latest version, use the command below:
```
npm install -g @asyncapi/cli
```
* If your template isn't compatible with the latest generator version, you can update it to a specific version of the generator. Check the [version you need](https://github.com/asyncapi/cli/releases) and specify the version you want by using the **@** symbol as shown in the command below:
```
npm install -g @asyncapi/cli@{version}
```
> Sometimes you have to force additional npm installation like this: `npm install -g --force @asyncapi/cli`

### Uninstall AsyncAPI CLI
To uninstall the generator, use the following command:
```
npm uninstall @asyncapi/cli -g
```

> :memo: **Note:** To use the generator in your CI/CD pipeline to automate whatever you generate for your event-driven architecture apps, install the AsyncAPI CLI in your pipeline. If you are using GitHub Actions, use [Github Actions for Generator](https://github.com/marketplace/actions/generator-for-asyncapi-documents).

## Generator Library in Node.js Apps
Use the generator library in your Node.js projects by installing it via the following command: `npm install @asyncapi/generator`.

> Don't include the `-g` flag in the installation command above since you're not installing the generator library globally but in your Node.js project.
31 changes: 31 additions & 0 deletions docs/versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: "Generator Version vs Template Version"
weight: 60
---
Florence-Njeri marked this conversation as resolved.
Show resolved Hide resolved

The generator tool generates whatever you want, as long as it can be defined in a template based on the [AsyncAPI file](asyncapi-document.md). On the other hand, a **template** is a file or group of files that specify the kind of output you expect from using the generator's features. For example, you may want to use the [NodeJS template](https://github.com/asyncapi/nodejs-template) to generate boilerplate code for your message-based APIs.

Templates are dependent on the generators' features. For example, the template you want to use may be compatible with the latest generator version but incompatible with the previous versions. Check the configuration file or ReadME of the template to see the version of the generator it supports. The generator has an `isTemplateCompatible` function that checks if the template is compatible with the version of the generator you want to use. If the template isn't compatible, you will see a terminal error output similar to the following:
```
Something went wrong:
Error: This template is not compatible with the current version of the generator (${generatorVersion}). This template is compatible with the following version range: ${generator}.`)
```

> Use the following command to check the version of the AsyncAPI CLI you have installed; `asyncapi --version`

It is better to lock a specific version of the template and the generator if you plan to use the AsyncAPI CLI and a particular template in production. The differences between using the version of the AsyncAPI CLI you have installed and locking a certain version on production are demonstrated in the following code snippets.

Generate HTML with the latest AsyncAPI CLI using the html-template.
```
npm install -g @asyncapi/cli
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./docs
```

Generate HTML using a particular version of the AsyncAPI CLI using the html-template.

```
npm install -g @asyncapi/cli@0.20.0
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@0.7.0 -o ./docs
```

> Before using newer versions of the template, always look at the [changelog](https://github.com/asyncapi/html-template/releases) first. If the generator's features are not important to you, just make sure to use a version compatible with your template.