Skip to content

Commit

Permalink
Update release workflow
Browse files Browse the repository at this point in the history
xiwenc committed Mar 25, 2024

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
1 parent fef8b91 commit 969f289
Showing 3 changed files with 87 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -25,4 +25,4 @@ jobs:
project_path: "./cmd/mendix-model-exporter"
binary_name: "mendix-model-exporter"
ldflags: "-s -w"
extra_files: LICENSE.md README.md
compress_assets: OFF
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Mendix Model Exporter

Mendix models are stored in a binary file with `.mpr` extension. This project aims to export Mendix models to a human readable format, such as Yaml. This enables developers to use traditional code analysis tools on Mendix models. Think of quality checks like linting, code formatting, etc.

![Mendix Model Exporter](./resources/model-new-entity.png)

See each Mendix document/object as a separate file in the output directory. And see the differences between versions in a version control system. Here we changed the `Documentation` of an entity and added a new `Entity` with one `Attribute`.

## Usage

### Download

First download the exporter program.

- Download the latest release from the [releases page](https://github.com/cinaq/mendix-model-exporter/releases)
- Run the executable with the following command line arguments:
- `--input` or `-i` to specify the input file or directory. Default is `./` which means the current directory. It will look for `.mpr` files in the current directory.
- `--output` or `-o` to specify the output directory. Default is `modelsource`

## pre-commit hook setup

> As of this writing, Mendix Studio Pro does not support Git hooks. You can use the following workaround to automatically export your Mendix model to Yaml before each commit. Make sure you have git-bash installed on your system. Download it from [here](https://git-scm.com/download/win).
After you open your `git` project in Mendix Studio Pro, navigate to the root of the project. Create a new file named `.git/hooks/pre-commit` and add the following content:

```bash
#!/bin/sh

# Program name and download URL
PROGRAM_NAME="mendix-model-exporter"
DOWNLOAD_URL="https://example.com/myprogram"

# Path to the program in the hooks directory
PROGRAM_PATH="$(dirname $0)/$PROGRAM_NAME"

# Check if the program exists, download it if it does not
if [ ! -f "$PROGRAM_PATH" ]; then
echo "Program not found, downloading..."
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
curl -L "$DOWNLOAD_URL-$OS-$ARCH" -o "$PROGRAM_PATH"
chmod +x "$PROGRAM_PATH"
fi

# Execute the program
"$PROGRAM_PATH"

# Check program execution result
if [ $? -ne 0 ]; then
echo "Program failed, aborting commit."
exit 1
fi

# Automatically stage changes made by your program
git add modelsource

# Exit with 0 to continue the commit process
exit 0
```

Set the executable bit on the file:

```bash
chmod +x .git/hooks/pre-commit
```

Now whenever you commit using git-bash, the Mendix model will be exported to Yaml before the commit. The changes will be staged automatically.

## Contribute

Create a PR with your changes. We will review and merge it.

## Features

- Export Mendix model to Yaml
- Incremental changes
- Human readable output

## TODO

- [x] Export Mendix model to Yaml
- [ ] Expand test coverage
- [ ] Support incremental changes
- [ ] Improve performance for large models
- [ ] Improve error handling
- [ ] Improve output human readability
Binary file added resources/model-new-entity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 969f289

Please sign in to comment.