Skip to content

Commit

Permalink
migrate vue to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 12, 2023
1 parent 90b99f2 commit 13f0c38
Show file tree
Hide file tree
Showing 85 changed files with 472 additions and 975 deletions.
2 changes: 1 addition & 1 deletion generators/client/files-common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const files = {
templates: ['.eslintignore', 'README.md.jhi.client'],
},
{
condition: generator => generator.microfrontend && (generator.clientFrameworkVue || generator.clientFrameworkReact),
condition: generator => generator.microfrontend && generator.clientFrameworkReact,
templates: ['webpack/webpack.microfrontend.js.jhi'],
},
{
Expand Down
12 changes: 1 addition & 11 deletions generators/client/generator-needles.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ClientGenerator from './index.mjs';
import { CLIENT_WEBPACK_DIR } from '../generator-constants.mjs';
import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs';

const { ANGULAR, VUE, REACT } = clientFrameworkTypes;
const { ANGULAR, REACT } = clientFrameworkTypes;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mockBlueprintSubGen: any = class extends ClientGenerator {
Expand Down Expand Up @@ -61,14 +61,4 @@ describe('needle API Webpack: JHipster client generator with blueprint', () => {
runResult.assertFileContent(`${CLIENT_WEBPACK_DIR}webpack.common.js`, '{ devServer: {} }');
});
});

describe('Vue clientFramework', () => {
before(() => {
return generateAppWithClientFramework(VUE);
});

it('should add webpack config to webpack.common.js', async () => {
runResult.assertFileContent(`${CLIENT_WEBPACK_DIR}webpack.common.js`, '{ devServer: {} }');
});
});
});
4 changes: 2 additions & 2 deletions generators/client/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
source.addWebpackConfig({
config: `${conditional}require('./webpack.microfrontend')(config, options, targetOptions)`,
});
} else if (application.clientFrameworkVue || application.clientFrameworkReact) {
} else if (application.clientFrameworkReact) {
source.addWebpackConfig({ config: "require('./webpack.microfrontend')({ serve: options.env.WEBPACK_SERVE })" });
} else {
} else if (!application.clientFrameworkVue) {
throw new Error(`Client framework ${application.clientFramework} doesn't support microfrontends`);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
limitations under the License.
-%>
{
<%_ if (clientFrameworkVue) { _%>
"extends": "@vue/tsconfig/tsconfig.dom.json",
<%_ } else { _%>
"extends": "../../../../tsconfig.json",
<%_ } _%>
"compilerOptions": {
"baseUrl": "./",
"sourceMap": false,
Expand Down
6 changes: 6 additions & 0 deletions generators/languages/files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export const clientI18nFiles = {
'user-management.json',
],
},
{
condition: ctx => ctx.clientFrameworkVue && ctx.enableTranslation,
path: `${CLIENT_MAIN_SRC_DIR}/i18n/`,
renameTo: context => `${context.clientSrcDir}/i18n/${context.lang}/${context.lang}.js`,
templates: ['index.js'],
},
{
from: context => `${CLIENT_MAIN_SRC_DIR}/i18n/${context.lang}/`,
to: context => `${context.clientSrcDir}/i18n/${context.lang}/`,
Expand Down
8 changes: 2 additions & 6 deletions generators/languages/languages.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { basicHelpers, defaultHelpers as helpers, result as runResult } from '../../test/support/index.mjs';

import { CLIENT_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, CLIENT_WEBPACK_DIR } from '../generator-constants.mjs';
import { CLIENT_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs';
import { supportedLanguages } from './support/index.mjs';

const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -84,13 +84,9 @@ const noLanguageFiles = languageValue => {
};

const containsLanguageInVueStore = languageValue => {
it(`add language ${languageValue} into translation-store.ts, webpack.common.js`, () => {
it(`add language ${languageValue} into translation-store.ts`, () => {
const langKey = languageValue.includes('-') ? `'${languageValue}'` : `${languageValue}`;
runResult.assertFileContent(`${CLIENT_MAIN_SRC_DIR}app/shared/config/languages.ts`, `${langKey}: { name:`);
runResult.assertFileContent(
`${CLIENT_WEBPACK_DIR}webpack.common.js`,
`{ pattern: './src/main/webapp/i18n/${languageValue}/*.json', fileName: './i18n/${languageValue}.json' }`,
);
});
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { all } from 'deepmerge';

export default all(Object.values(import.meta.glob('./*.json', { import: 'default', eager: true })));
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ public class SecurityConfiguration {
<%_ if (!skipClient) { _%>
.requestMatchers(mvc.pattern("/index.html"), mvc.pattern("/*.js"), mvc.pattern("/*.map"), mvc.pattern("/*.css")).permitAll()
.requestMatchers(mvc.pattern("/*.ico"), mvc.pattern("/*.png"), mvc.pattern("/*.svg"), mvc.pattern("/*.webapp")).permitAll()
<%_ if (clientFrameworkVue) { _%>
.requestMatchers(mvc.pattern("/assets/**")).permitAll()
<%_ } else { _%>
.requestMatchers(mvc.pattern("/app/**")).permitAll()
.requestMatchers(mvc.pattern("/i18n/**")).permitAll()
<%_ } _%>
.requestMatchers(mvc.pattern("/content/**")).permitAll()
.requestMatchers(mvc.pattern("/swagger-ui/**")).permitAll()
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ public class SecurityConfiguration {
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.securityMatcher(new NegatedServerWebExchangeMatcher(new OrServerWebExchangeMatcher(
<%_ if (clientFrameworkVue) { _%>
pathMatchers("/assets/**", "/swagger-ui/**")
<%_ } else { _%>
pathMatchers("/app/**", "/i18n/**", "/content/**", "/swagger-ui/**")
<%_ } _%>
)))
<%_ if (!applicationTypeMicroservice) { _%>
.cors(withDefaults())
Expand Down
Loading

0 comments on commit 13f0c38

Please sign in to comment.