Skip to content

Commit

Permalink
DCA11Y-1145: cover test case with project with submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
flipatlas committed Sep 20, 2024
1 parent f4a7b64 commit 729d407
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 3 deletions.
5 changes: 4 additions & 1 deletion frontend-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@
<filterProperties>
<repository.proxy.url>${repository.proxy.url}</repository.proxy.url>
</filterProperties>
<pomIncludes>**/pom.xml</pomIncludes>
<pomIncludes>
<pomInclude>**/pom.xml</pomInclude>
<pomInclude>!**/sub-*/pom.xml</pomInclude>
</pomIncludes>
</configuration>

<executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FNM_DIR=$HOME/.fnm
PATH=$FNM_DIR:$PATH
eval "$(fnm env --use-on-cd --version-file-strategy=recursive --shell bash)"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.15.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# invoker env variables are not loaded yet
export HOME="$(dirname "$0")"

export FNM_DIR="$HOME/.fnm";
mkdir "$FNM_DIR"

curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "$FNM_DIR" --skip-shell --force-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.environmentVariables.HOME=${basedir}/target/it/node-version-manager/fnm/with-modules
invoker.environmentVariables.FNM_DIR=${basedir}/target/it/node-version-manager/fnm/with-modules/.fnm
invoker.environmentVariables.XDG_DATA_HOME=${basedir}/target/it/node-version-manager/fnm/with-modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.eirslett</groupId>
<artifactId>fnm-with-modules</artifactId>
<version>0</version>
<packaging>pom</packaging>

<modules>
<module>sub-module</module>
</modules>


<build>
<pluginManagement>
<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>
<workingDirectory>${basedir}</workingDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>

<executions>
<execution>
<id>install node</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def p = "bash $basedir/install-fnm.sh".execute()
p.waitFor()
println p.text

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "example",
"version": "0.0.1",
"dependencies": {
"classnames": "^2.3.2"
},
"scripts": {
"prebuild": "npm install"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.eirslett</groupId>
<artifactId>fnm-with-modules</artifactId>
<version>0</version>
</parent>

<artifactId>fnm-with-modules-sub-module</artifactId>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>

<executions>
<execution>
<id>npm ci</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>ci</arguments>
</configuration>
</execution>

</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import org.codehaus.plexus.util.FileUtils

String buildLog = FileUtils.fileRead(new File(basedir, 'build.log'))
assert buildLog.contains('Installing node with FNM') : 'Node has been installed with a different version manager'

assert !new File(basedir, 'node').exists() : "Node was installed bypassing version manager"
assert new File(basedir, 'sub-module/node_modules').exists() : "Node modules were not installed in the base directory"
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import org.codehaus.plexus.util.FileUtils
String buildLog = FileUtils.fileRead(new File(basedir, 'build.log'))
assert buildLog.contains('Installing node with FNM') : 'Node has been installed with a different version manager'

assert !new File(basedir, 'node').exists() : "with-npm: Node was installed bypassing version manager"
assert new File(basedir, 'node_modules').exists() : "with-npm: Node modules were not installed in the base directory"
assert !new File(basedir, 'node').exists() : "Node was installed bypassing version manager"
assert new File(basedir, 'node_modules').exists() : "Node modules were not installed in the base directory"

0 comments on commit 729d407

Please sign in to comment.