-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add installer * apiDump + make everything internal
- Loading branch information
1 parent
100ccf0
commit 9f1c914
Showing
27 changed files
with
521 additions
and
170 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
.github/workflows/check-pull-request.yaml → .github/workflows/build-pull-request.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
name: check-pull-request | ||
name: Build pull request | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
check-pull-request: | ||
build-pull-request: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7 | ||
- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2 | ||
- run: | | ||
./gradlew build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish documentation | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2 | ||
- run: | | ||
export JAVA_HOME=$JAVA_HOME_21_X64 # Remove when ubuntu-latest updates to Java 21 | ||
./gradlew dokkatooGeneratePublicationHtml | ||
mkdir -p build/static | ||
cp -rf build/dokka/html build/static/kdoc | ||
- uses: JamesIves/github-pages-deploy-action@94f3c658273cf92fb48ef99e5fbc02bd2dc642b2 #v4.6.3 | ||
with: | ||
branch: gh-pages # The branch the action should deploy to. | ||
folder: build/static # The folder the action should deploy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import com.gradleup.librarian.gradle.librarianModule | ||
|
||
plugins { | ||
id("org.jetbrains.kotlin.jvm") | ||
alias(libs.plugins.serialization) | ||
alias(libs.plugins.kotlin) | ||
id("application") | ||
} | ||
|
||
dependencies { | ||
implementation(libs.clikt) | ||
implementation(libs.serialization.json) | ||
implementation(libs.apollo.tooling) | ||
implementation(libs.kotlinx.coroutines) | ||
implementation(libs.kotlinx.datetime) | ||
implementation(libs.okhttp) | ||
implementation(libs.jsonpathkt) | ||
implementation(libs.mordant) | ||
} | ||
|
||
librarianModule(true) | ||
|
||
application { | ||
mainClass.set("com.apollographql.cli.MainKt") | ||
applicationName = "apollo-kotlin-cli" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version.packageName=com.apollographql.cli |
77 changes: 77 additions & 0 deletions
77
apollo-cli/src/main/kotlin/com/apollographql/cli/InstallCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.apollographql.cli | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import java.io.File | ||
import kotlin.system.exitProcess | ||
|
||
private val initFilename = "init.sh" | ||
internal val home = File(System.getProperty("user.home")) | ||
internal val installDir = home.resolve(".apollo-kotlin-cli") | ||
|
||
/** | ||
* The install command is run from the install.sh script and finishes installation: | ||
* - copies files to ~/.apollo-kotlin-cli | ||
* - add ~/.apollo-kotlin-cli/init.sh to the .zshrc/.bashrc | ||
*/ | ||
internal class InstallCommand : CliktCommand( | ||
hidden = true, | ||
help = "installs apollo-kotlin-cli in your home directory" | ||
) { | ||
|
||
private fun copyFiles() { | ||
val uri = this::class.java.protectionDomain.codeSource.location.toURI() | ||
if (uri.scheme != "file") { | ||
System.err.println("Cannot install from non-file location '$uri'") | ||
exitProcess(1) | ||
} | ||
|
||
val sourceDir = File(uri.path).parentFile.parentFile | ||
|
||
sourceDir.resolve("lib").apply { | ||
check(exists()) { | ||
"Cannot find '$path': was this installed from a distribution?" | ||
} | ||
} | ||
sourceDir.resolve("bin").apply { | ||
check(exists()) { | ||
"Cannot find '$path': was this installed from a distribution?" | ||
} | ||
} | ||
|
||
sourceDir.copyRecursively(installDir, overwrite = true) | ||
|
||
installDir.resolve("bin/apollo-kotlin-cli").setExecutable(true) | ||
|
||
println("apollo-kotlin-cli has been installed in '${installDir.path}' ✅") | ||
|
||
installDir.resolve(initFilename).writeText(""" | ||
export PATH="$installDir/bin:${'$'}PATH" | ||
""".trimIndent()) | ||
} | ||
|
||
override fun run() { | ||
copyFiles() | ||
|
||
val source = "source \"${installDir.resolve(initFilename)}\"" | ||
var found = false | ||
listOf(".zshrc", ".bashrc").forEach { | ||
home.resolve(it).apply { | ||
if (exists()) { | ||
found = true | ||
if (!readText().contains(source)) { | ||
appendText("\n") | ||
appendText(source) | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!found) { | ||
println("Cannot detect your shell. Add the following to your init scripts:") | ||
println(source) | ||
} else { | ||
println("Open a new terminal or run the command below to start using apollo-kotlin-cli") | ||
println(source) | ||
} | ||
} | ||
} |
Oops, something went wrong.