Skip to content

Commit b505ea8

Browse files
committed
Implement hack for KGP ESM main file name bug
Closes #152
1 parent 51024ff commit b505ea8

File tree

28 files changed

+618
-1146
lines changed

28 files changed

+618
-1146
lines changed

.github/workflows/check.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
name: Check
2-
defaults:
3-
run:
2+
defaults:
3+
run:
44
shell: bash
55

6-
on:
6+
on:
77
workflow_dispatch:
88
workflow_call:
99

10-
jobs:
11-
check:
10+
jobs:
11+
check:
1212
name: Check on ubuntu-latest
1313
runs-on: ubuntu-latest
14-
env:
14+
env:
1515
GRADLE_OPTS: "-Dorg.gradle.daemon=true"
16-
steps:
16+
steps:
1717
- uses: actions/checkout@v3
1818

1919
- uses: actions/setup-java@v3
20-
with:
20+
with:
2121
distribution: 'adopt'
2222
java-version: 11
2323

2424
- name: Restore Gradle cache
2525
id: cache
2626
uses: actions/cache@v3
27-
with:
27+
with:
2828
path: |
2929
~/.gradle/caches
3030
~/.gradle/wrapper
@@ -51,7 +51,7 @@ jobs:
5151
5252
- uses: github/codeql-action/upload-sarif@v2
5353
if: ${{ always() }}
54-
with:
54+
with:
5555
sarif_file: ${{ github.workspace }}/detekt.sarif.json
5656
checkout_path: ${{ github.workspace }}
5757

@@ -60,30 +60,30 @@ jobs:
6060

6161
- uses: actions/upload-artifact@v3
6262
if: ${{ always() }}
63-
with:
63+
with:
6464
name: reports-${{ runner.os }}
6565
path: |
6666
**/build/reports
6767
6868
- name: Gradle Check Sandbox
6969
working-directory: sandbox
70-
run: ./gradlew check assemble pack publish --scan
70+
run: ../gradlew check assemble pack publish --scan
7171

7272
- uses: actions/upload-artifact@v3
7373
if: ${{ always() }}
74-
with:
74+
with:
7575
name: sandbox-${{ runner.os }}
7676
path: |
7777
sandbox/**/build/reports
7878
sandbox/**/build/publications
7979
8080
- name: Gradle Check Samples
8181
working-directory: samples
82-
run: ./gradlew check assemble pack publish --scan
82+
run: ../gradlew check assemble pack publish --scan
8383

8484
- uses: actions/upload-artifact@v3
8585
if: ${{ always() }}
86-
with:
86+
with:
8787
name: samples-${{ runner.os }}
8888
path: |
8989
samples/**/build/reports
@@ -103,7 +103,7 @@ jobs:
103103

104104
- uses: actions/upload-artifact@v3
105105
if: ${{ always() }}
106-
with:
106+
with:
107107
name: ts-consumer-${{ runner.os }}
108108
path: |
109109
sandbox/ts-consumer/build
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
name: Publish Sandbox to GitHub Packages
2-
on:
3-
workflow_dispatch:
4-
inputs:
5-
version:
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
66
required: true
77
description: Package version to publish under
8-
sandbox-module:
8+
sandbox-module:
99
required: false
1010
default: both
1111
description: Sandbox module to publish
12-
jobs:
13-
publish:
12+
jobs:
13+
publish:
1414
runs-on: ubuntu-latest
15-
permissions:
15+
permissions:
1616
contents: read
1717
packages: write
18-
steps:
18+
steps:
1919
- uses: actions/checkout@v3
2020

2121
- name: Restore Gradle cache
2222
id: cache
2323
uses: actions/cache@v3
24-
with:
24+
with:
2525
path: |
2626
~/.gradle/caches
2727
~/.gradle/wrapper
@@ -33,15 +33,15 @@ jobs:
3333
3434
- name: Set up JDK
3535
uses: actions/setup-java@v3
36-
with:
36+
with:
3737
java-version: 11
3838
distribution: 'adopt'
3939

