Skip to content

Commit 8f6f839

Browse files
committed
Fixed yarn install on CI
1 parent 7f86ae7 commit 8f6f839

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

build.gradle.kts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,43 +66,49 @@ if (kotlinVersion != kotlinGPVersion) {
6666
error("KGP version mismatch. Project version: $kotlinVersion, KGP version: $kotlinGPVersion")
6767
}
6868

69-
val isCI = System.getenv("TEAMCITY_VERSION") != null
70-
val localYarnUpdate = providers.gradleProperty("kotlinx.rpc.localYarnUpdate")
71-
7269
val executeNpmLogin by tasks.registering {
70+
val isCI = System.getenv("TEAMCITY_VERSION") != null
71+
val localYarnUpdate = project.providers.gradleProperty("kotlinx.rpc.localYarnUpdate")
72+
73+
if (!isCI && localYarnUpdate.orNull?.toBooleanStrictOrNull() != true) {
74+
return@registering
75+
}
76+
7377
val registryUrl = "https://packages.jetbrains.team/npm/p/krpc/build-deps/"
7478

7579
// To prevent leaking of credentials in VCS on dev machine use the build directory config file
7680
val buildYarnConfigFile = File(project.rootDir, "build/js/.yarnrc")
77-
val buildYarnYmlConfigFile = File(project.rootDir, "build/js/.yarnrc.yml")
81+
val buildNpmConfigFile = File(project.rootDir, "build/js/.npmrc")
7882

79-
doLast {
80-
val spacePassword: String = getSpacePassword()
81-
82-
if (!isCI && localYarnUpdate.orNull?.toBooleanStrictOrNull() != true) {
83-
return@doLast
84-
}
83+
val spacePassword: String = project.getSpacePassword()
8584

85+
doLast {
8686
if (spacePassword.split(".").size != 3) {
8787
error("Unexpected Space Token format")
8888
}
8989

90-
val outputYarnYmlText = """
91-
npmRegistryServer: \"$registryUrl\"
92-
npmAlwaysAuth: true
93-
npmAuthToken: "$spacePassword"
90+
val outputYarnText = """
91+
registry: "$registryUrl"
92+
""".trimIndent()
93+
94+
val outputNpmText = """
95+
registry: "$registryUrl"
96+
always-auth: true
97+
${registryUrl.removePrefix("https:")}:_authToken=$spacePassword
9498
""".trimIndent()
9599

96100
buildYarnConfigFile.createNewFile()
97-
buildYarnConfigFile.writeText("registry: $registryUrl")
98-
buildYarnYmlConfigFile.createNewFile()
99-
buildYarnYmlConfigFile.writeText(outputYarnYmlText)
101+
buildYarnConfigFile.writeText(outputYarnText)
102+
buildNpmConfigFile.createNewFile()
103+
buildNpmConfigFile.writeText(outputNpmText)
100104
}
101105

102106
outputs.file(buildYarnConfigFile).withPropertyName("buildOutputYarnFile")
103-
outputs.file(buildYarnYmlConfigFile).withPropertyName("buildOutputYarnYmlFile")
107+
outputs.file(buildNpmConfigFile).withPropertyName("buildOutputNpmFile")
104108
}
105109

110+
val isCI = System.getenv("TEAMCITY_VERSION") != null
111+
106112
plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class.java).configureEach {
107113
rootProject.extensions.configure(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension::class.java) {
108114
download = true

0 commit comments

Comments
 (0)