Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ jobs:
- name: "[CLI] Remove developer"
run: ./build/graal/spp-cli -v admin remove-developer test
- name: "[CLI] Add live breakpoint"
run: ./build/graal/spp-cli -v add-breakpoint -h 100 spp.example.webapp.model.User 48
run: ./build/graal/spp-cli -v add breakpoint -h 100 spp.example.webapp.model.User 48
- name: "[CLI] Add live log"
run: ./build/graal/spp-cli -v add-log -h 100 spp.example.webapp.model.User 48 test-message
run: ./build/graal/spp-cli -v add log -h 100 spp.example.webapp.model.User 48 test-message
- name: "[CLI] Get live instruments"
run: ./build/graal/spp-cli -v get-instruments
run: ./build/graal/spp-cli -v get instruments
- name: "[CLI] Get live breakpoints"
run: ./build/graal/spp-cli -v get-breakpoints
run: ./build/graal/spp-cli -v get breakpoints
- name: "[CLI] Get live logs"
run: ./build/graal/spp-cli -v get-logs
run: ./build/graal/spp-cli -v get logs
- name: "[CLI] Remove live instruments"
run: ./build/graal/spp-cli -v remove-instruments spp.example.webapp.model.User 48
run: ./build/graal/spp-cli -v remove instruments spp.example.webapp.model.User 48
- name: "[CLI] Reset"
run: ./build/graal/spp-cli -v admin reset

