diff --git a/README.md b/README.md index 028ea207cbc3fa9a12c75138bb751b260a239e63..7de144f9ee8354cf56d9c63512e1c245c57f8966 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ This is a cross-platform API wrapper for GitHub, GitLab, and Gitea, in an attemp What are you doing here? This project isn't finished yet! I'll update this once I have a better understanding of how kotlin-multiplatform works. +### Development + +The `:gitrest:jsBrowserTest` task seems to fail sporadically due to trying to parse... `/etc/fonts/fonts.conf`? Well, it spits out a lot of logs about it, then fails to actually run the tests, so it's not doing very much. You can append `-x :gitrest:jsBrowserTest` to any gradle commands to prevent it from running. + ### Example Projects #### example-kotlinbrowser @@ -20,6 +24,12 @@ This module is built using [yarn](https://yarnpkg.com/), to provide an example o - `./gradlew :example-nodejs:run`: execute the `src/index.js` file (with a few example tests/calls using Promises) +#### example-js + +This module demonstrates the use of the bundled JS file in a webpage, without the use of Kotlin/JS. + +- `./gradlew :example-js:run`: serve the `index.html` and `gitrest.js` files on `localhost:8080`. + ## Specification ### URI Scheme diff --git a/build.gradle b/build.gradle index 9bbeddf4829b7d1a9fb7aae7a712715a0b3aabd3..998c121c99b93596337ee516e158be630cc3573a 100644 --- a/build.gradle +++ b/build.gradle @@ -11,12 +11,14 @@ buildscript { maven { url "https://kotlin.bintray.com/kotlinx" } maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } + maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'com.android.tools.build:gradle:3.6.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath "gradle.plugin.com.github.salomonbrys.gradle.kotlin.js:kotlin-js-npm-bundle:1.0.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/example-js/build.gradle b/example-js/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..0821529e99da25981ac572933c5ad603cf0b3ad8 --- /dev/null +++ b/example-js/build.gradle @@ -0,0 +1,15 @@ +task copyFiles(type: Copy) { + dependsOn ':gitrest:jsBrowserWebpack' + from "../gitrest/build/distributions", "index.html" + into "$buildDir" +} + +task run { + dependsOn ':example-js:copyFiles' + doLast { + SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory() + HttpFileServer server = factory.start(new File("example-js/build"), 8080) + println("Server started on 8080 - Ctrl+C to kill it") + java.lang.Thread.sleep(Long.MAX_VALUE); + } +} diff --git a/example-js/index.html b/example-js/index.html new file mode 100644 index 0000000000000000000000000000000000000000..1d57436ec140051a6c698ba429fb5f8070c40c9b --- /dev/null +++ b/example-js/index.html @@ -0,0 +1,28 @@ + + +
+ +
+ Repository name:
+ Description:
+
+ git clone
+
+
+
+
+
+
diff --git a/example-kotlinbrowser/build.gradle b/example-kotlinbrowser/build.gradle
index bf66ad12dc3c7e613a9a79c3b44a5593b7a422ce..533fa2bcf72b913bc480ed55874dde0e80c97691 100644
--- a/example-kotlinbrowser/build.gradle
+++ b/example-kotlinbrowser/build.gradle
@@ -15,7 +15,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.6'
implementation "org.jetbrains.kotlinx:kotlinx-html-js:0.7.1"
- implementation project(':common')
+ implementation project(':gitrest')
}
kotlin.target.browser()
diff --git a/example-nodejs/build.gradle b/example-nodejs/build.gradle
index 4ccb47b0d6c848d1b8c1c13a16b3f3badeccdff8..a4a7faa1b5d40b057a037acbe6b703d128b01a38 100644
--- a/example-nodejs/build.gradle
+++ b/example-nodejs/build.gradle
@@ -20,7 +20,7 @@ node {
}
yarn_install {
- dependsOn ':common:assemble'
+ dependsOn ':gitrest:assemble'
}
task run(type: YarnTask) {
diff --git a/example-nodejs/package.json b/example-nodejs/package.json
index 8e336436aef9b29ccde4b6555b0bcd30bf685ac1..67d2af90ad6a3aa8481b77823a282c512119ef49 100644
--- a/example-nodejs/package.json
+++ b/example-nodejs/package.json
@@ -3,7 +3,7 @@
"version": "0.0.1",
"private": true,
"workspaces": [
- "../build/js/packages/git-rest-wrapper-common",
+ "../build/js/packages/git-rest-wrapper-gitrest",
"../build/js/packages_imported/*/*"
],
"devDependencies": {},
diff --git a/example-nodejs/src/index.js b/example-nodejs/src/index.js
index 9330bb00c06def8b983b6321bdde25fd58dc5d85..fcd44b14a32b374893c64ea4f666bf4404626dcf 100644
--- a/example-nodejs/src/index.js
+++ b/example-nodejs/src/index.js
@@ -1,11 +1,11 @@
-const { gitrest } = require("git-rest-wrapper-common");
+const { RequestProvider } = require("git-rest-wrapper-gitrest");
-let delegate = new gitrest.RequestProvider();
+let delegate = new RequestProvider();
delegate.getUser("fennifith").then((obj) => {
console.log(obj);
});
-delegate.getRepo("gitlab:snowdrift/outreach").then((obj) => {
+delegate.getRepo("gitlab@salsa.debian.org:reproducible-builds/reproducible-website").then((obj) => {
console.log(obj);
});
diff --git a/common/build.gradle b/gitrest/build.gradle
similarity index 85%
rename from common/build.gradle
rename to gitrest/build.gradle
index eb2b3e933f004e3784d1a57de4e92d917d679ea1..f5c553855cee3052c92d61c573f5a815791ef274 100644
--- a/common/build.gradle
+++ b/gitrest/build.gradle
@@ -9,6 +9,20 @@ kotlin {
js {
compilations.main.kotlinOptions.moduleKind = 'umd'
nodejs()
+ browser {
+ dceTask {
+ keep 'git-rest-wrapper-gitrest.RequestProvider', "ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io"
+ }
+ compilations.all {
+ kotlinOptions {
+ metaInfo = true
+ sourceMap = true
+ sourceMapEmbedSources = "always"
+ moduleKind = "umd"
+ main = "call"
+ }
+ }
+ }
}
sourceSets {
diff --git a/common/src/commonMain/kotlin/gitrest/RequestProviderDelegate.kt b/gitrest/src/commonMain/kotlin/gitrest/RequestProviderDelegate.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/RequestProviderDelegate.kt
rename to gitrest/src/commonMain/kotlin/gitrest/RequestProviderDelegate.kt
diff --git a/common/src/commonMain/kotlin/gitrest/base/RequestProvider.kt b/gitrest/src/commonMain/kotlin/gitrest/base/RequestProvider.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/base/RequestProvider.kt
rename to gitrest/src/commonMain/kotlin/gitrest/base/RequestProvider.kt
diff --git a/common/src/commonMain/kotlin/gitrest/base/ServiceBuilder.kt b/gitrest/src/commonMain/kotlin/gitrest/base/ServiceBuilder.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/base/ServiceBuilder.kt
rename to gitrest/src/commonMain/kotlin/gitrest/base/ServiceBuilder.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitea/GiteaProvider.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitea/GiteaProvider.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitea/GiteaProvider.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitea/GiteaProvider.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaLicense.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaLicense.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaLicense.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaLicense.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaRepo.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaRepo.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaRepo.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaRepo.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaUser.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaUser.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaUser.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitea/model/GiteaUser.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/github/GithubProvider.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/github/GithubProvider.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/github/GithubProvider.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/github/GithubProvider.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/github/model/GithubLicense.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/github/model/GithubLicense.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/github/model/GithubLicense.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/github/model/GithubLicense.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/github/model/GithubRepo.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/github/model/GithubRepo.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/github/model/GithubRepo.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/github/model/GithubRepo.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/github/model/GithubUser.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/github/model/GithubUser.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/github/model/GithubUser.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/github/model/GithubUser.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitlab/GitlabProvider.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/GitlabProvider.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitlab/GitlabProvider.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/GitlabProvider.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabLicense.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabLicense.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabLicense.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabLicense.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabRepo.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabRepo.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabRepo.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabRepo.kt
diff --git a/common/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabUser.kt b/gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabUser.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabUser.kt
rename to gitrest/src/commonMain/kotlin/gitrest/impl/gitlab/model/GitlabUser.kt
diff --git a/common/src/commonMain/kotlin/gitrest/model/DelegateResource.kt b/gitrest/src/commonMain/kotlin/gitrest/model/DelegateResource.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/model/DelegateResource.kt
rename to gitrest/src/commonMain/kotlin/gitrest/model/DelegateResource.kt
diff --git a/common/src/commonMain/kotlin/gitrest/model/License.kt b/gitrest/src/commonMain/kotlin/gitrest/model/License.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/model/License.kt
rename to gitrest/src/commonMain/kotlin/gitrest/model/License.kt
diff --git a/common/src/commonMain/kotlin/gitrest/model/ProviderString.kt b/gitrest/src/commonMain/kotlin/gitrest/model/ProviderString.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/model/ProviderString.kt
rename to gitrest/src/commonMain/kotlin/gitrest/model/ProviderString.kt
diff --git a/common/src/commonMain/kotlin/gitrest/model/Repo.kt b/gitrest/src/commonMain/kotlin/gitrest/model/Repo.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/model/Repo.kt
rename to gitrest/src/commonMain/kotlin/gitrest/model/Repo.kt
diff --git a/common/src/commonMain/kotlin/gitrest/model/User.kt b/gitrest/src/commonMain/kotlin/gitrest/model/User.kt
similarity index 100%
rename from common/src/commonMain/kotlin/gitrest/model/User.kt
rename to gitrest/src/commonMain/kotlin/gitrest/model/User.kt
diff --git a/common/src/commonTest/kotlin/gitrest/ProviderStringTest.kt b/gitrest/src/commonTest/kotlin/gitrest/ProviderStringTest.kt
similarity index 100%
rename from common/src/commonTest/kotlin/gitrest/ProviderStringTest.kt
rename to gitrest/src/commonTest/kotlin/gitrest/ProviderStringTest.kt
diff --git a/common/src/jsMain/kotlin/gitrest/RequestProvider.kt b/gitrest/src/jsMain/kotlin/RequestProvider.kt
similarity index 97%
rename from common/src/jsMain/kotlin/gitrest/RequestProvider.kt
rename to gitrest/src/jsMain/kotlin/RequestProvider.kt
index 94333ea04f75e9cd8a65252229476f15b992b83c..071f6b13fa77cf6cb435a637e699f0e28cb8ba21 100644
--- a/common/src/jsMain/kotlin/gitrest/RequestProvider.kt
+++ b/gitrest/src/jsMain/kotlin/RequestProvider.kt
@@ -1,5 +1,4 @@
-package gitrest
-
+import gitrest.RequestProviderDelegate
import gitrest.base.ServiceBuilder
import gitrest.impl.gitea.GiteaProvider
import gitrest.impl.github.GithubProvider
diff --git a/common/src/jsMain/kotlin/gitrest/js/License.kt b/gitrest/src/jsMain/kotlin/gitrest/js/License.kt
similarity index 100%
rename from common/src/jsMain/kotlin/gitrest/js/License.kt
rename to gitrest/src/jsMain/kotlin/gitrest/js/License.kt
diff --git a/common/src/jsMain/kotlin/gitrest/js/Repo.kt b/gitrest/src/jsMain/kotlin/gitrest/js/Repo.kt
similarity index 100%
rename from common/src/jsMain/kotlin/gitrest/js/Repo.kt
rename to gitrest/src/jsMain/kotlin/gitrest/js/Repo.kt
diff --git a/common/src/jsMain/kotlin/gitrest/js/User.kt b/gitrest/src/jsMain/kotlin/gitrest/js/User.kt
similarity index 100%
rename from common/src/jsMain/kotlin/gitrest/js/User.kt
rename to gitrest/src/jsMain/kotlin/gitrest/js/User.kt
diff --git a/common/src/jsTest/kotlin/gitrest/BasicTest.kt b/gitrest/src/jsTest/kotlin/gitrest/BasicTest.kt
similarity index 100%
rename from common/src/jsTest/kotlin/gitrest/BasicTest.kt
rename to gitrest/src/jsTest/kotlin/gitrest/BasicTest.kt
diff --git a/settings.gradle b/settings.gradle
index a54e00cd1ecd45e97860cbb451339bc905fc13d0..1de6002a1e83b5bb75d249228f828f11075f3f03 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,6 +1,7 @@
rootProject.name='git-rest-wrapper'
enableFeaturePreview('GRADLE_METADATA')
-include ':common'
+include ':gitrest'
include ':example-android'
+include ':example-js'
include ':example-nodejs'
include ':example-kotlinbrowser'