From 6d983ede2df88f3a36f7e25e1d54188a12786060 Mon Sep 17 00:00:00 2001 From: Pascal Honegger Date: Fri, 28 Apr 2023 15:02:06 +0200 Subject: [PATCH 1/8] feat(ci): release cli on tag creation --- .github/workflows/publish-release.yml | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..62268c83 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,35 @@ +name: Publish Release +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Build CLI + run: ./gradlew --no-daemon :cli:shadowDistZip :cli:shadowDistTar + + - name: Rename cli-shadow to cli + run: | + mv cli/build/distributions/cli-shadow.zip cli/build/distributions/cli.zip + mv cli/build/distributions/cli-shadow.tar cli/build/distributions/cli.tar + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + cli/build/distributions/cli.zip + cli/build/distributions/cli.tar + fail_on_unmatched_files: true From bc8908e8a905207bd8831cef1b83dff90322f4ea Mon Sep 17 00:00:00 2001 From: Pascal Honegger Date: Fri, 28 Apr 2023 15:27:13 +0200 Subject: [PATCH 2/8] feat(wrapper): create basic samtw scripts --- wrapper/samt-wrapper.properties | 2 ++ wrapper/samtw | 42 +++++++++++++++++++++++++++++++ wrapper/samtw.bat | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 wrapper/samt-wrapper.properties create mode 100755 wrapper/samtw create mode 100644 wrapper/samtw.bat diff --git a/wrapper/samt-wrapper.properties b/wrapper/samt-wrapper.properties new file mode 100644 index 00000000..93ea14f5 --- /dev/null +++ b/wrapper/samt-wrapper.properties @@ -0,0 +1,2 @@ +samtVersion=v0.0.1 +distributionUrl=https\://github.com/samtkit/core/releases/download/$samtVersion/cli.tar diff --git a/wrapper/samtw b/wrapper/samtw new file mode 100755 index 00000000..bf90f448 --- /dev/null +++ b/wrapper/samtw @@ -0,0 +1,42 @@ +#!/usr/bin/env sh + +if [ ! -f samt-wrapper.properties ]; then + echo "samt-wrapper.properties file not found." >&2 + exit 1 +fi + +. samt-wrapper.properties + +if ! command -v tar > /dev/null; then + echo "This script requires 'tar' to be installed." >&2 + exit 1 +fi + +mkdir -p .samt/cli + +if [ ! -f .samt/.gitignore ]; then + echo "*" > .samt/.gitignore +fi + +currentVersion=$(cat .samt/cli/version.txt 2> /dev/null || echo "0.0.0") + +if [ "$currentVersion" != "$samtVersion" ]; then + echo "Downloading samt $samtVersion from '$distributionUrl'..." + if command -v curl > /dev/null; then + if ! curl -s -L "$distributionUrl" | tar x -C .samt/cli; then + echo "An error occurred while downloading '$distributionUrl' archive using curl." >&2 + exit 1 + fi + echo "$samtVersion" > .samt/cli/version.txt + elif command -v curl > /dev/null; then + if ! wget -qO- "$distributionUrl" | tar x -C .samt/cli; then + echo "An error occurred while downloading '$distributionUrl' archive using wget." >&2 + exit 1 + fi + else + echo "samtw requires either 'curl' or 'wget' to be installed." >&2 + exit 1 + fi +fi + +exec ".samt/cli/cli-shadow/bin/cli" "$@" diff --git a/wrapper/samtw.bat b/wrapper/samtw.bat new file mode 100644 index 00000000..f7299cf0 --- /dev/null +++ b/wrapper/samtw.bat @@ -0,0 +1,44 @@ +@echo off + +if not exist samt-wrapper.properties ( + echo "samt-wrapper.properties not found." + exit /b 1 +) + +set /p samtVersion=nul || ( + echo "This script requires 'tar' to be installed." >&2 + exit /b 1 +) + +if not exist .samt\cli mkdir .samt\cli + +if not exist .samt\.gitignore echo *> .samt\.gitignore + +set "currentVersion=0.0.0" + +if exist .samt\cli\version.txt ( + set /p currentVersion=<.samt\cli\version.txt +) + +if "%currentVersion%" neq "%samtVersion%" ( + echo Downloading samt %samtVersion% from '%distributionUrl%'... + if exist %SystemRoot%\System32\curl.exe ( + curl -s -L "%distributionUrl%" | tar x -C .samt\cli || ( + echo An error occured while downloading '%distributionUrl%' archive using curl. >&2 + exit /b 1 + ) + ) else if exist %SystemRoot%\System32\wget.exe ( + wget -qO- "%distributionUrl%" | tar x -C .samt\cli || ( + echo An error occured while downloading '%distributionUrl%' archive using wget. >&2 + exit /b 1 + ) + ) else ( + echo samtw requires either 'curl' or 'wget' to be installed. >&2 + exit /b 1 + ) + echo %samtVersion% > .samt\cli\version.txt +) + +call ".samt\cli\cli-shadow\bin\cli.bat" %* From 84b4e665b163cfeb9461793315958fcc916edca5 Mon Sep 17 00:00:00 2001 From: Pascal Honegger Date: Fri, 28 Apr 2023 17:21:32 +0200 Subject: [PATCH 3/8] feat(readme): create initial readme --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..a24a7219 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +

