1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
plugins {
id 'refinery-frontend-workspace'
id 'refinery-sonarqube'
}
import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn
def viteOutputDir = "${buildDir}/vite"
def productionResources = file("${viteOutputDir}/production")
frontend {
assembleScript = 'run build'
}
configurations {
productionAssets {
canBeConsumed = true
canBeResolved = false
}
}
def installFrontend = tasks.named('installFrontend')
def sourcesWithoutTypegen = fileTree('src') {
exclude '**/*.typegen.ts'
}
def assembleFrontend = tasks.named('assembleFrontend')
assembleFrontend.configure {
dependsOn generateXStateTypes
inputs.dir 'public'
inputs.files sourcesWithoutTypegen
inputs.file 'index.html'
inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'vite.config.ts')
inputs.file rootProject.file('yarn.lock')
outputs.dir productionResources
}
artifacts {
productionAssets(productionResources) {
builtBy assembleFrontend
}
}
def generateXStateTypes = tasks.register('generateXStateTypes', RunYarn) {
dependsOn installFrontend
inputs.files sourcesWithoutTypegen
inputs.file 'package.json'
inputs.file rootProject.file('yarn.lock')
outputs.dir 'src'
script = 'run typegen'
description = 'Generate TypeScript typings for XState state machines.'
}
def typecheckFrontend = tasks.register('typecheckFrontend', RunYarn) {
dependsOn installFrontend
dependsOn generateXStateTypes
inputs.dir 'src'
inputs.dir 'types'
inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'tsconfig.node.json')
inputs.file rootProject.file('yarn.lock')
outputs.dir "${buildDir}/typescript"
script = 'run typecheck'
group = 'verification'
description = 'Check for TypeScript type errors.'
}
def lintFrontend = tasks.register('lintFrontend', RunYarn) {
dependsOn installFrontend
dependsOn generateXStateTypes
inputs.dir 'src'
inputs.dir 'types'
inputs.files('.eslintrc.cjs', 'prettier.config.cjs')
inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'tsconfig.node.json')
inputs.file rootProject.file('yarn.lock')
if (project.hasProperty('ci')) {
outputs.file "${buildDir}/eslint.json"
script = 'run lint:ci'
} else {
script = 'run lint'
}
group = 'verification'
description = 'Check for TypeScript lint errors and warnings.'
}
def prettier = tasks.register('fixFrontend', RunYarn) {
dependsOn installFrontend
dependsOn generateXStateTypes
inputs.dir 'src'
inputs.dir 'types'
inputs.files('.eslintrc.cjs', 'prettier.config.cjs')
inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'tsconfig.node.json')
inputs.file rootProject.file('yarn.lock')
script = 'run lint:fix'
group = 'verification'
description = 'Fix TypeScript lint errors and warnings.'
}
tasks.named('check') {
dependsOn(typecheckFrontend)
dependsOn(lintFrontend)
}
tasks.register('serveFrontend', RunYarn) {
dependsOn installFrontend
dependsOn generateXStateTypes
inputs.dir 'public'
inputs.files sourcesWithoutTypegen
inputs.file 'index.html'
inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'vite.config.ts')
inputs.file rootProject.file('yarn.lock')
outputs.dir "${viteOutputDir}/development"
script = 'run serve'
group = 'run'
description = 'Start a Vite dev server with hot module replacement.'
}
tasks.named('clean') {
delete 'dev-dist'
delete fileTree('src') {
include '**/*.typegen.ts'
}
}
sonarqube.properties {
properties['sonar.sources'] += ['src']
property 'sonar.nodejs.executable', "${frontend.nodeInstallDirectory.get()}/bin/node"
property 'sonar.eslint.reportPaths', "${buildDir}/eslint.json"
}
|