Skip to content

Commit

Permalink
Versions upgrade and sandbox cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetuska committed Jul 21, 2021
1 parent ddb09cb commit 23a359d
Show file tree
Hide file tree
Showing 34 changed files with 312 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ local.properties
apiDiff.api
public/
node_modules
*.log
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# v2.0.4
## Versions
* Kotlin: 1.5.21
* Gradle: 7.1.1
* JDK: 11

## Changes
* Updated versions
* Dynamic version ranges for increased compatibility
* Fixed a bug that always expected version to be a string
* Removed some duplicated code in sandbox
* New sandbox module to check that plugin can work with both, nodejs() and browser() flavours at the same time
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Gradle plugin enabling NPM publishing (essentially `maven-publish` for NPM packages). Integrates seamlessly with
Kotlin/JS/MPP plugin if applied, providing auto configurations.

> The plugin was last tested with `JDK 11`, `Kotlin 1.5.10` & `Gradle 7.0.2`
> The plugin was last tested with `JDK 11`, `Kotlin 1.5.21` & `Gradle 7.1.1`
## Setup

Expand All @@ -26,7 +26,7 @@ tasks:
```kotlin
plugins {
id("dev.petuska.npm.publish") version "<VERSION>"
kotlin("multiplatform") version "1.4.32" // Optional, also supports "js"
kotlin("multiplatform") version "1.5.21" // Optional, also supports "js"
}

kotlin {
Expand Down Expand Up @@ -228,7 +228,7 @@ This ensures that any given dependency does not appear in multiple dependency sc

## Known Issues

* [#6435](https://github.com/npm/npm/issues/6435): npm and yarn tries to download bundled dependencies. Can be overcome
* [#6435](https://github.com/npm/npm/issues/6435): (Only applies to legacy backend) npm and yarn tries to download bundled dependencies. Can be overcome
for npm (sadly not yarn) with `shrinkwrapBundledDependencies` option. Note that it works fine for both package
managers when installing from a tarball. Bug [#2143](https://github.com/npm/cli/issues/2143) on the new npm repo, so
please vote for that to get it fixed. Bug [#8436](https://github.com/yarnpkg/yarn/issues/8436) on the yarn repo, so
Expand Down
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ gradleEnterprise {
gitHooks {
setHooks(
mapOf(
"post-checkout" to "ktlintApplyToIdea",
"pre-commit" to "ktlintFormat",
"pre-push" to "check"
"pre-push" to "ktlintCheck"
)
)
}
Expand Down
10 changes: 2 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
# The following property is required to mitigate issue https://github.com/gradle/gradle/issues/11412.
systemProp.org.gradle.internal.publish.checksums.insecure=true
kotlin.code.style=official
kotlin.parallel.tasks.in.project=true
kotlin.js.generate.externals=false
kotlin.js.compiler=ir
kotlin.incremental.js=true
kotlin.mpp.stability.nowarn=true
kotlin.stdlib.default.dependency=false
org.gradle.project.sourceCompatibility=11
org.gradle.vfs.watch=true
org.gradle.parallel=true

version=0.0.0
group=dev.petuska
#publish.all=true
#publish.GitHub=true
#publish.Bintray=true
#publish.skip.all=true
#publish.skip.GitLab=true
#publish.skip.Bintray=true
group=dev.petuska
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
43 changes: 43 additions & 0 deletions sandbox/both/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
kotlin("js")
id("dev.petuska.npm.publish")
}

kotlin {
js {
nodejs()
browser()
useCommonJs()
binaries.library()
}
dependencies {
implementation(npm("axios", "*"))
api(devNpm("snabbdom", "*"))
implementation("io.ktor:ktor-client-core:_")
}
sourceSets {
all {
languageSettings.useExperimentalAnnotation("kotlin.js.ExperimentalJsExport")
}
}
}

npmPublishing {
organization = group as String

publications {
named("js") {
packageJsonTemplateFile = projectDir.resolve("../template.package.json")
packageJson {
author { name = "Martynas Petuška" }
}
}
}
repositories {
repository("GitLab") {
registry = uri("https://gitlab.com/api/v4/projects/${System.getenv("CI_PROJECT_ID")?.trim()}/packages/npm")
authToken = System.getenv("PRIVATE_TOKEN")?.trim() ?: ""
}
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package test.sandbox

import kotlin.js.JsExport
import io.ktor.http.HttpMethod

@JsExport
fun direct() {
println("Ktor method: ${HttpMethod.Get}")
}

@JsExport
fun sayHello(name: Name = "Mr. PP Trump"): Name = "Hello from $name".also { println(it) }
Expand All @@ -17,7 +22,3 @@ external interface Person {
val name: String
val sureName: String
}

fun main() {
println("Hey")
}
File renamed without changes.
2 changes: 1 addition & 1 deletion sandbox/browser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin {
dependencies {
implementation(npm("axios", "*"))
api(devNpm("snabbdom", "*"))
implementation("io.ktor:ktor-client-core:1.4.1")
implementation("io.ktor:ktor-client-core:_")
}
sourceSets {
all {
Expand Down
1 change: 1 addition & 0 deletions sandbox/browser/src
13 changes: 0 additions & 13 deletions sandbox/browser/src/main/kotlin/test/sandbox/index.kt

This file was deleted.

5 changes: 3 additions & 2 deletions sandbox/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("multiplatform") version "1.5.10" apply false
kotlin("multiplatform") apply false
id("dev.petuska.npm.publish") version "0.0.0"
}

Expand All @@ -17,7 +17,8 @@ npmPublishing {
organization = group as String
publications {
publication("custom") {
nodeJsDir = file("${System.getProperty("user.home")}/.gradle/nodejs/node-v12.16.1-linux-x64")
nodeJsDir = file("${System.getProperty("user.home")}/.gradle/nodejs").listFiles()?.find { it.name.startsWith("node") }
packageJsonTemplateFile = rootDir.resolve("template.package.json")
packageJson {
author to "Custom Author"
keywords = jsonArray(
Expand Down
1 change: 1 addition & 0 deletions sandbox/gradle
3 changes: 2 additions & 1 deletion sandbox/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
kotlin.mpp.stability.nowarn=true
org.gradle.vfs.watch=true
npm.publish.dry=true
org.gradle.parallel=true
npm.publish.dry=false
kotlin.js.compiler=ir
2 changes: 1 addition & 1 deletion sandbox/mpp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ kotlin {
sourceSets {
all {
dependencies {
implementation("io.ktor:ktor-client-core:1.4.1")
implementation("io.ktor:ktor-client-core:_")
implementation(devNpm("axios", "*"))
api(npm("snabbdom", "*"))
}
Expand Down
1 change: 1 addition & 0 deletions sandbox/mpp/src/commonMain/kotlin
1 change: 1 addition & 0 deletions sandbox/mpp/src/commonMain/resources
Empty file.
10 changes: 0 additions & 10 deletions sandbox/mpp/src/commonMain/resources/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion sandbox/node/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin {
dependencies {
implementation(npm("axios", "*"))
api(devNpm("snabbdom", "*"))
implementation("io.ktor:ktor-client-core:1.4.1")
implementation("io.ktor:ktor-client-core:_")
}
sourceSets {
all {
Expand Down
1 change: 1 addition & 0 deletions sandbox/node/src
13 changes: 0 additions & 13 deletions sandbox/node/src/main/kotlin/test/sandbox/index.kt

This file was deleted.

Empty file.
10 changes: 0 additions & 10 deletions sandbox/node/src/main/resources/index.html

This file was deleted.

10 changes: 7 additions & 3 deletions sandbox/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
rootProject.name = "sandbox"
pluginManagement {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("de.fayard.refreshVersions") version "0.10.1"
id("com.gradle.enterprise") version "3.6.3"
}

include(":node", ":browser", ":mpp")
rootProject.name = "sandbox"

include(":node", ":browser", ":both", ":mpp")
includeBuild("../") {
dependencySubstitution {
substitute(module("dev.petuska:npm-publish")).with(project(":"))
substitute(module("dev.petuska.npm.publish:dev.petuska.npm.publish.gradle.plugin")).with(project(":"))
}
}

22 changes: 22 additions & 0 deletions sandbox/ts-consumer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@dev.petuska/ts-consumer",
"main": "src/insex.ts",
"version": "0.0.0",
"license": "Apache-2.0",
"scripts": {
"clean": "rm -rf node_modules/@dev.petuska",
"start": "ts-node src/index.ts"
},
"dependencies": {
"@dev.petuska/both": "file:../both/build/publications/npm/dev.petuska-both-0.0.0.tgz",
"@dev.petuska/browser": "file:../browser/build/publications/npm/dev.petuska-browser-0.0.0.tgz",
"@dev.petuska/mpp-browser": "file:../mpp/build/publications/npm/dev.petuska-mpp-browser-0.0.0.tgz",
"@dev.petuska/mpp-node": "file:../mpp/build/publications/npm/dev.petuska-mpp-node-0.0.0.tgz",
"@dev.petuska/node": "file:../node/build/publications/npm/dev.petuska-node-0.0.0.tgz"
},
"devDependencies": {
"@types/node": "^16.4.0",
"ts-node": "^10.1.0",
"typescript": "^4.3.5"
}
}
11 changes: 11 additions & 0 deletions sandbox/ts-consumer/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import both from '@dev.petuska/both'
import browser from '@dev.petuska/browser'
import node from '@dev.petuska/node'
import mppBrowser from '@dev.petuska/mpp-browser'
import mppNode from '@dev.petuska/mpp-node'

both.test.sandbox.sayFormalHello({name: 'Both', sureName: 'Simple'})
browser.test.sandbox.sayFormalHello({name: 'Browser', sureName: 'Simple'})
node.test.sandbox.sayFormalHello({name: 'Node', sureName: 'Simple'})
mppBrowser.test.sandbox.sayFormalHello({name: 'Browser', sureName: 'MPP'})
mppNode.test.sandbox.sayFormalHello({name: 'Node', sureName: 'MPP'})
Loading

0 comments on commit 23a359d

Please sign in to comment.