Skip to content

Commit 3bd9c81

Browse files
authored
feat: small changes (#33)
1 parent a950653 commit 3bd9c81

File tree

25 files changed

+455
-198
lines changed

25 files changed

+455
-198
lines changed

README.md

+121-92
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,164 @@
11
[![License](https://img.shields.io/github/license/the-codegen-project/cli)](https://github.com/the-codegen-project/cli/blob/master/LICENSE)
22
[![Npm latest version](https://img.shields.io/npm/v/@the-codegen-project/cli)](https://www.npmjs.com/package/@the-codegen-project/cli)
33
![NPM Downloads](https://img.shields.io/npm/dw/%40the-codegen-project%2Fcli)
4-
![homebrew downloads](https://img.shields.io/homebrew/installs/dm/codegen?label=Brew)
5-
![Chocolatey Downloads](https://img.shields.io/chocolatey/dt/codegen?label=Chocolatey)
6-
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x64.pkg?label=MacOS)
4+
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/the-codegen-project/cli/.github%2Fworkflows%2Fruntime-testing.yml?label=runtime%20testing)
5+
![GitHub last commit](https://img.shields.io/github/last-commit/the-codegen-project/cli)
6+
7+
<!-- ![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x64.pkg?label=MacOS)
78
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.arm64.pkg?label=MacOS)
89
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x86.exe?label=Win)
910
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x64.exe?label=Win)
1011
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.tar.gz?label=Linux)
1112
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.deb?label=Linux)
12-
13+
![homebrew downloads](https://img.shields.io/homebrew/installs/dm/codegen?label=Brew)
14+
![Chocolatey Downloads](https://img.shields.io/chocolatey/dt/codegen?label=Chocolatey)-->
1315
---
1416

15-
The Codegen Project solves a single problem, how to simplify the implementation phase of software development for different standards.
17+
Simplifying your implementation phase when using standards such as AsyncAPI has never been easier.
1618

17-
Here are all the ways you can integrate and run The Codegen Project CLI. For a full list of commands [checkout the usage documentation](./docs/usage.md).
18-
19-
<h2 align="center">MacOS</h2>
20-
<!-- prettier-ignore-start -->
21-
<!-- markdownlint-disable -->
22-
<table align="center" style="width: 100%;">
19+
<table>
2320
<tr>
24-
<td>
25-
<b><a href="https://brew.sh/">Brew</a></b>
26-
27-
```
28-
brew install codegen
29-
```
30-
</td>
21+
<th colspan="3" style="text-align: center;">Anywhere</th>
3122
</tr>
3223
<tr>
3324
<td>
34-
<b>MacOS x64</b>
35-
36-
Install it through a dedicated `.pkg` file as a MacOS Application
37-
38-
```
39-
# Download latest release
40-
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x64.pkg
41-
# Install it
42-
sudo installer -pkg codegen.pkg -target /
43-
```
44-
</td>
45-
</tr>
46-
<tr>
25+
<div style="text-align: center;">
26+
TypeScript <video src='https://github.com/the-codegen-project/cli/assets/13396189/ef400456-3583-4e7a-aa65-f1db95f1c0ec' width=360></video>
27+
</div>
28+
</td>
4729
<td>
48-
<b>MacOS arm64</b>
49-
50-
Install it through a dedicated `.pkg` file as a MacOS Application for arm64
51-
```
52-
# Download latest release
53-
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.arm64.pkg
54-
# Install it
55-
sudo installer -pkg codegen.pkg -target /
56-
```
57-
</td>
30+
<div>
31+
Java Maven <video src='https://github.com/the-codegen-project/cli/assets/13396189/79b6019a-4e8f-4893-82ae-5b9f5c2cf2e6' width=360></video>
32+
</div>
33+
</td>
34+
<td>
35+
<div>
36+
Next.js <video src='https://github.com/the-codegen-project/cli/assets/13396189/e54aa060-61fc-49bd-b603-0a5f82667286' width=360></video>
37+
</div>
38+
</td>
5839
</tr>
5940
</table>
6041

61-
<h2 align="center">Windows</h2>
62-
<!-- prettier-ignore-start -->
63-
<!-- markdownlint-disable -->
64-
<table align="center" style="width: 100%;">
42+
## Install
43+
Install The Codegen Project any way you wish.
44+
45+
<table style="table-layout: fixed;">
46+
<tr style="height: 50px;">
47+
<th>NPM (All Platforms)</th>
48+
<th>MacOS x64</th>
49+
<th>MacOS arm64</th>
50+
<th>Windows x64</th>
51+
<th>Windows x32</th>
52+
<th>Linux (Debian)</th>
53+
<th>Linux (Others)</th>
54+
</tr>
6555
<tr>
66-
<td>
67-
<b><a href="https://chocolatey.org/install">Chocolatey</a></b>
56+
<td style="vertical-align: top; min-width: 300px;">
57+
<div>
6858

59+
#### Globally
60+
61+
```sh
62+
npm install -g @the-codegen-project/cli
6963
```
70-
choco install codegen
64+
65+
#### Locally
66+
67+
```sh
68+
npm install --save-dev @the-codegen-project/cli
7169
```
72-
</td>
73-
</tr>
74-
<tr>
75-
<td><b>Windows x64</b>
70+
</div>
71+
</td>
72+
<td style="vertical-align: top;">
73+
<div>
7674

77-
Manually download and run [`codegen.x64.exe`](https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x64.exe)
78-
</td>
79-
</tr>
80-
<tr>
81-
<td>
82-
<b>Windows x32</b>
75+
#### Download
76+
```sh
77+
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x64.pkg
78+
```
8379

84-
Manually download and run the executable [`codegen.x86.exe`](https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x86.exe)
85-
</td>
86-
</tr>
87-
</table>
80+
#### Install
81+
```sh
82+
sudo installer -pkg codegen.x64.pkg -target /
83+
```
8884

85+
</div>
86+
</td>
87+
<td style="vertical-align: top;">
88+
<div>
8989

90-
<h2 align="center">Linux</h2>
91-
<!-- prettier-ignore-start -->
92-
<!-- markdownlint-disable -->
93-
<table align="center" style="width: 100%;">
94-
<tr>
95-
<td><b>Debian</b>
90+
#### Download
91+
```sh
92+
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.arm64.pkg
93+
```
94+
#### Install
9695

96+
```sh
97+
sudo installer -pkg codegen.arm64.pkg -target /
9798
```
98-
# Download
99+
</div>
100+
</td>
101+
<td style="vertical-align: top;">
102+
<div>
103+
<a href="https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x64.exe">Download and run codegen.x64.exe</a>
104+
</div>
105+
</td>
106+
<td style="vertical-align: top;">
107+
<div>
108+
<a href="https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x86.exe">Download and run codegen.x86.exe</a>
109+
</div>
110+
</td>
111+
<td style="vertical-align: top;">
112+
<div>
113+
114+
#### Download
115+
```sh
99116
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.deb
117+
```
100118

101-
# Install
119+
#### Install
120+
```sh
102121
sudo apt install ./codegen.deb
103122
```
104-
</td>
105-
</tr>
106-
<tr>
107-
<td>
108-
<b>Others</b>
123+
</div>
124+
</td>
125+
<td style="vertical-align: top;">
126+
<div>
109127

110-
```
111-
# Download
128+
#### Download
129+
```sh
112130
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.tar.gz
113-
# Install
131+
```
132+
133+
#### Install
134+
135+
```sh
114136
tar -xzf codegen.tar.gz
115137
```
116138

117-
Remember to symlink the binaries `ln -s <absolute-path>/bin/codegen /user/local/bin/codegen` to access the CLI anywhere.
118-
</td>
139+
#### Symlink
140+
```sh
141+
ln -s <absolute-path>/bin/codegen /usr/local/bin/codegen
142+
```
143+
144+
</div>
145+
</td>
119146
</tr>
120147
</table>
121148

122-
<h2 align="center">Other ways</h2>
123-
<!-- prettier-ignore-start -->
124-
<!-- markdownlint-disable -->
125-
<table align="center" style="width: 100%;">
126-
<tr>
127-
<td>
128-
<b>NPM</b>
149+
## Initialize
150+
Add The Codegen Project configuration file, either manually or through the CLI;
151+
```sh
152+
codegen init
153+
```
129154

130-
```typescript
131-
npm install -g @the-codegen-project/cli
155+
<video src='https://github.com/the-codegen-project/cli/assets/13396189/6a351e0d-b5b2-4ca3-845a-556aeba490c9' width=1920></video>
156+
157+
Check out all the new generators here: https://github.com/the-codegen-project/cli/tree/main/docs/generators
158+
159+
## Generate
160+
With your configuration file in hand, time to generate the code and use it!
161+
162+
```sh
163+
codegen generate
132164
```
133-
</td>
134-
</tr>
135-
</table>

assets/generate-maven.webm

1.64 MB
Binary file not shown.

assets/generate-nextjs.webm

2.16 MB
Binary file not shown.

assets/generate-typescript.webm

1.5 MB
Binary file not shown.

assets/initialize.webm

1.4 MB
Binary file not shown.

docs/configurations.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Configurations
2+
3+
There are 3 possible configuration file types, `json`, `esm` (JavaScript), and `yaml`.
4+
5+
The only difference between them is what they enable you to do. The difference is `callbacks`, in a few places, you might want to provide a callback to control certain behavior in the generation library.
6+
7+
For example, with the [`custom`](./generators/custom.md) generator, you provide a callback to render something, this is not possible if your configuration file is either `json` or `yaml` format.
8+
9+
Reason those two exist, is because adding a `.js` configuration file to a Java project, might confuse developers, and if you dont need to take advantage of the customization features that require callback, it will probably be better to use one of the other two.
File renamed without changes.

examples/java-maven/codegen.js

-16
This file was deleted.

examples/typescript-library/codegen.js examples/java-maven/codegen.mjs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
export default {
33
inputType: 'asyncapi',
44
inputPath: 'asyncapi.json',
5-
language: 'typescript',
5+
language: 'java',
66
generators: [
77
{
88
preset: 'payloads',
9-
serializationType: 'json',
10-
outputPath: './src/__gen__'
9+
language: 'java',
10+
outputPath: './target/generated-sources/the/codegen/project',
11+
packageName: 'the.codegen.project',
12+
serializationType: 'json',
1113
}
1214
]
1315
};

examples/java-maven/pom.xml

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
35
<modelVersion>4.0.0</modelVersion>
46
<groupId>com.mycompany</groupId>
57
<artifactId>java-maven</artifactId>
@@ -9,7 +11,7 @@
911
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1012
<maven.compiler.source>1.8</maven.compiler.source>
1113
<maven.compiler.target>1.8</maven.compiler.target>
12-
<exec.mainClass>com.mycompany.java.maven.JavaMaven</exec.mainClass>
14+
<exec.mainClass>the.codegen.project.Main</exec.mainClass>
1315
</properties>
1416
<dependencies>
1517
<dependency>
@@ -30,11 +32,11 @@
3032
<id>Renaming build artifacts</id>
3133
<phase>generate-sources</phase>
3234
<goals>
33-
<goal>exec</goal>
35+
<goal>exec</goal>
3436
</goals>
3537
<configuration>
36-
<executable>codegen</executable>
37-
<commandlineArgs>generate</commandlineArgs>
38+
<executable>codegen</executable>
39+
<commandlineArgs>generate</commandlineArgs>
3840
</configuration>
3941
</execution>
4042
</executions>
@@ -51,12 +53,27 @@
5153
</goals>
5254
<configuration>
5355
<sources>
54-
<source>${project.build.directory}/generated</source>
56+
<source>${project.build.directory}/generated-sources</source>
5557
</sources>
5658
</configuration>
5759
</execution>
5860
</executions>
5961
</plugin>
62+
<plugin>
63+
<groupId>org.codehaus.mojo</groupId>
64+
<artifactId>exec-maven-plugin</artifactId>
65+
<version>1.2.1</version>
66+
<executions>
67+
<execution>
68+
<goals>
69+
<goal>java</goal>
70+
</goals>
71+
</execution>
72+
</executions>
73+
<configuration>
74+
<mainClass>the.codegen.project.Main</mainClass>
75+
</configuration>
76+
</plugin>
6077
</plugins>
6178
</build>
6279
</project>

examples/java-maven/src/main/java/com/mycompany/java/maven/JavaMaven.java examples/java-maven/src/main/java/the/codegen/project/Main.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.mycompany.java.maven;
1+
package the.codegen.project;
22

33
import com.fasterxml.jackson.core.JsonProcessingException;
44
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -7,7 +7,7 @@
77
*
88
* @author Lagoni
99
*/
10-
public class JavaMaven {
10+
public class Main {
1111
public static void main(String[] args) throws JsonProcessingException {
1212
UserSignedUp payload = new UserSignedUp();
1313
payload.setDisplayName("Lagoni");
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @type {import("@the-codegen-project/cli").TheCodegenConfiguration} **/
2+
export default {
3+
inputType: "asyncapi",
4+
inputPath: "asyncapi.json",
5+
language: "typescript",
6+
generators: [
7+
{
8+
preset: "payloads",
9+
outputPath: "src/__gen__/payloads",
10+
serializationType: "json"
11+
}
12+
]
13+
};

0 commit comments

Comments
 (0)