Skip to content

Commit

Permalink
parse more cli options
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 11, 2023
1 parent 755d5f1 commit 2748bfb
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 2 deletions.
1 change: 1 addition & 0 deletions generators/app/__snapshots__/generator.spec.mts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Options:
--project-version <value> project version to use, this option is not persisted (env: JHI_PROJECT_VERSION)
--jhipster-dependencies-version <value> jhipster-dependencies version to use, this option is not persisted (env: JHIPSTER_DEPENDENCIES_VERSION)
--with-generated-flag Add a GeneratedByJHipster annotation to all generated java classes and interfaces
--dev-database-type <value> Development database
--client-framework <value> Provide client framework for the application
--prettier-tab-width <value> Default tab width for prettier
--with-admin-ui Generate administrative user interface
Expand Down
4 changes: 4 additions & 0 deletions generators/app/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
} from '../generator-list.mjs';

import { applicationTypes, applicationOptions, clientFrameworkTypes } from '../../jdl/jhipster/index.mjs';
import command from './command.mjs';

const { MICROSERVICE } = applicationTypes;
const { NO: CLIENT_FRAMEWORK_NO } = clientFrameworkTypes;
Expand Down Expand Up @@ -65,6 +66,9 @@ export default class JHipsterAppGenerator extends BaseApplicationGenerator {
await this.checkForNewVersion();
}
},
loadOptions() {
this.parseJHipsterOptions(command.options);
},

validate() {
if (!this.skipChecks && this.jhipsterConfig.skipServer && this.jhipsterConfig.skipClient) {
Expand Down
13 changes: 13 additions & 0 deletions generators/client/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_CYPRESS, GENERATOR_COMMON, G
import { testFrameworkTypes, clientFrameworkTypes } from '../../jdl/jhipster/index.mjs';
import { createNeedleCallback } from '../base/support/index.mjs';
import { loadStoredAppOptions } from '../app/support/index.mjs';
import command from './command.mjs';

const { ANGULAR, VUE, REACT } = clientFrameworkTypes;
const { CYPRESS } = testFrameworkTypes;
Expand All @@ -52,6 +53,18 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
}
}

get initializing() {
return this.asInitializingTaskGroup({
loadOptions() {
this.parseJHipsterOptions(command.options);
},
});
}

get [BaseApplicationGenerator.INITIALIZING]() {
return this.delegateTasksToBlueprint(() => this.initializing);
}

get prompting() {
return this.asPromptingTaskGroup({
askForClient,
Expand Down
1 change: 1 addition & 0 deletions generators/jdl/__snapshots__/generator.spec.mts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Options:
--project-version <value> project version to use, this option is not persisted (env: JHI_PROJECT_VERSION)
--jhipster-dependencies-version <value> jhipster-dependencies version to use, this option is not persisted (env: JHIPSTER_DEPENDENCIES_VERSION)
--with-generated-flag Add a GeneratedByJHipster annotation to all generated java classes and interfaces
--dev-database-type <value> Development database
--client-framework <value> Provide client framework for the application
--prettier-tab-width <value> Default tab width for prettier
--with-admin-ui Generate administrative user interface
Expand Down
4 changes: 2 additions & 2 deletions generators/server/command.mts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
import { JHipsterCommandDefinition } from '../base/api.mjs';
import { GENERATOR_JAVA, GENERATOR_LIQUIBASE } from '../generator-list.mjs';
import { GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL } from '../generator-list.mjs';

const command: JHipsterCommandDefinition = {
options: {
Expand Down Expand Up @@ -86,7 +86,7 @@ const command: JHipsterCommandDefinition = {
hide: true,
},
},
import: [GENERATOR_JAVA, GENERATOR_LIQUIBASE],
import: [GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL],
};

export default command;
31 changes: 31 additions & 0 deletions generators/spring-data-relational/command.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright 2013-2023 the original author or authors from the JHipster project.
*
* This file is part of the JHipster project, see https://www.jhipster.tech/
* for more information.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { JHipsterCommandDefinition } from '../base/api.mjs';

const command: JHipsterCommandDefinition = {
options: {
devDatabaseType: {
description: 'Development database',
type: String,
scope: 'storage',
},
},
};

export default command;
13 changes: 13 additions & 0 deletions generators/spring-data-relational/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
} from './internal/dependencies.mjs';
import { hibernateSnakeCase } from '../server/support/string.mjs';
import { getJdbcUrl, getR2dbcUrl } from './support/index.mjs';
import command from './command.mjs';

const { SQL } = databaseTypes;

Expand All @@ -46,6 +47,18 @@ export default class SqlGenerator extends BaseApplicationGenerator<SpringBootGen
}
}

get initializing() {
return this.asInitializingTaskGroup({
loadOptions() {
this.parseJHipsterOptions(command.options);
},
});
}

get [BaseApplicationGenerator.INITIALIZING]() {
return this.delegateTasksToBlueprint(() => this.initializing);
}

get composing() {
return this.asComposingTaskGroup({
async composing() {
Expand Down
1 change: 1 addition & 0 deletions generators/spring-data-relational/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
* limitations under the License.
*/
export { default } from './generator.mjs';
export { default as command } from './command.mjs';

0 comments on commit 2748bfb

Please sign in to comment.