Skip to content

Commit 14654ff

Browse files
committed
rework CLI section to include all languages, codegen examples etc
1 parent a779c69 commit 14654ff

File tree

100 files changed

+4540
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+4540
-126
lines changed

docusaurus.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ const config = {
154154
"python",
155155
"kotlin",
156156
"swift",
157-
"rust"
157+
"rust",
158+
"shell-session"
158159
]
159160
},
160161
}),

sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const sidebars = {
2020
label: 'Quick Start',
2121
items: [
2222
'quick-start/javascript',
23+
'quick-start/rust',
2324
'quick-start/python',
2425
'quick-start/kotlin',
2526
'quick-start/swift',
26-
'quick-start/rust',
2727
]
2828
},
2929
'clients',
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
wrap
17+
.polywrap
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
id("com.android.application")
5+
id("org.jetbrains.kotlin.android")
6+
id("org.jetbrains.kotlin.plugin.serialization")
7+
id("com.github.node-gradle.node")
8+
}
9+
10+
android {
11+
namespace = "io.template.polywrap"
12+
compileSdk = 33
13+
14+
defaultConfig {
15+
applicationId = "io.template.polywrap"
16+
minSdk = 24
17+
targetSdk = 33
18+
versionCode = 1
19+
versionName = "1.0"
20+
21+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
22+
vectorDrawables {
23+
useSupportLibrary = true
24+
}
25+
}
26+
27+
buildTypes {
28+
release {
29+
isMinifyEnabled = false
30+
proguardFiles(
31+
getDefaultProguardFile("proguard-android-optimize.txt"),
32+
"proguard-rules.pro"
33+
)
34+
}
35+
}
36+
compileOptions {
37+
sourceCompatibility = JavaVersion.VERSION_17
38+
targetCompatibility = JavaVersion.VERSION_17
39+
}
40+
kotlinOptions {
41+
jvmTarget = "17"
42+
}
43+
buildFeatures {
44+
compose = true
45+
}
46+
composeOptions {
47+
kotlinCompilerExtensionVersion = "1.4.8"
48+
}
49+
packaging {
50+
resources {
51+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
52+
}
53+
}
54+
}
55+
56+
dependencies {
57+
// polywrap client
58+
implementation("io.polywrap:polywrap-client:0.10.4")
59+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.5.1")
60+
// polywrap logger plugin
61+
implementation("io.polywrap.plugins:logger:0.10.4")
62+
implementation("com.github.tony19:logback-android:3.0.0")
63+
64+
// ui
65+
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
66+
67+
// defaults
68+
implementation("androidx.core:core-ktx:1.10.1")
69+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
70+
implementation("androidx.activity:activity-compose:1.7.2")
71+
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
72+
implementation("androidx.compose.ui:ui")
73+
implementation("androidx.compose.ui:ui-graphics")
74+
implementation("androidx.compose.ui:ui-tooling-preview")
75+
implementation("androidx.compose.material3:material3")
76+
testImplementation("junit:junit:4.13.2")
77+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
78+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
79+
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
80+
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
81+
debugImplementation("androidx.compose.ui:ui-tooling")
82+
debugImplementation("androidx.compose.ui:ui-test-manifest")
83+
}
84+
85+
// set up NodeJS to run the Polywrap CLI
86+
// NodeJS installation will be stored in gradle cache
87+
node {
88+
val nullString: String? = null
89+
distBaseUrl.set(nullString)
90+
// Whether to download and install a specific Node.js version or not
91+
// If false, it will use the globally installed Node.js
92+
// If true, it will download node using above parameters
93+
// Note that npm is bundled with Node.js
94+
download.set(true)
95+
}
96+
97+
// run polwyrap codegen
98+
tasks.register<com.github.gradle.node.npm.task.NpxTask>("codegen") {
99+
group = "polywrap"
100+
dependsOn(tasks.npmInstall)
101+
command.set("polywrap")
102+
args.set(listOf("codegen",
103+
"-m", "$rootDir/polywrap.yaml",
104+
"-g", "$projectDir/src/main/java/wrap"
105+
))
106+
}
107+
108+
// set polywrap codegen to run before each build
109+
tasks.withType<KotlinCompile> { dependsOn("codegen") }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.template.polywrap
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("io.template.polywrap", appContext.packageName)
23+
}
24+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.Template"
14+
tools:targetApi="31">
15+
<activity
16+
android:name=".MainActivity"
17+
android:exported="true"
18+
android:label="@string/app_name"
19+
android:theme="@style/Theme.Template">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
26+
</application>
27+
28+
</manifest>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<configuration
2+
xmlns="https://tony19.github.io/logback-android/xml"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://tony19.github.io/logback-android/xml https://cdn.jsdelivr.net/gh/tony19/logback-android/logback.xsd"
5+
>
6+
<appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender">
7+
<tagEncoder>
8+
<pattern>%logger{12}</pattern>
9+
</tagEncoder>
10+
<encoder>
11+
<pattern>[%-20thread] %msg</pattern>
12+
</encoder>
13+
</appender>
14+
15+
<root level="DEBUG">
16+
<appender-ref ref="logcat" />
17+
</root>
18+
</configuration>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package io.template.polywrap
2+
3+
import android.os.Bundle
4+
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.setContent
6+
import androidx.compose.foundation.background
7+
import androidx.compose.foundation.layout.Arrangement
8+
import androidx.compose.foundation.layout.Column
9+
import androidx.compose.foundation.layout.fillMaxHeight
10+
import androidx.compose.foundation.layout.fillMaxSize
11+
import androidx.compose.foundation.layout.fillMaxWidth
12+
import androidx.compose.foundation.layout.height
13+
import androidx.compose.foundation.layout.padding
14+
import androidx.compose.material3.Button
15+
import androidx.compose.material3.MaterialTheme
16+
import androidx.compose.material3.Surface
17+
import androidx.compose.material3.Text
18+
import androidx.compose.runtime.Composable
19+
import androidx.compose.ui.Modifier
20+
import androidx.compose.ui.tooling.preview.Preview
21+
import androidx.compose.ui.unit.dp
22+
import androidx.lifecycle.viewmodel.compose.viewModel
23+
import io.template.myapplication.ui.theme.MyApplicationTheme
24+
25+
class MainActivity : ComponentActivity() {
26+
override fun onCreate(savedInstanceState: Bundle?) {
27+
super.onCreate(savedInstanceState)
28+
setContent {
29+
MyApplicationTheme {
30+
Column(
31+
verticalArrangement = Arrangement.Center,
32+
modifier = Modifier.fillMaxHeight().padding(16.dp)
33+
) {
34+
Surface(
35+
modifier = Modifier.fillMaxWidth().height(60.dp),
36+
color = MaterialTheme.colorScheme.background
37+
) {
38+
PolywrapDemo()
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
46+
@Composable
47+
fun PolywrapDemo(demoViewModel: PolywrapDemoViewModel = viewModel()) {
48+
Button(onClick = { demoViewModel.polywrapDemo() }) {
49+
Text(text = "Click here and check the logs!")
50+
}
51+
}
52+
53+
@Preview(showBackground = true)
54+
@Composable
55+
fun PolywrapDemoPreview() {
56+
MyApplicationTheme {
57+
PolywrapDemo()
58+
}
59+
}

0 commit comments

Comments
 (0)