diff options
Diffstat (limited to 'subprojects/docs/build.gradle.kts')
-rw-r--r-- | subprojects/docs/build.gradle.kts | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/subprojects/docs/build.gradle.kts b/subprojects/docs/build.gradle.kts new file mode 100644 index 00000000..9226ffe0 --- /dev/null +++ b/subprojects/docs/build.gradle.kts | |||
@@ -0,0 +1,91 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2024 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | |||
7 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn | ||
8 | import tools.refinery.gradle.utils.SonarPropertiesUtils | ||
9 | |||
10 | plugins { | ||
11 | id("tools.refinery.gradle.frontend-workspace") | ||
12 | id("tools.refinery.gradle.sonarqube") | ||
13 | } | ||
14 | |||
15 | frontend { | ||
16 | assembleScript.set("run build") | ||
17 | } | ||
18 | |||
19 | val srcDir = "src" | ||
20 | |||
21 | val docusaurusOutputDir = layout.buildDirectory.dir("docusaurus") | ||
22 | |||
23 | val configFiles: FileCollection = files( | ||
24 | rootProject.file("yarn.lock"), | ||
25 | rootProject.file("package.json"), | ||
26 | "package.json", | ||
27 | rootProject.file("tsconfig.base.json"), | ||
28 | "tsconfig.json", | ||
29 | "babel.config.config.ts", | ||
30 | "docusaurus.config.ts", | ||
31 | ) | ||
32 | |||
33 | val lintConfigFiles: FileCollection = configFiles + files( | ||
34 | rootProject.file(".eslintrc.cjs"), | ||
35 | rootProject.file("prettier.config.cjs") | ||
36 | ) | ||
37 | |||
38 | tasks { | ||
39 | assembleFrontend { | ||
40 | inputs.dir("src") | ||
41 | inputs.files(configFiles) | ||
42 | outputs.dir(docusaurusOutputDir) | ||
43 | } | ||
44 | |||
45 | val typeCheckFrontend by registering(RunYarn::class) { | ||
46 | dependsOn(installFrontend) | ||
47 | inputs.dir(srcDir) | ||
48 | inputs.files(configFiles) | ||
49 | outputs.dir(layout.buildDirectory.dir("typescript")) | ||
50 | script.set("run typecheck") | ||
51 | group = "verification" | ||
52 | description = "Check for TypeScript type errors." | ||
53 | } | ||
54 | |||
55 | val lintFrontend by registering(RunYarn::class) { | ||
56 | dependsOn(installFrontend) | ||
57 | dependsOn(typeCheckFrontend) | ||
58 | inputs.dir(srcDir) | ||
59 | inputs.files(lintConfigFiles) | ||
60 | outputs.file(layout.buildDirectory.file("eslint.json")) | ||
61 | script.set("run lint") | ||
62 | group = "verification" | ||
63 | description = "Check for TypeScript lint errors and warnings." | ||
64 | } | ||
65 | |||
66 | register<RunYarn>("fixFrontend") { | ||
67 | dependsOn(installFrontend) | ||
68 | dependsOn(typeCheckFrontend) | ||
69 | inputs.dir(srcDir) | ||
70 | inputs.files(lintConfigFiles) | ||
71 | script.set("run lint:fix") | ||
72 | group = "verification" | ||
73 | description = "Check for TypeScript lint errors and warnings." | ||
74 | } | ||
75 | |||
76 | check { | ||
77 | dependsOn(typeCheckFrontend) | ||
78 | dependsOn(lintFrontend) | ||
79 | } | ||
80 | |||
81 | clean { | ||
82 | delete(".docusaurus") | ||
83 | delete(".yarn") | ||
84 | } | ||
85 | } | ||
86 | |||
87 | sonarqube.properties { | ||
88 | SonarPropertiesUtils.addToList(properties, "sonar.sources", srcDir) | ||
89 | property("sonar.nodejs.executable", "${frontend.nodeInstallDirectory.get()}/bin/node") | ||
90 | property("sonar.eslint.reportPaths", "${layout.buildDirectory.get()}/eslint.json") | ||
91 | } | ||