-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nx-micronaut): add
nx-micronaut
plugin
This new plugin adds first-class support for [Micronaut framework](https://micronaut.io/). This will allow you (for example) to create cloud-native JVM-based applications in your Nx workspace.
- Loading branch information
Showing
77 changed files
with
2,469 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Run e2e Tests for nx-micronaut | ||
|
||
on: | ||
push: | ||
branches: [ develop ] | ||
paths: [ "nx.json", "package.json", "workspace.json", "packages/common/**", "packages/nx-micronaut/**" ] | ||
pull_request: | ||
branches: [ develop ] | ||
paths: [ "nx.json", "package.json", "workspace.json", "packages/common/**", "packages/nx-micronaut/**" ] | ||
|
||
jobs: | ||
run_e2e: | ||
name: Run e2e Tests | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
node-version: [16.x] | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Java | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- name: Cache Yarn | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: yarn | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ matrix.os }}-node-${{ matrix.node-version }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ matrix.os }}-node-${{ matrix.node-version }}-${{ env.cache-name }}- | ||
- name: Install packages | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Run e2e tests | ||
env: | ||
NX_E2E_CI_CACHE_KEY: e2e-gha-${{ matrix.os }}-${{ matrix.node-version }} | ||
NX_E2E_SKIP_BUILD_CLEANUP: ${{ 'true' }} | ||
NX_E2E_SKIP_DAEMON_CLEANUP: ${{ 'true' }} | ||
run: | | ||
yarn ts-node -P ./tools/tsconfig.tools.json ./tools/patch-nx-project.ts | ||
yarn run e2e nx-micronaut-e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eslint.validate": ["json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'nx-micronaut-e2e', | ||
preset: '../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
}, | ||
transform: { | ||
'^.+\\.[tj]s$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/e2e/nx-micronaut-e2e', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "application", | ||
"sourceRoot": "e2e/nx-micronaut-e2e/src", | ||
"targets": { | ||
"e2e": { | ||
"executor": "@nrwl/nx-plugin:e2e", | ||
"options": { | ||
"target": "nx-micronaut:build", | ||
"jestConfig": "e2e/nx-micronaut-e2e/jest.config.ts" | ||
} | ||
} | ||
}, | ||
"tags": [], | ||
"implicitDependencies": ["nx-micronaut"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
import { | ||
checkFilesExist, | ||
readFile, | ||
readJson, | ||
runNxCommandAsync, | ||
tmpProjPath, | ||
uniq, | ||
} from '@nrwl/nx-plugin/testing'; | ||
import { ensureNxProjectWithDeps } from '@nxrocks/common/testing'; | ||
|
||
import { lstatSync } from 'fs'; | ||
|
||
describe('nx-micronaut e2e', () => { | ||
const isWin = process.platform === "win32"; | ||
|
||
// Setting up individual workspaces per | ||
// test can cause e2e runs to take a long time. | ||
// For this reason, we recommend each suite only | ||
// consumes 1 workspace. The tests should each operate | ||
// on a unique project in the workspace, such that they | ||
// are not dependant on one another. | ||
beforeAll(() => { | ||
ensureNxProjectWithDeps('@nxrocks/nx-micronaut', 'dist/packages/nx-micronaut', | ||
[{ depPkgName: '@nxrocks/common', depDistPath: 'dist/packages/common' }]); | ||
}); | ||
|
||
afterAll(() => { | ||
// `nx reset` kills the daemon, and performs | ||
// some work which can help clean up e2e leftovers | ||
runNxCommandAsync('reset'); | ||
}); | ||
|
||
it('should create nx-micronaut with default options', async() => { | ||
const prjName = uniq('nx-micronaut'); | ||
await runNxCommandAsync( | ||
`generate @nxrocks/nx-micronaut:new ${prjName}` | ||
); | ||
|
||
const resultClean= await runNxCommandAsync(`clean ${prjName}`); | ||
expect(resultClean.stdout).toContain(`Executing command: ${isWin ? 'mvnw.bat' : './mvnw'} clean`) | ||
|
||
expect(() => | ||
checkFilesExist(`apps/${prjName}/mvnw`,`apps/${prjName}/pom.xml`, `apps/${prjName}/README.md`) | ||
).not.toThrow(); | ||
|
||
// make sure the build wrapper file is executable (*nix only) | ||
if(!isWin) { | ||
const execPermission = '755'; | ||
expect( | ||
lstatSync( | ||
tmpProjPath(`apps/${prjName}/mvnw`) | ||
).mode & octal(execPermission) | ||
).toEqual(octal(execPermission)); | ||
} | ||
|
||
}, 200000); | ||
|
||
it('should create nx-micronaut with given options', async() => { | ||
const prjName = uniq('nx-micronaut'); | ||
const buildSystem = 'MAVEN'; | ||
const basePackage = 'com.tinesoft'; | ||
const features="graphql"; | ||
|
||
await runNxCommandAsync( | ||
`generate @nxrocks/nx-micronaut:new ${prjName} --projectType default --buildSystem=${buildSystem} --basePackage=${basePackage} --features=${features}` | ||
); | ||
|
||
const resultClean= await runNxCommandAsync(`clean ${prjName}`); | ||
expect(resultClean.stdout).toContain(`Executing command: ${isWin ? 'mvnw.bat' : './mvnw'} clean`) | ||
|
||
expect(() => | ||
checkFilesExist( | ||
`apps/${prjName}/mvnw`, | ||
`apps/${prjName}/pom.xml`, | ||
`apps/${prjName}/README.md`, | ||
`apps/${prjName}/src/main/java/com/tinesoft/${prjName.split('-')[0]}/Application.java`) | ||
).not.toThrow(); | ||
|
||
const pomXml = readFile(`apps/${prjName}/pom.xml`); | ||
expect(pomXml).toContain(`<groupId>${basePackage}.${prjName.split('-')[0]}</groupId>`); | ||
expect(pomXml).toContain(`<artifactId>${prjName.split('-')[1]}</artifactId>`); | ||
|
||
// make sure the build wrapper file is executable (*nix only) | ||
if(!isWin) { | ||
const execPermission = '755'; | ||
expect( | ||
lstatSync( | ||
tmpProjPath(`apps/${prjName}/mvnw`) | ||
).mode & octal(execPermission) | ||
).toEqual(octal(execPermission)); | ||
} | ||
|
||
}, 200000); | ||
|
||
describe('--buildSystem=GRADLE', () => { | ||
it('should create a gradle micronaut project', async() => { | ||
const prjName = uniq('nx-micronaut'); | ||
|
||
await runNxCommandAsync( | ||
`generate @nxrocks/nx-micronaut:new ${prjName} --projectType default --buildSystem GRADLE` | ||
); | ||
|
||
const resultClean= await runNxCommandAsync(`clean ${prjName}`); | ||
expect(resultClean.stdout).toContain(`Executing command: ${isWin ? 'gradlew.bat' : './gradlew'} clean`) | ||
|
||
expect(() => | ||
checkFilesExist(`apps/${prjName}/gradlew`,`apps/${prjName}/build.gradle`, `apps/${prjName}/README.md`) | ||
).not.toThrow(); | ||
|
||
// make sure the build wrapper file is executable (*nix only) | ||
if(!isWin) { | ||
const execPermission = '755'; | ||
expect( | ||
lstatSync( | ||
tmpProjPath(`apps/${prjName}/gradlew`) | ||
).mode & octal(execPermission) | ||
).toEqual(octal(execPermission)); | ||
} | ||
|
||
}, 200000); | ||
}); | ||
|
||
describe('--buildSystem=GRADLE_KOTLIN', () => { | ||
it('should create a gradle micronaut project with kotlin', async() => { | ||
const prjName = uniq('nx-micronaut'); | ||
|
||
await runNxCommandAsync( | ||
`generate @nxrocks/nx-micronaut:new ${prjName} --projectType default --buildSystem GRADLE_KOTLIN` | ||
); | ||
|
||
const resultClean= await runNxCommandAsync(`clean ${prjName}`); | ||
expect(resultClean.stdout).toContain(`Executing command: ${isWin ? 'gradlew.bat' : './gradlew'} clean`) | ||
|
||
expect(() => | ||
checkFilesExist(`apps/${prjName}/gradlew`,`apps/${prjName}/build.gradle.kts`, `apps/${prjName}/README.md`) | ||
).not.toThrow(); | ||
|
||
// make sure the build wrapper file is executable (*nix only) | ||
if(!isWin) { | ||
const execPermission = '755'; | ||
expect( | ||
lstatSync( | ||
tmpProjPath(`apps/${prjName}/gradlew`) | ||
).mode & octal(execPermission) | ||
).toEqual(octal(execPermission)); | ||
} | ||
|
||
}, 200000); | ||
}); | ||
|
||
|
||
describe('--directory', () => { | ||
it('should create src in the specified directory', async () => { | ||
const prjName = uniq('nx-micronaut'); | ||
await runNxCommandAsync( | ||
`generate @nxrocks/nx-micronaut:new ${prjName} --directory subdir` | ||
); | ||
expect(() => | ||
checkFilesExist(`apps/subdir/${prjName}/mvnw`,`apps/subdir/${prjName}/pom.xml`, `apps/subdir/${prjName}/README.md`) | ||
).not.toThrow(); | ||
}, 120000); | ||
}); | ||
|
||
describe('--tags', () => { | ||
it('should add tags to the project', async () => { | ||
const prjName = uniq('nx-micronaut'); | ||
await runNxCommandAsync( | ||
`generate @nxrocks/nx-micronaut:new ${prjName} --tags e2etag,e2ePackage` | ||
); | ||
const project = readJson(`apps/${prjName}/project.json`); | ||
expect(project.tags).toEqual(['e2etag', 'e2ePackage']); | ||
}, 120000); | ||
}); | ||
|
||
function octal(value: string | number): number { | ||
if (typeof value === 'string') return parseInt(value, 8); | ||
return value; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*", ".releaserc.js"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["./package.json", "./generators.json", "./executors.json"], | ||
"parser": "jsonc-eslint-parser", | ||
"rules": { | ||
"@nrwl/nx/nx-plugin-checks": "error" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { createScopedReleaseConfig } = require('../../tools/release'); | ||
|
||
module.exports = createScopedReleaseConfig({ | ||
projectScope: 'nx-micronaut', | ||
projectRoot: 'packages/nx-micronaut', | ||
buildOutput: 'dist/packages/nx-micronaut', | ||
}); |
Oops, something went wrong.