Skip to content

Commit 95aef05

Browse files
Merge pull request #14 from samtkit/samt-wrapper
SAMT Wrapper
2 parents 3ec53c2 + 425738f commit 95aef05

File tree

6 files changed

+204
-1
lines changed

6 files changed

+204
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish Release
2+
on:
3+
push:
4+
tags:
5+
- "v*.*.*"
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-java@v3
15+
with:
16+
distribution: temurin
17+
java-version: 17
18+
- name: Setup Gradle
19+
uses: gradle/gradle-build-action@v2
20+
21+
- name: Build CLI
22+
run: ./gradlew --no-daemon :cli:shadowDistZip :cli:shadowDistTar
23+
24+
- name: Rename cli-shadow to cli
25+
run: |
26+
mv cli/build/distributions/cli-shadow.zip cli/build/distributions/cli.zip
27+
mv cli/build/distributions/cli-shadow.tar cli/build/distributions/cli.tar
28+
29+
- name: Release
30+
uses: softprops/action-gh-release@v1
31+
with:
32+
files: |
33+
cli/build/distributions/cli.zip
34+
cli/build/distributions/cli.tar
35+
fail_on_unmatched_files: true

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<h1 align="center">SAMT - Simple API Modeling Toolkit</h1>
2+
3+
<div align="center">
4+
5+
[![Latest Stable Release on GitHub](https://img.shields.io/github/v/release/samtkit/core?display_name=tag&sort=semver)](https://github.com/samtkit/core/releases/latest)
6+
[![Total Downloads on GitHub](https://img.shields.io/github/downloads/samtkit/core/total)](https://github.com/samtkit/core/releases/latest)
7+
[![MIT License](https://img.shields.io/github/license/samtkit/core)](./LICENSE)
8+
9+
</div>
10+
11+
<p align="center">
12+
<i>Tired of unreadable OpenAPI YAML files and a plethora of different tools?
13+
<br>SAMT is a developer-focused, extendable and easy-to-learn toolkit for modeling APIs using a business-first approach</i>
14+
<br>
15+
</p>
16+
17+
<hr>
18+
19+
## Documentation
20+
21+
Get started with SAMT, learn fundamental concepts or extend SAMT with a custom generator.
22+
23+
- [Getting Started](https://github.com/samtkit/core/wiki/Getting-Started)
24+
- [Modeling Concepts](https://github.com/samtkit/core/wiki/Modeling-Concepts)
25+
- [Visual Studio Code Plugin](https://marketplace.visualstudio.com/items?itemName=samt.samt)
26+
27+
### Advanced
28+
29+
- [Authoring Generators](https://github.com/samtkit/core/wiki/Authoring-Generators)
30+
- [Architecture](https://github.com/samtkit/core/wiki/Architecture)
31+
32+
## Development Setup
33+
34+
SAMT is written in [Kotlin](https://kotlinlang.org/) and uses [Gradle](https://gradle.org/) as a build tool, for the best developer experience we recommend using [IntelliJ](https://www.jetbrains.com/idea/).
35+
36+
If you want to start SAMT locally, simply clone the repository and compile it using Gradle:
37+
38+
```shell
39+
./gradlew assemble
40+
```
41+
42+
You can also compile the CLI module locally:
43+
44+
```shell
45+
./gradlew :cli:shadowJar
46+
```
47+
48+
And then compile SAMT files using this locally compiled version:
49+
50+
```shell
51+
java -jar ./cli/build/libs/samt-cli.jar ./specification/examples/todo-service/*.samt
52+
```
53+
54+
If you're more interested in the [SAMT Visual Studio Code plugin](https://github.com/samtkit/vscode) or the related language server, you can also compile it locally as well:
55+
56+
```shell
57+
./gradlew :language-server:shadowJar
58+
```
59+
60+
## Contributing
61+
62+
Want to report a bug, contribute code, or improve documentation? Excellent!
63+
Simply create an [issue](https://github.com/samtkit/core/issues),
64+
open a [pull request](https://github.com/samtkit/core/pulls) or
65+
start a [discussion](https://github.com/samtkit/core/discussions).

cli/src/main/kotlin/tools/samt/cli/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fun main(args: Array<String>) {
1212
val cliArgs = CliArgs()
1313
val jCommander = JCommander.newBuilder()
1414
.addObject(cliArgs)
15-
.programName("java -jar samt-cli.jar")
15+
.programName("./samtw")
1616
.build()
1717
jCommander.parse(*args)
1818
if (cliArgs.help) {

wrapper/samt-wrapper.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
samtVersion=v0.0.1
2+
distributionUrl=https\://github.com/samtkit/core/releases/download/$samtVersion/cli.tar

wrapper/samtw

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env sh
2+
3+
if [ ! -f ./samt-wrapper.properties ]; then
4+
echo "samt-wrapper.properties file not found." >&2
5+
exit 1
6+
fi
7+
8+
. ./samt-wrapper.properties
9+
10+
if ! command -v tar > /dev/null; then
11+
echo "This script requires 'tar' to be installed." >&2
12+
exit 1
13+
fi
14+
15+
mkdir -p .samt/cli
16+
17+
if [ ! -f .samt/.gitignore ]; then
18+
echo "*" > .samt/.gitignore
19+
fi
20+
21+
currentVersion=$(cat .samt/cli/version.txt 2> /dev/null || echo "0.0.0")
22+
23+
if [ "$currentVersion" != "$samtVersion" ]; then
24+
echo "Downloading samt $samtVersion from '$distributionUrl'..."
25+
if command -v curl > /dev/null; then
26+
if ! curl -s -L "$distributionUrl" | tar x -C .samt/cli; then
27+
echo "An error occurred while downloading '$distributionUrl' archive using curl." >&2
28+
exit 1
29+
fi
30+
echo "$samtVersion" > .samt/cli/version.txt
31+
elif command -v curl > /dev/null; then
32+
if ! wget -qO- "$distributionUrl" | tar x -C .samt/cli; then
33+
echo "An error occurred while downloading '$distributionUrl' archive using wget." >&2
34+
exit 1
35+
fi
36+
else
37+
echo "samtw requires either 'curl' or 'wget' to be installed." >&2
38+
exit 1
39+
fi
40+
fi
41+
42+
exec ".samt/cli/cli-shadow/bin/cli" "$@"

wrapper/samtw.bat

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@echo off
2+
3+
setlocal EnableDelayedExpansion
4+
5+
if not exist samt-wrapper.properties (
6+
echo "samt-wrapper.properties not found."
7+
exit /b 1
8+
)
9+
10+
for /f "tokens=1,2 delims==" %%G in (samt-wrapper.properties) do (
11+
if "%%G"=="samtVersion" (
12+
set "samtVersion=%%H"
13+
)
14+
if "%%G"=="distributionUrl" (
15+
set distributionUrlPattern=%%H
16+
)
17+
)
18+
19+
set distributionUrl=%distributionUrlPattern:$samtVersion=!samtVersion!%
20+
set distributionUrl=%distributionUrl:\:=:%
21+
22+
where tar >nul || (
23+
echo "This script requires 'tar' to be installed." >&2
24+
exit /b 1
25+
)
26+
27+
if not exist .samt\cli mkdir .samt\cli
28+
29+
if not exist .samt\.gitignore echo *> .samt\.gitignore
30+
31+
set "currentVersion=0.0.0"
32+
33+
if exist .samt\cli\version.txt (
34+
set /p currentVersion=<.samt\cli\version.txt
35+
)
36+
37+
if "%currentVersion%" neq "%samtVersion%" (
38+
echo Downloading samt %samtVersion% from '%distributionUrl%'...
39+
WHERE /q curl
40+
if %ERRORLEVEL% EQU 0 (
41+
curl -L -o .samt\cli\cli.tar "%distributionUrl%" || (
42+
echo An error occurred while downloading '%distributionUrl%' archive using curl. >&2
43+
exit /b 1
44+
)
45+
46+
) else (
47+
echo samtw requires 'curl' to be installed. >&2
48+
exit /b 1
49+
)
50+
51+
tar xf .samt\cli\cli.tar -C .samt\cli || (
52+
echo An error occurred while unpacking .samt\cli\cli.tar using tar. >&2
53+
exit /b 1
54+
)
55+
56+
echo %samtVersion%> .samt\cli\version.txt
57+
)
58+
59+
call ".samt\cli\cli-shadow\bin\cli.bat" %*

0 commit comments

Comments
 (0)