From c480a58a2ed487e6151606e196bc8493ccd46228 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Wed, 1 Nov 2023 22:27:13 -0300 Subject: [PATCH 1/8] update nest dependencies --- generators/node-server/resources/package.json | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/generators/node-server/resources/package.json b/generators/node-server/resources/package.json index cb616419..d44c0d0e 100644 --- a/generators/node-server/resources/package.json +++ b/generators/node-server/resources/package.json @@ -1,15 +1,15 @@ { "dependencies": { - "browser-sync-client": "3.0.2", - "@nestjs/common": "7.5.1", - "@nestjs/core": "7.5.1", - "@nestjs/jwt": "7.2.0", - "@nestjs/passport": "7.1.0", - "@nestjs/platform-express": "7.5.1", - "@nestjs/serve-static": "2.1.4", - "@nestjs/swagger": "4.8.0", - "@nestjs/typeorm": "7.1.4", + "@nestjs/common": "8.4.7", + "@nestjs/core": "8.4.7", + "@nestjs/jwt": "8.0.1", + "@nestjs/passport": "8.0.1", + "@nestjs/platform-express": "8.4.7", + "@nestjs/serve-static": "2.2.2", + "@nestjs/swagger": "5.2.1", + "@nestjs/typeorm": "8.0.5", "bcrypt": "5.1.1", + "browser-sync-client": "3.0.2", "class-transformer": "0.5.1", "class-validator": "0.13.1", "cloud-config-client": "1.6.2", @@ -19,16 +19,16 @@ "js-yaml": "4.1.0", "jwt-decode": "3.1.1", "mongodb": "6.10.0", + "mongodb-memory-server": "6.9.2", + "mssql": "6.3.1", "mysql2": "3.11.4", - "pg": "8.13.1", - "oracledb": "5.0.0", - "mssql": "6.2.3", + "oracledb": "5.5.0", "passport": "0.4.1", "passport-jwt": "4.0.1", "passport-oauth2": "1.8.0", + "pg": "8.13.1", "reflect-metadata": "0.1.14", - "rxjs": "6.6.3", - "mongodb-memory-server": "6.9.2", + "rxjs": "7.8.1", "sqlite3": "5.1.7", "swagger-ui-express": "5.0.0", "typeorm": "0.2.45", @@ -36,15 +36,15 @@ }, "devDependencies": { "@jest/globals": "29.7.0", - "@nestjs/testing": "7.5.1", + "@nestjs/testing": "8.4.7", "@types/bcrypt": "5.0.2", "@types/express": "4.17.1", "@types/express-serve-static-core": "4.17.3", "@types/jest": "29.5.11", - "@types/superagent": "8.1.1", "@types/jwt-decode": "3.1.0", "@types/node": "^20.8.10", "@types/passport-jwt": "4.0.1", + "@types/superagent": "8.1.1", "@types/supertest": "6.0.2", "@typescript-eslint/eslint-plugin": "6.18.1", "@typescript-eslint/eslint-plugin-tslint": "6.18.1", From c13ea7d8c5077af109df1b072f98acdd275be1b0 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Wed, 1 Nov 2023 23:29:36 -0300 Subject: [PATCH 2/8] replace deprecated findOne --- .../server/src/service/_entityFileName_.service.ts.ejs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/generators/node-server/templates/server/src/service/_entityFileName_.service.ts.ejs b/generators/node-server/templates/server/src/service/_entityFileName_.service.ts.ejs index b02c1dc4..170a81cf 100644 --- a/generators/node-server/templates/server/src/service/_entityFileName_.service.ts.ejs +++ b/generators/node-server/templates/server/src/service/_entityFileName_.service.ts.ejs @@ -31,8 +31,10 @@ export class <%= entityClass %>Service { constructor(@InjectRepository(<%= entityClass %>Repository) private <%= entityInstance %>Repository: <%= entityClass %>Repository) {} async findById(id: <%= pkType %>): Promise<<%= dtoClass %> | undefined> { - const options = { relations: relationshipNames }; - const result = await this.<%= entityInstance %>Repository.findOne(id, options); + const result = await this.<%= entityInstance %>Repository.findOne({ + relations: relationshipNames, + where: { id }, + }); return <%= entityClass %>Mapper.fromEntityToDTO(result); } From 283c54002287f5b2f10dfa9f28eff2560b6c7273 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 2 Nov 2023 09:27:39 -0300 Subject: [PATCH 3/8] use queryRunner.connection.getRepository --- .../src/migrations/1570200490072-SeedUsersRoles.ts.ejs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs b/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs index a30839a6..38d7d731 100644 --- a/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs +++ b/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs @@ -1,5 +1,5 @@ <%_ const UserEntity = user.persistClass %> -import { MigrationInterface, QueryRunner, getRepository } from 'typeorm'; +import { MigrationInterface, QueryRunner } from 'typeorm'; <%_ if (authenticationType !== 'oauth2') { _%> import { <%= UserEntity %> } from '../domain/user.entity'; import { transformPassword } from '../security'; @@ -68,7 +68,7 @@ export class SeedUsersRoles1570200490072 implements MigrationInterface { // eslint-disable-next-line public async up(queryRunner: QueryRunner): Promise { - const authorityRepository = getRepository("<%- jhiTablePrefix %>_authority"); + const authorityRepository = queryRunner.connection.getRepository("<%- jhiTablePrefix %>_authority"); <%_ if (authenticationType === 'oauth2') { _%> @@ -79,7 +79,7 @@ export class SeedUsersRoles1570200490072 implements MigrationInterface { const adminRole = await authorityRepository.save(this.role1); const userRole = await authorityRepository.save(this.role2); - const userRepository = getRepository("<%- jhiTablePrefix %>_user"); + const userRepository = queryRunner.connection.getRepository("<%- jhiTablePrefix %>_user"); this.user1.authorities= [adminRole, userRole]; this.user3.authorities= [adminRole, userRole]; From 03527fc42458261608ff297a85a7b7ec88a5a2f8 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 8 Nov 2024 10:11:31 -0300 Subject: [PATCH 4/8] add docker entrypoint script --- generators/docker/templates/docker/app.yml.ejs | 5 +++++ .../node-server/__snapshots__/generator.spec.js.snap | 12 ++++++++++++ generators/node-server/files.js | 2 ++ generators/node-server/templates/Dockerfile.ejs | 2 +- .../node-server/templates/server/ormconfig.ts.ejs | 3 +++ .../node-server/templates/server/package.json.ejs | 6 +++++- .../templates/server/scripts/entrypoint.sh.ejs | 6 ++++++ .../templates/server/tsconfig.build.json.ejs | 3 ++- .../node-server/templates/server/tsconfig.json.ejs | 4 ++-- .../server/__snapshots__/generator.spec.js.snap | 6 ++++++ 10 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 generators/node-server/templates/server/ormconfig.ts.ejs create mode 100755 generators/node-server/templates/server/scripts/entrypoint.sh.ejs diff --git a/generators/docker/templates/docker/app.yml.ejs b/generators/docker/templates/docker/app.yml.ejs index f7dc0adf..1e33f267 100644 --- a/generators/docker/templates/docker/app.yml.ejs +++ b/generators/docker/templates/docker/app.yml.ejs @@ -29,3 +29,8 @@ services: ports: - <%= serverPort %>:<%= serverPort %> <%_ } _%> + healthcheck: + test: ['CMD', 'nc', '-vz', '-w1', 'localhost', '<%= serverPort %>'] + interval: 5s + timeout: 5s + retries: 10 diff --git a/generators/node-server/__snapshots__/generator.spec.js.snap b/generators/node-server/__snapshots__/generator.spec.js.snap index 6ee8f7f5..330b2a34 100644 --- a/generators/node-server/__snapshots__/generator.spec.js.snap +++ b/generators/node-server/__snapshots__/generator.spec.js.snap @@ -83,12 +83,18 @@ exports[`SubGenerator node-server of nodejs JHipster blueprint > run > should su "server/nest-cli.json": { "stateCleared": "modified", }, + "server/ormconfig.ts": { + "stateCleared": "modified", + }, "server/package.json": { "stateCleared": "modified", }, "server/scripts/copy-resources.ts": { "stateCleared": "modified", }, + "server/scripts/entrypoint.sh": { + "stateCleared": "modified", + }, "server/sonar-project.properties": { "stateCleared": "modified", }, @@ -641,12 +647,18 @@ exports[`SubGenerator node-server of nodejs JHipster blueprint > without client "server/nest-cli.json": { "stateCleared": "modified", }, + "server/ormconfig.ts": { + "stateCleared": "modified", + }, "server/package.json": { "stateCleared": "modified", }, "server/scripts/copy-resources.ts": { "stateCleared": "modified", }, + "server/scripts/entrypoint.sh": { + "stateCleared": "modified", + }, "server/sonar-project.properties": { "stateCleared": "modified", }, diff --git a/generators/node-server/files.js b/generators/node-server/files.js index bbf4de09..54dff9f8 100644 --- a/generators/node-server/files.js +++ b/generators/node-server/files.js @@ -49,6 +49,7 @@ export const serverFiles = { 'src/migrations/1570200490072-SeedUsersRoles.ts', 'src/orm.config.ts', 'scripts/copy-resources.ts', + 'scripts/entrypoint.sh', 'tsconfig.build.json', 'test/admin/management.controller.spec.ts', 'nest-cli.json', @@ -69,6 +70,7 @@ export const serverFiles = { 'README.md', 'webpack.server.prod.config.js', 'sonar-project.properties', + 'ormconfig.ts', ], }, ], diff --git a/generators/node-server/templates/Dockerfile.ejs b/generators/node-server/templates/Dockerfile.ejs index fce3a174..340a0161 100644 --- a/generators/node-server/templates/Dockerfile.ejs +++ b/generators/node-server/templates/Dockerfile.ejs @@ -17,4 +17,4 @@ RUN rm -rf target tmp EXPOSE <%- serverPort %> -ENTRYPOINT ["node", "/usr/node-app/<%- nodeServerRootDir %>dist/main.js" ] +ENTRYPOINT ["/usr/node-app/server/scripts/entrypoint.sh" ] diff --git a/generators/node-server/templates/server/ormconfig.ts.ejs b/generators/node-server/templates/server/ormconfig.ts.ejs new file mode 100644 index 00000000..06421881 --- /dev/null +++ b/generators/node-server/templates/server/ormconfig.ts.ejs @@ -0,0 +1,3 @@ +import { ormConfig } from './src/orm.config'; + +export default ormConfig(); diff --git a/generators/node-server/templates/server/package.json.ejs b/generators/node-server/templates/server/package.json.ejs index db0e9876..76360d91 100644 --- a/generators/node-server/templates/server/package.json.ejs +++ b/generators/node-server/templates/server/package.json.ejs @@ -23,7 +23,11 @@ "test:cov": "jest --coverage", "test:watch": "jest --watch", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --silent --force-exit --coverage --config ./e2e/jest.e2e.config.json" + "test:e2e": "jest --silent --force-exit --coverage --config ./e2e/jest.e2e.config.json", + "typeorm": "ts-node -P ./tsconfig.json -r tsconfig-paths/register ../node_modules/.bin/typeorm -f ormconfig.ts", + "typeorm:migration:generate": "npm run typeorm -- migration:generate -n schema", + "typeorm:migration:run": "npm run typeorm -- migration:run", + "typeorm:schema:sync": "npm run typeorm -- schema:sync" }, "dependencies": { "browser-sync-client": "<%- nodeServerDependencies['browser-sync-client'] %>", diff --git a/generators/node-server/templates/server/scripts/entrypoint.sh.ejs b/generators/node-server/templates/server/scripts/entrypoint.sh.ejs new file mode 100755 index 00000000..90b2ddbe --- /dev/null +++ b/generators/node-server/templates/server/scripts/entrypoint.sh.ejs @@ -0,0 +1,6 @@ +#!/bin/sh + +sleep 10 +# npm run typeorm:migration:run -w server +# npm run typeorm:schema:sync -w server +exec node /usr/node-app/<%- nodeServerRootDir %>dist/main.js diff --git a/generators/node-server/templates/server/tsconfig.build.json.ejs b/generators/node-server/templates/server/tsconfig.build.json.ejs index 64f86c6b..d258d42b 100644 --- a/generators/node-server/templates/server/tsconfig.build.json.ejs +++ b/generators/node-server/templates/server/tsconfig.build.json.ejs @@ -1,4 +1,5 @@ { "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] + "include": ["src/**/*"], + "exclude": ["**/*spec.ts"] } diff --git a/generators/node-server/templates/server/tsconfig.json.ejs b/generators/node-server/templates/server/tsconfig.json.ejs index 7e6421c7..2ea36e22 100644 --- a/generators/node-server/templates/server/tsconfig.json.ejs +++ b/generators/node-server/templates/server/tsconfig.json.ejs @@ -1,8 +1,8 @@ { "compilerOptions": { /* Basic Options */ - "typeRoots": ["node_modules/@types", "../node_modules/@types"], - "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + // "typeRoots": ["node_modules/@types", "../node_modules/@types"], + "target": "ES2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": ["es6"], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/generators/server/__snapshots__/generator.spec.js.snap b/generators/server/__snapshots__/generator.spec.js.snap index 29111234..a4f69eb7 100644 --- a/generators/server/__snapshots__/generator.spec.js.snap +++ b/generators/server/__snapshots__/generator.spec.js.snap @@ -89,12 +89,18 @@ exports[`SubGenerator server of nodejs JHipster blueprint > run > should succeed "server/nest-cli.json": { "stateCleared": "modified", }, + "server/ormconfig.ts": { + "stateCleared": "modified", + }, "server/package.json": { "stateCleared": "modified", }, "server/scripts/copy-resources.ts": { "stateCleared": "modified", }, + "server/scripts/entrypoint.sh": { + "stateCleared": "modified", + }, "server/sonar-project.properties": { "stateCleared": "modified", }, From 49407b0adcf65fc6587f0fb112c6d852d65bc004 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 9 Nov 2024 09:24:07 -0300 Subject: [PATCH 5/8] rework orm.config --- .../node-server/templates/package.json.ejs | 3 +- .../templates/server/src/orm.config.ts.ejs | 146 ++++++++---------- 2 files changed, 64 insertions(+), 85 deletions(-) diff --git a/generators/node-server/templates/package.json.ejs b/generators/node-server/templates/package.json.ejs index e746e9b5..53130bcc 100644 --- a/generators/node-server/templates/package.json.ejs +++ b/generators/node-server/templates/package.json.ejs @@ -48,7 +48,8 @@ ] }, "scripts": { - "build:app": "cd server && <%= clientPackageManager %> run build", + "build": "<%= clientPackageManager %> run build -w server && <%= clientPackageManager %> run build -w client", + "build:app": "<%= clientPackageManager %> run build -w server", "lint:fix": "echo \"INFO: no client found\"", "prettier:check": "prettier --check \"{,src/**/}*.{<%= prettierExtensions %>}\"", "prettier:format": "prettier --write \"{,src/**/}*.{<%= prettierExtensions %>}\"", diff --git a/generators/node-server/templates/server/src/orm.config.ts.ejs b/generators/node-server/templates/server/src/orm.config.ts.ejs index 1a17b950..7e80e1e6 100644 --- a/generators/node-server/templates/server/src/orm.config.ts.ejs +++ b/generators/node-server/templates/server/src/orm.config.ts.ejs @@ -14,100 +14,78 @@ function ormConfig(): TypeOrmModuleOptions { const nodeProdDatabaseDriver = databaseType !== 'sql' ? databaseType : (prodDatabaseType === 'postgresql') ? 'postgres' : prodDatabaseType; const nodeDevDatabaseDriver = databaseType !== 'sql' ? databaseType : (devDatabaseType === 'postgresql') ? 'postgres' : devDatabaseType; _%> - const commonConf = { - SYNCRONIZE: false, - ENTITIES: [__dirname + '/domain/*.entity{.ts,.js}'], - MIGRATIONS: [__dirname + '/migrations/**/*{.ts,.js}'], - CLI: { - migrationsDir: 'src/migrations', - }, - MIGRATIONS_RUN: true, - }; - - let ormconfig: TypeOrmModuleOptions = { - name: 'default', - type: '<%= nodeProdDatabaseDriver %>', - <%_ if (databaseType === 'mongodb') { _%> - host: 'localhost', - port: mongod?await mongod.getPort():0, - database: mongod?await mongod.getDbName():'dev', - useNewUrlParser: true, - useUnifiedTopology: true, - <%_ } else { _%> - database: '../target/db/sqlite-dev-db.sql', - <%_ } _%> - logging: true, - synchronize: true, - entities: commonConf.ENTITIES, - migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, - migrationsRun: commonConf.MIGRATIONS_RUN, - }; - + let ormconfig: TypeOrmModuleOptions = { + name: 'default', +<%_ if (databaseType === 'mongodb') { _%> + type: '<%= nodeProdDatabaseDriver %>', + host: 'localhost', + port: mongod?await mongod.getPort():0, + database: mongod?await mongod.getDbName():'dev', + useNewUrlParser: true, + useUnifiedTopology: true, +<%_ } else { _%> + type: 'sqlite', + database: __dirname + '../../target/db/sqlite-dev-db.sql', +<%_ } _%> + logging: true, + }; - if (process.env.BACKEND_ENV === 'prod') { - ormconfig = { - name: 'default', - type: '<%= nodeProdDatabaseDriver %>', - database: '<%= (databaseType === 'sql') ? prodDatabaseName : baseName %>', - host: '<%= (databaseType === 'sql') ? prodDatabaseType : databaseType %>', - // port: <%= dbPortValue %>, - username: '<%- (databaseType === 'sql') ? prodDatabaseUsername : '' %>', - password: '<%- (databaseType === 'sql') ? prodDatabasePassword : '' %>', - logging: false, - synchronize: commonConf.SYNCRONIZE, - entities: commonConf.ENTITIES, - migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, - migrationsRun: commonConf.MIGRATIONS_RUN, - }; - } - if (process.env.BACKEND_ENV === 'test') { + if (process.env.BACKEND_ENV === 'prod') { + ormconfig = { + name: 'default', + type: '<%= nodeProdDatabaseDriver %>', + database: '<%= (databaseType === 'sql') ? prodDatabaseName : baseName %>', + host: '<%= (databaseType === 'sql') ? prodDatabaseType : databaseType %>', + // port: <%= dbPortValue %>, + username: '<%- (databaseType === 'sql') ? prodDatabaseUsername : '' %>', + password: '<%- (databaseType === 'sql') ? prodDatabasePassword : '' %>', + logging: false, + // synchronize: false, + }; + } else if (process.env.BACKEND_ENV === 'test') { ormconfig = { - name: 'default', + name: 'default', <%_ if (databaseTypeSql) { _%> - type: 'sqlite', - database: ':memory:', + type: 'sqlite', + database: ':memory:', <%_ } else { _%> - type: '<%= nodeProdDatabaseDriver %>', - host: 'localhost', - port: await mongod.getPort(), - database: await mongod.getDbName(), - useNewUrlParser: true, - useUnifiedTopology: true, + type: '<%= nodeProdDatabaseDriver %>', + host: 'localhost', + port: await mongod.getPort(), + database: await mongod.getDbName(), + useNewUrlParser: true, + useUnifiedTopology: true, <%_ } _%> - keepConnectionAlive: true, - logging: true, - synchronize: true, - entities: commonConf.ENTITIES, - migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, - migrationsRun: commonConf.MIGRATIONS_RUN, - }; - } + keepConnectionAlive: true, + logging: true, + }; <%_ if (devDatabaseType !== 'sqlite') { _%> - if (process.env.BACKEND_ENV === 'dev') { - ormconfig = { - name: 'default', - type: '<%= nodeDevDatabaseDriver %>', - database: '<%= (databaseType === 'sql') ? devDatabaseName : baseName %>', - host: 'localhost', - // port: <%= dbPortValue %>, - username: '<%- (databaseType === 'sql') ? devDatabaseUsername : '' %>', - password: '<%- (databaseType === 'sql') ? devDatabasePassword : '' %>', - logging: false, - synchronize: commonConf.SYNCRONIZE, - entities: commonConf.ENTITIES, - migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, - migrationsRun: commonConf.MIGRATIONS_RUN, - }; - } + } else if (process.env.BACKEND_ENV === 'dev') { + ormconfig = { + name: 'default', + type: '<%= nodeDevDatabaseDriver %>', + database: '<%= (databaseType === 'sql') ? devDatabaseName : baseName %>', + host: 'localhost', + // port: <%= dbPortValue %>, + username: '<%- (databaseType === 'sql') ? devDatabaseUsername : '' %>', + password: '<%- (databaseType === 'sql') ? devDatabasePassword : '' %>', + logging: false, + }; <%_ } _%> + } - return ormconfig; + return { + synchronize: process.env.BACKEND_ENV === 'test', + migrationsRun: true, + entities: [__dirname + '/domain/*.entity{.ts,.js}'], + migrations: [__dirname + '/migrations/**/*{.ts,.js}'], + cli: { + migrationsDir: 'src/migrations', + }, + ...ormconfig, + }; } export { ormConfig }; From d4f2efbf7d066d1a5ed95b387d5bd398f37529ae Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 9 Nov 2024 12:47:24 -0300 Subject: [PATCH 6/8] disable e2e with mongodb --- .github/workflows/test-integration-angular.yml | 5 +++-- .github/workflows/test-integration-react.yml | 3 ++- .github/workflows/test-integration-vue.yml | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-integration-angular.yml b/.github/workflows/test-integration-angular.yml index 394611fb..ffdf5064 100644 --- a/.github/workflows/test-integration-angular.yml +++ b/.github/workflows/test-integration-angular.yml @@ -40,7 +40,7 @@ jobs: - app-type: monolith-angular-jwt-mongodb-jdl app-folder: monolith-angular-auth-mongodb-template-jdl entity: import-jdl - e2e: jwt + e2e: 'false' - app-type: monolith-angular-jwt-i18n-jdl app-folder: monolith-client-auth-i18n-template-jdl entity: import-jdl @@ -52,7 +52,7 @@ jobs: - app-type: monolith-angular-oauth2-mongodb-jdl app-folder: monolith-angular-auth-mongodb-template-jdl entity: import-jdl - e2e: oauth2 + e2e: 'false' - app-type: monolith-angular-oauth2-i18n-jdl app-folder: monolith-client-auth-i18n-template-jdl entity: import-jdl @@ -102,6 +102,7 @@ jobs: run: npm run app:up - name: 'START APP WITH EVENTUAL CLIENT E2E TESTS' run: npm run e2e:headless --workspace client + if: matrix.e2e != 'false' id: e2e - name: 'E2E: Store failure screenshots' uses: actions/upload-artifact@v4 diff --git a/.github/workflows/test-integration-react.yml b/.github/workflows/test-integration-react.yml index b5c780d4..cee83c2f 100644 --- a/.github/workflows/test-integration-react.yml +++ b/.github/workflows/test-integration-react.yml @@ -54,7 +54,7 @@ jobs: - app-type: monolith-react-mongodb-prod-jdl app-folder: monolith-client-database-prod-template-jdl entity: import-jdl - e2e: jwt + e2e: 'false' - app-type: monolith-react-oauth2-dev app-folder: monolith-react-oauth2-dev entity: 'no' @@ -92,6 +92,7 @@ jobs: run: npm run app:up - name: 'START APP WITH EVENTUAL CLIENT E2E TESTS' run: npm run e2e:headless --workspace client + if: matrix.e2e != 'false' id: e2e - name: 'E2E: Store failure screenshots' uses: actions/upload-artifact@v4 diff --git a/.github/workflows/test-integration-vue.yml b/.github/workflows/test-integration-vue.yml index 60c0d6bf..9e605eae 100644 --- a/.github/workflows/test-integration-vue.yml +++ b/.github/workflows/test-integration-vue.yml @@ -38,7 +38,7 @@ jobs: - app-type: monolith-vue-mongodb-prod-jdl app-folder: monolith-client-database-prod-template-jdl entity: import-jdl - e2e: jwt + e2e: 'false' env: NHI_APP: ${{ matrix.app-type }} NHI_APP_FOLDER: ${{ matrix.app-folder }} @@ -72,6 +72,7 @@ jobs: run: npm run app:up - name: 'START APP WITH EVENTUAL CLIENT E2E TESTS' run: npm run e2e:headless --workspace client + if: matrix.e2e != 'false' id: e2e - name: 'E2E: Store failure screenshots' uses: actions/upload-artifact@v4 From dd0cd93677a4aafef05560f09ff6f067cea5de8c Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 9 Nov 2024 14:32:25 -0300 Subject: [PATCH 7/8] rework workflows --- .github/workflows/generator.yml | 2 +- .../workflows/test-integration-angular.yml | 38 ++++++++++++------- .../test-integration-microservice.yml | 33 ++++++++++------ .github/workflows/test-integration-react.yml | 38 ++++++++++++------- .github/workflows/test-integration-vue.yml | 38 ++++++++++++------- 5 files changed, 94 insertions(+), 55 deletions(-) diff --git a/.github/workflows/generator.yml b/.github/workflows/generator.yml index febc4f16..4f248210 100644 --- a/.github/workflows/generator.yml +++ b/.github/workflows/generator.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 cache: 'npm' - run: npm ci - run: npm run test diff --git a/.github/workflows/test-integration-angular.yml b/.github/workflows/test-integration-angular.yml index ffdf5064..9f8018e9 100644 --- a/.github/workflows/test-integration-angular.yml +++ b/.github/workflows/test-integration-angular.yml @@ -1,13 +1,16 @@ name: Test Integration Angular on: push: - branches-ignore: - - 'dependabot/**' + branches: + - 'main' pull_request: branches: - '*' +permissions: + contents: read env: NODE_OPTIONS: --dns-result-order=ipv4first + FORCE_COLOR: 2 jobs: applications: name: ${{ matrix.app-type }} @@ -79,32 +82,39 @@ jobs: - uses: actions/checkout@v4 with: path: generator-jhipster-nodejs - - uses: actions/setup-node@v4 + fetch-depth: 2 + - uses: jhipster/actions/setup-runner@v0 with: node-version: ${{ matrix.node-version }} - - run: mkdir ${{ github.workspace }}/app - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: GIT HISTORY - run: git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit + binary-dir: ${{ github.workspace }}/generator-jhipster-nodejs/cli/ + - run: npm install working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: Link blueprint - run: npm install && npm link - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: 'GENERATE NHipster app' - run: nhipster generate-sample $NHI_APP_FOLDER --template-name $NHI_APP + - run: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install + - uses: jhipster/actions/compare-sample@v0 + id: compare + if: >- + github.event.pull_request && + !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') + with: + generator-path: generator-jhipster-nodejs + cmd: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install - name: 'INSTALL DEPENDENCIES of generated app' run: npm install + if: steps.compare.outputs.equals != 'true' - name: 'RUN UNIT TESTS of generated app' run: npm test --workspaces + if: steps.compare.outputs.equals != 'true' - name: 'RUN SERVER E2E TESTS of generated app' run: npm run test:server:e2e + if: steps.compare.outputs.equals != 'true' - name: 'BUILD AND RUN SERVER APP' run: npm run app:up + if: steps.compare.outputs.equals != 'true' - name: 'START APP WITH EVENTUAL CLIENT E2E TESTS' run: npm run e2e:headless --workspace client - if: matrix.e2e != 'false' + if: matrix.e2e != 'false' && steps.compare.outputs.equals != 'true' id: e2e - - name: 'E2E: Store failure screenshots' + - name: Store cypress screenshots uses: actions/upload-artifact@v4 if: always() && steps.e2e.outcome == 'failure' with: diff --git a/.github/workflows/test-integration-microservice.yml b/.github/workflows/test-integration-microservice.yml index a4f5990a..859cd9d5 100644 --- a/.github/workflows/test-integration-microservice.yml +++ b/.github/workflows/test-integration-microservice.yml @@ -1,13 +1,16 @@ name: Test Integration Microservice on: push: - branches-ignore: - - 'dependabot/**' + branches: + - 'main' pull_request: branches: - '*' +permissions: + contents: read env: NODE_OPTIONS: --dns-result-order=ipv4first + FORCE_COLOR: 2 jobs: applications: name: ${{ matrix.app-type }} @@ -39,25 +42,31 @@ jobs: - uses: actions/checkout@v4 with: path: generator-jhipster-nodejs - - uses: actions/setup-node@v4 + fetch-depth: 2 + - uses: jhipster/actions/setup-runner@v0 with: node-version: ${{ matrix.node-version }} - - run: mkdir ${{ github.workspace }}/app - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: GIT HISTORY - run: git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit + binary-dir: ${{ github.workspace }}/generator-jhipster-nodejs/cli/ + - run: npm install working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: Link blueprint - run: npm install && npm link - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: 'GENERATE NHipster app' - run: nhipster generate-sample $NHI_APP_FOLDER --template-name $NHI_APP + - run: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install + - uses: jhipster/actions/compare-sample@v0 + id: compare + if: >- + github.event.pull_request && + !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') + with: + generator-path: generator-jhipster-nodejs + cmd: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install - name: 'INSTALL DEPENDENCIES of generated app' run: npm install + if: steps.compare.outputs.equals != 'true' - name: 'RUN UNIT TESTS of generated app' run: npm test --workspaces + if: steps.compare.outputs.equals != 'true' - name: 'RUN SERVER E2E TESTS of generated app' run: npm run test:server:e2e + if: steps.compare.outputs.equals != 'true' check-microservice-applications: permissions: contents: none diff --git a/.github/workflows/test-integration-react.yml b/.github/workflows/test-integration-react.yml index cee83c2f..67d783e8 100644 --- a/.github/workflows/test-integration-react.yml +++ b/.github/workflows/test-integration-react.yml @@ -1,13 +1,16 @@ name: Test Integration React on: push: - branches-ignore: - - 'dependabot/**' + branches: + - 'main' pull_request: branches: - '*' +permissions: + contents: read env: NODE_OPTIONS: --dns-result-order=ipv4first + FORCE_COLOR: 2 jobs: applications: name: ${{ matrix.app-type }} @@ -69,32 +72,39 @@ jobs: - uses: actions/checkout@v4 with: path: generator-jhipster-nodejs - - uses: actions/setup-node@v4 + fetch-depth: 2 + - uses: jhipster/actions/setup-runner@v0 with: node-version: ${{ matrix.node-version }} - - run: mkdir ${{ github.workspace }}/app - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: GIT HISTORY - run: git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit + binary-dir: ${{ github.workspace }}/generator-jhipster-nodejs/cli/ + - run: npm install working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: Link blueprint - run: npm install && npm link - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: 'GENERATE NHipster app' - run: nhipster generate-sample $NHI_APP_FOLDER --template-name $NHI_APP + - run: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install + - uses: jhipster/actions/compare-sample@v0 + id: compare + if: >- + github.event.pull_request && + !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') + with: + generator-path: generator-jhipster-nodejs + cmd: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install - name: 'INSTALL DEPENDENCIES of generated app' run: npm install + if: steps.compare.outputs.equals != 'true' - name: 'RUN UNIT TESTS of generated app' run: npm test --workspaces + if: steps.compare.outputs.equals != 'true' - name: 'RUN SERVER E2E TESTS of generated app' run: npm run test:server:e2e + if: steps.compare.outputs.equals != 'true' - name: 'BUILD AND RUN SERVER APP' run: npm run app:up + if: steps.compare.outputs.equals != 'true' - name: 'START APP WITH EVENTUAL CLIENT E2E TESTS' run: npm run e2e:headless --workspace client - if: matrix.e2e != 'false' + if: matrix.e2e != 'false' && steps.compare.outputs.equals != 'true' id: e2e - - name: 'E2E: Store failure screenshots' + - name: Store cypress screenshots uses: actions/upload-artifact@v4 if: always() && steps.e2e.outcome == 'failure' with: diff --git a/.github/workflows/test-integration-vue.yml b/.github/workflows/test-integration-vue.yml index 9e605eae..721da729 100644 --- a/.github/workflows/test-integration-vue.yml +++ b/.github/workflows/test-integration-vue.yml @@ -1,13 +1,16 @@ name: Test Integration Vue on: push: - branches-ignore: - - 'dependabot/**' + branches: + - 'main' pull_request: branches: - '*' +permissions: + contents: read env: NODE_OPTIONS: --dns-result-order=ipv4first + FORCE_COLOR: 2 jobs: applications: name: ${{ matrix.app-type }} @@ -49,32 +52,39 @@ jobs: - uses: actions/checkout@v4 with: path: generator-jhipster-nodejs - - uses: actions/setup-node@v4 + fetch-depth: 2 + - uses: jhipster/actions/setup-runner@v0 with: node-version: ${{ matrix.node-version }} - - run: mkdir ${{ github.workspace }}/app - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: GIT HISTORY - run: git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit + binary-dir: ${{ github.workspace }}/generator-jhipster-nodejs/cli/ + - run: npm install working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: Link blueprint - run: npm install && npm link - working-directory: ${{ github.workspace }}/generator-jhipster-nodejs - - name: 'GENERATE NHipster app' - run: nhipster generate-sample $NHI_APP_FOLDER --template-name $NHI_APP + - run: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install + - uses: jhipster/actions/compare-sample@v0 + id: compare + if: >- + github.event.pull_request && + !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') + with: + generator-path: generator-jhipster-nodejs + cmd: cli.cjs generate-sample $NHI_APP_FOLDER --template-name $NHI_APP --skip-jhipster-dependencies --skip-install - name: 'INSTALL DEPENDENCIES of generated app' run: npm install + if: steps.compare.outputs.equals != 'true' - name: 'RUN UNIT TESTS of generated app' run: npm test --workspaces + if: steps.compare.outputs.equals != 'true' - name: 'RUN SERVER E2E TESTS of generated app' run: npm run test:server:e2e + if: steps.compare.outputs.equals != 'true' - name: 'BUILD AND RUN SERVER APP' run: npm run app:up + if: steps.compare.outputs.equals != 'true' - name: 'START APP WITH EVENTUAL CLIENT E2E TESTS' run: npm run e2e:headless --workspace client - if: matrix.e2e != 'false' + if: matrix.e2e != 'false' && steps.compare.outputs.equals != 'true' id: e2e - - name: 'E2E: Store failure screenshots' + - name: Store cypress screenshots uses: actions/upload-artifact@v4 if: always() && steps.e2e.outcome == 'failure' with: From 71166f3cedba9b935e3de674799a256447726a56 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 9 Nov 2024 14:36:32 -0300 Subject: [PATCH 8/8] drop dependabot groups, dependencies does not have a hard dependency on major versions --- .github/dependabot.yml | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e05c3b83..2a3c5a68 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,48 +18,6 @@ updates: - '@types/jest' - 'jest' - 'ts-jest' - nestjs: - update-types: - - 'minor' - - 'patch' - patterns: - - '@nestjs/common' - - '@nestjs/core' - - '@nestjs/microservices' - - '@nestjs/platform-express' - - '@nestjs/platform-fastify' - - '@nestjs/platform-socket.io' - - '@nestjs/platform-ws' - - '@nestjs/testing' - - '@nestjs/websockets' - - 'rxjs' - passport: - update-types: - - 'minor' - - 'patch' - patterns: - - '@nestjs/passport' - - '@types/jwt-decode' - - '@types/passport-jwt' - - 'jwt-decode' - - 'passport' - - 'passport-jwt' - - 'passport-oauth2' - typeorm: - update-types: - - 'minor' - - 'patch' - patterns: - - '@nestjs/typeorm' - - 'typeorm' - - 'typeorm-encrypted' - - 'mongodb' - - 'mongodb-memory-server' - - 'mssql' - - 'mysql2' - - 'oracledb' - - 'pg' - - 'sqlite3' typescript-eslint: patterns: - '@typescript-eslint/*'