Expand Down
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ plugins {

val cliGroup: String by project
val projectVersion: String by project
val jacksonVersion: String by project
val apolloVersion: String by project
val commonsLang3Version: String by project
val cliktVersion: String by project
Expand All @@ -34,7 +33,7 @@ dependencies {
implementation("com.apollographql.apollo3:apollo-runtime:$apolloVersion")
api("com.apollographql.apollo3:apollo-api:$apolloVersion")

implementation("com.github.sourceplusplus.protocol:protocol:$projectVersion")
implementation("com.github.sourceplusplus.protocol:protocol:2bd4bea9ad")

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
Expand All @@ -47,13 +46,10 @@ dependencies {
implementation("com.github.ajalt.clikt:clikt:$cliktVersion")
implementation("org.bouncycastle:bcprov-jdk15on:$bouncycastleVersion")
implementation("org.bouncycastle:bcpkix-jdk15on:$bouncycastleVersion")
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion")
implementation("commons-io:commons-io:$commonsIoVersion")
implementation("com.auth0:java-jwt:$auth0JwtVersion")
implementation("eu.geekplace.javapinning:java-pinning-core:1.2.0")

implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2")

testImplementation("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ projectVersion=0.4.1

vertxVersion=4.2.4
graalVersion = 21.3.0
jacksonVersion=2.13.1
apolloVersion=3.1.0
commonsLang3Version = 3.12.0
cliktVersion = 3.2.0
Expand Down
71 changes: 44 additions & 27 deletions src/main/kotlin/spp/cli/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
package spp.cli

import com.github.ajalt.clikt.core.subcommands
import spp.cli.commands.Admin
import spp.cli.commands.Developer
import spp.cli.commands.Version
import spp.cli.commands.admin.Admin
import spp.cli.commands.admin.Reset
import spp.cli.commands.admin.access.*
import spp.cli.commands.admin.developer.AddDeveloper
Expand All @@ -31,12 +32,12 @@ import spp.cli.commands.admin.permission.GetDeveloperPermissions
import spp.cli.commands.admin.permission.GetRolePermissions
import spp.cli.commands.admin.permission.RemoveRolePermission
import spp.cli.commands.admin.role.*
import spp.cli.commands.developer.GetSelf
import spp.cli.commands.instrument.*
import spp.cli.commands.view.AddViewSubscription
import spp.cli.commands.view.ClearViewSubscriptions
import spp.cli.commands.view.GetViewSubscriptions
import spp.cli.commands.view.SubscribeView
import spp.cli.commands.developer.*
import spp.cli.commands.developer.instrument.*
import spp.cli.commands.developer.view.AddView
import spp.cli.commands.developer.view.GetViews
import spp.cli.commands.developer.view.RemoveAllViews
import spp.cli.commands.developer.view.SubscribeView

object Main {

Expand Down Expand Up @@ -77,27 +78,43 @@ object Main {
//etc
Reset()
),
//instrument
AddBreakpoint(),
AddLog(),
AddMeter(),
AddSpan(),
GetBreakpoints(),
GetInstruments(),
GetLogs(),
GetMeters(),
GetSpans(),
RemoveInstrument(),
RemoveInstruments(),
ClearInstruments(),
SubscribeEvents(),
//view
AddViewSubscription(),
ClearViewSubscriptions(),
GetViewSubscriptions(),
SubscribeView(),
Developer().subcommands(
GetSelf()
),
Add().subcommands(
//instrument
AddBreakpoint(),
AddLog(),
AddMeter(),
AddSpan(),
//view
AddView()
),
Get().subcommands(
//instrument
GetInstruments(),
GetBreakpoints(),
GetLogs(),
GetMeters(),
GetSpans(),
//view
GetViews()
),
Remove().subcommands(
//instrument
RemoveInstrument(),
RemoveInstruments(),
RemoveAllInstruments(),
//view
RemoveAllViews()
),
Subscribe().subcommands(
//instrument
SubscribeInstrument(),
//view
SubscribeView()
),
//etc
GetSelf(),
Version()
).main(args)
}
Expand Down
15 changes: 3 additions & 12 deletions src/main/kotlin/spp/cli/PlatformCLI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ import com.apollographql.apollo3.exception.ApolloException
import com.apollographql.apollo3.network.okHttpClient
import com.auth0.jwt.JWT
import com.auth0.jwt.algorithms.Algorithm
import com.fasterxml.jackson.databind.module.SimpleModule
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.file
import eu.geekplace.javapinning.JavaPinning
import io.vertx.core.json.jackson.DatabindCodec
import kotlinx.datetime.Clock
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.Instant
import kotlinx.datetime.plus
import okhttp3.OkHttpClient
import okhttp3.Request
Expand All @@ -44,7 +41,6 @@ import org.bouncycastle.openssl.PEMParser
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter
import org.bouncycastle.util.encoders.Hex
import spp.protocol.platform.developer.Developer
import spp.protocol.util.KSerializers
import java.io.File
import java.io.StringReader
import java.security.SecureRandom
Expand Down Expand Up @@ -82,14 +78,9 @@ object PlatformCLI : CliktCommand(name = "spp-cli", allowMultipleSubcommands = t
}
var developer: Developer = Developer("system")

override fun run() {
val module = SimpleModule()
module.addSerializer(Instant::class.java, KSerializers.KotlinInstantSerializer())
module.addDeserializer(Instant::class.java, KSerializers.KotlinInstantDeserializer())
DatabindCodec.mapper().registerModule(module)
}
override fun run() = Unit

private fun connectToPlatform(): ApolloClient {
fun connectToPlatform(): ApolloClient {
val serverUrl = if (platformHost.startsWith("http")) {
platformHost
} else {
Expand Down Expand Up @@ -142,7 +133,7 @@ object PlatformCLI : CliktCommand(name = "spp-cli", allowMultipleSubcommands = t

if (resp.code != 202) {
val decoded = JWT.decode(jwtToken)
developer = Developer(decoded.getClaim("developer_id").asString())
developer = Developer(decoded.getClaim("developer_id").asString(), jwtToken)
}
} else if (resp.code == 401 && accessToken.isNullOrEmpty()) {
throw IllegalStateException("Connection failed. Reason: Missing access token")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package spp.cli.commands.admin
package spp.cli.commands

import com.github.ajalt.clikt.core.CliktCommand

class Admin : CliktCommand() {
class Admin : CliktCommand(help = "Administrator commands") {
override fun run() = Unit
}
24 changes: 24 additions & 0 deletions src/main/kotlin/spp/cli/commands/Developer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Source++, the open-source live coding platform.
* Copyright (C) 2022 CodeBrig, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package spp.cli.commands

import com.github.ajalt.clikt.core.CliktCommand

class Developer : CliktCommand(help = "Developer commands") {
override fun run() = Unit
}
2 changes: 1 addition & 1 deletion src/main/kotlin/spp/cli/commands/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package spp.cli.commands
import com.github.ajalt.clikt.core.CliktCommand
import java.util.*

class Version : CliktCommand() {
class Version : CliktCommand(help = "Display version information") {
private val BUILD = ResourceBundle.getBundle("build")

override fun run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import spp.cli.PlatformCLI
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.access.AddAccessPermissionMutation
import spp.cli.protocol.access.adapter.AddAccessPermissionMutation_ResponseAdapter.AddAccessPermission
import spp.cli.protocol.type.AccessType
import spp.cli.util.JsonCleaner
import spp.protocol.platform.auth.AccessType
import kotlin.system.exitProcess

class AddAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
Expand All @@ -43,7 +43,10 @@ class AddAccessPermission : CliktCommand(printHelpOnEmptyArgs = true) {
override fun run() = runBlocking {
val response = try {
PlatformCLI.apolloClient.mutation(
AddAccessPermissionMutation(Optional.Present(locationPatterns), type)
AddAccessPermissionMutation(
Optional.Present(locationPatterns),
spp.cli.protocol.type.AccessType.valueOf(type.toString())
)
).execute()
} catch (e: Exception) {
echoError(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import spp.cli.Main
import spp.cli.PlatformCLI.apolloClient
import spp.cli.PlatformCLI.echoError
import spp.cli.protocol.permission.AddRolePermissionMutation
import spp.cli.protocol.type.RolePermission
import spp.protocol.platform.auth.RolePermission
import kotlin.system.exitProcess

class AddRolePermission : CliktCommand(printHelpOnEmptyArgs = true) {
Expand Down
24 changes: 24 additions & 0 deletions src/main/kotlin/spp/cli/commands/developer/Add.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Source++, the open-source live coding platform.
* Copyright (C) 2022 CodeBrig, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package spp.cli.commands.developer

import com.github.ajalt.clikt.core.CliktCommand

class Add : CliktCommand(help = "Add live instruments/views") {
override fun run() = Unit
}
24 changes: 24 additions & 0 deletions src/main/kotlin/spp/cli/commands/developer/Get.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Source++, the open-source live coding platform.
* Copyright (C) 2022 CodeBrig, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package spp.cli.commands.developer

import com.github.ajalt.clikt.core.CliktCommand

class Get : CliktCommand(help = "Get live instruments/views") {
override fun run() = Unit
}
2 changes: 1 addition & 1 deletion src/main/kotlin/spp/cli/commands/developer/GetSelf.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import spp.cli.protocol.developer.adapter.GetSelfQuery_ResponseAdapter.GetSelf
import spp.cli.util.JsonCleaner
import kotlin.system.exitProcess

class GetSelf : CliktCommand() {
class GetSelf : CliktCommand(help = "Get the current developer's profile") {

override fun run() = runBlocking {
val response = try {
Expand Down
24 changes: 24 additions & 0 deletions src/main/kotlin/spp/cli/commands/developer/Remove.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Source++, the open-source live coding platform.
* Copyright (C) 2022 CodeBrig, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package spp.cli.commands.developer

import com.github.ajalt.clikt.core.CliktCommand

class Remove : CliktCommand(help = "Remove live instruments/views") {
override fun run() = Unit
}
24 changes: 24 additions & 0 deletions src/main/kotlin/spp/cli/commands/developer/Subscribe.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Source++, the open-source live coding platform.
* Copyright (C) 2022 CodeBrig, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package spp.cli.commands.developer

import com.github.ajalt.clikt.core.CliktCommand

class Subscribe : CliktCommand(help = "Subscribe to live instrument/view streams") {
override fun run() = Unit
}
Loading