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

DCA11Y-1145: Support standard Node version files #3

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c57447e
DCA11Y-1145: Support standard files
atl-mk Jul 19, 2024
25a8b8e
DCA11Y-1145: Validate and fixup node versions
atl-mk Jul 21, 2024
adbc21b
DCA11Y-1145: Log where the version of Node was found
atl-mk Jul 21, 2024
f220262
DCA11Y-1145: Fix .tools-version filename
atl-mk Jul 21, 2024
8804ff5
DCA11Y-1145: Support node version file being specified
atl-mk Jul 21, 2024
a438004
DCA11Y-1145: Fix compiling node version file
atl-mk Jul 22, 2024
d5fa3cf
DCA11Y-1145: Fix name to 'tool versions' inline with the file
atl-mk Jul 24, 2024
3f9fb33
DCA11Y-1145: Add .tool-versions IT
atl-mk Jul 24, 2024
999f9b6
DCA11Y-1145: Add support for comments on the main line of .nvmrc like…
atl-mk Jul 24, 2024
9b07808
DCA11Y-1145: Add IT for .nvmrc files
atl-mk Jul 24, 2024
aff09fd
DCA11Y-1145: Fix nodeVersion being a readOnly property
atl-mk Jul 24, 2024
8e95116
DCA11Y-1145: Add empty line UT
atl-mk Jul 24, 2024
8f4da9b
DCA11Y-1145: Add specified version file IT
atl-mk Jul 24, 2024
9f84ec9
DCA11Y-1145: Use the working directory
atl-mk Jul 24, 2024
3c0ed88
DCA11Y-1145: Update the CHANGELOG
atl-mk Jul 24, 2024
44ef7af
DCA11Y-1145: Update the README.md with usage guidance
atl-mk Jul 24, 2024
d9f4116
DCA11Y-1145: Work around test runner setup
atl-mk Jul 24, 2024
589f352
DCA11Y-1145: Fix unreadable version file exception message to include…
atl-mk Sep 20, 2024
e14561f
DCA11Y-1145: Add support for mise config files
atl-mk Sep 20, 2024
a71d7f8
DCA11Y-1145: Add future code name releases
atl-mk Sep 20, 2024
13eb4d1
DCA11Y-1145: Comment reason for lowercasing the version
atl-mk Sep 20, 2024
710764d
DCA11Y-1145: Add handling of loosely-defined major versions
atl-mk Sep 27, 2024
a816c38
DCA11Y-1145: normalize printed paths
flipatlas Sep 30, 2024
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
12 changes: 11 additions & 1 deletion FORK_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

[unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.1.1...HEAD
### Added

- [DCA11Y-1145]: Automatic version detection of the Node version from `.tool-versions`, `.node-version`, and `.nvmrc` files
- [DCA11Y-1145]: The configuration property `nodeVersionFile` to specify a file that can be read in `install-node-and-npm`, `install-node-and-pnpm`, and `install-node-and-yarn`

### Changed

- [DCA11Y-1145]: Now tolerant of `v` missing or present at the start of a Node version

[DCA11Y-1145]: https://hello.jira.atlassian.cloud/browse/DCA11Y-1145
[unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.15.0...HEAD
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,24 @@ Only Atlassians may release a new version, [follow this guide](https://hello.atl

## Usage guidance

### Format of the Node version

It shouldn't matter if the `v` prefix is present, e.g. `14.8.0` and `v14.8.0`.

Old, non-standard, and codename versions are also supported if they're [available](https://nodejs.org/dist), e.g. `latest-v12.x`.

### Using Node version files

The plugin should automatically detect the version from files like: `.node-version`, `.nvmrc`, and `.tool-versions`. Comments in the files should be ignored. If the file is not in the working directory, nor any of the parent directories, it can be manually set in the configuration like so:

```xml
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<nodeVersionFile>${project.basedir}/dotfiles/.nvmrc</nodeVersionFile>
</configuration>
</plugin>
```

[![Cheers from Atlassian](https://raw.githubusercontent.com/atlassian-internal/oss-assets/master/banner-cheers-light.png)](https://www.atlassian.com)
4 changes: 4 additions & 0 deletions frontend-maven-plugin/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# comment
atl-mk marked this conversation as resolved.
Show resolved Hide resolved

v22.5.1 ! comment
// comment
6 changes: 6 additions & 0 deletions frontend-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
<goal>run</goal>
<goal>verify</goal>
</goals>
<configuration>
<environmentVariables>
<MISE_CONFIG_DIR>TESTDIR</MISE_CONFIG_DIR>
<MISE_ENV>TESTPROFILE</MISE_ENV>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
10 changes: 10 additions & 0 deletions frontend-maven-plugin/src/it/mise-config-file/.mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tools]
java = "temurin-21"
maven = "3.9"
pre-commit = "latest"
ktlint = "latest"
python = "3.12"
# node 22.5.1
node = "22.5.1"
# node 22.5.1
yarn = "1.22.22"
12 changes: 12 additions & 0 deletions frontend-maven-plugin/src/it/mise-config-file/package-lock.json

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

4 changes: 4 additions & 0 deletions frontend-maven-plugin/src/it/mise-config-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "example",
"version": "0.0.1"
}
34 changes: 34 additions & 0 deletions frontend-maven-plugin/src/it/mise-config-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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>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 npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
5 changes: 5 additions & 0 deletions frontend-maven-plugin/src/it/mise-config-file/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assert new File(basedir, 'target/node').exists() : "Node was not installed in the custom install directory";

String buildLog = new File(basedir, 'build.log').text
assert buildLog.contains('.mise.toml') : 'The wrong file was used'
assert buildLog.contains('Installing node version v22.5.1') : 'The correct node version was not detected'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tools]
java = "temurin-21"
maven = "3.9"
pre-commit = "latest"
ktlint = "latest"
python = "3.12"
# node 22.5.1
node = "22.5.1"
# node 22.5.1
yarn = "1.22.22"

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,4 @@
{
"name": "example",
"version": "0.0.1"
}
34 changes: 34 additions & 0 deletions frontend-maven-plugin/src/it/mise-env-config-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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>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 npm</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,5 @@
assert new File(basedir, 'target/node').exists() : "Node was not installed in the custom install directory";

String buildLog = new File(basedir, 'build.log').text
assert buildLog.contains(['TESTDIR','mise.TESTPROFILE.toml'].join(File.separator)) : 'The wrong file was used'
assert buildLog.contains('Installing node version v22.5.1') : 'The correct node version was not detected'

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,4 @@
{
"name": "example",
"version": "0.0.1"
}
34 changes: 34 additions & 0 deletions frontend-maven-plugin/src/it/nested-project-nvmrc-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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>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 npm</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,5 @@
assert new File(basedir, 'target/node').exists() : "Node was not installed in the custom install directory";

String buildLog = new File(basedir, 'build.log').text
assert buildLog.contains(['frontend-maven-plugin','.nvmrc'].join(File.separator)) : 'The wrong file was used'
assert buildLog.contains('Installing node version v22.5.1') : 'The correct node version was not detected'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.5.1

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,4 @@
{
"name": "example",
"version": "0.0.1"
}
35 changes: 35 additions & 0 deletions frontend-maven-plugin/src/it/specified-node-version-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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>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>
<nodeVersionFile>${project.basedir}/dotfiles/.nvmrc</nodeVersionFile>
<installDirectory>target</installDirectory>
</configuration>

<executions>

<execution>
<id>install node and npm</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,5 @@
assert new File(basedir, 'target/node').exists() : "Node was not installed in the custom install directory";

String buildLog = new File(basedir, 'build.log').text
assert buildLog.contains(['specified-node-version-file', 'dotfiles', '.nvmrc'].join(File.separator)) : 'The wrong file was used'
assert buildLog.contains('Installing node version v22.5.1') : 'The correct node version was not detected'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node v22.5.1
12 changes: 12 additions & 0 deletions frontend-maven-plugin/src/it/tool-versions-file/package-lock.json

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

4 changes: 4 additions & 0 deletions frontend-maven-plugin/src/it/tool-versions-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "example",
"version": "0.0.1"
}
34 changes: 34 additions & 0 deletions frontend-maven-plugin/src/it/tool-versions-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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>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 npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
5 changes: 5 additions & 0 deletions frontend-maven-plugin/src/it/tool-versions-file/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assert new File(basedir, 'target/node').exists() : "Node was not installed in the custom install directory";

String buildLog = new File(basedir, 'build.log').text
assert buildLog.contains('.tool-versions') : 'The wrong file was used'
assert buildLog.contains('Installing node version v22.5.1') : 'The correct node version was not detected'
Loading
Loading