Skip to content

Commit 78e2dbe

Browse files
committedNov 17, 2021
lck JS deps
1 parent f103861 commit 78e2dbe

File tree

2 files changed

+3762
-1
lines changed

2 files changed

+3762
-1
lines changed
 

‎build.gradle.kts

+69-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ version = "1.4.0-SNAPSHOT"
1111

1212
java.sourceCompatibility = JavaVersion.VERSION_1_8
1313

14+
15+
16+
1417
idea {
1518
module {
1619
isDownloadSources = true
@@ -290,4 +293,69 @@ publishing {
290293
}
291294
}
292295
}
293-
}
296+
}
297+
298+
299+
300+
/*******FIX JS DEPS******** https://blog.jetbrains.com/kotlin/2021/10/control-over-npm-dependencies-in-kotlin-js/ *****/
301+
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) {
302+
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().disableGranularWorkspaces()
303+
}
304+
tasks.register("backupYarnLock") {
305+
dependsOn(":kotlinNpmInstall")
306+
307+
doLast {
308+
copy {
309+
from("$rootDir/build/js/yarn.lock")
310+
rename { "yarn.lock.bak" }
311+
into(rootDir)
312+
}
313+
}
314+
315+
inputs.file("$rootDir/build/js/yarn.lock").withPropertyName("inputFile")
316+
outputs.file("$rootDir/yarn.lock.bak").withPropertyName("outputFile")
317+
}
318+
319+
val restoreYarnLock = tasks.register("restoreYarnLock") {
320+
doLast {
321+
copy {
322+
from("$rootDir/yarn.lock.bak")
323+
rename { "yarn.lock" }
324+
into("$rootDir/build/js")
325+
}
326+
}
327+
328+
inputs.file("$rootDir/yarn.lock.bak").withPropertyName("inputFile")
329+
outputs.file("$rootDir/build/js/yarn.lock").withPropertyName("outputFile")
330+
}
331+
332+
tasks.named("kotlinNpmInstall").configure {
333+
dependsOn(restoreYarnLock)
334+
}
335+
336+
tasks.register("validateYarnLock") {
337+
dependsOn(":kotlinNpmInstall")
338+
339+
doLast {
340+
val expected = file("$rootDir/yarn.lock.bak").readText()
341+
val actual = file("$rootDir/build/js/yarn.lock").readText()
342+
343+
if (expected != actual) {
344+
throw AssertionError(
345+
"Generated yarn.lock differs from the one in the repository. " +
346+
"It can happen because someone has updated a dependency and haven't run `./gradlew :backupYarnLock --refresh-dependencies` " +
347+
"afterwards."
348+
)
349+
}
350+
}
351+
352+
inputs.files("$rootDir/yarn.lock.bak", "$rootDir/build/js/yarn.lock").withPropertyName("inputFiles")
353+
}
354+
355+
allprojects {
356+
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask> {
357+
args += "--ignore-scripts"
358+
}
359+
}
360+
361+
/**********************************************************************************************************************/

0 commit comments

Comments
 (0)
Please sign in to comment.