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

Misc #1041

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Misc #1041

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
23 changes: 17 additions & 6 deletions generators/cypress/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { cypressEntityFiles, cypressFiles } from './files.js';

const { ANGULAR } = clientFrameworkTypes;

const WAIT_TIMEOUT = 3 * 60000;

export default class CypressGenerator extends BaseApplicationGenerator {
async beforeQueue() {
if (!this.fromBlueprint) {
Expand Down Expand Up @@ -188,22 +190,28 @@ export default class CypressGenerator extends BaseApplicationGenerator {
},

configure({ application }) {
const { devServerPort, devServerPortProxy: devServerPortE2e = devServerPort } = application;

const clientPackageJson = this.createStorage(this.destinationPath(application.clientRootDir!, 'package.json'));
clientPackageJson.merge({
devDependencies: {
'eslint-plugin-cypress': application.nodeDependencies['eslint-plugin-cypress'],
},
scripts: {
'ci:e2e:run': 'concurrently -k -s first -n application,e2e -c red,blue npm:ci:e2e:server:start npm:e2e:headless',
'ci:e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue npm:app:start npm:e2e:headless`,
cypress: 'cypress open --e2e',
e2e: 'npm run e2e:cypress:headed --',
'e2e:headless': 'npm run e2e:cypress --',
'e2e:cypress:headed': 'npm run e2e:cypress -- --headed',
'e2e:cypress': 'cypress run --e2e --browser chrome',
'e2e:cypress:headed': 'npm run e2e:cypress -- --headed',
'e2e:cypress:record': 'npm run e2e:cypress -- --record',
cypress: 'cypress open --e2e',
'e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue npm:app:start npm:e2e`,
'e2e:devserver': `concurrently -k -s first -n backend,frontend,e2e -c red,yellow,blue npm:backend:start npm:start "wait-on -t ${WAIT_TIMEOUT} http-get://127.0.0.1:${devServerPortE2e} && npm run e2e:headless -- -c baseUrl=http://localhost:${devServerPortE2e}"`,
'pree2e:headless': 'npm run ci:server:await',
'e2e:headless': 'npm run e2e:cypress --',
},
});
},

configureAudits({ application }) {
if (!application.cypressAudit) return;
const clientPackageJson = this.createStorage(this.destinationPath(application.clientRootDir!, 'package.json'));
Expand All @@ -220,7 +228,7 @@ export default class CypressGenerator extends BaseApplicationGenerator {
});
},
configureCoverage({ application, source }) {
const { cypressCoverage, clientFrameworkAngular, dasherizedBaseName } = application;
const { cypressCoverage, clientFrameworkAngular, clientRootDir, dasherizedBaseName } = application;
if (!cypressCoverage) return;
const clientPackageJson = this.createStorage(this.destinationPath(application.clientRootDir!, 'package.json'));
clientPackageJson.merge({
Expand All @@ -241,7 +249,10 @@ export default class CypressGenerator extends BaseApplicationGenerator {
});
if (clientFrameworkAngular) {
// Add 'ng build --configuration instrumenter' support
this.createStorage('angular.json').setPath(`projects.${dasherizedBaseName}.architect.build.configurations.instrumenter`, {});
this.createStorage(`${clientRootDir}angular.json`).setPath(
`projects.${dasherizedBaseName}.architect.build.configurations.instrumenter`,
{},
);
source.addWebpackConfig?.({
config: `targetOptions.configuration === 'instrumenter'
? {
Expand Down
1 change: 0 additions & 1 deletion generators/java/generators/node/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export default class NodeGenerator extends BaseApplicationGenerator {
blocks: [
{
condition: (ctx: any) => ctx.useNpmWrapper,
transform: false,
templates: ['npmw', 'npmw.cmd'],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ setlocal

set NPMW_DIR=%~dp0

if exist "%NPMW_DIR%mvnw.cmd" (
set NODE_EXE=^"^"
set NODE_PATH=%NPMW_DIR%target\node\
set NPM_EXE=^"%NPMW_DIR%target\node\npm.cmd^"
set INSTALL_NPM_COMMAND=^"%NPMW_DIR%mvnw.cmd^" -Pwebapp frontend:install-node-and-npm@install-node-and-npm
) else (
set NODE_EXE=^"%NPMW_DIR%build\node\bin\node.exe^"
set NODE_PATH=%NPMW_DIR%build\node\bin\
set NPM_EXE=^"%NPMW_DIR%build\node\lib\node_modules\npm\bin\npm-cli.js^"
set INSTALL_NPM_COMMAND=^"%NPMW_DIR%gradlew.bat^" npmSetup
)
<%_ if (buildToolMaven) { _%>
set NODE_EXE=^"^"
set NODE_PATH=%NPMW_DIR%target\node\
set NPM_EXE=^"%NPMW_DIR%target\node\npm.cmd^"
set INSTALL_NPM_COMMAND=^"%NPMW_DIR%mvnw.cmd^" -Pwebapp frontend:install-node-and-npm@install-node-and-npm
<%_ } else if (buildToolGradle) { _%>
set NODE_EXE=^"%NPMW_DIR%build\node\bin\node.exe^"
set NODE_PATH=%NPMW_DIR%build\node\bin\
set NPM_EXE=^"%NPMW_DIR%build\node\lib\node_modules\npm\bin\npm-cli.js^"
set INSTALL_NPM_COMMAND=^"%NPMW_DIR%gradlew.bat^" npmSetup --no-daemon
<%_ } _%>

if not exist %NPM_EXE% (
call %INSTALL_NPM_COMMAND%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

basedir=$(dirname "$0")

<%_ if (buildToolMaven) { _%>
if [ -f "$basedir/mvnw" ]; then
bindir="$basedir/target/node"
repodir="$basedir/target/node/node_modules"
installCommand="$basedir/mvnw --batch-mode -ntp -Pwebapp frontend:install-node-and-npm@install-node-and-npm"
elif [ -f "$basedir/gradlew" ]; then
<%_ } else if (buildToolGradle) { _%>
if [ -f "$basedir/gradlew" ]; then
bindir="$basedir/build/node/bin"
repodir="$basedir/build/node/lib/node_modules"
installCommand="$basedir/gradlew npmSetup"
installCommand="$basedir/gradlew npmSetup --no-daemon"
<%_ } _%>
else
echo "Using npm installed globally"
exec npm "$@"
Expand Down
17 changes: 2 additions & 15 deletions generators/java/generators/server/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export default class ServerGenerator extends BaseApplicationGenerator {
if (buildTool === 'maven') {
const excludeWebapp = application.skipClient ? '' : ' -Dskip.installnodenpm -Dskip.npm';
scriptsStorage.set({
'app:start': './mvnw',
'app:start': './mvnw -ntp --batch-mode',
'backend:info': './mvnw --version',
'backend:doc:test': './mvnw -ntp javadoc:javadoc --batch-mode',
'backend:nohttp:test': './mvnw -ntp checkstyle:check --batch-mode',
'backend:start': `./mvnw${excludeWebapp}`,
'backend:start': `./mvnw${excludeWebapp} -ntp --batch-mode`,
'java:jar': './mvnw -ntp verify -DskipTests --batch-mode',
'java:war': './mvnw -ntp verify -DskipTests --batch-mode -Pwar',
'java:docker': './mvnw -ntp verify -DskipTests -Pprod jib:dockerBuild',
Expand Down Expand Up @@ -98,9 +98,7 @@ export default class ServerGenerator extends BaseApplicationGenerator {
});
},
packageJsonE2eScripts({ application }) {
const { devServerPort, devServerPortProxy: devServerPortE2e = devServerPort } = application;
const scriptsStorage = this.packageJson.createStorage('scripts');
const buildCmd = application.buildToolGradle ? 'gradlew' : 'mvnw -ntp';

let applicationWaitTimeout = WAIT_TIMEOUT * (application.applicationTypeGateway ? 2 : 1);
applicationWaitTimeout = application.authenticationTypeOauth2 ? applicationWaitTimeout * 2 : applicationWaitTimeout;
Expand All @@ -110,17 +108,6 @@ export default class ServerGenerator extends BaseApplicationGenerator {
scriptsStorage.set({
'ci:server:await': `echo "Waiting for server at port $npm_package_config_backend_port to start" && wait-on -t ${applicationWaitTimeout} ${applicationEndpoint} && echo "Server at port $npm_package_config_backend_port started"`,
});

// TODO add e2eTests property to application.
if (this.jhipsterConfig.testFrameworks?.includes('cypress')) {
scriptsStorage.set({
'pree2e:headless': 'npm run ci:server:await',
'ci:e2e:run': 'concurrently -k -s first -n application,e2e -c red,blue npm:ci:e2e:server:start npm:e2e:headless',
'ci:e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue "./${buildCmd}" npm:e2e:headless`,
'e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue "./${buildCmd}" npm:e2e`,
'e2e:devserver': `concurrently -k -s first -n backend,frontend,e2e -c red,yellow,blue npm:backend:start npm:start "wait-on -t ${WAIT_TIMEOUT} http-get://127.0.0.1:${devServerPortE2e} && npm run e2e:headless -- -c baseUrl=http://localhost:${devServerPortE2e}"`,
});
}
},
});
}
Expand Down
Loading