Skip to content

Commit

Permalink
Merge branch 'jhipster-upstream' + upgrdae primeng to 9.0.6 + fix tes…
Browse files Browse the repository at this point in the history
…t animations
  • Loading branch information
yelhouti committed Apr 27, 2020
2 parents c9064b4 + 03eb84e commit 6392d83
Show file tree
Hide file tree
Showing 419 changed files with 29,510 additions and 5,026 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2019 the original author or authors from the JHipster project.
* Copyright 2013-2020 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.
Expand Down Expand Up @@ -35,7 +35,7 @@ const files = {
'package.json',
'proxy.conf.json',
'tsconfig.json',
'tsconfig-aot.json',
'tsconfig.app.json',
'tslint.json',
'.eslintrc.json',
'.eslintignore',
Expand Down Expand Up @@ -94,6 +94,7 @@ const files = {
],
swagger: [
{
condition: generator => !generator.reactive,
path: MAIN_SRC_DIR,
templates: ['swagger-ui/index.html', { file: 'swagger-ui/dist/images/throbber.gif', method: 'copy' }]
}
Expand Down Expand Up @@ -237,6 +238,7 @@ const files = {
{ file: 'admin/docs/docs.module.ts', method: 'processJs' },
{ file: 'admin/docs/docs.component.ts', method: 'processJs' },
'admin/docs/docs.component.html',
'admin/docs/docs.scss',
{ file: 'admin/health/health.route.ts', method: 'processJs' },
{ file: 'admin/health/health.module.ts', method: 'processJs' },
{ file: 'admin/health/health.component.ts', method: 'processJs' },
Expand Down Expand Up @@ -317,7 +319,10 @@ const files = {
'core/core.module.ts',
// login
'core/login/login.service.ts',
'core/user/account.model.ts'
'core/user/account.model.ts',

// icons
'core/icons/font-awesome-icons.ts'
]
},
{
Expand All @@ -342,7 +347,7 @@ const files = {
{
condition: generator => generator.enableTranslation,
path: ANGULAR_DIR,
templates: ['core/language/language.constants.ts', 'core/language/language.helper.ts']
templates: ['core/language/language.constants.ts']
}
],
angularShared: [
Expand All @@ -355,6 +360,7 @@ const files = {
'shared/constants/error.constants.ts',
'shared/constants/input.constants.ts',
'shared/constants/pagination.constants.ts',
'shared/constants/authority.constants.ts',
// models
'shared/util/request-util.ts',
// alert service code
Expand Down Expand Up @@ -501,7 +507,7 @@ module.exports = {
};

function writeFiles() {
mkdirp(MAIN_SRC_DIR);
mkdirp(this.CLIENT_MAIN_SRC_DIR);
// write angular 2.x and above files
this.writeFilesToDisk(files, this, false, './angular');
}
11 changes: 6 additions & 5 deletions generators/client/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/* eslint-disable consistent-return */
const chalk = require('chalk');
const ClientGenerator = require('generator-jhipster/generators/client');
const writeAngularFiles = require('./templates/files-angular').writeFiles;
const writeAngularFiles = require('./files-angular').writeFiles;

module.exports = class extends ClientGenerator {
constructor(args, opts) {
super(args, Object.assign({ fromBlueprint: true }, opts)); // fromBlueprint variable is important
super(args, { fromBlueprint: true, ...opts }); // fromBlueprint variable is important

const jhContext = (this.jhipsterContext = this.options.jhipsterContext);

if (!jhContext) {
this.error(
`This is a JHipster blueprint and should be used only like ${chalk.yellow('jhipster --blueprint primeng-blueprint')}`
);
this.error(`This is a JHipster blueprint and should be used only like ${chalk.yellow('jhipster --blueprint helloworld')}`);
}

this.configOptions = jhContext.configOptions || {};

// This sets up options for this sub generator and is being reused from JHipster
jhContext.setupClientOptions(this, jhContext);
}
Expand Down Expand Up @@ -75,6 +74,8 @@ module.exports = class extends ClientGenerator {
// }
// };
// If the prompts need to be overriden then use the code commented out above instead

// Here we are not overriding this phase and hence its being handled by JHipster
return super._prompting();
}

Expand Down
245 changes: 245 additions & 0 deletions generators/client/needle-api/needle-client-angular.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
/**
* Copyright 2013-2020 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.
*/
const chalk = require('chalk');
const _ = require('lodash');
const needleClientBase = require('./needle-client');
const constants = require('generator-jhipster/generators/generator-constants');
const jhipsterUtils = require('generator-jhipster/generators/utils');

module.exports = class extends needleClientBase {
addGlobalSCSSStyle(style, comment) {
const filePath = `${this.CLIENT_MAIN_SRC_DIR}content/scss/global.scss`;
this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-main');
}

addVendorSCSSStyle(style, comment) {
const filePath = `${this.CLIENT_MAIN_SRC_DIR}content/scss/vendor.scss`;
super.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-vendor');
}

addModule(appName, angularName, folderName, fileName, enableTranslation, clientFramework) {
const modulePath = `${this.CLIENT_MAIN_SRC_DIR}app/app.module.ts`;
const importNeedle = 'jhipster-needle-angular-add-module-import';
const moduleNeedle = 'jhipster-needle-angular-add-module';

this._genericAddModule(
appName,
angularName,
folderName,
fileName,
enableTranslation,
clientFramework,
modulePath,
importNeedle,
moduleNeedle
);
}

addToAdminModule(appName, adminAngularName, adminFolderName, adminFileName, enableTranslation, clientFramework) {
const adminModulePath = `${this.CLIENT_MAIN_SRC_DIR}app/admin/admin-routing.module.ts`;
const importNeedle = 'jhipster-needle-add-admin-module-import';
const moduleNeedle = 'jhipster-needle-add-admin-module';

this._genericAddModule(
appName,
adminAngularName,
adminFolderName,
adminFileName,
enableTranslation,
clientFramework,
adminModulePath,
importNeedle,
moduleNeedle
);
}

_genericAddModule(
appName,
angularName,
folderName,
fileName,
enableTranslation,
clientFramework,
modulePath,
importNeedle,
moduleNeedle
) {
const errorMessage = `${chalk.yellow('Reference to ') +
angularName +
folderName +
fileName +
enableTranslation +
clientFramework} ${chalk.yellow(`not added to ${modulePath}.\n`)}`;

const importRewriteFileModel = this._generateRewriteFileModelWithImportStatement(
appName,
angularName,
folderName,
fileName,
modulePath,
importNeedle
);
this.addBlockContentToFile(importRewriteFileModel, errorMessage);

const moduleRewriteFileModel = this._generateRewriteFileModelAddModule(appName, angularName, modulePath, moduleNeedle);
this.addBlockContentToFile(moduleRewriteFileModel, errorMessage);
}

_generateRewriteFileModelWithImportStatement(appName, angularName, folderName, fileName, modulePath, needle) {
const importStatement = this._generateImportStatement(appName, angularName, folderName, fileName);

return this.generateFileModel(modulePath, needle, this.generator.stripMargin(importStatement));
}

_generateImportStatement(appName, angularName, folderName, fileName) {
let importStatement = `|import { ${appName}${angularName}Module } from './${folderName}/${fileName}.module';`;
if (importStatement.length > constants.LINE_LENGTH) {
// prettier-ignore
importStatement = `|import {
| ${appName}${angularName}Module
|} from './${folderName}/${fileName}.module';`;
}

return importStatement;
}

_generateRewriteFileModelAddModule(appName, angularName, modulePath, needle) {
return this.generateFileModel(modulePath, needle, this.generator.stripMargin(`|${appName}${angularName}Module,`));
}

addIcon(iconName) {
const iconsPath = `${this.CLIENT_MAIN_SRC_DIR}app/core/icons/font-awesome-icons.ts`;
const iconImport = `fa${this.generator.upperFirstCamelCase(iconName)}`;
if (!jhipsterUtils.checkRegexInFile(iconsPath, new RegExp(`\\b${iconImport}\\b`), this.generator)) {
try {
jhipsterUtils.replaceContent(
{
file: iconsPath,
pattern: /(\r?\n)(\s*)\/\/ jhipster-needle-add-icon-import/g,
content: `,\n ${iconImport}\n // jhipster-needle-add-icon-import`
},
this.generator
);
} catch (e) {
this.generator.log(
chalk.yellow('\nUnable to find ') +
iconsPath +
chalk.yellow(' or other error. Icon imports not updated with icon ') +
iconImport +
chalk.yellow('.\n')
);
this.generator.debug('Error:', e);
}
}
}

addEntityToMenu(routerName, enableTranslation, entityTranslationKeyMenu) {
const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`;
const entityMenuPath = `${this.CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`;
const entityEntry =
// prettier-ignore
this.generator.stripMargin(`|<li>
| <a class="dropdown-item" routerLink="${routerName}" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }" (click)="collapseNavbar()">
| <i class="fa fa-asterisk"></i>
| <span${enableTranslation ? ` jhiTranslate="global.menu.entities.${entityTranslationKeyMenu}"` : ''}>${_.startCase(routerName)}</span>
| </a>
| </li>`);
const rewriteFileModel = this.generateFileModel(entityMenuPath, 'jhipster-needle-add-entity-to-menu', entityEntry);

this.addBlockContentToFile(rewriteFileModel, errorMessage);
}

addElementToMenu(routerName, iconName, enableTranslation, translationKeyMenu = routerName) {
const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`;
const entityMenuPath = `${this.CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`;
// prettier-ignore
const entityEntry = `<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link" routerLink="${routerName}" (click)="collapseNavbar()">
<i class="fa fa-${iconName}"></i>
<span${enableTranslation ? ` jhiTranslate="global.menu.${translationKeyMenu}"` : ''}>${_.startCase(routerName)}</span>
</a>
</li>`;
const rewriteFileModel = this.generateFileModel(entityMenuPath, 'jhipster-needle-add-element-to-menu', entityEntry);

this.addBlockContentToFile(rewriteFileModel, errorMessage);
this.addIcon(iconName);
}

addElementToAdminMenu(routerName, iconName, enableTranslation, translationKeyMenu = routerName) {
const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to admin menu.\n')}`;
const navbarAdminPath = `${this.CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`;
// prettier-ignore
const entityEntry = `<li>
<a class="dropdown-item" routerLink="${routerName}" routerLinkActive="active" (click)="collapseNavbar()">
<i class="fa fa-${iconName}"></i>
<span${enableTranslation ? ` jhiTranslate="global.menu.admin.${translationKeyMenu}"` : ''}>${_.startCase(routerName)}</span>
</a>
</li>`;
const rewriteFileModel = this.generateFileModel(navbarAdminPath, 'jhipster-needle-add-element-to-admin-menu', entityEntry);

this.addBlockContentToFile(rewriteFileModel, errorMessage);
this.addIcon(iconName);
}

_addRoute(route, modulePath, moduleName, needleName, filePath, prefix = ',') {
const isRouteAlreadyAdded = jhipsterUtils.checkStringInFile(filePath, `path: '${route}'`, this.generator);
if (isRouteAlreadyAdded) {
return;
}
const errorMessage = `${chalk.yellow('Route ') + route + chalk.yellow(` not added to ${filePath}.\n`)}`;
const routingEntry = this.generator.stripMargin(`${prefix}
| {
| path: '${route}',
| loadChildren: () => import('${modulePath}').then(m => m.${moduleName})
| }`);
const rewriteFileModel = this.generateFileModel(filePath, needleName, routingEntry);
this.addBlockContentToFile(rewriteFileModel, errorMessage);
}

addEntityToModule(entityInstance, entityClass, entityAngularName, entityFolderName, entityFileName, entityUrl, microServiceName) {
const entityModulePath = `${this.CLIENT_MAIN_SRC_DIR}app/entities/entity.module.ts`;
try {
const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(
entityModulePath,
`path: '${entityUrl}'`,
this.generator
);

if (!isSpecificEntityAlreadyGenerated) {
const appName = this.generator.getAngularXAppName();
const isAnyEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(entityModulePath, 'loadChildren', this.generator);
const prefix = isAnyEntityAlreadyGenerated ? ',' : '';

const modulePath = `./${entityFolderName}/${entityFileName}.module`;
const moduleName = microServiceName
? `${this.generator.upperFirstCamelCase(microServiceName)}${entityAngularName}Module`
: `${appName}${entityAngularName}Module`;

this._addRoute(entityUrl, modulePath, moduleName, 'jhipster-needle-add-entity-route', entityModulePath, prefix);
}
} catch (e) {
this.generator.debug('Error:', e);
}
}

addAdminRoute(route, modulePath, moduleName) {
const adminModulePath = `${this.CLIENT_MAIN_SRC_DIR}app/admin/admin-routing.module.ts`;
this._addRoute(route, modulePath, moduleName, 'jhipster-needle-add-admin-route', adminModulePath);
}
};
46 changes: 46 additions & 0 deletions generators/client/needle-api/needle-client-i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright 2013-2020 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.
*/
const chalk = require('chalk');
const _ = require('lodash');
const needleClient = require('./needle-client');

module.exports = class extends needleClient {
addElementTranslationKey(key, value, language) {
const errorMessage = ' not added as a new entity in the menu.';
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-element');
}

addAdminElementTranslationKey(key, value, language) {
const errorMessage = ' not added as a new entry in the admin menu.';
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-admin-element');
}

addEntityTranslationKey(key, value, language) {
const errorMessage = ' not added as a new entity in the menu.';
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-entry');
}

_addTranslationKey(key, value, language, errorMessage, needle) {
const fullErrorMessage = `${chalk.yellow(' Reference to ') + language} ${chalk.yellow(errorMessage)}`;
const fullPath = `${this.CLIENT_MAIN_SRC_DIR}i18n/${language}/global.json`;
const rewriteFileModel = this.generateFileModel(fullPath, needle, `"${key}": "${_.startCase(value)}",`);

this.addBlockContentToFile(rewriteFileModel, fullErrorMessage);
}
};
Loading

0 comments on commit 6392d83

Please sign in to comment.