-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: yarn berry detection in case working directory is changed
Furthermore, prevent errors in case of berry usage and attempt to add arguments, which are not supported by berry.
- Loading branch information
Showing
14 changed files
with
1,040 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
893 changes: 893 additions & 0 deletions
893
frontend-maven-plugin/src/it/yarn-berry-integration/.yarn/releases/yarn-4.1.1.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
frontend-maven-plugin/src/it/yarn-berry-integration/.yarnrc.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cacheFolder: .yarn/cache | ||
|
||
enableGlobalCache: false | ||
|
||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-4.1.1.cjs |
8 changes: 8 additions & 0 deletions
8
frontend-maven-plugin/src/it/yarn-berry-integration/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "example", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"less": "~3.0.2" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
49 changes: 49 additions & 0 deletions
49
frontend-maven-plugin/src/it/yarn-berry-integration/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http:https://maven.apache.org/POM/4.0.0" xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.github.eirslett</groupId> | ||
<artifactId>example</artifactId> | ||
<version>0</version> | ||
<packaging>pom</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.github.eirslett</groupId> | ||
<artifactId>frontend-maven-plugin</artifactId> | ||
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md --> | ||
<version>@project.version@</version> | ||
|
||
<configuration> | ||
<installDirectory>target</installDirectory> | ||
</configuration> | ||
|
||
<executions> | ||
|
||
<execution> | ||
<id>install node and yarn</id> | ||
<goals> | ||
<goal>install-node-and-yarn</goal> | ||
</goals> | ||
<configuration> | ||
<nodeVersion>v20.12.2</nodeVersion> | ||
<yarnVersion>v1.22.22</yarnVersion> | ||
</configuration> | ||
</execution> | ||
|
||
<execution> | ||
<id>yarn install</id> | ||
<goals> | ||
<goal>yarn</goal> | ||
</goals> | ||
<configuration> | ||
<arguments>install --no-immutable</arguments> | ||
</configuration> | ||
</execution> | ||
|
||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
8 changes: 8 additions & 0 deletions
8
frontend-maven-plugin/src/it/yarn-berry-integration/verify.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
assert new File(basedir, 'target/node').exists() : "Node was not installed in the custom install directory"; | ||
assert new File(basedir, 'node_modules').exists() : "Node modules were not installed in the base directory"; | ||
assert new File(basedir, 'node_modules/less/package.json').exists() : "Less dependency has not been installed successfully"; | ||
|
||
String buildLog = new File(basedir, 'build.log').text | ||
assert buildLog.contains('BUILD SUCCESS') : 'build was not successful' | ||
//TODO: Find a suitable replacement for this if it's necessary. | ||
//assert buildLog.replace(File.separatorChar, '/' as char).matches('(?s).+Unpacking .+\\Q/local-repo/com/github/eirslett/yarn/[1-9\\.]*/yarn-[1-9\\.]*.tar.gz\\E into .+/target/node/yarn.+') : 'incorrect local repository location' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...maven-plugin/src/main/java/com/github/eirslett/maven/plugins/frontend/mojo/YarnUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.eirslett.maven.plugins.frontend.mojo; | ||
|
||
import java.io.File; | ||
import java.util.stream.Stream; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
|
||
public class YarnUtils { | ||
|
||
private static final String YARNRC_YAML_FILE_NAME = ".yarnrc.yml"; | ||
|
||
/** | ||
* Checks whether a .yarnrc.yml file exists at the project root | ||
* (in multi-module builds, it will be the Reactor project) | ||
* | ||
* @param session | ||
* the current maven session | ||
* @param workingDirectory | ||
* the configured working directory | ||
* | ||
* @return true if the .yarnrc.yml file exists, false otherwise | ||
*/ | ||
public static boolean isYarnrcYamlFilePresent(MavenSession session, File workingDirectory) { | ||
Stream<File> filesToCheck = Stream.of( | ||
new File(session.getCurrentProject().getBasedir(), YARNRC_YAML_FILE_NAME), | ||
new File(session.getRequest().getMultiModuleProjectDirectory(), YARNRC_YAML_FILE_NAME), | ||
new File(session.getExecutionRootDirectory(), YARNRC_YAML_FILE_NAME), | ||
new File(workingDirectory, YARNRC_YAML_FILE_NAME) | ||
); | ||
|
||
return filesToCheck | ||
.anyMatch(File::exists); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters