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 assembleFrontend = tasks.named('assembleFrontend') assembleFrontend.configure { inputs.dir 'src' 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 typecheckFrontend = tasks.register('typecheckFrontend', RunYarn) { dependsOn installFrontend inputs.dir 'src' 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 inputs.dir 'src' 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 inputs.dir 'src' 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 inputs.dir 'src' 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.' } sonarqube.properties { properties['sonar.sources'] += ['src'] property 'sonar.nodejs.executable', "${frontend.nodeInstallDirectory.get()}/bin/node" property 'sonar.eslint.reportPaths', "${buildDir}/eslint.json" }