Skip to content

Commit

Permalink
NO-ISSUE: Add form-generation-tool README.md (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
pefernan authored Aug 30, 2023
1 parent 5a92746 commit b8634d1
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 1 deletion.
83 changes: 83 additions & 0 deletions packages/form-generation-tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## Form Generation Tool

This is a utility CLI to help generating forms in differents formats for BPMN processes and User Tasks in your Kogito projects.

### How does it work?

When building a Kogito project, Kogito generates JSON schemas to represent the data models for both Processes and User Tasks.

This tool locates those JSON Schemas in the project and taking advantage of the [Uniforms](https://uniforms.tools) APIs, processes them and generate static forms as a resources in the project `src/main/resoures/form` folder.

### Form Types

There are two types of form supported with differnt styling and output format:

- **Patternfly**: generates a React (`.tsx`) forms using Patternfly 4 components. Implementation can be found in `@kie-tools/uniforms-patternfly-codegen`

- **Bootstrap 4**: generates a HTML (`.html`) forms using Bootstrap 4 styling.

Each generated form consist in two files, the source code (`.tsx` or `.html`) and a companion `.config` file that defines the external resources (`css` / `js`) the form may need.

## Build

In order to build the CLI you must run the following command in the root folder of the repository:

```shell script
pnpm -F @kie-tools/form-generation-tool... build:prod
```

After the command has finished, go to `packages/form-generation-tool/dist` folder and you'll find the CLI binary (`form-generation-cli-macos`, `form-generation-cli-linux` or `form-generation-cli-win.exe` depending on your OS).

## Running the CLI

In the command line just execute the CLI binary:

```shell script
./form-generation-cli-linux
```

This command will start a wizard to help you generate the forms:

1. First set the path to your Kogito Project.

![Step 1: Set the Kogito Project path](./docs/form-generation-1.png)

> **ℹ️ NOTE:** Make sure your Kogito project has been compiled, otherwhise the CLI won't be able to find all the form schemas.
2. Select one of the availables the Form types (Patternfly or Bootstrap 4).

![Step 2: Select the Form type](./docs/form-generation-2.png)

3. Confirm Selection to start the Form Generation process.

![Step 3: Select the Form type](./docs/form-generation-3.png)

4. If the Form generation process is succesful, you'll get a confirmation message.

![Form generation succesfully finished](./docs/form-generation-4.png)

The generated forms will be stored in the `src/main/resources/forms` folder of the Kogito project.

![List of generated forms in project](./docs/form-generation-5.png)

## Using the Custom Forms with Runtime Tools Quarkus Extension

If your project is a Quarkus based Kogito project, you can use and test them by using the **Runtime Tools Quarkus Extension**.

To do so, just add the following dependency in your project `pom.xml`:

```xml
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>runtime-tools-quarkus-extension</artifactId>
<version>${version}</version>
</dependency>
```

And start the project in Dev mode with the command:

```shell script
mvn clean quarkus:dev
```

For more information on how to setup the **Runtime Tools Quarkus Extension** in your project look at the oficial Kogito [documentation](https://docs.kogito.kie.org/latest/html_single/#con-runtime-tools-dev-ui_kogito-developing-process-services).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/form-generation-tool/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function run() {
console.log("Kogito Form Generation CLI");
console.log("===========================");
console.log();
console.log("This tool will help you generate forms for User Tasks in your Kogito Projects.");
console.log("This tool will help you generate forms for the Processes and User Tasks in your Kogito Projects.");
console.log(
"The tool will search for the User Tasks JSON schemas generated in your project, so make sure the project is build."
);
Expand Down
3 changes: 3 additions & 0 deletions packages/uniforms-bootstrap4-codegen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Uniforms Bootstrap 4 Codegen

This module contains the [Uniforms](https://uniforms.tools) theme contain to generate Bootstrap 4 forms for the `@kie-tools/form-generation-tool`.
3 changes: 3 additions & 0 deletions packages/uniforms-patternfly-codegen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Uniforms Patternfly Codegen

This module contains the [Uniforms](https://uniforms.tools) theme contain to generate Patternfly forms for the `@kie-tools/form-generation-tool`.

0 comments on commit b8634d1

Please sign in to comment.