Skip to content

Commit

Permalink
feat(gradle): gradle atomizer
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Jun 28, 2024
1 parent 22aa2d9 commit 289bbba
Show file tree
Hide file tree
Showing 10 changed files with 436 additions and 60 deletions.
10 changes: 10 additions & 0 deletions graph/ui-project-details/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */
export default {
displayName: 'graph-ui-project-details',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]sx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/graph/graph-ui-project-details',
};
3 changes: 3 additions & 0 deletions graph/ui-project-details/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./tsconfig.storybook.json"
}
Expand Down
20 changes: 20 additions & 0 deletions graph/ui-project-details/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
2 changes: 1 addition & 1 deletion graph/ui-tooltips/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default {
'^.+\\.[tj]sx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/graph/ui-graph',
coverageDirectory: '../../coverage/graph/graph-ui-tooltips',
};
48 changes: 25 additions & 23 deletions packages/gradle/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ describe('@nx/gradle:init', () => {
});
const nxJson = readNxJson(tree);
expect(nxJson.plugins).toMatchInlineSnapshot(`
[
{
"options": {
"buildTargetName": "build",
"classesTargetName": "classes",
"testTargetName": "test",
},
"plugin": "@nx/gradle",
},
]
`);
[
{
"options": {
"buildTargetName": "build",
"ciTargetName": "test-ci",
"classesTargetName": "classes",
"testTargetName": "test",
},
"plugin": "@nx/gradle",
},
]
`);
});

it('should not overwrite existing plugins', async () => {
Expand All @@ -42,18 +43,19 @@ describe('@nx/gradle:init', () => {
});
const nxJson = readNxJson(tree);
expect(nxJson.plugins).toMatchInlineSnapshot(`
[
"foo",
{
"options": {
"buildTargetName": "build",
"classesTargetName": "classes",
"testTargetName": "test",
},
"plugin": "@nx/gradle",
},
]
`);
[
"foo",
{
"options": {
"buildTargetName": "build",
"ciTargetName": "test-ci",
"classesTargetName": "classes",
"testTargetName": "test",
},
"plugin": "@nx/gradle",
},
]
`);
});

it('should not add plugin if already in array', async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/gradle/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function addPlugin(tree: Tree) {
plugin: '@nx/gradle',
options: {
testTargetName: 'test',
ciTargetName: 'test-ci',
classesTargetName: 'classes',
buildTargetName: 'build',
},
Expand Down
5 changes: 2 additions & 3 deletions packages/gradle/src/plugin/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { readFileSync } from 'node:fs';
import { basename } from 'node:path';

import {
GRADLE_BUILD_FILES,
getCurrentGradleReport,
newLineSeparator,
} from '../utils/get-gradle-report';
Expand Down Expand Up @@ -58,14 +59,12 @@ export const createDependencies: CreateDependencies = async (
return Array.from(dependencies);
};

const gradleConfigFileNames = new Set(['build.gradle', 'build.gradle.kts']);

function findGradleFiles(fileMap: FileMap): string[] {
const gradleFiles: string[] = [];

for (const [_, files] of Object.entries(fileMap.projectFileMap)) {
for (const file of files) {
if (gradleConfigFileNames.has(basename(file.file))) {
if (GRADLE_BUILD_FILES.includes(basename(file.file))) {
gradleFiles.push(file.file);
}
}
Expand Down
Loading

0 comments on commit 289bbba

Please sign in to comment.