Skip to content

Commit

Permalink
DCA11Y-1145: add tests for nvm and fnm
Browse files Browse the repository at this point in the history
  • Loading branch information
flipatlas committed Sep 16, 2024
1 parent 82ae5d6 commit d2f488e
Show file tree
Hide file tree
Showing 20 changed files with 265 additions and 0 deletions.
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 --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,4 @@
invoker.environmentVariables.HOME=${basedir}/target/its/node-version-manager-install-with-fnm
invoker.environmentVariables.FNM_DIR=${basedir}/target/its/node-version-manager-install-with-fnm/.fnm
invoker.environmentVariables.XDG_DATA_HOME=${basedir}/target/its/node-version-manager-install-with-fnm
invoker.environmentVariables.SHELL=bash

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,61 @@
<?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>example</artifactId>
<version>0</version>
<packaging>pom</packaging>

<build>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.codehaus.mojo</groupId>-->
<!-- <artifactId>exec-maven-plugin</artifactId>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>Install nvm</id>-->
<!-- <phase>generate-sources</phase>-->
<!-- <goals>-->
<!-- <goal>exec</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <executable>${basedir}/install-nvm.sh</executable>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<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>
<nodeVersion>v20.15.1</nodeVersion>
<workingDirectory>${basedir}</workingDirectory>
</configuration>

<executions>
<execution>
<id>install node</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<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,3 @@
def p = "sh $basedir/install-fnm.sh".execute()
p.waitFor()
println p.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import org.codehaus.plexus.util.FileUtils

// assert
assert !new File(basedir, 'node').exists() : "Node was installed in the custom install directory"
assert new File(basedir, 'node_modules').exists() : "Node modules were not installed in the base directory"

String buildLog = FileUtils.fileRead(new File(basedir, 'build.log'))
assert buildLog.contains('BUILD SUCCESS') : 'build was not successful'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm into the shell

# disable global fnm if installed
fnm() {
exit 1;
}
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,17 @@
#!/bin/bash

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

export NVM_DIR="$HOME/.nvm";
mkdir "$NVM_DIR"
echo "NVM_DIR set";

(
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" &&
cd "$NVM_DIR" &&
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
);
echo "NVM checked out";


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.environmentVariables.HOME=${basedir}/target/its/node-version-manager-install-with-nvm
invoker.environmentVariables.NVM_DIR=${basedir}/target/its/node-version-manager-install-with-nvm/.nvm
invoker.environmentVariables.SHELL=bash

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,61 @@
<?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>example</artifactId>
<version>0</version>
<packaging>pom</packaging>

<build>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.codehaus.mojo</groupId>-->
<!-- <artifactId>exec-maven-plugin</artifactId>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>Install nvm</id>-->
<!-- <phase>generate-sources</phase>-->
<!-- <goals>-->
<!-- <goal>exec</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <executable>${basedir}/install-nvm.sh</executable>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<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>
<nodeVersion>v20.15.1</nodeVersion>
<workingDirectory>${basedir}</workingDirectory>
</configuration>

<executions>
<execution>
<id>install node</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<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,3 @@
def p = "sh $basedir/install-nvm.sh".execute()
p.waitFor()
println p.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import org.codehaus.plexus.util.FileUtils

// assert
assert !new File(basedir, 'node').exists() : "Node was installed in the custom install directory"
assert new File(basedir, 'node_modules').exists() : "Node modules were not installed in the base directory"

String buildLog = FileUtils.fileRead(new File(basedir, 'build.log'))
assert buildLog.contains('BUILD SUCCESS') : 'build was not successful'

0 comments on commit d2f488e

Please sign in to comment.