Skip to content

Commit 18cead6

Browse files
committed
Minor fixes
Update yarn -> npm
1 parent 392f100 commit 18cead6

File tree

12 files changed

+9620
-5137
lines changed

12 files changed

+9620
-5137
lines changed

.idea/kotlinx-rpc.iml

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler-plugin/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ org.gradle.configuration-cache=true
1919
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
2020
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
2121

22+
# https://youtrack.jetbrains.com/issue/KT-78504
23+
kotlin.js.yarn=false
24+
2225
# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
2326
kotlinx.rpc.plugin.internalDevelopment=true
2427

docs/environment.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,27 @@ Here is a 'simple' guide for solving problems:
363363
- Try different IDE version (last resort)
364364
- Docker
365365
- `Cannot connect to the Docker daemon` - open `Docker Desktop`
366+
- Kotlin/Js or Kotlin/Wasm
367+
- `kotlinUpgradePackageLock` or `kotlinWasmUpgradePackageLock` (and also `kotlinNpmInstall` or `kotlinWasmNpmInstall`)
368+
have a funny tendency to fail sometimes, and you don't know why.
369+
I'll tell you!
370+
We use proxy repos, and sometimes dependencies get downloaded from the wrong source.
371+
Make sure ALL urls in `package-lock.json` files start with `https://packages.jetbrains.team/npm/p/krpc/build-deps/`.
372+
If something doesn't work, your steps are:
373+
- Delete `package-lock.json` file
374+
- Delete `<REPO_ROOT>/build/js` / `<REPO_ROOT>/build/wasm`
375+
- Run `kotlinUpgradePackageLock` / `kotlinWasmUpgradePackageLock`
376+
- If the problem persists:
377+
- Check that `<REPO_ROOT>/build/<target>/.npmrc` AND `<REPO_ROOT>/build/<target>/.yarnrc` are present
378+
- Check that `.yarnrc` contains one line: `registry: "https://packages.jetbrains.team/npm/p/krpc/build-deps/"`
379+
- Check that `.npmrc` contains the following lines:
380+
- `registry="https://packages.jetbrains.team/npm/p/krpc/build-deps/"`
381+
- `always-auth=true`
382+
- `save-exact=true`
383+
- `//packages.jetbrains.team/npm/p/krpc/build-deps/:_authToken=<your_auth_token>`,
384+
where `<your_auth_token>` is from the [proxy-repositories.md](proxy-repositories.md) guide.
385+
- Check that `<USER_HOME>/.npmrc` / `<USER_HOME>/.yarnrc` don't interfere
386+
command to debug. Replace versions of tools if needed.
366387

367388
Something doesn't work, and you are sure it's not your fault? Report it appropriately! Don't be lazy.
368389

@@ -377,7 +398,8 @@ all included builds (not subprojects) must reflect the change.
377398
- `checkLegacyAbi` / `updateLegacyAbi` - ABI checks.
378399
See https://kotlinlang.org/docs/whatsnew22.html#binary-compatibility-validation-included-in-kotlin-gradle-plugin.
379400
Former BCV: https://github.com/Kotlin/binary-compatibility-validator
380-
- `kotlinUpgradeYarnLock` - update [kotlin-js-store](../kotlin-js-store) contents, usually after Kotlin version update.
401+
- `kotlinUpgradePackageLock` / `kotlinWasmUpgradePackageLock` - update [kotlin-js-store](../kotlin-js-store) contents,
402+
usually after Kotlin version update.
381403
- `updateDocsChangelog` - put modified [CONTRIBUTING.md](../CONTRIBUTING.md) into [topics](pages/kotlinx-rpc/topics)
382404
- `detekt` - run detekt checks.
383405
- `verifyPlatformTable` / `dumpPlatformTable` - Update [platforms.topic](pages/kotlinx-rpc/topics/platforms.topic)

dokka-plugin/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ org.gradle.configuration-cache=true
1919
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
2020
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
2121

22+
# https://youtrack.jetbrains.com/issue/KT-78504
23+
kotlin.js.yarn=false
24+
2225
# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
2326
kotlinx.rpc.plugin.internalDevelopment=true
2427

gradle-conventions/src/main/kotlin/util/tasks/npm.kt

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,37 @@ import org.gradle.api.Project
99
import org.gradle.kotlin.dsl.*
1010
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsEnvSpec
1111
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
12-
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
13-
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
14-
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootEnvSpec
12+
import org.jetbrains.kotlin.gradle.targets.js.npm.BaseNpmExtension
13+
import org.jetbrains.kotlin.gradle.targets.js.npm.LockFileMismatchReport
14+
import org.jetbrains.kotlin.gradle.targets.wasm.nodejs.WasmNodeJsEnvSpec
15+
import org.jetbrains.kotlin.gradle.targets.wasm.nodejs.WasmNodeJsRootPlugin
16+
import org.jetbrains.kotlin.gradle.targets.web.nodejs.BaseNodeJsEnvSpec
17+
import org.jetbrains.kotlin.gradle.targets.web.nodejs.CommonNodeJsRootPlugin
18+
import org.jetbrains.kotlin.gradle.targets.web.npm.CommonNpmResolverPlugin
1519
import util.other.optionalProperty
1620
import util.other.spacePassword
1721
import util.other.useProxyRepositories
1822
import java.io.File
1923

