Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip ci vue vite #868

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions generators/bootstrap-application-base/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import assert from 'assert';
import os from 'os';
import _ from 'lodash';
import chalk from 'chalk';
import { passthrough } from '@yeoman/transform';

import BaseApplicationGenerator from '../base-application/index.mjs';
import {
Expand Down Expand Up @@ -274,6 +275,38 @@ export default class BootstrapApplicationBase extends BaseApplicationGenerator {
return this.preparingEachEntityRelationship;
}

get default() {
return this.asDefaultTaskGroup({
task({ application }) {
const isPackageJson = file => file.path === this.destinationPath('package.json');
const populateNullValues = dependencies => {
if (!dependencies) return;
for (const key of Object.keys(dependencies)) {
if (dependencies[key] === null && application.nodeDependencies[key]) {
dependencies[key] = application.nodeDependencies[key];
}
}
};
this.queueTransformStream(
passthrough(file => {
if (isPackageJson(file)) {
const content = JSON.parse(file.contents.toString());
populateNullValues(content.dependencies);
populateNullValues(content.devDependencies);
populateNullValues(content.peerDependencies);
file.contents = Buffer.from(JSON.stringify(content));
}
}),
{ streamOptions: { filter: isPackageJson } },
);
},
});
}

get [BaseApplicationGenerator.DEFAULT]() {
return this.default;
}

/**
* Return the user home
*/
Expand Down
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 @@ -16,12 +16,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-%>
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title><%= baseName %> - Swagger UI</title>
<base href="/swagger-ui/"/>
<base href="/swagger-ui/" />
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
Expand Down Expand Up @@ -91,20 +91,23 @@
urls = (
await Promise.allSettled(
services.map(async service => {
return axios.get(`/services/${service}/management/jhiopenapigroups`, axiosConfig).then(response => {
if (Array.isArray(response.data)) {
return response.data.map(({ group, description }) => ({
name: description,
url: `/services/${service}${baseUrl}/${group}`,
}));
}
return undefined;
}).catch(() => {
return axios
.get(`/services/${service}${baseUrl}`, axiosConfig)
.then(() => [{ url: `/services/${service}${baseUrl}`, name: `${service} (default)` }]);
});
})
return axios
.get(`/services/${service}/management/jhiopenapigroups`, axiosConfig)
.then(response => {
if (Array.isArray(response.data)) {
return response.data.map(({ group, description }) => ({
name: description,
url: `/services/${service}/${baseUrl}/${group}`,
}));
}
return undefined;
})
.catch(() => {
return axios
.get(`/services/${service}/${baseUrl}`, axiosConfig)
.then(() => [{ url: `/services/${service}/${baseUrl}`, name: `${service} (default)` }]);
});
}),
)
)
.filter(settled => settled.status === 'fulfilled')
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 })));
10 changes: 9 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,14 @@ task webapp_test(type: NpmTask) {
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>
<%_ if (clientFrameworkVue) { _%>
inputs.files("tsconfig.json", "tsconfig.app.json")
.withPropertyName("tsconfig")
.withPathSensitivity(PathSensitivity.RELATIVE)

inputs.files("vite.config.ts")
.withPropertyName("vite")
.withPathSensitivity(PathSensitivity.RELATIVE)

inputs.files(".postcssrc")
.withPropertyName("postcssrc")
.withPathSensitivity(PathSensitivity.RELATIVE)
Expand Down
10 changes: 9 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,6 +146,14 @@ task webapp(type: NpmTask) {
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>
<%_ if (clientFrameworkVue) { _%>
inputs.files("tsconfig.json", "tsconfig.app.json")
.withPropertyName("tsconfig")
.withPathSensitivity(PathSensitivity.RELATIVE)

inputs.files("vite.config.ts")
.withPropertyName("vite")
.withPathSensitivity(PathSensitivity.RELATIVE)

inputs.files(".postcssrc")
.withPropertyName("postcssrc")
.withPathSensitivity(PathSensitivity.RELATIVE)
Expand Down
5 changes: 4 additions & 1 deletion generators/server/templates/pom.xml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -986,15 +986,18 @@
<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>vite.config.ts</include>
<include>.postcssrc.js</include>
<%_ } _%>
</includes>
Expand Down
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
Loading