Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use downloaded Yarn as per documentation #285

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install yarn
run: npm install -g yarn@1.22.17
- name: Gradle Version
run: ./gradlew --version
- name: Build Node.js Scripts Project
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install yarn
run: npm install -g yarn@1.22.17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install yarn
run: npm install -g yarn@1.22.17
- name: Build
run: ./gradlew build
- name: Publish
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 6.x *(unreleased)*
* Upgrade default Node to 18.17.1 and npm to 9.6.7
* Always use downloaded Yarn as per documentation [#284](https://github.com/node-gradle/gradle-node-plugin/issues/284)

## Version 6.0.0 *(2023-08-15)*
* Removed deprecated `nodeModulesDir` from `NodeExtension`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ open class VariantComputer {
fun computeYarnBinDir(yarnDirProvider: Provider<Directory>, platform: Property<Platform>) = computeProductBinDir(yarnDirProvider, platform)

fun computeYarnExec(nodeExtension: NodeExtension, yarnBinDirProvider: Provider<Directory>): Provider<String> {
return zip(nodeExtension.yarnCommand, nodeExtension.download, yarnBinDirProvider).map {
val (yarnCommand, download, yarnBinDir) = it
return zip(nodeExtension.yarnCommand, yarnBinDirProvider).map {
val (yarnCommand, yarnBinDir) = it
val command = if (nodeExtension.resolvedPlatform.get().isWindows()) {
yarnCommand.mapIf({ it == "yarn" }) { "yarn.cmd" }
} else yarnCommand
if (download) yarnBinDir.dir(command).asFile.absolutePath else command
// This is conceptually pretty simple as we per documentation always download yarn
yarnBinDir.dir(command).asFile.absolutePath
}
}

Expand Down
20 changes: 8 additions & 12 deletions src/main/kotlin/com/github/gradle/node/yarn/exec/YarnExecRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ abstract class YarnExecRunner {
yarnBinDirProvider: Provider<Directory>,
variantComputer: VariantComputer
): Provider<List<String>> {
return nodeExtension.download.flatMap { download ->
if (!download) {
providers.provider { listOf<String>() }
}
val nodeBinDirProvider = variantComputer.computeNodeBinDir(nodeDirProvider, nodeExtension.resolvedPlatform)
val npmDirProvider = variantComputer.computeNpmDir(nodeExtension, nodeDirProvider)
val npmBinDirProvider = variantComputer.computeNpmBinDir(npmDirProvider, nodeExtension.resolvedPlatform)
zip(nodeBinDirProvider, npmBinDirProvider, yarnBinDirProvider)
.map { (nodeBinDir, npmBinDir, yarnBinDir) ->
listOf(yarnBinDir, npmBinDir, nodeBinDir).map { file -> file.asFile.absolutePath }
}
}
// This is conceptually pretty simple as we per documentation always download yarn
val nodeBinDirProvider = variantComputer.computeNodeBinDir(nodeDirProvider, nodeExtension.resolvedPlatform)
val npmDirProvider = variantComputer.computeNpmDir(nodeExtension, nodeDirProvider)
val npmBinDirProvider = variantComputer.computeNpmBinDir(npmDirProvider, nodeExtension.resolvedPlatform)
return zip(nodeBinDirProvider, npmBinDirProvider, yarnBinDirProvider)
.map { (nodeBinDir, npmBinDir, yarnBinDir) ->
listOf(yarnBinDir, npmBinDir, nodeBinDir).map { file -> file.asFile.absolutePath }
}
}
}
Loading