4040
- name: Publish
4141
working-directory: sandbox
4242
run: |
4343
VERSION=${VERSION:=${{ github.event.inputs.version }}}
44-
./gradlew :${{ github.event.inputs.sandbox-module }}:publishJsNpmPublicationToGitHub \
45-
-Pnpm.publish.repository.GitHub.authToken="${{ github.token }}" \
46-
-Pnpm.publish.version=${VERSION/v} \
47-
-Pnpm.publish.organization=${{ github.repository_owner }}
44+
../gradlew :${{ github.event.inputs.sandbox-module }}:publishJsNpmPublicationToGitHub \
45+
-Pnpm.publish.repository.GitHub.authToken="${{ github.token }}" \
46+
-Pnpm.publish.version=${VERSION/v} \
47+
-Pnpm.publish.organization=${{ github.repository_owner }}

CHANGELOG.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
### Verified Versions
13+
14+
- Kotlin: 1.9.22
15+
- Gradle: 8.5
16+
- JDK: 11
17+
18+
### Added
19+
20+
### Changed
21+
22+
### Removed
23+
24+
---
25+
26+
## [3.4.2]
27+
1228
This is a maintenance release with a few minor bugfixes.
1329

1430
### Verified Versions
1531

32+
- Kotlin: 1.9.22
33+
- Gradle: 8.5
34+
- JDK: 11
35+
36+
### Added
37+
38+
### Changed
39+
40+
- Upgraded dependencies
41+
- Switched out `com.netflix.nebula.node` plugin hook for node autoconfig to `com.github.node-gradle.node` plugin which
42+
it depends on
43+
- Implemented a patch for older KGP users to remedy https://youtrack.jetbrains.com/issue/KT-59523 when using ESM
44+
45+
### Removed
46+
47+
---
48+
49+
## [3.4.1]
50+
51+
### Verified Versions
52+
1653
- Kotlin: 1.9.0
1754
- Gradle: 8.2.1
1855
- JDK: 11
1956

2057
### Added
2158

59+
- Utility DSL to set NpmRegistry::uri via Provider<String>
60+
2261
### Changed
2362

63+
- Added trailing slashes to npmjs and github registry convenience DSL URIs
64+
- Fixed configuration cache issues with Boolean property chains
65+
2466
### Removed
2567

2668
---
@@ -406,7 +448,9 @@ This is a maintenance release with a few minor bugfixes.
406448

407449
---
408450

409-
[Unreleased]: https://github.com/mpetuska/npm-publish/compare/3.4.1...HEAD
451+
[Unreleased]: https://github.com/mpetuska/npm-publish/compare/3.4.2...HEAD
452+
453+
[3.4.2]: https://github.com/mpetuska/npm-publish/compare/3.4.1...3.4.2
410454

411455
[3.4.1]: https://github.com/mpetuska/npm-publish/compare/3.4.0...3.4.1
412456

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ tasks:
2626

2727
```kotlin title="build.gradle.kts"
2828
plugins {
29-
id("dev.petuska.npm.publish") version "<VERSION>"
30-
kotlin("multiplatform") version "<VERSION>>" // Optional, also supports "js"
29+
id("dev.petuska.npm.publish") version "<VERSION>"
30+
kotlin("multiplatform") version "<VERSION>>" // Optional, also supports "js"
3131
}
3232

3333
kotlin {
34-
js(IR) {
35-
binaries.library()
36-
browser() // or nodejs()
37-
}
34+
js(IR) {
35+
binaries.library()
36+
browser() // or nodejs()
37+
}
3838
}
3939

4040
npmPublish {
41-
registries {
42-
register("npmjs") {
43-
uri.set("https://registry.npmjs.org")
44-
authToken.set("obfuscated")
41+
registries {
42+
register("npmjs") {
43+
uri.set("https://registry.npmjs.org")
44+
authToken.set("obfuscated")
45+
}
4546
}
46-
}
4747
}
4848
```
4949

build-conventions/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id("com.gradle.enterprise") version "3.14"
2+
id("com.gradle.enterprise") version "+"
33
}
44

55
@Suppress("UnstableApiUsage")

build.gradle.kts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ plugins {
55
id("convention.git-hooks")
66
}
77

