[JENKINS-73744] npm scripts lint:fix do not work (#9718)

Co-authored-by: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>
This commit is contained in:
Thorsten Scherler 2024-09-16 11:40:32 +02:00 committed by GitHub
parent 239ced05af
commit 0037be68b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 653 additions and 563 deletions

24
.gitignore vendored
View File

@ -55,7 +55,27 @@ jenkins_*.changes
*.pkg
*.zip
push-build.sh
war/node_modules/
war/yarn-error.log
node_modules/
yarn-error.log
.java-version
.checkstyle
/rebel.xml
junit.xml
# Yarn
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
.yarn/*
.yarnrc.yml
!.yarn/patches
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
# Node
node/
node_modules/
# Generated JavaScript Bundles
jsbundles

View File

@ -10,14 +10,14 @@ node/
.yarnrc.yml
# libraries / external deps / generated files
src/main/js/plugin-setup-wizard/bootstrap-detached.js
src/main/webapp/scripts/yui
src/main/webapp/jsbundles/
src/main/scss/_bootstrap.scss
war/src/main/js/plugin-setup-wizard/bootstrap-detached.js
war/src/main/webapp/scripts/yui
war/src/main/webapp/jsbundles/
war/src/main/scss/_bootstrap.scss
# test files that we don't need formatted
../test/src/test/resources
../test/jmh-report.json
test/src/test/resources
test/jmh-report.json
# doesn't work, see https://github.com/prettier/prettier/issues/5340
*.hbs
@ -25,4 +25,4 @@ src/main/scss/_bootstrap.scss
.yarn
# Incorrectly flagging forwarding slashes in regex
../.github/renovate.json
.github/renovate.json

View File

@ -1,7 +1,7 @@
module.exports = {
extends: "stylelint-config-standard",
customSyntax: "postcss-scss",
ignoreFiles: ["src/main/scss/_bootstrap.scss"],
ignoreFiles: ["war/src/main/scss/_bootstrap.scss"],
rules: {
"no-descending-specificity": null,
"selector-class-pattern": "[a-z]",

View File

@ -55,13 +55,12 @@ MAVEN_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/ja
To run the Yarn frontend build, after [building the WAR file](#building-the-war-file), add the downloaded versions of Node and Yarn to your path:
```sh
export PATH=$PWD/war/node:$PWD/war/node/yarn/dist/bin:$PATH
export PATH=$PWD/node:$PWD/node/yarn/dist/bin:$PATH
```
Then you can run Yarn with e.g.
```sh
cd war
yarn
```
@ -75,10 +74,9 @@ On one terminal, start a development server that will not process frontend asset
MAVEN_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED' mvn -pl war jetty:run -Dskip.yarn
```
On another terminal, move to the `war` folder and start a [webpack](https://webpack.js.org/) dev server, after [adding Node and Yarn to your path](#running-the-yarn-frontend-build):
Open another terminal and start a [webpack](https://webpack.js.org/) dev server, after [adding Node and Yarn to your path](#running-the-yarn-frontend-build):
```sh
cd war
yarn start
```
@ -113,14 +111,12 @@ mvn spotless:apply
To view frontend issues, after [adding Node and Yarn to your path](#running-the-yarn-frontend-build), run:
```sh
cd war
yarn lint
```
To fix frontend issues, after [adding Node and Yarn to your path](#running-the-yarn-frontend-build), run:
```sh
cd war
yarn lint:fix
```

View File

@ -16,8 +16,8 @@ module.exports = [
"**/jsbundles/",
// External scripts
"war/.pnp.cjs",
"war/.pnp.loader.mjs",
".pnp.cjs",
".pnp.loader.mjs",
"war/src/main/js/plugin-setup-wizard/bootstrap-detached.js",
"war/src/main/webapp/scripts/yui/*",
],
@ -93,7 +93,7 @@ module.exports = [
"eslint.config.cjs",
"war/postcss.config.js",
"war/webpack.config.js",
"war/.stylelintrc.js",
".stylelintrc.js",
],
languageOptions: {
globals: {

View File

@ -10,16 +10,16 @@
},
"private": true,
"scripts": {
"dev": "webpack --config webpack.config.js",
"prod": "webpack --config webpack.config.js --mode=production",
"dev": "webpack --config war/webpack.config.js",
"prod": "webpack --config war/webpack.config.js --mode=production",
"build": "yarn prod",
"start": "yarn dev --watch",
"lint:js": "eslint ../ && prettier --check ../",
"lint:js-ci": "eslint ../ -f checkstyle -o target/eslint-warnings.xml && prettier --check ../",
"lint:css": "stylelint src/main/scss",
"lint:css-ci": "stylelint src/main/scss --custom-formatter stylelint-checkstyle-reporter -o target/stylelint-warnings.xml",
"lint:js": "eslint . && prettier --check .",
"lint:js-ci": "eslint . -f checkstyle -o target/eslint-warnings.xml && prettier --check .",
"lint:css": "stylelint war/src/main/scss",
"lint:css-ci": "stylelint war/src/main/scss --custom-formatter stylelint-checkstyle-reporter -o target/stylelint-warnings.xml",
"lint:ci": "yarn lint:js-ci && yarn lint:css-ci",
"lint:fix": "eslint --fix ../ && prettier --write ../ && stylelint src/main/scss --fix",
"lint:fix": "eslint --fix . && prettier --write . && stylelint war/src/main/scss --fix",
"lint": "yarn lint:js && yarn lint:css"
},
"devDependencies": {

193
pom.xml
View File

@ -98,6 +98,12 @@ THE SOFTWARE.
<spotless.check.skip>false</spotless.check.skip>
<!-- Make sure to keep the jetty-ee9-maven-plugin version in war/pom.xml in sync with the Jetty release in Winstone: -->
<winstone.version>8.1</winstone.version>
<node.version>20.17.0</node.version>
<!-- frontend-maven-plugin will install this Yarn version as bootstrap, then hand over control to Yarn Berry. -->
<yarn.version>1.22.19</yarn.version>
<!-- maven-antrun-plugin will download this Yarn version. -->
<yarn-berry.version>4.4.1</yarn-berry.version>
<yarn-berry.sha256sum>920b4530755296dc2ce8b4351f057d4a26429524fcb2789d277560d94837c27e</yarn-berry.sha256sum>
</properties>
<!--
@ -415,5 +421,192 @@ THE SOFTWARE.
<changelog.url>https://www.jenkins.io/changelog-stable</changelog.url>
</properties>
</profile>
<profile>
<id>yarn-ci-lint</id>
<activation>
<property>
<name>env.CI</name>
</property>
<file>
<exists>package.json</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.15.0</version>
<executions>
<execution>
<id>yarn lint:ci</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>lint:ci</arguments>
<skip>${yarn.lint.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>yarn-lint</id>
<activation>
<property>
<name>!env.CI</name>
</property>
<file>
<exists>package.json</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.15.0</version>
<executions>
<execution>
<id>yarn lint</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>lint</arguments>
<skip>${yarn.lint.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>yarn-execution</id>
<activation>
<file>
<exists>package.json</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>download-yarn</id>
<goals>
<goal>run</goal>
</goals>
<phase>initialize</phase>
<configuration>
<target>
<property name="yarn.dest" value="${project.basedir}/.yarn/releases/yarn-${yarn-berry.version}.cjs" />
<dirname file="${yarn.dest}" property="yarn.dest.dir" />
<mkdir dir="${yarn.dest.dir}" />
<get dest="${yarn.dest}" src="https://repo.yarnpkg.com/${yarn-berry.version}/packages/yarnpkg-cli/bin/yarn.js" usetimestamp="true" />
<checksum algorithm="SHA-256" file="${yarn.dest}" property="${yarn-berry.sha256sum}" verifyProperty="yarn.checksum.matches" />
<condition property="yarn.checksum.matches.fail">
<equals arg1="${yarn.checksum.matches}" arg2="false" />
</condition>
<fail if="yarn.checksum.matches.fail">Checksum error</fail>
<echo file="${project.basedir}/.yarnrc.yml">yarnPath: ${yarn.dest}</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.15.0</version>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<phase>initialize</phase>
<configuration>
<nodeVersion>v${node.version}</nodeVersion>
<yarnVersion>v${yarn.version}</yarnVersion>
<nodeDownloadRoot>https://repo.jenkins-ci.org/nodejs-dist/</nodeDownloadRoot>
<!-- tried to create a mirror for yarnDownloadRoot but it did not work -->
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>initialize</phase>
</execution>
<execution>
<id>yarn build</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
<execution>
<id>yarn lint</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>lint:ci</arguments>
<skip>${yarn.lint.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>clean-node</id>
<activation>
<property>
<name>cleanNode</name>
</property>
<file>
<exists>package.json</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<!-- Version specified in grandparent POM -->
<configuration>
<filesets>
<fileset>
<directory>node</directory>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>node_modules</directory>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -49,12 +49,7 @@ THE SOFTWARE.
<mina-sshd-api.version>2.13.2-125.v200281b_61d59</mina-sshd-api.version>
<!-- Minimum Remoting version, which is tested for API compatibility, duplicated so that renovate only updates the latest remoting version property -->
<remoting.minimum.supported.version>3107.v665000b_51092</remoting.minimum.supported.version>
<node.version>20.17.0</node.version>
<!-- frontend-maven-plugin will install this Yarn version as bootstrap, then hand over control to Yarn Berry. -->
<yarn.version>1.22.19</yarn.version>
<!-- maven-antrun-plugin will download this Yarn version. -->
<yarn-berry.version>4.4.1</yarn-berry.version>
<yarn-berry.sha256sum>920b4530755296dc2ce8b4351f057d4a26429524fcb2789d277560d94837c27e</yarn-berry.sha256sum>
</properties>
<dependencyManagement>
@ -727,132 +722,5 @@ THE SOFTWARE.
</build>
</profile>
<!--
The following profiles are required to integration the node/yarn build into this maven build.
Hopefully we can push these profiles down into a parent pom.
-->
<profile>
<id>yarn-execution</id>
<activation>
<file>
<exists>package.json</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>download-yarn</id>
<goals>
<goal>run</goal>
</goals>
<phase>initialize</phase>
<configuration>
<target>
<property name="yarn.dest" value="${project.basedir}/.yarn/releases/yarn-${yarn-berry.version}.cjs" />
<dirname file="${yarn.dest}" property="yarn.dest.dir" />
<mkdir dir="${yarn.dest.dir}" />
<get dest="${yarn.dest}" src="https://repo.yarnpkg.com/${yarn-berry.version}/packages/yarnpkg-cli/bin/yarn.js" usetimestamp="true" />
<checksum algorithm="SHA-256" file="${yarn.dest}" property="${yarn-berry.sha256sum}" verifyProperty="yarn.checksum.matches" />
<condition property="yarn.checksum.matches.fail">
<equals arg1="${yarn.checksum.matches}" arg2="false" />
</condition>
<fail if="yarn.checksum.matches.fail">Checksum error</fail>
<echo file="${project.basedir}/.yarnrc.yml">yarnPath: ${yarn.dest}</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.15.0</version>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<phase>initialize</phase>
<configuration>
<nodeVersion>v${node.version}</nodeVersion>
<yarnVersion>v${yarn.version}</yarnVersion>
<nodeDownloadRoot>https://repo.jenkins-ci.org/nodejs-dist/</nodeDownloadRoot>
<!-- tried to create a mirror for yarnDownloadRoot but it did not work -->
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>initialize</phase>
</execution>
<execution>
<id>yarn build</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
<execution>
<id>yarn lint</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>lint:ci</arguments>
<skip>${yarn.lint.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>clean-node</id>
<activation>
<property>
<name>cleanNode</name>
</property>
<file>
<exists>package.json</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<!-- Version specified in grandparent POM -->
<configuration>
<filesets>
<fileset>
<directory>node</directory>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>node_modules</directory>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

File diff suppressed because it is too large Load Diff