Skip to content

Commit

Permalink
Merge pull request #27465 from mshima/vue-bootswatch
Browse files Browse the repository at this point in the history
client: retrieve bootstrap v4 themes for vue
  • Loading branch information
DanielFran authored Oct 1, 2024
2 parents d37d27b + 02c443f commit cf58c6e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions generators/client/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ export const askForClientTheme = asPromptingTask(async function askForClientThem
if (control.existingProject && !this.options.askAnswered) return;

const config = this.jhipsterConfigWithDefaults;
const { clientFramework } = config;

await this.prompt(
{
type: 'list',
name: 'clientTheme',
when: () => ['angular', 'react', 'vue'].includes(config.clientFramework!),
when: () => ['angular', 'react', 'vue'].includes(clientFramework!),
message: 'Would you like to use a Bootswatch theme (https://bootswatch.com/)?',
choices: async () => {
const bootswatchChoices = await retrieveOnlineBootswatchThemes().catch(errorMessage => {
const bootswatchChoices = await retrieveOnlineBootswatchThemes({ clientFramework }).catch(errorMessage => {
this.log.warn(errorMessage);
return retrieveLocalBootswatchThemes();
return retrieveLocalBootswatchThemes({ clientFramework });
});
return [
{
Expand Down Expand Up @@ -74,15 +76,15 @@ export const askForClientThemeVariant = asPromptingTask(async function askForCli
);
});

async function retrieveOnlineBootswatchThemes(): Promise<Choice[]> {
return _retrieveBootswatchThemes(true);
async function retrieveOnlineBootswatchThemes({ clientFramework }): Promise<Choice[]> {
return _retrieveBootswatchThemes({ clientFramework, useApi: true });
}

async function retrieveLocalBootswatchThemes(): Promise<Choice[]> {
return _retrieveBootswatchThemes(false);
async function retrieveLocalBootswatchThemes({ clientFramework }): Promise<Choice[]> {
return _retrieveBootswatchThemes({ clientFramework, useApi: false });
}

async function _retrieveBootswatchThemes(useApi): Promise<Choice[]> {
async function _retrieveBootswatchThemes({ clientFramework, useApi }): Promise<Choice[]> {
const errorMessage = 'Could not fetch bootswatch themes from API. Using default ones.';
if (!useApi) {
return [
Expand Down Expand Up @@ -116,7 +118,7 @@ async function _retrieveBootswatchThemes(useApi): Promise<Choice[]> {

return new Promise((resolve, reject) => {
httpsGet(
'https://bootswatch.com/api/5.json',
`https://bootswatch.com/api/${clientFramework === 'vue' ? '4' : '5'}.json`,

body => {
try {
Expand Down

0 comments on commit cf58c6e

Please sign in to comment.