8-
nexusPublishing.repositories {
9-
sonatype {
10-
nexusUrl by uri("https://s01.oss.sonatype.org/service/local/")
11-
snapshotRepositoryUrl by uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
8+
nexusPublishing {
9+
repositories {
10+
sonatype {
11+
nexusUrl by uri("https://s01.oss.sonatype.org/service/local/")
12+
snapshotRepositoryUrl by uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
13+
}
1214
}
1315
}
1416

gradle/libs.versions.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[versions]
2-
detekt = "1.23.0"
3-
dokka = "1.8.20"
2+
detekt = "1.23.4"
3+
dokka = "1.9.10"
44
java = "11"
5-
junit-jupiter = "5.10.0"
6-
kotest = "5.6.2"
7-
kotlin = "1.9.0"
5+
junit-jupiter = "5.10.1"
6+
kotest = "5.8.0"
7+
kotlin = "1.9.22"
88

99
[libraries]
1010
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
@@ -16,7 +16,7 @@ plugin-container-tasks = "dev.petuska:container-tasks-gradle-plugin:0.0.4"
1616
plugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
1717
plugin-git-hooks = "com.github.jakemarsden:git-hooks-gradle-plugin:0.0.2"
1818
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
19-
plugin-nebula-node = "com.netflix.nebula:nebula-node-plugin:3.0.0"
19+
plugin-node-gradle = "com.github.node-gradle:gradle-node-plugin:7.0.1"
2020
plugin-versions = "com.github.ben-manes:gradle-versions-plugin:0.47.0"
2121
plugin-versions-update = "nl.littlerobots.vcu:plugin:0.8.1"
2222

@@ -29,4 +29,4 @@ kotest-assertions = [
2929
[plugins]
3030
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
3131
nexus-publish = "io.github.gradle-nexus.publish-plugin:1.3.0"
32-
plugin-publish = "com.gradle.plugin-publish:1.2.0"
32+
plugin-publish = "com.gradle.plugin-publish:1.2.1"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

npm-publish-gradle-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ kotlin {
1717
explicitApi()
1818
dependencies {
1919
compileOnly(libs.plugin.kotlin)
20-
compileOnly(libs.plugin.nebula.node)
20+
compileOnly(libs.plugin.node.gradle)
2121

2222
testImplementation(libs.plugin.kotlin)
2323
}

npm-publish-gradle-plugin/src/main/kotlin/NpmPublishPlugin.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dev.petuska.npm.publish
22

3-
import com.moowork.gradle.node.task.SetupTask
3+
import com.github.gradle.node.task.NodeSetupTask
44
import dev.petuska.npm.publish.config.configure
55
import dev.petuska.npm.publish.extension.NpmPublishExtension
66
import dev.petuska.npm.publish.task.NodeExecTask
@@ -28,11 +28,10 @@ public class NpmPublishPlugin : Plugin<Project> {
2828
override fun apply(project: Project): Unit = with(project) {
2929
val extension = extensions.create(NpmPublishExtension.NAME, NpmPublishExtension::class.java)
3030
configure(extension)
31-
pluginManager.withPlugin(NEBULA_NODE_PLUGIN) {
32-
val nebulaNodeHome = project.tasks.named<SetupTask>(SetupTask.NAME)
33-
.map { it.takeIf { it.enabled }.unsafeCast<SetupTask>() }
34-
.map(SetupTask::getNodeDir)
35-
.let(layout::dir)
31+
pluginManager.withPlugin(NODE_GRADLE_PLUGIN) {
32+
val nebulaNodeHome = project.tasks.named<NodeSetupTask>(NodeSetupTask.NAME)
33+
.map { it.takeIf { it.enabled }.unsafeCast<NodeSetupTask>() }
34+
.flatMap(NodeSetupTask::nodeDir)
3635
extension.nodeHome.convention(
3736
sysProjectEnvPropertyConvention(
3837
name = "nodeHome",
@@ -87,6 +86,6 @@ public class NpmPublishPlugin : Plugin<Project> {
8786
private companion object {
8887
private const val KOTLIN_JS_PLUGIN = "org.jetbrains.kotlin.js"
8988
private const val KOTLIN_MPP_PLUGIN = "org.jetbrains.kotlin.multiplatform"
90-
private const val NEBULA_NODE_PLUGIN = "com.netflix.nebula.node"
89+
private const val NODE_GRADLE_PLUGIN = "com.github.node-gradle.node"
9190
}
9291
}

0 commit comments

Comments
 (0)