Skip to content

Commit a46e973

Browse files
committed
upgarde angular to version 7.9.3+
1 parent 2c38787 commit a46e973

File tree

368 files changed

+8777
-7027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

368 files changed

+8777
-7027
lines changed

generators/client/files-angular.js

Lines changed: 112 additions & 96 deletions
Large diffs are not rendered by default.

generators/client/index.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright 2013-2022 the original author or authors from the JHipster project.
3+
*
4+
* This file is part of the JHipster project, see https://www.jhipster.tech/
5+
* for more information.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* https://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
export { default } from './index.js';
20+
export { files as angularFiles } from './files-angular.js';
21+
export { files as commonFiles } from './files-common.js';
22+
export { files as reactFiles } from './files-react.js';
23+
export { files as vueFiles } from './files-vue.js';

generators/client/needle-api/needle-client-angular.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2021 the original author or authors from the JHipster project.
2+
* Copyright 2013-2022 the original author or authors from the JHipster project.
33
*
44
* This file is part of the JHipster project, see https://www.jhipster.tech/
55
* for more information.

generators/client/needle-api/needle-client-i18n.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2021 the original author or authors from the JHipster project.
2+
* Copyright 2013-2022 the original author or authors from the JHipster project.
33
*
44
* This file is part of the JHipster project, see https://www.jhipster.tech/
55
* for more information.
@@ -20,24 +20,24 @@ const chalk = require('chalk');
2020
const needleClient = require('./needle-client');
2121

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

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

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

