KT-34468 Yarn. Support dependency GitHub version
This commit is contained in:
committed by
Ilya Goncharov
parent
afb8ff1dd5
commit
c2b3dd8b33
+4
-3
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
|||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmApi
|
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmApi
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency
|
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution
|
import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLock.Companion.dependencyKey
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class YarnBasics : NpmApi {
|
abstract class YarnBasics : NpmApi {
|
||||||
@@ -99,7 +100,7 @@ abstract class YarnBasics : NpmApi {
|
|||||||
) {
|
) {
|
||||||
val yarnLock = nodeWorkDir.resolve("yarn.lock")
|
val yarnLock = nodeWorkDir.resolve("yarn.lock")
|
||||||
if (yarnLock.isFile) {
|
if (yarnLock.isFile) {
|
||||||
val byKey = YarnLock.parse(yarnLock).entries.associateBy { it.key }
|
val byKey = YarnLock.parse(yarnLock).entries.associateBy { it.dependencyKey }
|
||||||
val visited = mutableMapOf<NpmDependency, NpmDependency>()
|
val visited = mutableMapOf<NpmDependency, NpmDependency>()
|
||||||
|
|
||||||
fun resolveRecursively(src: NpmDependency): NpmDependency {
|
fun resolveRecursively(src: NpmDependency): NpmDependency {
|
||||||
@@ -112,10 +113,10 @@ abstract class YarnBasics : NpmApi {
|
|||||||
}
|
}
|
||||||
visited[src] = src
|
visited[src] = src
|
||||||
|
|
||||||
val key = YarnLock.key(src.key, src.version)
|
val key = dependencyKey(src.key, src.version)
|
||||||
val deps = byKey[key]
|
val deps = byKey[key]
|
||||||
?: if (src.version == "*") byKey.entries
|
?: if (src.version == "*") byKey.entries
|
||||||
.firstOrNull { it.key.startsWith(YarnLock.key(src.key, "")) }
|
.firstOrNull { it.key.startsWith(dependencyKey(src.key, "")) }
|
||||||
?.value
|
?.value
|
||||||
else null
|
else null
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -25,7 +25,10 @@ data class YarnLock(val entries: List<Entry>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun key(packageKey: String, version: String) = "$packageKey@$version"
|
val Entry.dependencyKey: String
|
||||||
|
get() = key.replace("@github:", "@")
|
||||||
|
|
||||||
|
fun dependencyKey(packageKey: String, version: String) = "$packageKey@$version"
|
||||||
|
|
||||||
private class Node(val parent: Node?, val value: String? = null) {
|
private class Node(val parent: Node?, val value: String? = null) {
|
||||||
var indent: String? = null
|
var indent: String? = null
|
||||||
|
|||||||
Reference in New Issue
Block a user