Skip to content

Commit

Permalink
Merge pull request #274 from modelix/feature/vue-model-api
Browse files Browse the repository at this point in the history
feat(vue-model-api): add a library to use models from Vue.js
  • Loading branch information
odzhychko authored Oct 27, 2023
2 parents 8e1e388 + 1d30585 commit 16a0b1f
Show file tree
Hide file tree
Showing 39 changed files with 11,165 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
/mps-model-server/ @slisson
/mps-model-server-plugin/ @slisson
/ts-model-api/ @slisson
/vue-model-api/ @odzhychko
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ repos:
# IMPORTANT: keep in sync with the version configured in build.gradle.kts
- --ktlint-version=0.50.0
- --autofix
- repo: https://github.com/pre-commit/mirrors-prettier
# IMPORTANT: keep in sync with the version configured in `vue-model-api/package.json`
rev: v3.0.3
hooks:
- id: prettier
files: ^(vue-model-api)|(model-api-gen-gradle-test/vue-integration)/
- repo: https://github.com/pre-commit/mirrors-eslint
# IMPORTANT: keep versions of hook and additional dependencies in sync with the versions configured in `vue-model-api/package.json`
rev: v8.50.0
hooks:
- id: eslint
additional_dependencies:
- "[email protected]"
- "[email protected]"
- "@typescript-eslint/[email protected]"
- "@typescript-eslint/[email protected]"
files: ^vue-model-api/src/
'types': [ts]
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ fun computeVersion(): Any {
return if (versionFile.exists()) {
versionFile.readText().trim()
} else {
gitVersion().let { if (it.endsWith("-SNAPSHOT")) it else "$it-SNAPSHOT" }.also { versionFile.writeText(it) }
gitVersion()
// Avoid duplicated "-SNAPSHOT" ending
.let { if (it.endsWith("-SNAPSHOT")) it else "$it-SNAPSHOT" }
// Normalize the version so that is always a valid NPM version.
.let { if (it.matches("""\d+\.\d+.\d+-.*""".toRegex())) it else "0.0.1-$it" }
.also { versionFile.writeText(it) }
}
}

Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
"mps-model-server",
"mps-model-server-plugin",
"ts-model-api",
"vue-model-api",
],
],
"subject-case": [0, 'never']
Expand Down
1 change: 1 addition & 0 deletions model-api-gen-gradle-test/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ rootProject.name = "model-api-gen-gradle-test"
include("metamodel-export")
include("typescript-generation")
include("kotlin-generation")
include("vue-integration")
12 changes: 8 additions & 4 deletions model-api-gen-gradle-test/typescript-generation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import org.modelix.metamodel.gradle.GenerateMetaModelSources
import com.github.gradle.node.npm.task.NpmTask

plugins {
base
alias(libs.plugins.node)
id("org.modelix.model-api-gen") apply false
}

val codeGenerationTask = project(":metamodel-export").tasks.named<GenerateMetaModelSources>("generateMetaModelSources")

tasks.named("npm_run_build") {
inputs.dir(codeGenerationTask.map { it.typescriptOutputDir })
dependsOn(":metamodel-export:generateMetaModelSources")
inputs.dir(layout.buildDirectory.dir("typescript_src"))
inputs.file("package.json")
inputs.file("package-lock.json")

Expand All @@ -23,3 +22,8 @@ tasks.assemble {
tasks.clean {
dependsOn("npm_run_clean")
}

tasks.register<NpmTask>("packJsPackage") {
dependsOn("npm_run_build")
args.set(listOf("pack", "--pack-destination", "build"))
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions model-api-gen-gradle-test/typescript-generation/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@modelix/model-api-gen-gradle-test",
"name": "typescript-generation",
"version": "0.0.0",
"description": "",
"keywords": [
Expand All @@ -14,10 +14,7 @@
},
"license": "Apache 2.0",
"files": [
"dist/*.*js.map",
"dist/*.*js",
"dist/*.d.ts.map",
"dist/*.d.ts"
"dist/"
],
"type": "commonjs",
"main": "dist/index",
Expand Down
2 changes: 2 additions & 0 deletions model-api-gen-gradle-test/vue-integration/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gradle
build
Empty file.
26 changes: 26 additions & 0 deletions model-api-gen-gradle-test/vue-integration/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import com.github.gradle.node.npm.task.NpmTask

plugins {
base
alias(libs.plugins.node)
}

val updateDependencies = tasks.create<NpmTask>("updateDependencies") {
dependsOn(":typescript-generation:packJsPackage")
args.set(
listOf(
"install",
"../../model-client/build/npmDevPackage/model-client.tgz",
"../../vue-model-api/build/npmDevPackage/vue-model-api.tgz",
"../typescript-generation/build/typescript-generation-0.0.0.tgz",
),
)
}

tasks.npmInstall {
dependsOn(updateDependencies)
}

tasks.check {
dependsOn("npm_run_test")
}
5 changes: 5 additions & 0 deletions model-api-gen-gradle-test/vue-integration/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
Loading

0 comments on commit 16a0b1f

Please sign in to comment.