38-
_addTranslationKey(key, value, language, errorMessage, needle) {
38+
_addTranslationKey(key, value, language, errorMessage, needle, webappSrcDir = this.CLIENT_MAIN_SRC_DIR) {
3939
const fullErrorMessage = `${chalk.yellow(' Reference to ') + language} ${chalk.yellow(errorMessage)}`;
40-
const fullPath = `${this.CLIENT_MAIN_SRC_DIR}i18n/${language}/global.json`;
40+
const fullPath = `${webappSrcDir}i18n/${language}/global.json`;
4141
const rewriteFileModel = this.generateFileModel(fullPath, needle, `"${key}": "${value}",`);
4242

4343
this.addBlockContentToFile(rewriteFileModel, fullErrorMessage);

generators/client/needle-api/needle-client-react.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2021 the original author or authors from the JHipster project.
2+
* Copyright 2013-2022 the original author or authors from the JHipster project.
33
*
44
* This file is part of the JHipster project, see https://www.jhipster.tech/
55
* for more information.
@@ -29,20 +29,27 @@ module.exports = class extends needleClientBase {
2929

3030
addEntityToMenu(routerName, enableTranslation, entityTranslationKeyMenu, entityTranslationValue = _.startCase(routerName)) {
3131
const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`;
32-
const entityMenuPath = `${this.CLIENT_MAIN_SRC_DIR}app/shared/layout/menus/entities.tsx`;
32+
const entityMenuPath = `${this.CLIENT_MAIN_SRC_DIR}app/entities/menu.tsx`;
3333
const entityEntry =
3434
// prettier-ignore
3535
this.generator.stripMargin(`|<MenuItem icon="asterisk" to="/${routerName}">
36-
| ${enableTranslation ? `<Translate contentKey="global.menu.entities.${entityTranslationKeyMenu}" />` : `${entityTranslationValue}`}
37-
| </MenuItem>`);
36+
| ${enableTranslation ? `<Translate contentKey="global.menu.entities.${entityTranslationKeyMenu}" />` : `${entityTranslationValue}`}
37+
| </MenuItem>`);
3838
const rewriteFileModel = this.generateFileModel(entityMenuPath, 'jhipster-needle-add-entity-to-menu', entityEntry);
3939

4040
this.addBlockContentToFile(rewriteFileModel, errorMessage);
4141
}
4242

43-
addEntityToModule(entityInstance, entityClass, entityName, entityFolderName, entityFileName) {
44-
const indexModulePath = `${this.CLIENT_MAIN_SRC_DIR}app/entities/index.tsx`;
45-
const indexReducerPath = `${this.CLIENT_MAIN_SRC_DIR}app/shared/reducers/index.ts`;
43+
addEntityToModule(
44+
entityInstance,
45+
entityClass,
46+
entityName,
47+
entityFolderName,
48+
entityFileName,
49+
{ applicationTypeMicroservice, CLIENT_MAIN_SRC_DIR } = {}
50+
) {
51+
const indexModulePath = `${CLIENT_MAIN_SRC_DIR}app/entities/routes.tsx`;
52+
const indexReducerPath = `${CLIENT_MAIN_SRC_DIR}app/entities/reducers.ts`;
4653

4754
const errorMessage = path =>
4855
`${chalk.yellow('Reference to ') + entityInstance + entityClass + entityFolderName + entityFileName} ${chalk.yellow(
@@ -59,27 +66,19 @@ module.exports = class extends needleClientBase {
5966
const indexAddRoutePathRewriteFileModel = this.generateFileModel(
6067
indexModulePath,
6168
'jhipster-needle-add-route-path',
62-
this.generator.stripMargin(`|<ErrorBoundaryRoute path={\`\${match.url}${entityFileName}\`} component={${entityName}} />`)
69+
this.generator.stripMargin(
70+
`|<Route path="${applicationTypeMicroservice ? '/' : ''}${entityFileName}/*" element={<${entityName} />} />`
71+
)
6372
);
6473
this.addBlockContentToFile(indexAddRoutePathRewriteFileModel, errorMessage(indexModulePath));
6574

6675
const reducerAddImportRewriteFileModel = this.generateFileModel(
6776
indexReducerPath,
6877
'jhipster-needle-add-reducer-import', // prettier-ignore
69-
this.generator.stripMargin(`|// prettier-ignore
70-
|import ${entityInstance}, {
71-
| ${entityName}State
72-
|} from 'app/entities/${entityFolderName}/${entityFileName}.reducer';`)
78+
this.generator.stripMargin(`import ${entityInstance} from 'app/entities/${entityFolderName}/${entityFileName}.reducer';`)
7379
);
7480
this.addBlockContentToFile(reducerAddImportRewriteFileModel, errorMessage(indexReducerPath));
7581

76-
const reducerAddTypeRewriteFileModel = this.generateFileModel(
77-
indexReducerPath,
78-
'jhipster-needle-add-reducer-type',
79-
this.generator.stripMargin(`| readonly ${entityInstance}: ${entityName}State;`)
80-
);
81-
this.addBlockContentToFile(reducerAddTypeRewriteFileModel, errorMessage(indexReducerPath));
82-
8382
const reducerAddCombineRewriteFileModel = this.generateFileModel(
8483
indexReducerPath,
8584
'jhipster-needle-add-reducer-combine',

generators/client/needle-api/needle-client-vue.js

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2021 the original author or authors from the JHipster project.
2+
* Copyright 2013-2022 the original author or authors from the JHipster project.
33
*
44
* This file is part of the JHipster project, see https://www.jhipster.tech/
55
* for more information.
@@ -24,15 +24,25 @@ const needleClientBase = require('./needle-client');
2424
module.exports = class extends needleClientBase {
2525
addEntityToMenu(routerName, enableTranslation, entityTranslationKeyMenu, entityTranslationValue = _.startCase(routerName)) {
2626
const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`;
27-
const filePath = `${this.CLIENT_MAIN_SRC_DIR}/app/core/jhi-navbar/jhi-navbar.vue`;
27+
const filePath = `${this.CLIENT_MAIN_SRC_DIR}/app/entities/entities-menu.vue`;
28+
29+
const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(
30+
filePath,
31+
`<b-dropdown-item to="/${routerName}">`,
32+
this.generator
33+
);
34+
if (isSpecificEntityAlreadyGenerated) {
35+
return;
36+
}
37+
2838
const menuI18nTitle = enableTranslation ? ` v-text="$t('global.menu.entities.${entityTranslationKeyMenu}')"` : '';
2939
const entityEntry =
3040
// prettier-ignore
3141
this.generator.stripMargin(
32-
`<b-dropdown-item to="/${routerName}">
33-
| <font-awesome-icon icon="asterisk" />
34-
| <span${menuI18nTitle}>${entityTranslationValue}</span>
35-
| </b-dropdown-item>`);
42+
`|<b-dropdown-item to="/${routerName}">
43+
| <font-awesome-icon icon="asterisk" />
44+
| <span${menuI18nTitle}>${entityTranslationValue}</span>
45+
| </b-dropdown-item>`);
3646

3747
const rewriteFileModel = this.generateFileModel(filePath, 'jhipster-needle-add-entity-to-menu', entityEntry);
3848
this.addBlockContentToFile(rewriteFileModel, errorMessage);
@@ -41,6 +51,16 @@ module.exports = class extends needleClientBase {
4151
addEntityToRouterImport(entityName, fileName, folderName, readOnly) {
4252
const errorMessage = `${chalk.yellow('Reference to entity ') + entityName} ${chalk.yellow('not added to router entities import.\n')}`;
4353
const filePath = `${this.CLIENT_MAIN_SRC_DIR}/app/router/entities.ts`;
54+
55+
const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(
56+
filePath,
57+
`import('@/entities/${folderName}/${fileName}.vue');`,
58+
this.generator
59+
);
60+
if (isSpecificEntityAlreadyGenerated) {
61+
return;
62+
}
63+
4464
let entityEntry;
4565
if (!readOnly) {
4666
// prettier-ignore
@@ -70,8 +90,7 @@ module.exports = class extends needleClientBase {
7090
const errorMessage = `${chalk.yellow('Reference to entity ') + entityName} ${chalk.yellow('not added to router entities.\n')}`;
7191
const filePath = `${this.CLIENT_MAIN_SRC_DIR}/app/router/entities.ts`;
7292

73-
const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(filePath, `path: '/${entityFileName}'`, this.generator);
74-
93+
const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(filePath, `path: '${entityFileName}'`, this.generator);
7594
if (isSpecificEntityAlreadyGenerated) {
7695
return;
7796
}
@@ -81,25 +100,25 @@ module.exports = class extends needleClientBase {
81100
// prettier-ignore
82101
entityEntry = this.generator.stripMargin(
83102
`|{
84-
| path: '/${entityFileName}',
103+
| path: '${entityFileName}',
85104
| name: '${entityName}',
86105
| component: ${entityName},
87106
| meta: { authorities: [Authority.USER] }
88107
| },
89108
| {
90-
| path: '/${entityFileName}/new',
109+
| path: '${entityFileName}/new',
91110
| name: '${entityName}Create',
92111
| component: ${entityName}Update,
93112
| meta: { authorities: [Authority.USER] }
94113
| },
95114
| {
96-
| path: '/${entityFileName}/:${entityInstance}Id/edit',
115+
| path: '${entityFileName}/:${entityInstance}Id/edit',
97116
| name: '${entityName}Edit',
98117
| component: ${entityName}Update,
99118
| meta: { authorities: [Authority.USER] }
100119
| },
101120
| {
102-
| path: '/${entityFileName}/:${entityInstance}Id/view',
121+
| path: '${entityFileName}/:${entityInstance}Id/view',
103122
| name: '${entityName}View',
104123
| component: ${entityName}Details,
105124
| meta: { authorities: [Authority.USER] }
@@ -124,6 +143,7 @@ module.exports = class extends needleClientBase {
124143
}
125144

126145
const rewriteFileModel = this.generateFileModel(filePath, 'jhipster-needle-add-entity-to-router', entityEntry);
146+
rewriteFileModel.prettierAware = true;
127147
this.addBlockContentToFile(rewriteFileModel, errorMessage);
128148
}
129149

@@ -152,4 +172,34 @@ module.exports = class extends needleClientBase {
152172
const rewriteFileModel = this.generateFileModel(filePath, 'jhipster-needle-add-entity-service-to-main', entityEntry);
153173
this.addBlockContentToFile(rewriteFileModel, errorMessage);
154174
}
175+
176+
addEntityServiceToEntitiesComponentImport(entityName, entityClass, entityFileName, entityFolderName) {
177+
const errorMessage = `${chalk.yellow('Reference to entity ') + entityClass} ${chalk.yellow(
178+
'not added to import in entities component.\n'
179+
)}`;
180+
const filePath = `${this.CLIENT_MAIN_SRC_DIR}/app/entities/entities.component.ts`;
181+
182+
// prettier-ignore
183+
const entityEntry = `import ${entityName}Service from './${entityFolderName}/${entityFileName}.service';`;
184+
185+
const rewriteFileModel = this.generateFileModel(
186+
filePath,
187+
'jhipster-needle-add-entity-service-to-entities-component-import',
188+
entityEntry
189+
);
190+
this.addBlockContentToFile(rewriteFileModel, errorMessage);
191+
}
192+
193+
addEntityServiceToEntitiesComponent(entityInstance, entityName) {
194+
const errorMessage = `${chalk.yellow('Reference to entity ') + entityName} ${chalk.yellow(
195+
'not added to service in entities component.\n'
196+
)}`;
197+
const filePath = `${this.CLIENT_MAIN_SRC_DIR}/app/entities/entities.component.ts`;
198+
199+
// prettier-ignore
200+
const entityEntry = `@Provide('${entityInstance}Service') private ${entityInstance}Service = () => new ${entityName}Service();`;
201+
202+
const rewriteFileModel = this.generateFileModel(filePath, 'jhipster-needle-add-entity-service-to-entities-component', entityEntry);
203+
this.addBlockContentToFile(rewriteFileModel, errorMessage);
204+
}
155205
};

generators/client/needle-api/needle-client-webpack.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2021 the original author or authors from the JHipster project.
2+
* Copyright 2013-2022 the original author or authors from the JHipster project.
33
*
44
* This file is part of the JHipster project, see https://www.jhipster.tech/
55
* for more information.
@@ -23,18 +23,31 @@ const CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR;
2323
const SUPPORTED_CLIENT_FRAMEWORKS = constants.SUPPORTED_CLIENT_FRAMEWORKS;
2424

2525
module.exports = class extends needleClient {
26-
copyExternalAssets(source, target) {
26+
_getWebpackFile(clientFramework = this.clientFramework) {
27+
return this.clientFramework === SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR
28+
? `${CLIENT_WEBPACK_DIR}/webpack.custom.js`
29+
: `${CLIENT_WEBPACK_DIR}/webpack.common.js`;
30+
}
31+
32+
copyExternalAssets(source, target, clientFramework) {
2733
const errorMessage = 'Resource path not added to JHipster app.';
28-
const webpackDevPath =
29-
this.clientFramework === SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR
30-
? `${CLIENT_WEBPACK_DIR}/webpack.custom.js`
31-
: `${CLIENT_WEBPACK_DIR}/webpack.common.js`;
3234
let assetBlock = '';
3335
if (source && target) {
3436
assetBlock = `{ from: '${source}', to: '${target}' },`;
3537
}
36-
const rewriteFileModel = this.generateFileModel(webpackDevPath, 'jhipster-needle-add-assets-to-webpack', assetBlock);
38+
const rewriteFileModel = this.generateFileModel(
39+
this._getWebpackFile(clientFramework),
40+
'jhipster-needle-add-assets-to-webpack',
41+
assetBlock
42+
);
3743

3844
this.addBlockContentToFile(rewriteFileModel, errorMessage);
3945
}
46+
47+
addWebpackConfig(config, clientFramework) {
48+
config = `,${config}`;
49+
const rewriteFileModel = this.generateFileModel(this._getWebpackFile(clientFramework), 'jhipster-needle-add-webpack-config', config);
50+
rewriteFileModel.prettierAware = true;
51+
this.addBlockContentToFile(rewriteFileModel, 'Webpack config not added to JHipster app.\n');
52+
}
4053
};

generators/client/needle-api/needle-client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2021 the original author or authors from the JHipster project.
2+
* Copyright 2013-2022 the original author or authors from the JHipster project.
33
*
44
* This file is part of the JHipster project, see https://www.jhipster.tech/
55
* for more information.
@@ -23,7 +23,7 @@ module.exports = class extends needleBase {
2323
super(generator);
2424

2525
this.CLIENT_MAIN_SRC_DIR = generator.CLIENT_MAIN_SRC_DIR;
26-
this.clientFramework = generator.clientFramework;
26+
this.clientFramework = generator.clientFramework || generator.jhipsterConfig.clientFramework;
2727

2828
if (!this.CLIENT_MAIN_SRC_DIR) {
2929
generator.error('Client destination folder is missing');

generators/client/templates/angular/.browserslistrc.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%#
2-
Copyright 2013-2021 the original author or authors from the JHipster project.
2+
Copyright 2013-2022 the original author or authors from the JHipster project.
33
44
This file is part of the JHipster project, see https://www.jhipster.tech/
55
for more information.

generators/client/templates/angular/.eslintrc.json.ejs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%#
2-
Copyright 2013-2021 the original author or authors from the JHipster project.
2+
Copyright 2013-2022 the original author or authors from the JHipster project.
33
44
This file is part of the JHipster project, see https://www.jhipster.tech/
55
for more information.
@@ -35,7 +35,16 @@
3535
"parserOptions": {
3636
"ecmaVersion": 2018,
3737
"sourceType": "module",
38-
"project": "./tsconfig.json"
38+
"project": [
39+
"./tsconfig.app.json",
40+
<%_ if (cypressTests) { _%>
41+
"./<%= this.CLIENT_TEST_SRC_DIR %>cypress/tsconfig.json",
42+
<%_ } _%>
43+
<%_ if (protractorTests) { _%>
44+
"./tsconfig.e2e.json",
45+
<%_ } _%>
46+
"./tsconfig.spec.json"
47+
]
3948
},
4049
"rules": {
4150
"@angular-eslint/component-selector": [
@@ -92,6 +101,7 @@
92101
"@typescript-eslint/no-parameter-properties": ["warn", { "allows": ["public", "private", "protected"] }],
93102
"@typescript-eslint/no-shadow": ["error"],
94103
"@typescript-eslint/no-unnecessary-condition": "error",
104+
"@typescript-eslint/no-unsafe-argument": "off",
95105
"@typescript-eslint/no-unsafe-assignment": "off",
96106
"@typescript-eslint/no-unsafe-call": "off",
97107
"@typescript-eslint/no-unsafe-member-access": "off",

0 commit comments

Comments
 (0)