UNPKG

generator-begcode

Version:

Spring Boot + Angular/React/Vue in one handy generator

67 lines (66 loc) 2.92 kB
import { camelCase, defaults, kebabCase, startCase, upperFirst } from 'lodash-es'; import BaseApplicationGenerator from '../base-application/index.js'; import { getHipster } from '../base/support/index.js'; import { getDefaultAppName } from './support/index.js'; import { validateProjectName } from './support/name-resolver.js'; export default class ProjectNameGenerator extends BaseApplicationGenerator { javaApplication; defaultBaseName = () => getDefaultAppName({ reproducible: this.options.reproducible, javaApplication: this.javaApplication, }); validateBaseName = (input) => validateProjectName(input, { javaApplication: this.javaApplication }); async beforeQueue() { this.sharedData.getControl().existingProject = Boolean(this.options.defaults || this.options.applicationWithConfig || (this.jhipsterConfig.baseName !== undefined && this.config.existed)); if (!this.fromBlueprint) { await this.composeWithBlueprints(); } } get initializing() { return this.asInitializingTaskGroup({ parseOptions() { if (this.options.defaults) { if (!this.jhipsterConfig.baseName) { this.jhipsterConfig.baseName = this.defaultBaseName(); } } }, }); } get [BaseApplicationGenerator.INITIALIZING]() { return this.delegateTasksToBlueprint(() => this.initializing); } get loading() { return this.asLoadingTaskGroup({ load({ application }) { const { baseName, projectDescription } = this.jhipsterConfig; application.baseName = baseName; application.projectDescription = projectDescription; }, }); } get [BaseApplicationGenerator.LOADING]() { return this.delegateTasksToBlueprint(() => this.loading); } get preparing() { return this.asPreparingTaskGroup({ preparing({ application }) { const { baseName, upperFirstCamelCaseBaseName } = application; const humanizedBaseName = baseName.toLowerCase() === 'jhipster' ? 'JHipster' : startCase(baseName); defaults(application, { humanizedBaseName, camelizedBaseName: camelCase(baseName), hipster: getHipster(baseName), capitalizedBaseName: upperFirst(baseName), dasherizedBaseName: kebabCase(baseName), lowercaseBaseName: baseName.toLowerCase(), upperFirstCamelCaseBaseName, projectDescription: `Description for ${humanizedBaseName}`, }); }, }); } get [BaseApplicationGenerator.PREPARING]() { return this.delegateTasksToBlueprint(() => this.preparing); } }