20-
fun Project.configureNpm() {
21-
val kotlinMasterBuild by optionalProperty()
22-
23-
val executeNpmLogin by tasks.registering {
24+
private inline fun <
25+
reified Plugin : CommonNodeJsRootPlugin,
26+
reified Spec : BaseNodeJsEnvSpec
27+
> Project.registerExecuteNpmLoginTask(
28+
target: String,
29+
npmInstallTaskName: String,
30+
useProxy: Boolean,
31+
) {
32+
val capitalizedTarget = target.replaceFirstChar { it.titlecase() }
33+
val task = tasks.register("execute${capitalizedTarget}NpmLogin") {
2434
if (!useProxyRepositories) {
25-
return@registering
35+
return@register
2636
}
2737

2838
val registryUrl = "https://packages.jetbrains.team/npm/p/krpc/build-deps/"
2939

3040
// To prevent leaking of credentials in VCS on dev machine use the build directory config file
31-
val buildYarnConfigFile = File(project.rootDir, "build/js/.yarnrc")
32-
val buildNpmConfigFile = File(project.rootDir, "build/js/.npmrc")
41+
val buildYarnConfigFile = File(project.rootDir, "build/$target/.yarnrc")
42+
val buildNpmConfigFile = File(project.rootDir, "build/$target/.npmrc")
3343

3444
val spacePassword: String? = spacePassword
3545

@@ -64,35 +74,46 @@ fun Project.configureNpm() {
6474
outputs.file(buildNpmConfigFile).withPropertyName("buildOutputNpmFile")
6575
}
6676

67-
val useProxy = useProxyRepositories
68-
69-
plugins.withType(NodeJsRootPlugin::class.java).configureEach {
70-
rootProject.extensions.configure<NodeJsEnvSpec> {
77+
plugins.withType<Plugin>().configureEach {
78+
rootProject.extensions.configure<Spec> {
7179
download = true
80+
7281
if (useProxy) {
7382
downloadBaseUrl = "https://packages.jetbrains.team/files/p/krpc/build-deps/"
7483
}
7584
}
7685

77-
tasks.named("kotlinNpmInstall").configure {
78-
dependsOn(executeNpmLogin)
86+
tasks.named(npmInstallTaskName).configure {
87+
dependsOn(task)
7988
}
8089
}
90+
}
91+
92+
fun Project.configureNpm() {
93+
val kotlinMasterBuild by optionalProperty()
94+
val useProxy = useProxyRepositories
95+
96+
registerExecuteNpmLoginTask<NodeJsRootPlugin, NodeJsEnvSpec>(
97+
target = "js",
98+
npmInstallTaskName = "kotlinNpmInstall",
99+
useProxy = useProxy,
100+
)
101+
102+
registerExecuteNpmLoginTask<WasmNodeJsRootPlugin, WasmNodeJsEnvSpec>(
103+
target = "wasm",
104+
npmInstallTaskName = "kotlinWasmNpmInstall",
105+
useProxy = useProxy,
106+
)
81107

82108
// necessary for CI js tests
83-
rootProject.plugins.withType<YarnPlugin> {
84-
rootProject.extensions.configure<YarnRootEnvSpec> {
109+
rootProject.plugins.withType<CommonNpmResolverPlugin> {
110+
rootProject.extensions.configure<BaseNpmExtension> {
85111
ignoreScripts = false
86-
download = true
87112

88-
yarnLockMismatchReport = if (useProxy && !kotlinMasterBuild) {
89-
YarnLockMismatchReport.FAIL
113+
packageLockMismatchReport = if (useProxy && !kotlinMasterBuild) {
114+
LockFileMismatchReport.FAIL
90115
} else {
91-
YarnLockMismatchReport.WARNING
92-
}
93-
94-
if (useProxy) {
95-
downloadBaseUrl = "https://packages.jetbrains.team/files/p/krpc/build-deps/"
116+
LockFileMismatchReport.WARNING
96117
}
97118
}
98119
}

gradle-plugin/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ org.gradle.configuration-cache=true
1919
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
2020
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
2121

22+
# https://youtrack.jetbrains.com/issue/KT-78504
23+
kotlin.js.yarn=false
24+
2225
# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
2326
kotlinx.rpc.plugin.internalDevelopment=true
2427

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ org.gradle.configuration-cache=true
1919
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
2020
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
2121

22+
# https://youtrack.jetbrains.com/issue/KT-78504
23+
kotlin.js.yarn=false
24+
2225
# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
2326
kotlinx.rpc.plugin.internalDevelopment=true
2427

0 commit comments

Comments
 (0)