generator-fedhipster
Version:
Spring Boot + Angular/React in one handy generator
59 lines (54 loc) • 2.11 kB
JavaScript
/**
* Copyright 2013-2019 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
*
* http://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 writeFiles = require('./files').writeFiles;
const utils = require('../utils');
const BaseBlueprintGenerator = require('../generator-base-blueprint');
/* constants used throughout */
let useBlueprint;
module.exports = class extends BaseBlueprintGenerator {
constructor(args, opts) {
super(args, opts);
utils.copyObjectProps(this, opts.context);
this.configOptions = this.options.configOptions || {};
if (this.databaseType === 'cassandra') {
this.pkType = 'UUID';
}
const blueprint = this.options.blueprint || this.configOptions.blueprint || this.config.get('blueprint');
if (!opts.fromBlueprint) {
// use global variable since getters dont have access to instance property
useBlueprint = this.composeBlueprint(blueprint, 'entity-server', {
...this.options,
context: opts.context,
debug: opts.context.isDebugEnabled,
configOptions: this.configOptions
});
} else {
useBlueprint = false;
}
}
// Public API method used by the getter and also by Blueprints
_writing() {
return writeFiles();
}
get writing() {
if (useBlueprint) return;
return this._writing();
}
};