@panomc/plugin-kit 0.0.0-stage → 1.0.0-dev.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/pano-bootstrap.css +17903 -0
- package/bin/__tests__/new/e2e.test.js +111 -0
- package/bin/__tests__/new/helpers.js +76 -0
- package/bin/__tests__/new/new.test.js +472 -0
- package/bin/new.js +530 -0
- package/bin/pano-plugin.js +162 -0
- package/bin/templates/plugin/README.md +30 -0
- package/bin/templates/plugin/_gitignore +15 -0
- package/bin/templates/plugin/build.gradle.kts +389 -0
- package/bin/templates/plugin/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/bin/templates/plugin/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/bin/templates/plugin/gradle.properties +55 -0
- package/bin/templates/plugin/gradlew +249 -0
- package/bin/templates/plugin/gradlew.bat +92 -0
- package/bin/templates/plugin/package.json.tpl +14 -0
- package/bin/templates/plugin/rollup.config.js +2 -0
- package/bin/templates/plugin/settings.gradle.kts +5 -0
- package/bin/templates/plugin/src/main/kotlin/__PKGPATH__/__CLASS__Plugin.kt +50 -0
- package/bin/templates/plugin/src/main/kotlin/__PKGPATH__/frontend/ExampleFallbackPage.kt +28 -0
- package/bin/templates/plugin/src/main/kotlin/__PKGPATH__/routes/GetHelloAPI.kt +19 -0
- package/bin/templates/plugin/src/main/kotlin/com/panomc/plugins/license/LicenseGuard.kt +30 -0
- package/bin/templates/plugin/src/main/kotlin/com/panomc/plugins/license/PluginLicenseClient.kt +144 -0
- package/bin/templates/plugin/src/main/resources/config.conf +1 -0
- package/bin/templates/plugin/src/main/resources/frontend-targets.json +1 -0
- package/bin/templates/plugin/src/main/resources/locales/en-US.json +3 -0
- package/bin/templates/plugin/src/main/resources/logo.png +0 -0
- package/bin/templates/plugin/src/theme/views/HelloPage.svelte +26 -0
- package/bin/ui.js +96 -0
- package/package.json +48 -4
- package/src/config.js +191 -0
- package/src/controller/__tests__/controller.test.js +647 -0
- package/src/controller/index.js +604 -0
- package/src/dev.js +208 -0
- package/src/index.js +22 -0
- package/src/rollup/__tests__/controllers/controllers.test.js +418 -0
- package/src/rollup/__tests__/controllers/fixture.js +143 -0
- package/src/rollup/__tests__/controllers/golden/controllers.json +34 -0
- package/src/rollup/__tests__/controllers/golden/controllers.types.js +69 -0
- package/src/rollup/__tests__/controllers/golden/pano-plugin.json +16 -0
- package/src/rollup/__tests__/controllers/golden/pano-plugin.lock.json +27 -0
- package/src/rollup/__tests__/controllers/golden/pano-plugin.with-views.json +54 -0
- package/src/rollup/__tests__/preset/preset.test.js +418 -0
- package/src/rollup/__tests__/rules/_build.js +39 -0
- package/src/rollup/__tests__/rules/_fixture.js +83 -0
- package/src/rollup/__tests__/rules/helpers.test.js +148 -0
- package/src/rollup/__tests__/rules/rules.test.js +259 -0
- package/src/rollup/__tests__/rules/stamp.test.js +113 -0
- package/src/rollup/__tests__/samples/samples.test.js +481 -0
- package/src/rollup/__tests__/seams/config.test.js +78 -0
- package/src/rollup/__tests__/seams/lock.test.js +124 -0
- package/src/rollup/__tests__/seams/sdk-seams.test.js +93 -0
- package/src/rollup/__tests__/seams/stubs.test.js +52 -0
- package/src/rollup/__tests__/views/helpers.js +82 -0
- package/src/rollup/__tests__/views/views.test.js +522 -0
- package/src/rollup/__tests__/widgets/helpers.js +117 -0
- package/src/rollup/__tests__/widgets/widgets.test.js +422 -0
- package/src/rollup/cli-build.js +90 -0
- package/src/rollup/cli-check.js +280 -0
- package/src/rollup/cli-classes.js +75 -0
- package/src/rollup/client-gen.js +67 -0
- package/src/rollup/controllers.js +434 -0
- package/src/rollup/entry.js +250 -0
- package/src/rollup/helpers.js +193 -0
- package/src/rollup/index.js +601 -0
- package/src/rollup/integrate.js +205 -0
- package/src/rollup/lock.js +230 -0
- package/src/rollup/meta.js +479 -0
- package/src/rollup/rules.js +950 -0
- package/src/rollup/samples.js +667 -0
- package/src/rollup/stamp.js +410 -0
- package/src/rollup/types.js +248 -0
- package/src/rollup/views.js +1205 -0
- package/src/rollup/widgets.js +1000 -0
- package/src/styles/__tests__/fallback/__snapshots__/build-fallback-css.test.js.snap +173 -0
- package/src/styles/__tests__/fallback/build-fallback-css.test.js +526 -0
- package/src/styles/__tests__/fallback/fixtures/base.css +247 -0
- package/src/styles/__tests__/fallback/plugins.test.js +301 -0
- package/src/styles/__tests__/lint/check-styles.test.js +423 -0
- package/src/styles/__tests__/lint/fixtures/ProductCard.golden.svelte +13 -0
- package/src/styles/__tests__/lint/fixtures/ProductCard.in.svelte +13 -0
- package/src/styles/__tests__/lint/semantic-classes.test.js +364 -0
- package/src/styles/bootstrap-classes.js +155 -0
- package/src/styles/check-styles.js +626 -0
- package/src/styles/fallback-css.js +1182 -0
- package/src/styles/plugin-css.js +237 -0
- package/src/styles/scan.js +206 -0
- package/src/styles/semantic-classes.js +436 -0
- package/src/styles/tokens.map.js +53 -0
- package/README.md +0 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @@NAME@@
|
|
2
|
+
|
|
3
|
+
A plugin for [Pano](https://panomc.com), scaffolded by `bunx @panomc/plugin-kit new @@ID@@`.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Needs: JDK 17+, Bun, Pano with Development Mode on
|
|
9
|
+
cd <pano>/plugins && bunx @panomc/plugin-kit new my-plugin # installs
|
|
10
|
+
cd my-plugin && bun run dev # first run builds the jar (minutes); restart Pano once, then open /my-plugin
|
|
11
|
+
New page: src/theme/views/X.svelte with export const view = { path: '/x' }
|
|
12
|
+
Helper: any .js beside it, imported as usual (ships readable)
|
|
13
|
+
Closed logic: src/theme/controllers/x.js -> plugin('my-plugin').require('x')
|
|
14
|
+
Panel page: src/main.js -> pano.ui.page.register({ path, component }) (unchanged)
|
|
15
|
+
Look: classes <ns>-x__part; a <style> block is allowed (every selector starts with .<ns>-)
|
|
16
|
+
Sample data: bunx pano-plugin samples X Check: bunx pano-plugin check
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This plugin is `@@ID@@`: open `/@@ID@@` on the site to see `src/theme/views/HelloPage.svelte`, which shows the answer
|
|
20
|
+
of `src/main/kotlin/@@PKGPATH@@/routes/GetHelloAPI.kt`.
|
|
21
|
+
|
|
22
|
+
| Where | What |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `src/theme/views/` | the site pages, one `.svelte` file each (`export const view = { path }`) |
|
|
25
|
+
| `src/main/kotlin/` | the plugin class and its API endpoints |
|
|
26
|
+
| `src/main/resources/frontend-targets.json` | links this plugin sends out (empty), see `ExampleFallbackPage.kt` |
|
|
27
|
+
| `src/main/resources/locales/` | texts, keyed `plugins.@@ID@@.<key>` |
|
|
28
|
+
| `gradle.properties` | id, name, class, author, `panoPluginsDir` (where the jar is copied) |
|
|
29
|
+
|
|
30
|
+
Build the jar with `./gradlew build` (add `-Pnoui` to skip the UI build); `bun run build` builds only the UI.
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import java.net.URL
|
|
2
|
+
import java.util.Properties
|
|
3
|
+
import java.util.zip.ZipFile
|
|
4
|
+
|
|
5
|
+
plugins {
|
|
6
|
+
kotlin("jvm") version "2.2.21"
|
|
7
|
+
kotlin("kapt") version "2.2.21"
|
|
8
|
+
id("com.gradleup.shadow") version "8.3.8"
|
|
9
|
+
`maven-publish`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
group = "@@PACKAGE@@"
|
|
13
|
+
version =
|
|
14
|
+
(if (project.hasProperty("version") && project.findProperty("version") != "unspecified") project.findProperty("version") else "local-build")!!
|
|
15
|
+
|
|
16
|
+
val pf4jVersion: String by project
|
|
17
|
+
val vertxVersion: String by project
|
|
18
|
+
val gsonVersion: String by project
|
|
19
|
+
val handlebarsVersion: String by project
|
|
20
|
+
val springContextVersion: String by project
|
|
21
|
+
val bootstrap = (project.findProperty("bootstrap") as String?)?.toBoolean() ?: false
|
|
22
|
+
val noui = project.hasProperty("noui")
|
|
23
|
+
// Where copyJar puts the jar: the pluginsDir of the pano-web-platform tree when this plugin is built inside
|
|
24
|
+
// it, else panoPluginsDir of gradle.properties (".." = the plugins folder this plugin lives in).
|
|
25
|
+
val pluginsDir: File? =
|
|
26
|
+
(if (rootProject.extra.has("pluginsDir")) rootProject.extra["pluginsDir"] as File? else null)
|
|
27
|
+
?: (findProperty("panoPluginsDir") as String?)?.takeIf { it.isNotBlank() }?.let { projectDir.resolve(it) }
|
|
28
|
+
|
|
29
|
+
val os = System.getProperty("os.name").lowercase()
|
|
30
|
+
val arch = System.getProperty("os.arch").lowercase()
|
|
31
|
+
|
|
32
|
+
val isWindows = os.contains("win")
|
|
33
|
+
val isMac = os.contains("mac")
|
|
34
|
+
val isLinux = os.contains("nix") || os.contains("nux") || os.contains("linux")
|
|
35
|
+
|
|
36
|
+
val isAarch64 = arch.contains("aarch64") || arch.contains("arm64")
|
|
37
|
+
val isX64 = arch.contains("x86_64") || arch.contains("amd64")
|
|
38
|
+
|
|
39
|
+
val bunVersion = "1.2.0"
|
|
40
|
+
val bunPlatform = when {
|
|
41
|
+
isWindows && isX64 -> "bun-windows-x64"
|
|
42
|
+
// isWindows && isAarch64 -> "bun-windows-aarch64"
|
|
43
|
+
isMac && isX64 -> "bun-darwin-x64"
|
|
44
|
+
isMac && isAarch64 -> "bun-darwin-aarch64"
|
|
45
|
+
isLinux && isX64 -> "bun-linux-x64"
|
|
46
|
+
isLinux && isAarch64 -> "bun-linux-aarch64"
|
|
47
|
+
else -> throw RuntimeException("Unsupported OS or Architecture")
|
|
48
|
+
}
|
|
49
|
+
val bunUrl = "https://github.com/oven-sh/bun/releases/download/bun-v$bunVersion/$bunPlatform.zip"
|
|
50
|
+
|
|
51
|
+
val bunDir = File(layout.buildDirectory.asFile.get().absolutePath, "bun")
|
|
52
|
+
val bunBinDir = File(bunDir, bunPlatform)
|
|
53
|
+
var bunBin = if (isWindows) File(bunBinDir, "bun.exe") else File(bunBinDir, "bun")
|
|
54
|
+
|
|
55
|
+
val pluginId: String by project
|
|
56
|
+
|
|
57
|
+
// api-level: "panoApiLevel" of the pano-web-platform tree this plugin is built in, else "current" from
|
|
58
|
+
// the pano-api-level.properties inside the Pano jar on compileClasspath. `apiLevel=` in gradle.properties lowers it.
|
|
59
|
+
val panoApiLevel: String? by lazy {
|
|
60
|
+
(findProperty("apiLevel") as String?)
|
|
61
|
+
?: (rootProject.findProperty("panoApiLevel") as String?)
|
|
62
|
+
?: configurations.findByName("compileClasspath")?.files?.firstNotNullOfOrNull { jar ->
|
|
63
|
+
if (!jar.isFile || !jar.name.endsWith(".jar")) null
|
|
64
|
+
else ZipFile(jar).use { zip ->
|
|
65
|
+
zip.getEntry("pano-api-level.properties")?.let { entry ->
|
|
66
|
+
Properties().apply { load(zip.getInputStream(entry)) }.getProperty("current")
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
val pluginName: String by project
|
|
72
|
+
val pluginDescription: String? by project
|
|
73
|
+
val pluginPanoVersion: String by project
|
|
74
|
+
val pluginClass: String by project
|
|
75
|
+
val pluginDeveloper: String by project
|
|
76
|
+
val pluginLicense: String? by project
|
|
77
|
+
val pluginSourceUrl: String? by project
|
|
78
|
+
val pluginDependencies: String? by project
|
|
79
|
+
val pluginRequires: String? by project
|
|
80
|
+
val pluginFreemium: String? by project
|
|
81
|
+
|
|
82
|
+
val organization: String? by project
|
|
83
|
+
|
|
84
|
+
repositories {
|
|
85
|
+
mavenCentral()
|
|
86
|
+
maven("https://jitpack.io")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
dependencies {
|
|
90
|
+
if (bootstrap) {
|
|
91
|
+
compileOnly(project(mapOf("path" to ":Pano")))
|
|
92
|
+
} else {
|
|
93
|
+
compileOnly("com.github.panomc:pano:v1.0.0-alpha.463")
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
compileOnly(kotlin("stdlib-jdk8"))
|
|
97
|
+
compileOnly(kotlin("reflect"))
|
|
98
|
+
|
|
99
|
+
compileOnly("org.pf4j:pf4j:${pf4jVersion}")
|
|
100
|
+
kapt("org.pf4j:pf4j:${pf4jVersion}")
|
|
101
|
+
compileOnly("io.vertx:vertx-web:${vertxVersion}")
|
|
102
|
+
compileOnly("io.vertx:vertx-lang-kotlin:${vertxVersion}")
|
|
103
|
+
compileOnly("io.vertx:vertx-lang-kotlin-coroutines:${vertxVersion}")
|
|
104
|
+
compileOnly("io.vertx:vertx-jdbc-client:${vertxVersion}")
|
|
105
|
+
compileOnly("io.vertx:vertx-json-schema:${vertxVersion}")
|
|
106
|
+
compileOnly("io.vertx:vertx-web-validation:${vertxVersion}")
|
|
107
|
+
compileOnly("io.vertx:vertx-mysql-client:${vertxVersion}")
|
|
108
|
+
|
|
109
|
+
// https://mvnrepository.com/artifact/org.springframework/spring-context
|
|
110
|
+
compileOnly("org.springframework:spring-context:${springContextVersion}")
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
val panoLicensePublicKey: String? by project
|
|
114
|
+
val premiumLicenseSrcDir = layout.buildDirectory.dir("generated/license-source")
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Resolves the panomc.com license verification public key for build-time embedding.
|
|
118
|
+
*
|
|
119
|
+
* Property / env semantics (highest priority first):
|
|
120
|
+
* - `-PpanoLicensePublicKey=<base64|PEM>` explicit override
|
|
121
|
+
* - `PANO_LICENSE_PUBLIC_KEY` same when property unset
|
|
122
|
+
* - `-PlicenseServer=dev|prod|<url>` auto-fetch from license server
|
|
123
|
+
* - `PANO_LICENSE_SERVER` same when property unset (e.g. CI)
|
|
124
|
+
* - (none) empty key → plugin builds as FREE
|
|
125
|
+
*
|
|
126
|
+
* Result is cached under `build/license-key-cache/`.
|
|
127
|
+
*/
|
|
128
|
+
fun resolveLicensePublicKey(): String {
|
|
129
|
+
val explicitProp = (panoLicensePublicKey ?: "").let(::stripPemAndWhitespace).takeIf { it.isNotEmpty() }
|
|
130
|
+
val explicitEnv = System.getenv("PANO_LICENSE_PUBLIC_KEY")?.trim()?.takeIf { it.isNotEmpty() }
|
|
131
|
+
?.let(::stripPemAndWhitespace)?.takeIf { it.isNotEmpty() }
|
|
132
|
+
val explicit = explicitProp ?: explicitEnv
|
|
133
|
+
if (explicit != null) return explicit
|
|
134
|
+
|
|
135
|
+
val serverProp = (project.findProperty("licenseServer") as String?)?.trim().orEmpty()
|
|
136
|
+
val serverEnv = System.getenv("PANO_LICENSE_SERVER")?.trim().orEmpty()
|
|
137
|
+
val server = serverProp.ifEmpty { serverEnv }
|
|
138
|
+
if (server.isEmpty()) return ""
|
|
139
|
+
|
|
140
|
+
val baseUrl = when (server.lowercase()) {
|
|
141
|
+
"dev" -> "https://api-dev.panomc.com"
|
|
142
|
+
"prod", "production" -> "https://api.panomc.com"
|
|
143
|
+
else -> server.removeSuffix("/")
|
|
144
|
+
}
|
|
145
|
+
val cacheRoot = layout.buildDirectory.dir("license-key-cache").get().asFile
|
|
146
|
+
cacheRoot.mkdirs()
|
|
147
|
+
val cacheFile = cacheRoot.resolve(baseUrl.replace(Regex("[^A-Za-z0-9._-]"), "_") + ".pem")
|
|
148
|
+
|
|
149
|
+
if (!cacheFile.exists() || cacheFile.length() == 0L) {
|
|
150
|
+
logger.lifecycle("Fetching license public key from $baseUrl...")
|
|
151
|
+
val payload = try {
|
|
152
|
+
URL("$baseUrl/platform/api/licenses/public-key")
|
|
153
|
+
.openConnection()
|
|
154
|
+
.apply {
|
|
155
|
+
connectTimeout = 10_000
|
|
156
|
+
readTimeout = 10_000
|
|
157
|
+
setRequestProperty("Accept", "application/json")
|
|
158
|
+
}
|
|
159
|
+
.getInputStream()
|
|
160
|
+
.bufferedReader()
|
|
161
|
+
.use { it.readText() }
|
|
162
|
+
} catch (e: Exception) {
|
|
163
|
+
throw GradleException(
|
|
164
|
+
"Failed to fetch license public key from $baseUrl/platform/api/licenses/public-key: " +
|
|
165
|
+
"${e.message}. Either bring the license server up, drop the -PlicenseServer flag " +
|
|
166
|
+
"(builds the plugin as FREE), or set -PpanoLicensePublicKey=<base64> manually.",
|
|
167
|
+
e
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
cacheFile.writeText(payload)
|
|
171
|
+
}
|
|
172
|
+
return parsePublicKeyResponse(cacheFile.readText())
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fun parsePublicKeyResponse(rawJson: String): String {
|
|
176
|
+
val keyField = Regex("\"publicKeyBase64\"\\s*:\\s*\"([^\"]+)\"").find(rawJson)?.groupValues?.get(1)
|
|
177
|
+
if (!keyField.isNullOrBlank()) return stripPemAndWhitespace(keyField)
|
|
178
|
+
val pemField = Regex("\"publicKey\"\\s*:\\s*\"((?:\\\\.|[^\"\\\\])*)\"")
|
|
179
|
+
.find(rawJson)?.groupValues?.get(1)
|
|
180
|
+
if (!pemField.isNullOrBlank()) {
|
|
181
|
+
val unescaped = pemField.replace("\\n", "\n").replace("\\\"", "\"").replace("\\\\", "\\")
|
|
182
|
+
return stripPemAndWhitespace(unescaped)
|
|
183
|
+
}
|
|
184
|
+
throw GradleException(
|
|
185
|
+
"License server response did not contain `publicKeyBase64` or `publicKey`. Got: ${rawJson.take(200)}"
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
fun stripPemAndWhitespace(input: String): String =
|
|
190
|
+
input
|
|
191
|
+
.replace(Regex("-----BEGIN [^-]+-----"), "")
|
|
192
|
+
.replace(Regex("-----END [^-]+-----"), "")
|
|
193
|
+
.replace(Regex("\\s+"), "")
|
|
194
|
+
|
|
195
|
+
tasks {
|
|
196
|
+
register("generatePluginBuildConstants") {
|
|
197
|
+
val outputDir = premiumLicenseSrcDir
|
|
198
|
+
val versionString = version.toString()
|
|
199
|
+
val licenseServerInput = (project.findProperty("licenseServer") as String?) ?: ""
|
|
200
|
+
val explicitKeyInput = (panoLicensePublicKey ?: "")
|
|
201
|
+
|
|
202
|
+
outputs.dir(outputDir)
|
|
203
|
+
// Cache invalidation triggers: any of these inputs changing forces re-generation.
|
|
204
|
+
inputs.property("licenseServer", licenseServerInput)
|
|
205
|
+
inputs.property("panoLicensePublicKey", explicitKeyInput)
|
|
206
|
+
inputs.property("version", versionString)
|
|
207
|
+
|
|
208
|
+
doLast {
|
|
209
|
+
// Single-line Base64 SubjectPublicKeyInfo body or empty string for free builds.
|
|
210
|
+
val cleanedPubKey = resolveLicensePublicKey()
|
|
211
|
+
val file = outputDir.get().asFile
|
|
212
|
+
.resolve("com/panomc/plugins/license/PluginBuildConstants.kt")
|
|
213
|
+
file.parentFile.mkdirs()
|
|
214
|
+
val escapedPubKey = cleanedPubKey
|
|
215
|
+
.replace("\\", "\\\\")
|
|
216
|
+
.replace("\"", "\\\"")
|
|
217
|
+
file.writeText(
|
|
218
|
+
"""package com.panomc.plugins.license
|
|
219
|
+
|
|
220
|
+
internal object PluginBuildConstants {
|
|
221
|
+
const val VERSION: String = "$versionString"
|
|
222
|
+
const val PANO_PUBLIC_KEY_BASE64: String = "$escapedPubKey"
|
|
223
|
+
}
|
|
224
|
+
"""
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
register("installBun") {
|
|
230
|
+
doLast {
|
|
231
|
+
if (!bunBin.exists()) {
|
|
232
|
+
println("🚀 Couldn't find Bun, downloading: $bunUrl")
|
|
233
|
+
|
|
234
|
+
val zipFile = File(bunDir, "$bunPlatform.zip")
|
|
235
|
+
zipFile.parentFile.mkdirs()
|
|
236
|
+
|
|
237
|
+
URL(bunUrl).openStream().use { input ->
|
|
238
|
+
zipFile.outputStream().use { output ->
|
|
239
|
+
input.copyTo(output)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
copy {
|
|
244
|
+
from(zipTree(zipFile))
|
|
245
|
+
into(bunDir)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (!isWindows) {
|
|
249
|
+
bunBin.setExecutable(true)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
zipFile.delete()
|
|
253
|
+
println("✅ Bun successfully downloaded: ${bunBin.absolutePath}")
|
|
254
|
+
} else {
|
|
255
|
+
println("✅ Bun is downloaded already: ${bunBin.absolutePath}")
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
register("buildUI", Exec::class) {
|
|
261
|
+
dependsOn("installBun")
|
|
262
|
+
println(bunBin.absolutePath)
|
|
263
|
+
commandLine(bunBin.absolutePath, "run", "build")
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
register("zipPluginUI", Zip::class) {
|
|
267
|
+
dependsOn("buildUI")
|
|
268
|
+
|
|
269
|
+
from("src/main/resources/plugin-ui")
|
|
270
|
+
archiveFileName.set("plugin-ui.zip")
|
|
271
|
+
destinationDirectory.set(file("src/main/resources"))
|
|
272
|
+
|
|
273
|
+
doLast {
|
|
274
|
+
val pluginUIFolder = file("src/main/resources/plugin-ui")
|
|
275
|
+
if (pluginUIFolder.exists()) {
|
|
276
|
+
pluginUIFolder.deleteRecursively()
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
outputs.upToDateWhen { false }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
shadowJar {
|
|
284
|
+
manifest {
|
|
285
|
+
attributes["id"] = pluginId
|
|
286
|
+
panoApiLevel?.let { attributes["api-level"] = it }
|
|
287
|
+
attributes["name"] = pluginName
|
|
288
|
+
pluginDescription?.let { attributes["description"] = it }
|
|
289
|
+
attributes["pano-version"] = pluginPanoVersion
|
|
290
|
+
attributes["main-class"] = pluginClass
|
|
291
|
+
attributes["version"] = version
|
|
292
|
+
attributes["developer"] = pluginDeveloper
|
|
293
|
+
pluginLicense?.let { attributes["license"] = it }
|
|
294
|
+
pluginSourceUrl?.let { attributes["source-url"] = it }
|
|
295
|
+
pluginDependencies?.let { attributes["dependencies"] = it }
|
|
296
|
+
pluginRequires?.let { attributes["requires"] = it }
|
|
297
|
+
// Read by the host into PanoPluginDescriptor.freemium; see gradle.properties.
|
|
298
|
+
pluginFreemium?.let { attributes["freemium"] = it }
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
archiveFileName.set("$pluginId-$version.jar")
|
|
302
|
+
|
|
303
|
+
dependencies {
|
|
304
|
+
exclude(dependency("io.vertx:vertx-core"))
|
|
305
|
+
exclude {
|
|
306
|
+
it.moduleGroup == "io.netty" || it.moduleGroup == "org.slf4j"
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
register("copyJar") {
|
|
312
|
+
pluginsDir?.let {
|
|
313
|
+
doLast {
|
|
314
|
+
copy {
|
|
315
|
+
from(shadowJar.get().archiveFile.get().asFile.absolutePath)
|
|
316
|
+
into(it)
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
outputs.upToDateWhen { false }
|
|
322
|
+
mustRunAfter(shadowJar)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
jar {
|
|
326
|
+
enabled = false
|
|
327
|
+
dependsOn(shadowJar)
|
|
328
|
+
dependsOn("copyJar")
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
tasks.named("build") {
|
|
333
|
+
if (!noui) {
|
|
334
|
+
dependsOn("zipPluginUI")
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
tasks.named("processResources") {
|
|
339
|
+
if (!noui) {
|
|
340
|
+
dependsOn("zipPluginUI")
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
publishing {
|
|
345
|
+
repositories {
|
|
346
|
+
maven {
|
|
347
|
+
name = pluginId
|
|
348
|
+
url = uri("https://maven.pkg.github.com/$organization/$pluginId")
|
|
349
|
+
credentials {
|
|
350
|
+
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME_GITHUB")
|
|
351
|
+
password = project.findProperty("gpr.token") as String? ?: System.getenv("TOKEN_GITHUB")
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
publications {
|
|
357
|
+
create<MavenPublication>("shadow") {
|
|
358
|
+
project.extensions.configure<com.github.jengelman.gradle.plugins.shadow.ShadowExtension> {
|
|
359
|
+
artifactId = pluginId
|
|
360
|
+
component(this@create)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
java {
|
|
367
|
+
toolchain {
|
|
368
|
+
languageVersion.set(JavaLanguageVersion.of(11)) // Java 11 toolchain
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
kotlin {
|
|
373
|
+
jvmToolchain(11)
|
|
374
|
+
sourceSets.named("main") {
|
|
375
|
+
kotlin.srcDir(premiumLicenseSrcDir)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Both compileKotlin AND kaptGenerateStubsKotlin consume the generated sources, so wire
|
|
380
|
+
// the dependency on every Kotlin/kapt task that reads them. Plain `compileKotlin.dependsOn`
|
|
381
|
+
// alone makes Gradle 9 fail with implicit-dependency validation errors on kapt stubs.
|
|
382
|
+
tasks.matching { it.name == "compileKotlin" || it.name == "kaptGenerateStubsKotlin" }
|
|
383
|
+
.configureEach { dependsOn("generatePluginBuildConstants") }
|
|
384
|
+
|
|
385
|
+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
|
386
|
+
compilerOptions {
|
|
387
|
+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
|
|
388
|
+
}
|
|
389
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
pluginId=@@ID@@
|
|
2
|
+
pluginName=@@NAME@@
|
|
3
|
+
pluginDescription=@@NAME@@, a plugin for Pano.
|
|
4
|
+
pluginPanoVersion=local-build
|
|
5
|
+
|
|
6
|
+
# Where `./gradlew build` copies the jar: the plugins folder of your Pano (this plugin lives in it).
|
|
7
|
+
panoPluginsDir=..
|
|
8
|
+
|
|
9
|
+
# api-level: written into the jar by build.gradle.kts from the Pano it compiles against. The pinned Pano dependency does
|
|
10
|
+
# not carry the level yet, and without it Pano refuses the plugin ("needs API level 0"). Delete this line once the Pano
|
|
11
|
+
# dependency in build.gradle.kts carries the level (pano-api-level.properties inside its jar).
|
|
12
|
+
apiLevel=1
|
|
13
|
+
pluginClass=@@PACKAGE@@.@@CLASS@@Plugin
|
|
14
|
+
pluginDeveloper=@@AUTHOR@@
|
|
15
|
+
pluginLicense=MIT
|
|
16
|
+
pluginSourceUrl=
|
|
17
|
+
pluginDependencies=
|
|
18
|
+
pluginRequires=
|
|
19
|
+
|
|
20
|
+
# --- Freemium ------------------------------------------------------------------------
|
|
21
|
+
# Set to true to ship a freemium plugin: it installs and runs for free, and gates optional
|
|
22
|
+
# paid features on a tier bought from the store (Pro, Ultra …):
|
|
23
|
+
#
|
|
24
|
+
# if (hasTier("pro")) { enableProFeature() }
|
|
25
|
+
#
|
|
26
|
+
# The panel then shows a Freemium badge and embeds the store's package view on the addon
|
|
27
|
+
# detail page. Tiers are published by the store, not declared here.
|
|
28
|
+
#
|
|
29
|
+
# Mutually exclusive with the premium licensing below — a freemium plugin that calls
|
|
30
|
+
# requireLicense() fails startup on purpose.
|
|
31
|
+
pluginFreemium=false
|
|
32
|
+
|
|
33
|
+
# --- Premium plugin licensing ---------------------------------------------------------
|
|
34
|
+
# This template is FREE by default. To ship a premium plugin, build with one of:
|
|
35
|
+
# ./gradlew build -PlicenseServer=dev
|
|
36
|
+
# ./gradlew build -PlicenseServer=prod
|
|
37
|
+
# ./gradlew build -PlicenseServer=https://my.host
|
|
38
|
+
# ./gradlew build -PpanoLicensePublicKey=<base64>
|
|
39
|
+
# Or set env vars (same semantics as pano-web-platform premium plugins / CI):
|
|
40
|
+
# PANO_LICENSE_SERVER=dev|prod or full URL
|
|
41
|
+
# PANO_LICENSE_PUBLIC_KEY=<base64|PEM>
|
|
42
|
+
# Without any of these, the embedded public key is empty and
|
|
43
|
+
# PluginLicenseClient.requireValidLicense() is a no-op.
|
|
44
|
+
# The resourceId on panomc.com store is the same as pluginId (above).
|
|
45
|
+
# Premium forks: in GitHub Actions you can set PANO_LICENSE_SERVER on the Gradle build
|
|
46
|
+
# step (e.g. dev on `dev` branch, prod on `main`) — do not enable that for this free
|
|
47
|
+
# template repo unless you intend releases to require a license.
|
|
48
|
+
|
|
49
|
+
pf4jVersion=3.11.1
|
|
50
|
+
vertxVersion=4.5.7
|
|
51
|
+
gsonVersion=2.11.0
|
|
52
|
+
handlebarsVersion=4.4.0
|
|
53
|
+
springContextVersion=5.3.39
|
|
54
|
+
# GitHub organization or user that owns the repository (only used by the maven publication).
|
|
55
|
+
organization=@@ORG@@
|