-
-
Notifications
You must be signed in to change notification settings - Fork 34
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 dynamic prompt to fetch quarkus extensions list
BREAKING CHANGE: Nx `v15.8.x` is now the minimum required version to run the plugin We now leverage Nx's new `NX_INTERACTIVE` environment variable to check whether we are running in interactive mode (normal cli) or not. When true, we automatically fetch `Quarkus` extensions and present them in an **autocomplete** prompt with **multi-select** support, so you can easily select which ones you want to include in your project.
- Loading branch information
Showing
10 changed files
with
68 additions
and
8 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,19 @@ | ||
# Recipes | ||
|
||
Some helpful recipes to help you best use the plugin. | ||
|
||
## Adding Quarkus extensions | ||
|
||
When running the `@nxrocks/nx-quarkus:project` generator from a non-interactive mode (like from `Nx Console`), we cannot automatically fetch and present to you, the list | ||
of `Quarkus` extensions (as we do in interactive, CLI mode). This is due to a limitation in Nx API, which does not support (yet?), such asynchronous prompts. | ||
|
||
You will need to fetch and enter the extensions ids manually: | ||
|
||
1. Go to [https://code.quarkus.io/api/extensions](https://code.quarkus.io/api/extensions) | ||
![Extract of Quarkus extensions](images/quarkus-extensions-list.png) | ||
|
||
> * Each `id` or `shortName`(when not empty) is the "id" of a Quarkus extension | ||
> * For example, `resteasy-reactive` for `io.quarkus:quarkus-resteasy-reactive`, `io.quarkus:quarkus-rest-client-reactive-jsonb` for `io.quarkus:quarkus-rest-client-reactive-jsonb`, etc. | ||
2. In Nx Console UI, enter the extensions ids you want to use, separated by a comma | ||
![Adding extensions in Nx Console](images/nx-console-add-extensions.png) |
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.
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { generateQuarkusProject } from './generate-quarkus-project'; | ||
export { addFormattingWithSpotless } from './add-formatting-with-spotless'; | ||
export { addMavenPublishPlugin } from './add-maven-publish-plugin'; | ||
export { normalizeOptions } from './normalize-options'; | ||
export { normalizeOptions } from './normalize-options'; | ||
export { promptQuarkusExtensions } from './prompt-quarkus-extensions'; |
23 changes: 23 additions & 0 deletions
23
packages/nx-quarkus/src/generators/project/lib/prompt-quarkus-extensions.ts
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,23 @@ | ||
import { NormalizedSchema } from "../schema"; | ||
import { prompt } from 'enquirer'; | ||
import { fetchQuarkusExtensions } from "../../../utils/quarkus-utils"; | ||
import { logger } from "@nrwl/devkit"; | ||
|
||
|
||
export async function promptQuarkusExtensions(options: NormalizedSchema) { | ||
|
||
if (options.extensions === undefined && process.env.NX_INTERACTIVE === 'true') { | ||
|
||
logger.info(`⏳ Fetching Quarkus extensions list. Please wait...`); | ||
|
||
const extensions = (await fetchQuarkusExtensions(options)).map(e => e.id); | ||
|
||
options.projectExtensions = await prompt({ | ||
name: 'extensions', | ||
message: 'What extensions would you like to use? (type something to filter, press [space] to multi-select)', | ||
type: 'autocomplete', | ||
choices: extensions, | ||
multiple: true, | ||
}).then((a) => a['extensions']); | ||
} | ||
} |
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