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 13, 2023
1 parent bc13e4b commit 441318c
Show file tree
Hide file tree
Showing 83 changed files with 625 additions and 332 deletions.
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: {} }');
});
});
});
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 && !ctx.microfrontend,
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 })));
20 changes: 19 additions & 1 deletion generators/server/templates/build.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ task webapp_test(type: NpmTask) {
inputs.dir("<%= clientSrcDir %>")
.withPropertyName("webapp-source-dir")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ if (!clientFrameworkAngular) { _%>
<%_ if (clientFrameworkReact) { _%>
inputs.files("tsconfig.json")
.withPropertyName("tsconfig")
.withPathSensitivity(PathSensitivity.RELATIVE)
Expand All @@ -524,6 +524,24 @@ task webapp_test(type: NpmTask) {
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>
<%_ if (clientFrameworkVue) { _%>
inputs.files("tsconfig.json", "tsconfig.app.json")
.withPropertyName("tsconfig")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ if (microfrontend) { _%>
def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>")
webpackDevFiles.exclude("webpack.prod.js")
inputs.files(webpackDevFiles)
.withPropertyName("webpack-dir")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } else { _%>
inputs.files("vite.config.ts")
.withPropertyName("vite")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>
inputs.files(".postcssrc")
.withPropertyName("postcssrc")
.withPathSensitivity(PathSensitivity.RELATIVE)
Expand Down
19 changes: 18 additions & 1 deletion generators/server/templates/gradle/profile_dev.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ task webapp(type: NpmTask) {
inputs.dir("<%= clientSrcDir %>")
.withPropertyName("webapp-source-dir")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ if (!clientFrameworkAngular) { _%>
<%_ if (clientFrameworkReact) { _%>
inputs.files("tsconfig.json")
.withPropertyName("tsconfig")
.withPathSensitivity(PathSensitivity.RELATIVE)
Expand All @@ -146,9 +146,26 @@ task webapp(type: NpmTask) {
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>
<%_ if (clientFrameworkVue) { _%>
inputs.files("tsconfig.json", "tsconfig.app.json")
.withPropertyName("tsconfig")
.withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(".postcssrc")
.withPropertyName("postcssrc")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ if (microfrontend) { _%>
def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>")
webpackDevFiles.exclude("webpack.prod.js")
inputs.files(webpackDevFiles)
.withPropertyName("webpack-dir")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } else { _%>
inputs.files("vite.config.ts")
.withPropertyName("vite")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>
<%_ } _%>
outputs.dir("<%= clientDistDir %>")
.withPropertyName("webapp-build-dir")
Expand Down
9 changes: 8 additions & 1 deletion generators/server/templates/pom.xml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -986,16 +986,23 @@
<include>target/classes/static/**/*.*</include>
<include>package-lock.json</include>
<include>package.json</include>
<include>webpack/*.*</include>
<include>tsconfig.json</include>
<%_ if (clientFrameworkAngular) { _%>
<include>tsconfig.app.json</include>
<include>webpack/*.*</include>
<%_ } _%>
<%_ if (clientFrameworkReact) { _%>
<include>.postcss.config.js</include>
<include>webpack/*.*</include>
<%_ } _%>
<%_ if (clientFrameworkVue) { _%>
<include>tsconfig.app.json</include>
<include>.postcssrc.js</include>
<%_ if (microfrontend) { _%>
<include>webpack/*.*</include>
<%_ } else { _%>
<include>vite.config.ts</include>
<%_ } _%>
<%_ } _%>
</includes>
<excludes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,16 @@ 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()
<%_ if (microfrontend) { _%>
.requestMatchers(mvc.pattern("/app/**")).permitAll()
.requestMatchers(mvc.pattern("/i18n/**")).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,19 @@ public class SecurityConfiguration {
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.securityMatcher(new NegatedServerWebExchangeMatcher(new OrServerWebExchangeMatcher(
<%_ if (clientFrameworkVue) { _%>
pathMatchers(
"/assets/**",
<%_ if (microfrontend) { _%>
"/app/**",
"/i18n/**",
"/content/**",
<%_ } _%>
"/swagger-ui/**"
)
<%_ } else { _%>
pathMatchers("/app/**", "/i18n/**", "/content/**", "/swagger-ui/**")
<%_ } _%>
)))
<%_ if (!applicationTypeMicroservice) { _%>
.cors(withDefaults())
Expand Down
Loading

0 comments on commit 441318c

Please sign in to comment.