Skip to content

Commit

Permalink
Fix Boolean property chaining
Browse files Browse the repository at this point in the history
Closes #145
  • Loading branch information
mpetuska committed Jul 24, 2023
1 parent 15a7ebc commit 51024ff
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 31 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ This is a maintenance release with a few minor bugfixes.

---

## [3.4.1]

### Verified Versions

- Kotlin: 1.9.0
- Gradle: 8.2.1
- JDK: 11

### Added

- Utility DSL to set NpmRegistry::uri via Provider<String>

### Changed

- Added trailing slashes to npmjs and github registry convenience DSL URIs
- Fixed configuration cache issues with Boolean property chains

### Removed

---

## [3.4.0]

This is a maintenance release with a few minor bugfixes.
Expand Down Expand Up @@ -385,7 +406,9 @@ This is a maintenance release with a few minor bugfixes.

---

[Unreleased]: https://github.com/mpetuska/npm-publish/compare/3.4.0...HEAD
[Unreleased]: https://github.com/mpetuska/npm-publish/compare/3.4.1...HEAD

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

[3.4.0]: https://github.com/mpetuska/npm-publish/compare/3.3.1...3.4.0

Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
detekt = "1.23.0"
dokka = "1.8.20"
java = "11"
junit-jupiter = "5.9.3"
junit-jupiter = "5.10.0"
kotest = "5.6.2"
kotlin = "1.9.0"

Expand All @@ -22,8 +22,8 @@ plugin-versions-update = "nl.littlerobots.vcu:plugin:0.8.1"

[bundles]
kotest-assertions = [
"kotest-assertions-core",
"kotest-assertions-json",
"kotest-assertions-core",
"kotest-assertions-json",
]

[plugins]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal fun Project.configure(registry: NpmRegistry) {
registry.otp.convention(sysProjectEnvPropertyConvention(prefix + "otp"))
registry.authToken.convention(sysProjectEnvPropertyConvention(prefix + "authToken"))
registry.dry.convention(
sysProjectEnvPropertyConvention(prefix + "dry", extension.dry.map(Boolean::toString)).map { it.notFalse() }
sysProjectEnvPropertyConvention(prefix + "dry", extension.dry.map(Boolean?::toString)).map { it.notFalse() }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public abstract class NpmPublishExtension : WithGradleFactories(), ExtensionAwar
public fun NpmRegistries.npmjs(action: Action<NpmRegistry>): NamedDomainObjectProvider<NpmRegistry> {
val name = "npmjs"
val config: NpmRegistry.() -> Unit = {
uri.set(URI("https://registry.npmjs.org"))
uri.set(URI("https://registry.npmjs.org/"))
action.execute(this)
}
return if (names.contains(name)) named(name, config) else register(name, config)
Expand All @@ -135,7 +135,7 @@ public abstract class NpmPublishExtension : WithGradleFactories(), ExtensionAwar
public fun NpmRegistries.github(action: Action<NpmRegistry>): NamedDomainObjectProvider<NpmRegistry> {
val name = "github"
val config: NpmRegistry.() -> Unit = {
uri.set(URI("https://npm.pkg.github.com"))
uri.set(URI("https://npm.pkg.github.com/"))
action.execute(this)
}
return if (names.contains(name)) named(name, config) else register(name, config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dev.petuska.npm.publish.util.NamedInput
import dev.petuska.npm.publish.util.NpmPublishDsl
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import java.net.URI
Expand Down Expand Up @@ -65,6 +66,14 @@ public abstract class NpmRegistry : NamedInput {
set(URI(uri))
}

/**
* Convenience DSL to set [URI] properties via [Provider]<[String]>
* @param uri to use when constructing [URI] instance
*/
public fun Property<URI>.set(uri: Provider<String>) {
set(uri.map(::URI))
}

init {
access.convention(NpmAccess.PUBLIC)
dry.convention(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public abstract class NpmPublishTask : NpmExecTask() {
if (reg.authToken.isPresent) add("--//$repo:_authToken=${reg.authToken.get()}")
if (d) add("--dry-run")
if (tag.isPresent) add("--tag=${tag.get()}")
// add("${uri.scheme.trim()}://$repo")
}
npmExec(args) { it.workingDir(packageDir.get()) }.rethrowFailure()
if (!d) info { "Published package at $pDir to ${reg.name} registry" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private const val GLOBAL_PREFIX: String = "npm.publish."
* Convention resolution order by descending priority
* 1. CLI arguments (`--arg=value`)
* 2. System properties (`-Dprop=value`)
* 3. Gradle properties (`-Pprop=value`,
* 3. Gradle's properties (`-Pprop=value`,
* `ORG_GRADLE_PROJECT_prop=value` env variable,
* `-Dorg.gradle.project.prop=value` system property
* or `prop=value` stored in `gradle.properties` file)
Expand All @@ -26,7 +26,6 @@ internal fun Project.sysProjectEnvPropertyConvention(
): Provider<String> {
val propName = GLOBAL_PREFIX + name
val envName = name.uppercase(Locale.getDefault()).replace(".", "_")

return providers.systemProperty(propName)
.orElse(providers.provider { extensions.extraProperties.properties[propName]?.toString() })
.orElse(providers.gradleProperty(propName))
Expand Down
6 changes: 3 additions & 3 deletions samples/local-ts-consumer/ts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==

"@types/node@^18.0.0":
version "18.16.19"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.19.tgz#cb03fca8910fdeb7595b755126a8a78144714eea"
integrity sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==
version "18.17.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.0.tgz#35d44267a33dd46b49ee0f73d31b05fd7407e290"
integrity sha512-GXZxEtOxYGFchyUzxvKI14iff9KZ2DI+A6a37o6EQevtg6uO9t+aUZKcaC1Te5Ng1OnLM7K9NVVj+FbecD9cJg==

acorn-walk@^8.1.1:
version "8.2.0"
Expand Down
36 changes: 18 additions & 18 deletions sandbox/ts-consumer/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"@jridgewell/trace-mapping" "0.3.9"

"@jridgewell/resolve-uri@^3.0.3":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
version "3.1.1"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721"
integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==

"@jridgewell/sourcemap-codec@^1.4.10":
version "1.4.14"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==
version "1.4.15"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==

"@jridgewell/[email protected]":
version "0.3.9"
Expand Down Expand Up @@ -62,24 +62,24 @@
integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==

"@tsconfig/node16@^1.0.2":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e"
integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9"
integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==

"@types/node@^18.0.0":
version "18.16.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.3.tgz#6bda7819aae6ea0b386ebc5b24bdf602f1b42b01"
integrity sha512-OPs5WnnT1xkCBiuQrZA4+YAV4HEJejmHneyraIaxsbev5yCEr6KMwINNFP9wQeFIw8FWcoTqF3vQsa5CDaI+8Q==
version "18.17.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.0.tgz#35d44267a33dd46b49ee0f73d31b05fd7407e290"
integrity sha512-GXZxEtOxYGFchyUzxvKI14iff9KZ2DI+A6a37o6EQevtg6uO9t+aUZKcaC1Te5Ng1OnLM7K9NVVj+FbecD9cJg==

acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==

acorn@^8.4.1:
version "8.8.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73"
integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==
version "8.10.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==

arg@^4.1.0:
version "4.1.3"
Expand Down Expand Up @@ -176,9 +176,9 @@ ts-node@^10.1.0:
yn "3.1.1"

typescript@^5.0.0:
version "5.0.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==

v8-compile-cache-lib@^3.0.1:
version "3.0.1"
Expand Down

0 comments on commit 51024ff

Please sign in to comment.