Skip to content

Commit 0037be6

Browse files
scherlerjanfaracikMarkEWaite
authored
[JENKINS-73744] npm scripts lint:fix do not work (#9718)
Co-authored-by: Jan Faracik <[email protected]> Co-authored-by: Mark Waite <[email protected]>
1 parent 239ced0 commit 0037be6

10 files changed

+653
-563
lines changed

war/.babelrc .babelrc

File renamed without changes.

.gitignore

+22-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,27 @@ jenkins_*.changes
5555
*.pkg
5656
*.zip
5757
push-build.sh
58-
war/node_modules/
59-
war/yarn-error.log
58+
node_modules/
59+
yarn-error.log
6060
.java-version
6161
.checkstyle
62+
63+
/rebel.xml
64+
junit.xml
65+
66+
# Yarn
67+
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
68+
.pnp.*
69+
.yarn/*
70+
.yarnrc.yml
71+
!.yarn/patches
72+
!.yarn/plugins
73+
!.yarn/sdks
74+
!.yarn/versions
75+
76+
# Node
77+
node/
78+
node_modules/
79+
80+
# Generated JavaScript Bundles
81+
jsbundles

war/.prettierignore .prettierignore

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ node/
1010
.yarnrc.yml
1111

1212
# libraries / external deps / generated files
13-
src/main/js/plugin-setup-wizard/bootstrap-detached.js
14-
src/main/webapp/scripts/yui
15-
src/main/webapp/jsbundles/
16-
src/main/scss/_bootstrap.scss
13+
war/src/main/js/plugin-setup-wizard/bootstrap-detached.js
14+
war/src/main/webapp/scripts/yui
15+
war/src/main/webapp/jsbundles/
16+
war/src/main/scss/_bootstrap.scss
1717

1818
# test files that we don't need formatted
19-
../test/src/test/resources
20-
../test/jmh-report.json
19+
test/src/test/resources
20+
test/jmh-report.json
2121

2222
# doesn't work, see https://github.com/prettier/prettier/issues/5340
2323
*.hbs
2424

2525
.yarn
2626

2727
# Incorrectly flagging forwarding slashes in regex
28-
../.github/renovate.json
28+
.github/renovate.json

war/.stylelintrc.js .stylelintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
extends: "stylelint-config-standard",
33
customSyntax: "postcss-scss",
4-
ignoreFiles: ["src/main/scss/_bootstrap.scss"],
4+
ignoreFiles: ["war/src/main/scss/_bootstrap.scss"],
55
rules: {
66
"no-descending-specificity": null,
77
"selector-class-pattern": "[a-z]",

CONTRIBUTING.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@ MAVEN_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/ja
5555
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:
5656

5757
```sh
58-
export PATH=$PWD/war/node:$PWD/war/node/yarn/dist/bin:$PATH
58+
export PATH=$PWD/node:$PWD/node/yarn/dist/bin:$PATH
5959
```
6060

6161
Then you can run Yarn with e.g.
6262

6363
```sh
64-
cd war
6564
yarn
6665
```
6766

@@ -75,10 +74,9 @@ On one terminal, start a development server that will not process frontend asset
7574
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
7675
```
7776

78-
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):
77+
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):
7978

8079
```sh
81-
cd war
8280
yarn start
8381
```
8482

@@ -113,14 +111,12 @@ mvn spotless:apply
113111
To view frontend issues, after [adding Node and Yarn to your path](#running-the-yarn-frontend-build), run:
114112

115113
```sh
116-
cd war
117114
yarn lint
118115
```
119116

120117
To fix frontend issues, after [adding Node and Yarn to your path](#running-the-yarn-frontend-build), run:
121118

122119
```sh
123-
cd war
124120
yarn lint:fix
125121
```
126122

eslint.config.cjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ module.exports = [
1616
"**/jsbundles/",
1717

1818
// External scripts
19-
"war/.pnp.cjs",
20-
"war/.pnp.loader.mjs",
19+
".pnp.cjs",
20+
".pnp.loader.mjs",
2121
"war/src/main/js/plugin-setup-wizard/bootstrap-detached.js",
2222
"war/src/main/webapp/scripts/yui/*",
2323
],
@@ -93,7 +93,7 @@ module.exports = [
9393
"eslint.config.cjs",
9494
"war/postcss.config.js",
9595
"war/webpack.config.js",
96-
"war/.stylelintrc.js",
96+
".stylelintrc.js",
9797
],
9898
languageOptions: {
9999
globals: {

war/package.json package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
},
1111
"private": true,
1212
"scripts": {
13-
"dev": "webpack --config webpack.config.js",
14-
"prod": "webpack --config webpack.config.js --mode=production",
13+
"dev": "webpack --config war/webpack.config.js",
14+
"prod": "webpack --config war/webpack.config.js --mode=production",
1515
"build": "yarn prod",
1616
"start": "yarn dev --watch",
17-
"lint:js": "eslint ../ && prettier --check ../",
18-
"lint:js-ci": "eslint ../ -f checkstyle -o target/eslint-warnings.xml && prettier --check ../",
19-
"lint:css": "stylelint src/main/scss",
20-
"lint:css-ci": "stylelint src/main/scss --custom-formatter stylelint-checkstyle-reporter -o target/stylelint-warnings.xml",
17+
"lint:js": "eslint . && prettier --check .",
18+
"lint:js-ci": "eslint . -f checkstyle -o target/eslint-warnings.xml && prettier --check .",
19+
"lint:css": "stylelint war/src/main/scss",
20+
"lint:css-ci": "stylelint war/src/main/scss --custom-formatter stylelint-checkstyle-reporter -o target/stylelint-warnings.xml",
2121
"lint:ci": "yarn lint:js-ci && yarn lint:css-ci",
22-
"lint:fix": "eslint --fix ../ && prettier --write ../ && stylelint src/main/scss --fix",
22+
"lint:fix": "eslint --fix . && prettier --write . && stylelint war/src/main/scss --fix",
2323
"lint": "yarn lint:js && yarn lint:css"
2424
},
2525
"devDependencies": {

pom.xml

+193
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ THE SOFTWARE.
9898
<spotless.check.skip>false</spotless.check.skip>
9999
<!-- Make sure to keep the jetty-ee9-maven-plugin version in war/pom.xml in sync with the Jetty release in Winstone: -->
100100
<winstone.version>8.1</winstone.version>
101+
<node.version>20.17.0</node.version>
102+
<!-- frontend-maven-plugin will install this Yarn version as bootstrap, then hand over control to Yarn Berry. -->
103+
<yarn.version>1.22.19</yarn.version>
104+
<!-- maven-antrun-plugin will download this Yarn version. -->
105+
<yarn-berry.version>4.4.1</yarn-berry.version>
106+
<yarn-berry.sha256sum>920b4530755296dc2ce8b4351f057d4a26429524fcb2789d277560d94837c27e</yarn-berry.sha256sum>
101107
</properties>
102108

103109
<!--
@@ -415,5 +421,192 @@ THE SOFTWARE.
415421
<changelog.url>https://www.jenkins.io/changelog-stable</changelog.url>
416422
</properties>
417423
</profile>
424+
<profile>
425+
<id>yarn-ci-lint</id>
426+
<activation>
427+
<property>
428+
<name>env.CI</name>
429+
</property>
430+
<file>
431+
<exists>package.json</exists>
432+
</file>
433+
</activation>
434+
<build>
435+
<plugins>
436+
<plugin>
437+
<groupId>com.github.eirslett</groupId>
438+
<artifactId>frontend-maven-plugin</artifactId>
439+
<version>1.15.0</version>
440+
<executions>
441+
<execution>
442+
<id>yarn lint:ci</id>
443+
<goals>
444+
<goal>yarn</goal>
445+
</goals>
446+
<configuration>
447+
<arguments>lint:ci</arguments>
448+
<skip>${yarn.lint.skip}</skip>
449+
</configuration>
450+
</execution>
451+
</executions>
452+
</plugin>
453+
</plugins>
454+
</build>
455+
</profile>
456+
<profile>
457+
<id>yarn-lint</id>
458+
<activation>
459+
<property>
460+
<name>!env.CI</name>
461+
</property>
462+
<file>
463+
<exists>package.json</exists>
464+
</file>
465+
</activation>
466+
<build>
467+
<plugins>
468+
<plugin>
469+
<groupId>com.github.eirslett</groupId>
470+
<artifactId>frontend-maven-plugin</artifactId>
471+
<version>1.15.0</version>
472+
<executions>
473+
<execution>
474+
<id>yarn lint</id>
475+
<goals>
476+
<goal>yarn</goal>
477+
</goals>
478+
<configuration>
479+
<arguments>lint</arguments>
480+
<skip>${yarn.lint.skip}</skip>
481+
</configuration>
482+
</execution>
483+
</executions>
484+
</plugin>
485+
</plugins>
486+
</build>
487+
</profile>
488+
<profile>
489+
<id>yarn-execution</id>
490+
<activation>
491+
<file>
492+
<exists>package.json</exists>
493+
</file>
494+
</activation>
495+
<build>
496+
<plugins>
497+
<plugin>
498+
<groupId>org.apache.maven.plugins</groupId>
499+
<artifactId>maven-antrun-plugin</artifactId>
500+
<executions>
501+
<execution>
502+
<id>download-yarn</id>
503+
<goals>
504+
<goal>run</goal>
505+
</goals>
506+
<phase>initialize</phase>
507+
<configuration>
508+
<target>
509+
<property name="yarn.dest" value="${project.basedir}/.yarn/releases/yarn-${yarn-berry.version}.cjs" />
510+
<dirname file="${yarn.dest}" property="yarn.dest.dir" />
511+
<mkdir dir="${yarn.dest.dir}" />
512+
<get dest="${yarn.dest}" src="https://repo.yarnpkg.com/${yarn-berry.version}/packages/yarnpkg-cli/bin/yarn.js" usetimestamp="true" />
513+
<checksum algorithm="SHA-256" file="${yarn.dest}" property="${yarn-berry.sha256sum}" verifyProperty="yarn.checksum.matches" />
514+
<condition property="yarn.checksum.matches.fail">
515+
<equals arg1="${yarn.checksum.matches}" arg2="false" />
516+
</condition>
517+
<fail if="yarn.checksum.matches.fail">Checksum error</fail>
518+
<echo file="${project.basedir}/.yarnrc.yml">yarnPath: ${yarn.dest}</echo>
519+
</target>
520+
</configuration>
521+
</execution>
522+
</executions>
523+
</plugin>
524+
<plugin>
525+
<groupId>com.github.eirslett</groupId>
526+
<artifactId>frontend-maven-plugin</artifactId>
527+
<version>1.15.0</version>
528+
<executions>
529+
530+
<execution>
531+
<id>install node and yarn</id>
532+
<goals>
533+
<goal>install-node-and-yarn</goal>
534+
</goals>
535+
<phase>initialize</phase>
536+
<configuration>
537+
<nodeVersion>v${node.version}</nodeVersion>
538+
<yarnVersion>v${yarn.version}</yarnVersion>
539+
<nodeDownloadRoot>https://repo.jenkins-ci.org/nodejs-dist/</nodeDownloadRoot>
540+
<!-- tried to create a mirror for yarnDownloadRoot but it did not work -->
541+
</configuration>
542+
</execution>
543+
544+
<execution>
545+
<id>yarn install</id>
546+
<goals>
547+
<goal>yarn</goal>
548+
</goals>
549+
<phase>initialize</phase>
550+
</execution>
551+
552+
<execution>
553+
<id>yarn build</id>
554+
<goals>
555+
<goal>yarn</goal>
556+
</goals>
557+
<phase>generate-sources</phase>
558+
<configuration>
559+
<arguments>build</arguments>
560+
</configuration>
561+
</execution>
562+
563+
<execution>
564+
<id>yarn lint</id>
565+
<goals>
566+
<goal>yarn</goal>
567+
</goals>
568+
<configuration>
569+
<arguments>lint:ci</arguments>
570+
<skip>${yarn.lint.skip}</skip>
571+
</configuration>
572+
</execution>
573+
</executions>
574+
</plugin>
575+
</plugins>
576+
</build>
577+
</profile>
578+
579+
<profile>
580+
<id>clean-node</id>
581+
<activation>
582+
<property>
583+
<name>cleanNode</name>
584+
</property>
585+
<file>
586+
<exists>package.json</exists>
587+
</file>
588+
</activation>
589+
<build>
590+
<plugins>
591+
<plugin>
592+
<groupId>org.apache.maven.plugins</groupId>
593+
<artifactId>maven-clean-plugin</artifactId>
594+
<!-- Version specified in grandparent POM -->
595+
<configuration>
596+
<filesets>
597+
<fileset>
598+
<directory>node</directory>
599+
<followSymlinks>false</followSymlinks>
600+
</fileset>
601+
<fileset>
602+
<directory>node_modules</directory>
603+
<followSymlinks>false</followSymlinks>
604+
</fileset>
605+
</filesets>
606+
</configuration>
607+
</plugin>
608+
</plugins>
609+
</build>
610+
</profile>
418611
</profiles>
419612
</project>

0 commit comments

Comments
 (0)