UNPKG

generator-jhipster

Version:

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

163 lines (142 loc) 4.12 kB
/** * Copyright 2013-2021 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. */ /* eslint-disable consistent-return */ const chalk = require('chalk'); const { generateMixedChain } = require('../../lib/support/mixin.cjs'); const { INITIALIZING_PRIORITY, CONFIGURING_PRIORITY, COMPOSING_PRIORITY, LOADING_PRIORITY, PREPARING_PRIORITY, WRITING_PRIORITY, } = require('../../lib/constants/priorities.cjs'); const { GENERATOR_SPRING_BOOT } = require('../generator-list'); const { files } = require('./files.cjs'); const { dependencyChain } = require('./mixin.cjs'); const MixedChain = generateMixedChain(GENERATOR_SPRING_BOOT); module.exports = class extends MixedChain { constructor(args, options, features) { super(args, options, { jhipsterModular: true, unique: 'namespace', ...features }); // Register options available to cli. if (!this.fromBlueprint) { this.registerCommonOptions(); this.registerChainOptions(); } if (this.options.help) return; // Application context for templates this.application = {}; if (this.options.defaults) { this.configureChain(); } } async _beforeQueue() { if (!this.fromBlueprint) { const configure = this.options.configure || !this.shouldComposeModular(); for (const generator of dependencyChain) { await this.dependsOnJHipster(generator, [], { configure }); } await this.composeWithBlueprints(GENERATOR_SPRING_BOOT); } } get initializing() { return { validateFromCli() { this.checkInvocationFromCLI(); }, sayHello() { if (!this.showHello()) return; this.log(chalk.white('⬢ Welcome to the JHipster Spring Boot ⬢')); }, loadRuntimeOptions() { this.loadRuntimeOptions(); }, loadOptionsConstants() { this.loadChainOptionsConstants(); }, }; } get [INITIALIZING_PRIORITY]() { if (this.delegateToBlueprint) return; return this.initializing; } get configuring() { return { configure() { this.configureSpringBoot(); }, }; } get [CONFIGURING_PRIORITY]() { if (this.delegateToBlueprint) return; return this.configuring; } get composing() { return { async compose() { if (!this.shouldComposeModular()) return; await this.composeWithSpringBootConfig(); }, }; } get [COMPOSING_PRIORITY]() { if (this.delegateToBlueprint) return; return this.composing; } get loading() { return { configureChain() { this.configureChain(); }, loadConstants() { this.loadChainConstants(this.application); }, loadConfig() { this.loadChainConfig(this.application); }, }; } get [LOADING_PRIORITY]() { if (this.delegateToBlueprint) return; return this.loading; } get preparing() { return { prepareDerivedProperties() { this.prepareChainDerivedProperties(this.application); }, }; } get [PREPARING_PRIORITY]() { if (this.delegateToBlueprint) return; return this.preparing; } get writing() { return { async writeFiles() { if (this.shouldSkipFiles()) return; await this.writeFiles({ sections: files, context: this.application }); }, }; } get [WRITING_PRIORITY]() { if (this.delegateToBlueprint) return; return this.writing; } };