-
-
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-quarkus): add
link
generator to link projects implicitly
- Loading branch information
Showing
6 changed files
with
134 additions
and
2 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,30 @@ | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { Tree, readProjectConfiguration, addProjectConfiguration } from '@nrwl/devkit'; | ||
|
||
import generator from './generator'; | ||
import { LinkGeneratorSchema } from './schema'; | ||
|
||
describe('link generator', () => { | ||
let tree: Tree; | ||
const options: LinkGeneratorSchema = { sourceProjectName: 'quarkusapp', targetProjectName: 'ngapp' }; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
addProjectConfiguration(tree, options.sourceProjectName, { | ||
projectType: 'application', | ||
sourceRoot: `apps/${options.sourceProjectName}/src`, | ||
root: `apps/${options.sourceProjectName}`, | ||
}); | ||
addProjectConfiguration(tree, options.targetProjectName, { | ||
projectType: 'application', | ||
sourceRoot: `apps/${options.targetProjectName}/src`, | ||
root: `apps/${options.targetProjectName}`, | ||
}); | ||
}); | ||
|
||
it('should run successfully', async () => { | ||
await generator(tree, options); | ||
const targetProject = readProjectConfiguration(tree, options.targetProjectName); | ||
expect(targetProject.implicitDependencies).toEqual([options.sourceProjectName]); | ||
}) | ||
}); |
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,22 @@ | ||
import { | ||
readProjectConfiguration, | ||
Tree, | ||
updateProjectConfiguration, | ||
} from '@nrwl/devkit'; | ||
import { LinkGeneratorSchema } from './schema'; | ||
|
||
|
||
export default async function (tree: Tree, options: LinkGeneratorSchema) { | ||
|
||
readProjectConfiguration(tree, options.sourceProjectName); | ||
const targetProject = readProjectConfiguration(tree, options.targetProjectName); | ||
|
||
const targetProjectImplicitDependencies = targetProject.implicitDependencies || []; | ||
|
||
if(!targetProjectImplicitDependencies.includes(options.sourceProjectName)) { | ||
targetProjectImplicitDependencies.push(options.sourceProjectName); | ||
targetProject.implicitDependencies = targetProjectImplicitDependencies; | ||
updateProjectConfiguration(tree, options.targetProjectName, targetProject); | ||
} | ||
|
||
} |
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,4 @@ | ||
export interface LinkGeneratorSchema { | ||
sourceProjectName: string; | ||
targetProjectName: string; | ||
} |
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,28 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "Link", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"sourceProjectName": { | ||
"type": "string", | ||
"description": "The name of the source(Quarkus) project to link from ", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name of the source (Quarkus) project to link from?" | ||
}, | ||
"targetProjectName": { | ||
"type": "string", | ||
"description": "The name of the target project to link to ", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 1 | ||
}, | ||
"x-prompt": "What name of the target project to link to?" | ||
} | ||
}, | ||
"required": ["sourceProjectName", "targetProjectName"] | ||
} |