Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ out/
bin/
*.log
.vscode/
src/main/generated/
src/main/generated/

node_modules/
*.tsbuildinfo
52 changes: 52 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
@file:Suppress("UnstableApiUsage")

import com.github.gradle.node.NodeExtension
import com.github.gradle.node.npm.task.NpmTask
import org.gradle.kotlin.dsl.configure

plugins {
id("org.openrewrite.build.recipe-library") version "latest.release"
id("org.openrewrite.build.moderne-source-available-license") version "latest.release"
id("com.github.node-gradle.node") version "latest.release"
}

group = "org.openrewrite.recipe"
Expand Down Expand Up @@ -108,3 +115,48 @@ tasks.test {
tasks.withType<JavaCompile> {
options.compilerArgs.add("-Arewrite.javaParserClasspathFrom=resources")
}

// Override the defaults because the JavaScript code is one directory down (recipes-testing/).
extensions.configure<NodeExtension> {
workDir.set(projectDir.resolve("recipes-testing"))
npmWorkDir.set(projectDir.resolve("recipes-testing"))
nodeProjectDir.set(projectDir.resolve("recipes-testing"))
}

val npmInstall = tasks.named("npmInstall")

val npmBuild = tasks.register<NpmTask>("npmBuild") {
inputs.files(npmInstall)
.withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(file("recipes-testing/package.json"))
.withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(fileTree("recipes-testing/src"))
.withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir(file("recipes-testing/dist/"))

args = listOf("run", "build")
}

val npmTest = tasks.register<NpmTask>("npmTest") {
inputs.files(npmInstall)
.withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(fileTree("recipes-testing") {
include("*.json")
include("jest.config.js")
}).withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(fileTree("recipes-testing/src"))
.withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(fileTree("recipes-testing/test"))
.withPathSensitivity(PathSensitivity.RELATIVE)
dependsOn(npmBuild)

args = listOf("run", "test")
}

tasks.named("check") {
dependsOn(npmTest)
}

tasks.named("build") {
dependsOn(npmBuild)
}
1 change: 1 addition & 0 deletions recipes-testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
17 changes: 17 additions & 0 deletions recipes-testing/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
testTimeout: 30000,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
'^@openrewrite/recipes-testing/(.*)$': '<rootDir>/dist/src/$1'
},
transform: {
'^.+\\.tsx?$': ['ts-jest', {
tsconfig: 'tsconfig.test.json',
}],
},
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.d.ts'],
};
Loading