SAMT - Simple API Modeling Toolkit

+ +
+ +[![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) +[![Total Downloads on GitHub](https://img.shields.io/github/downloads/samtkit/core/total)](https://github.com/samtkit/core/releases/latest) +[![MIT License](https://img.shields.io/github/license/samtkit/core)](./LICENSE) + +
+ +

+ Tired of unreadable OpenAPI YAML files and a plethora of different tools? +
SAMT is a developer-focussed, extendable and easy-to-learn toolkit for modeling APIs using a business-first approach
+
+

+ +
+ +## Documentation + +Get started with SAMT, learn fundamental concepts or extend SAMT with a custom generator. + +- [Getting Started](https://github.com/samtkit/core/wiki/Getting-Started) +- [Modeling Concepts](https://github.com/samtkit/core/wiki/Modeling-Concepts) +- [Visual Studio Code Plugin](https://marketplace.visualstudio.com/items?itemName=samt.samt) + +### Advanced + +- [Authoring Generators](https://github.com/samtkit/core/wiki/Authoring-Generators) +- [Architecture](https://github.com/samtkit/core/wiki/Architecture) + +## Development Setup + +## Contributing + +Want to report a bug, contribute code, or improve documentation? Excellent! Simply create +an [issue](https://github.com/samtkit/core/issues), open a [pull request](https://github.com/samtkit/core/pulls) or +start a [discussion](https://github.com/samtkit/core/discussions). From f51ff73080ce05928378350281eea34de7321cb9 Mon Sep 17 00:00:00 2001 From: Marcel Joss Date: Fri, 28 Apr 2023 17:53:29 +0200 Subject: [PATCH 4/8] fix(wrapper): add . to relative paths --- wrapper/samtw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrapper/samtw b/wrapper/samtw index bf90f448..ddf27724 100755 --- a/wrapper/samtw +++ b/wrapper/samtw @@ -1,11 +1,11 @@ #!/usr/bin/env sh -if [ ! -f samt-wrapper.properties ]; then +if [ ! -f ./samt-wrapper.properties ]; then echo "samt-wrapper.properties file not found." >&2 exit 1 fi -. samt-wrapper.properties +. ./samt-wrapper.properties if ! command -v tar > /dev/null; then echo "This script requires 'tar' to be installed." >&2 From 5294c963fa766eac8ce715b37d5dc38ce30eeaae Mon Sep 17 00:00:00 2001 From: Pascal Honegger Date: Sat, 29 Apr 2023 14:05:35 +0200 Subject: [PATCH 5/8] fix(wrapper): correct bat file usage to work on Windows 10 and Windows 11 --- wrapper/samtw.bat | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/wrapper/samtw.bat b/wrapper/samtw.bat index f7299cf0..9e09ee07 100644 --- a/wrapper/samtw.bat +++ b/wrapper/samtw.bat @@ -1,11 +1,23 @@ @echo off +setlocal EnableDelayedExpansion + if not exist samt-wrapper.properties ( echo "samt-wrapper.properties not found." exit /b 1 ) -set /p samtVersion=nul || ( echo "This script requires 'tar' to be installed." >&2 @@ -24,21 +36,24 @@ if exist .samt\cli\version.txt ( if "%currentVersion%" neq "%samtVersion%" ( echo Downloading samt %samtVersion% from '%distributionUrl%'... - if exist %SystemRoot%\System32\curl.exe ( - curl -s -L "%distributionUrl%" | tar x -C .samt\cli || ( + WHERE /q curl + if %ERRORLEVEL% EQU 0 ( + curl -L -o .samt\cli\cli.tar "%distributionUrl%" || ( echo An error occured while downloading '%distributionUrl%' archive using curl. >&2 exit /b 1 ) - ) else if exist %SystemRoot%\System32\wget.exe ( - wget -qO- "%distributionUrl%" | tar x -C .samt\cli || ( - echo An error occured while downloading '%distributionUrl%' archive using wget. >&2 - exit /b 1 - ) + ) else ( - echo samtw requires either 'curl' or 'wget' to be installed. >&2 + echo samtw requires 'curl' to be installed. >&2 + exit /b 1 + ) + + tar xf .samt\cli\cli.tar -C .samt\cli || ( + echo An error occured while unpacking .samt\cli\cli.tar using tar. >&2 exit /b 1 ) - echo %samtVersion% > .samt\cli\version.txt + + echo %samtVersion%> .samt\cli\version.txt ) call ".samt\cli\cli-shadow\bin\cli.bat" %* From 5e939fd4cd6e8046e3acdc115f18d70af80d7ad0 Mon Sep 17 00:00:00 2001 From: Pascal Honegger Date: Sat, 29 Apr 2023 14:11:01 +0200 Subject: [PATCH 6/8] fix(wrapper): fix typo occured => occurred --- wrapper/samtw.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrapper/samtw.bat b/wrapper/samtw.bat index 9e09ee07..5830d87b 100644 --- a/wrapper/samtw.bat +++ b/wrapper/samtw.bat @@ -39,7 +39,7 @@ if "%currentVersion%" neq "%samtVersion%" ( WHERE /q curl if %ERRORLEVEL% EQU 0 ( curl -L -o .samt\cli\cli.tar "%distributionUrl%" || ( - echo An error occured while downloading '%distributionUrl%' archive using curl. >&2 + echo An error occurred while downloading '%distributionUrl%' archive using curl. >&2 exit /b 1 ) @@ -49,7 +49,7 @@ if "%currentVersion%" neq "%samtVersion%" ( ) tar xf .samt\cli\cli.tar -C .samt\cli || ( - echo An error occured while unpacking .samt\cli\cli.tar using tar. >&2 + echo An error occurred while unpacking .samt\cli\cli.tar using tar. >&2 exit /b 1 ) From 14b716f27647a2ce35567faf6d3583cb6768be3d Mon Sep 17 00:00:00 2001 From: Pascal Honegger Date: Sat, 29 Apr 2023 16:52:32 +0200 Subject: [PATCH 7/8] feat(readme): add development setup documentation --- README.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a24a7219..a72105f7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@

Tired of unreadable OpenAPI YAML files and a plethora of different tools? -
SAMT is a developer-focussed, extendable and easy-to-learn toolkit for modeling APIs using a business-first approach
+
SAMT is a developer-focused, extendable and easy-to-learn toolkit for modeling APIs using a business-first approach

@@ -31,8 +31,35 @@ Get started with SAMT, learn fundamental concepts or extend SAMT with a custom g ## Development Setup +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/). + +If you want to start SAMT locally, simply clone the repository and compile it using Gradle: + +```shell +./gradlew assemble +``` + +You can also compile the CLI module locally: + +```shell +./gradlew :cli:shadowJar +``` + +And then compile SAMT files using this locally compiled version: + +```shell +java -jar ./cli/build/libs/samt-cli.jar ./specification/examples/todo-service/*.samt +``` + +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: + +```shell +./gradlew :language-server:shadowJar +``` + ## Contributing -Want to report a bug, contribute code, or improve documentation? Excellent! Simply create -an [issue](https://github.com/samtkit/core/issues), open a [pull request](https://github.com/samtkit/core/pulls) or +Want to report a bug, contribute code, or improve documentation? Excellent! +Simply create an [issue](https://github.com/samtkit/core/issues), +open a [pull request](https://github.com/samtkit/core/pulls) or start a [discussion](https://github.com/samtkit/core/discussions). From 425738fabb4f1410d6fd643e6270437d06aef61f Mon Sep 17 00:00:00 2001 From: Pascal Honegger Date: Sat, 29 Apr 2023 16:52:48 +0200 Subject: [PATCH 8/8] feat(wrapper): use wrapper as program name within CLI --- cli/src/main/kotlin/tools/samt/cli/App.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/main/kotlin/tools/samt/cli/App.kt b/cli/src/main/kotlin/tools/samt/cli/App.kt index e0755852..e9a03b43 100644 --- a/cli/src/main/kotlin/tools/samt/cli/App.kt +++ b/cli/src/main/kotlin/tools/samt/cli/App.kt @@ -12,7 +12,7 @@ fun main(args: Array) { val cliArgs = CliArgs() val jCommander = JCommander.newBuilder() .addObject(cliArgs) - .programName("java -jar samt-cli.jar") + .programName("./samtw") .build() jCommander.parse(*args) if (cliArgs.help) {