diff options
Diffstat (limited to 'subprojects/frontend')
-rw-r--r-- | subprojects/frontend/build.gradle.kts | 140 |
1 files changed, 72 insertions, 68 deletions
diff --git a/subprojects/frontend/build.gradle.kts b/subprojects/frontend/build.gradle.kts index ab2f61c9..80f10f7e 100644 --- a/subprojects/frontend/build.gradle.kts +++ b/subprojects/frontend/build.gradle.kts | |||
@@ -1,18 +1,19 @@ | |||
1 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn | 1 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn |
2 | import tools.refinery.buildsrc.SonarPropertiesUtils | 2 | import tools.refinery.gradle.utils.SonarPropertiesUtils |
3 | 3 | ||
4 | plugins { | 4 | plugins { |
5 | id("refinery-frontend-workspace") | 5 | id("tools.refinery.gradle.frontend-workspace") |
6 | id("refinery-sonarqube") | 6 | id("tools.refinery.gradle.sonarqube") |
7 | } | 7 | } |
8 | 8 | ||
9 | val viteOutputDir = "$buildDir/vite" | ||
10 | val productionResources = file("$viteOutputDir/production") | ||
11 | |||
12 | frontend { | 9 | frontend { |
13 | assembleScript.set("run build") | 10 | assembleScript.set("run build") |
14 | } | 11 | } |
15 | 12 | ||
13 | val viteOutputDir = "$buildDir/vite" | ||
14 | |||
15 | val productionResources = file("$viteOutputDir/production") | ||
16 | |||
16 | val productionAssets: Configuration by configurations.creating { | 17 | val productionAssets: Configuration by configurations.creating { |
17 | isCanBeConsumed = true | 18 | isCanBeConsumed = true |
18 | isCanBeResolved = false | 19 | isCanBeResolved = false |
@@ -53,78 +54,81 @@ val assembleFiles = assembleSources + assembleConfigFiles | |||
53 | 54 | ||
54 | val lintingFiles = sourcesWithTypes + buildScripts + sharedConfigFiles | 55 | val lintingFiles = sourcesWithTypes + buildScripts + sharedConfigFiles |
55 | 56 | ||
56 | val generateXStateTypes by tasks.registering(RunYarn::class) { | 57 | tasks { |
57 | dependsOn(tasks.installFrontend) | 58 | val generateXStateTypes by registering(RunYarn::class) { |
58 | inputs.files(sourcesWithoutTypes) | 59 | dependsOn(installFrontend) |
59 | inputs.files(installationState) | 60 | inputs.files(sourcesWithoutTypes) |
60 | outputs.dir("src") | 61 | inputs.files(installationState) |
61 | script.set("run typegen") | 62 | outputs.dir("src") |
62 | description = "Generate TypeScript typings for XState state machines." | 63 | script.set("run typegen") |
63 | } | 64 | description = "Generate TypeScript typings for XState state machines." |
65 | } | ||
64 | 66 | ||
65 | tasks.assembleFrontend { | 67 | assembleFrontend { |
66 | dependsOn(generateXStateTypes) | 68 | dependsOn(generateXStateTypes) |
67 | inputs.files(assembleFiles) | 69 | inputs.files(assembleFiles) |
68 | outputs.dir(productionResources) | 70 | outputs.dir(productionResources) |
69 | } | 71 | } |
70 | 72 | ||
71 | artifacts { | 73 | |
72 | add("productionAssets", productionResources) { | 74 | val typeCheckFrontend by registering(RunYarn::class) { |
73 | builtBy(tasks.assembleFrontend) | 75 | dependsOn(installFrontend) |
76 | dependsOn(generateXStateTypes) | ||
77 | inputs.files(lintingFiles) | ||
78 | outputs.dir("$buildDir/typescript") | ||
79 | script.set("run typecheck") | ||
80 | group = "verification" | ||
81 | description = "Check for TypeScript type errors." | ||
74 | } | 82 | } |
75 | } | ||
76 | 83 | ||
77 | val typeCheckFrontend by tasks.registering(RunYarn::class) { | 84 | val lintFrontend by registering(RunYarn::class) { |
78 | dependsOn(tasks.installFrontend) | 85 | dependsOn(installFrontend) |
79 | dependsOn(generateXStateTypes) | 86 | dependsOn(generateXStateTypes) |
80 | inputs.files(lintingFiles) | 87 | dependsOn(typeCheckFrontend) |
81 | outputs.dir("$buildDir/typescript") | 88 | inputs.files(lintingFiles) |
82 | script.set("run typecheck") | 89 | outputs.file("$buildDir/eslint.json") |
83 | group = "verification" | 90 | script.set("run lint") |
84 | description = "Check for TypeScript type errors." | 91 | group = "verification" |
85 | } | 92 | description = "Check for TypeScript lint errors and warnings." |
93 | } | ||
86 | 94 | ||
87 | val lintFrontend by tasks.registering(RunYarn::class) { | 95 | register<RunYarn>("fixFrontend") { |
88 | dependsOn(tasks.installFrontend) | 96 | dependsOn(installFrontend) |
89 | dependsOn(generateXStateTypes) | 97 | dependsOn(generateXStateTypes) |
90 | dependsOn(typeCheckFrontend) | 98 | dependsOn(typeCheckFrontend) |
91 | inputs.files(lintingFiles) | 99 | inputs.files(lintingFiles) |
92 | outputs.file("$buildDir/eslint.json") | 100 | script.set("run lint:fix") |
93 | script.set("run lint") | 101 | group = "verification" |
94 | group = "verification" | 102 | description = "Fix TypeScript lint errors and warnings." |
95 | description = "Check for TypeScript lint errors and warnings." | 103 | } |
96 | } | ||
97 | 104 | ||
98 | val fixFrontend by tasks.registering(RunYarn::class) { | 105 | check { |
99 | dependsOn(tasks.installFrontend) | 106 | dependsOn(typeCheckFrontend) |
100 | dependsOn(generateXStateTypes) | 107 | dependsOn(lintFrontend) |
101 | dependsOn(typeCheckFrontend) | 108 | } |
102 | inputs.files(lintingFiles) | ||
103 | script.set("run lint:fix") | ||
104 | group = "verification" | ||
105 | description = "Fix TypeScript lint errors and warnings." | ||
106 | } | ||
107 | 109 | ||
108 | tasks.check { | 110 | register<RunYarn>("serveFrontend") { |
109 | dependsOn(typeCheckFrontend) | 111 | dependsOn(installFrontend) |
110 | dependsOn(lintFrontend) | 112 | dependsOn(generateXStateTypes) |
111 | } | 113 | inputs.files(assembleFiles) |
114 | outputs.dir("$viteOutputDir/development") | ||
115 | script.set("run serve") | ||
116 | group = "run" | ||
117 | description = "Start a Vite dev server with hot module replacement." | ||
118 | } | ||
112 | 119 | ||
113 | tasks.register<RunYarn>("serveFrontend") { | 120 | clean { |
114 | dependsOn(tasks.installFrontend) | 121 | delete("dev-dist") |
115 | dependsOn(generateXStateTypes) | 122 | delete(fileTree("src") { |
116 | inputs.files(assembleFiles) | 123 | include("**/*.typegen.ts") |
117 | outputs.dir("$viteOutputDir/development") | 124 | }) |
118 | script.set("run serve") | 125 | } |
119 | group = "run" | ||
120 | description = "Start a Vite dev server with hot module replacement." | ||
121 | } | 126 | } |
122 | 127 | ||
123 | tasks.clean { | 128 | artifacts { |
124 | delete("dev-dist") | 129 | add("productionAssets", productionResources) { |
125 | delete(fileTree("src") { | 130 | builtBy(tasks.assembleFrontend) |
126 | include("**/*.typegen.ts") | 131 | } |
127 | }) | ||
128 | } | 132 | } |
129 | 133 | ||
130 | sonarqube.properties { | 134 | sonarqube.properties { |