From 19fb166e8de4d45f915fcc286c9810302178945f Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 10:53:53 +0100 Subject: [PATCH 01/24] Fix comment in esmodules-bundler --- esbuild/esmodules-bundler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esbuild/esmodules-bundler.js b/esbuild/esmodules-bundler.js index 5774ae47391..e73aab0df47 100644 --- a/esbuild/esmodules-bundler.js +++ b/esbuild/esmodules-bundler.js @@ -3,7 +3,7 @@ const { dtsPlugin } = require('esbuild-plugin-d.ts'); const { build } = require('esbuild'); const fs = require('fs'); const { resolve } = require('path'); -// add files to be transformed from CommonJs to EsModules in the following list +// add files to be transformed from ESModules to CommonJS in the following list const options = [ { name: 'keycloak-admin-client-lib', From 2b35c75933473f00305075eeb4daecc41ea829a0 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 10:54:50 +0100 Subject: [PATCH 02/24] Remove empty file test.ts --- apps/server/src/test.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/server/src/test.ts diff --git a/apps/server/src/test.ts b/apps/server/src/test.ts deleted file mode 100644 index e69de29bb2d..00000000000 From e3b9b337bd7a211210468f4d7e8aee7a9aeaad65 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 12:39:41 +0100 Subject: [PATCH 03/24] Move fishery from devDependencies to dependencies --- package-lock.json | 4 +--- package.json | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4aee4aa2569..585ad37f6b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -80,6 +80,7 @@ "feathers-hooks-common": "^8.1.1", "feathers-swagger": "^3.0.0", "file-type": "^18.5.0", + "fishery": "^2.2.2", "freeport": "^1.0.5", "gm": "^1.25.0", "html-entities": "^2.3.2", @@ -189,7 +190,6 @@ "eslint-plugin-no-only-tests": "^3.3.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-promise": "^7.1.0", - "fishery": "^2.2.2", "jest": "^29.2.2", "jwt-decode": "^3.1.2", "mocha": "^9.1.3", @@ -14503,7 +14503,6 @@ }, "node_modules/fishery": { "version": "2.2.2", - "dev": true, "license": "MIT", "dependencies": { "lodash.mergewith": "^4.6.2" @@ -18989,7 +18988,6 @@ }, "node_modules/lodash.mergewith": { "version": "4.6.2", - "dev": true, "license": "MIT" }, "node_modules/lodash.once": { diff --git a/package.json b/package.json index c058c93fffb..8a337bb5d0a 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "generate-client:tsp-api": "openapi-generator-cli generate -c ./openapitools.json --generator-key tsp-api", "pregenerate-client:courses-api": "rimraf ./apps/server/src/infra/courses-client/generated", "generate-client:courses-api": "openapi-generator-cli generate -c ./openapitools.json --generator-key courses-api", - "generate-client:lessons-api":"openapi-generator-cli generate -c ./openapitools.json --generator-key svs-lesson-api", + "generate-client:lessons-api": "openapi-generator-cli generate -c ./openapitools.json --generator-key svs-lesson-api", "pregenerate-client:tldraw-api": "rimraf ./apps/server/src/infra/tldraw-client/generated", "generate-client:tldraw-api": "openapi-generator-cli generate -c ./openapitools.json --generator-key tldraw-api" }, @@ -194,6 +194,7 @@ "feathers-hooks-common": "^8.1.1", "feathers-swagger": "^3.0.0", "file-type": "^18.5.0", + "fishery": "^2.2.2", "freeport": "^1.0.5", "gm": "^1.25.0", "html-entities": "^2.3.2", @@ -303,7 +304,6 @@ "eslint-plugin-no-only-tests": "^3.3.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-promise": "^7.1.0", - "fishery": "^2.2.2", "jest": "^29.2.2", "jwt-decode": "^3.1.2", "mocha": "^9.1.3", From a56d53151100aba32dd6850e47e2982c2685c07d Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 12:39:59 +0100 Subject: [PATCH 04/24] Copy factories from testing to management module --- .../seed-data/factory/base.factory.ts | 164 ++++++++++++++++++ .../factory/county.embeddable.factory.ts | 17 ++ .../factory/federal-state.factory.ts | 18 ++ .../seed-data/factory/role.factory.ts | 9 + .../factory/school.entity.factory.ts | 12 ++ .../seed-data/factory/schoolyear.factory.ts | 32 ++++ .../factory/system.entity.factory.ts | 99 +++++++++++ .../management/seed-data/federalstates.ts | 4 +- .../src/modules/management/seed-data/roles.ts | 2 +- .../modules/management/seed-data/schools.ts | 3 +- .../management/seed-data/schoolyears.ts | 2 +- .../modules/management/seed-data/systems.ts | 2 +- 12 files changed, 358 insertions(+), 6 deletions(-) create mode 100644 apps/server/src/modules/management/seed-data/factory/base.factory.ts create mode 100644 apps/server/src/modules/management/seed-data/factory/county.embeddable.factory.ts create mode 100644 apps/server/src/modules/management/seed-data/factory/federal-state.factory.ts create mode 100644 apps/server/src/modules/management/seed-data/factory/role.factory.ts create mode 100644 apps/server/src/modules/management/seed-data/factory/school.entity.factory.ts create mode 100644 apps/server/src/modules/management/seed-data/factory/schoolyear.factory.ts create mode 100644 apps/server/src/modules/management/seed-data/factory/system.entity.factory.ts diff --git a/apps/server/src/modules/management/seed-data/factory/base.factory.ts b/apps/server/src/modules/management/seed-data/factory/base.factory.ts new file mode 100644 index 00000000000..5db3cd71d5a --- /dev/null +++ b/apps/server/src/modules/management/seed-data/factory/base.factory.ts @@ -0,0 +1,164 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import type { EntityId } from '@shared/domain/types'; +import { BuildOptions, DeepPartial, Factory, GeneratorFn, HookFn } from 'fishery'; + +/** + * Entity factory based on thoughtbot/fishery + * https://github.com/thoughtbot/fishery + * + * @template T The entity to be built + * @template U The properties interface of the entity + * @template I The transient parameters that your factory supports + * @template C The class of the factory object being created. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export class BaseFactory { + protected readonly propsFactory: Factory; + + constructor(private readonly EntityClass: { new (props: U): T }, propsFactory: Factory) { + this.propsFactory = propsFactory; + } + + /** + * Define a factory + * @template T The entity to be built + * @template U The properties interface of the entity + * @template I The transient parameters that your factory supports + * @template C The class of the factory object being created. + * @param EntityClass The constructor of the entity to be built. + * @param generator Your factory function - see `Factory.define()` in thoughtbot/fishery + * @returns + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + static define>( + this: new (EntityClass: { new (props: U): T }, propsFactory: Factory) => F, + EntityClass: { new (props: U): T }, + generator: GeneratorFn + ): F { + const propsFactory = Factory.define(generator); + const factory = new this(EntityClass, propsFactory); + return factory; + } + + /** + * Build an entity using your factory + * @param params + * @returns an entity + */ + build(params?: DeepPartial, options: BuildOptions = {}): T { + const props = this.propsFactory.build(params, options); + const entity = new this.EntityClass(props); + + return entity; + } + + /** + * Build an entity using your factory and generate a id for it. + * @param params + * @param id + * @returns an entity + */ + buildWithId(params?: DeepPartial, id?: string, options: BuildOptions = {}): T { + const entity = this.build(params, options) as { _id: ObjectId; id: EntityId }; + const generatedId = new ObjectId(id); + const entityWithId = Object.assign(entity, { _id: generatedId, id: generatedId.toHexString() }); + + return entityWithId as T; + } + + /** + * Build a list of entities using your factory + * @param number + * @param params + * @returns a list of entities + */ + buildList(number: number, params?: DeepPartial, options: BuildOptions = {}): T[] { + const list: T[] = []; + for (let i = 0; i < number; i += 1) { + list.push(this.build(params, options)); + } + + return list; + } + + buildListWithId(number: number, params?: DeepPartial, options: BuildOptions = {}): T[] { + const list: T[] = []; + for (let i = 0; i < number; i += 1) { + list.push(this.buildWithId(params, undefined, options)); + } + + return list; + } + + /** + * Extend the factory by adding a function to be called after an object is built. + * @param afterBuildFn - the function to call. It accepts your object of type T. The value this function returns gets returned from "build" + * @returns a new factory + */ + afterBuild(afterBuildFn: HookFn): this { + const newPropsFactory = this.propsFactory.afterBuild(afterBuildFn); + const newFactory = this.clone(newPropsFactory); + + return newFactory; + } + + /** + * Extend the factory by adding default associations to be passed to the factory when "build" is called + * @param associations + * @returns a new factory + */ + associations(associations: Partial): this { + const newPropsFactory = this.propsFactory.associations(associations); + const newFactory = this.clone(newPropsFactory); + + return newFactory; + } + + /** + * Extend the factory by adding default parameters to be passed to the factory when "build" is called + * @param params + * @returns a new factory + */ + params(params: DeepPartial): this { + const newPropsFactory = this.propsFactory.params(params); + const newFactory = this.clone(newPropsFactory); + + return newFactory; + } + + /** + * Extend the factory by adding default transient parameters to be passed to the factory when "build" is called + * @param transient - transient params + * @returns a new factory + */ + transient(transient: Partial): this { + const newPropsFactory = this.propsFactory.transient(transient); + const newFactory = this.clone(newPropsFactory); + + return newFactory; + } + + /** + * Set sequence back to its default value + */ + rewindSequence(): void { + this.propsFactory.rewindSequence(); + } + + protected clone>(this: F, propsFactory: Factory): F { + const copy = new (this.constructor as { + new (EntityClass: { new (props: U): T }, propsOfFactory: Factory): F; + })(this.EntityClass, propsFactory); + + return copy; + } + + /** + * Get the next sequence value + * @returns the next sequence value + */ + protected sequence(): number { + // eslint-disable-next-line @typescript-eslint/dot-notation + return this.propsFactory['sequence'](); + } +} diff --git a/apps/server/src/modules/management/seed-data/factory/county.embeddable.factory.ts b/apps/server/src/modules/management/seed-data/factory/county.embeddable.factory.ts new file mode 100644 index 00000000000..58842c7f61b --- /dev/null +++ b/apps/server/src/modules/management/seed-data/factory/county.embeddable.factory.ts @@ -0,0 +1,17 @@ +import { CountyEmbeddable } from '@shared/domain/entity'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { BaseFactory } from './base.factory'; + +export const countyEmbeddableFactory = BaseFactory.define( + CountyEmbeddable, + ({ sequence }) => { + const county = { + _id: new ObjectId(), + name: `County ${sequence}`, + countyId: sequence, + antaresKey: `antaresKey ${sequence}`, + }; + + return county; + } +); diff --git a/apps/server/src/modules/management/seed-data/factory/federal-state.factory.ts b/apps/server/src/modules/management/seed-data/factory/federal-state.factory.ts new file mode 100644 index 00000000000..cb09d7cfa81 --- /dev/null +++ b/apps/server/src/modules/management/seed-data/factory/federal-state.factory.ts @@ -0,0 +1,18 @@ +import { FederalStateEntity, FederalStateProperties } from '@shared/domain/entity'; +import { BaseFactory } from './base.factory'; +import { countyEmbeddableFactory } from './county.embeddable.factory'; + +export const federalStateFactory = BaseFactory.define( + FederalStateEntity, + () => { + return { + name: 'Hamburg', + abbreviation: 'HH', + logoUrl: + 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Coat_of_arms_of_Hamburg.svg/1200px-Coat_of_arms_of_Hamburg.svg.png', + counties: countyEmbeddableFactory.buildList(2), + createdAt: new Date(2020, 1), + updatedAt: new Date(2020, 1), + }; + } +); diff --git a/apps/server/src/modules/management/seed-data/factory/role.factory.ts b/apps/server/src/modules/management/seed-data/factory/role.factory.ts new file mode 100644 index 00000000000..ea982edf1e5 --- /dev/null +++ b/apps/server/src/modules/management/seed-data/factory/role.factory.ts @@ -0,0 +1,9 @@ +import { Role, RoleProperties } from '@shared/domain/entity'; +import { RoleName } from '@shared/domain/interface'; +import { BaseFactory } from './base.factory'; + +export const roleFactory = BaseFactory.define(Role, ({ sequence }) => { + return { + name: `role${sequence}` as unknown as RoleName, + }; +}); diff --git a/apps/server/src/modules/management/seed-data/factory/school.entity.factory.ts b/apps/server/src/modules/management/seed-data/factory/school.entity.factory.ts new file mode 100644 index 00000000000..d8fe77a84f4 --- /dev/null +++ b/apps/server/src/modules/management/seed-data/factory/school.entity.factory.ts @@ -0,0 +1,12 @@ +import { SchoolEntity, SchoolProperties } from '@shared/domain/entity'; +import { BaseFactory } from './base.factory'; +import { federalStateFactory } from './federal-state.factory'; +import { schoolYearFactory } from './schoolyear.factory'; + +export const schoolEntityFactory = BaseFactory.define(SchoolEntity, ({ sequence }) => { + return { + name: `school #${sequence}`, + currentYear: schoolYearFactory.build(), + federalState: federalStateFactory.build(), + }; +}); diff --git a/apps/server/src/modules/management/seed-data/factory/schoolyear.factory.ts b/apps/server/src/modules/management/seed-data/factory/schoolyear.factory.ts new file mode 100644 index 00000000000..3c5e77d986a --- /dev/null +++ b/apps/server/src/modules/management/seed-data/factory/schoolyear.factory.ts @@ -0,0 +1,32 @@ +import { SchoolYearEntity, SchoolYearProperties } from '@shared/domain/entity/schoolyear.entity'; +import { BaseFactory } from './base.factory'; + +type SchoolYearTransientParams = { + startYear: number; +}; + +class SchoolYearFactory extends BaseFactory { + public withStartYear(startYear: number): this { + this.rewindSequence(); + return this.transient({ startYear }); + } +} + +export const schoolYearFactory = SchoolYearFactory.define(SchoolYearEntity, ({ transientParams, sequence }) => { + const now = new Date(); + const startYearWithoutSequence = transientParams?.startYear ?? now.getFullYear(); + const sequenceStartingWithZero = sequence - 1; + let correction = 0; + + if (now.getMonth() < 7 && !transientParams?.startYear) { + correction = 1; + } + + const startYear = startYearWithoutSequence + sequenceStartingWithZero - correction; + + const name = `${startYear}/${(startYear + 1).toString().slice(-2)}`; + const startDate = new Date(`${startYear}-08-01`); + const endDate = new Date(`${startYear + 1}-07-31`); + + return { name, startDate, endDate }; +}); diff --git a/apps/server/src/modules/management/seed-data/factory/system.entity.factory.ts b/apps/server/src/modules/management/seed-data/factory/system.entity.factory.ts new file mode 100644 index 00000000000..88e1e9a6b05 --- /dev/null +++ b/apps/server/src/modules/management/seed-data/factory/system.entity.factory.ts @@ -0,0 +1,99 @@ +import { + LdapConfigEntity, + OauthConfigEntity, + OidcConfigEntity, + SystemEntity, + SystemEntityProps, +} from '@modules/system/entity'; +import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; +import { SystemTypeEnum } from '@shared/domain/types'; +import { DeepPartial } from 'fishery'; +import { BaseFactory } from './base.factory'; + +export const systemOauthConfigEntityFactory = BaseFactory.define( + OauthConfigEntity, + () => { + return { + clientId: '12345', + clientSecret: 'mocksecret', + idpHint: 'mock-oauth-idpHint', + tokenEndpoint: 'https://mock.de/mock/auth/public/mockToken', + grantType: 'authorization_code', + redirectUri: 'https://mockhost:3030/api/v3/sso/oauth/', + scope: 'openid uuid', + responseType: 'code', + authEndpoint: 'https://mock.de/auth', + provider: 'mock_type', + logoutEndpoint: 'https://mock.de/logout', + issuer: 'mock_issuer', + jwksEndpoint: 'https://mock.de/jwks', + endSessionEndpoint: 'https://mock.de/logout', + }; + } +); + +export const systemLdapConfigEntityFactory = BaseFactory.define( + LdapConfigEntity, + () => { + return { + url: 'ldaps:mock.de:389', + active: true, + }; + } +); + +export const systemOidcConfigEntityFactory = BaseFactory.define( + OidcConfigEntity, + () => { + return { + clientId: 'mock-client-id', + clientSecret: 'mock-client-secret', + idpHint: 'mock-oidc-idpHint', + defaultScopes: 'openid email userinfo', + authorizationUrl: 'https://mock.tld/auth', + tokenUrl: 'https://mock.tld/token', + userinfoUrl: 'https://mock.tld/userinfo', + logoutUrl: 'https://mock.tld/logout', + }; + } +); + +export class SystemEntityFactory extends BaseFactory { + withOauthConfig(otherParams?: DeepPartial): this { + const params: DeepPartial = { + type: SystemTypeEnum.OAUTH, + oauthConfig: systemOauthConfigEntityFactory.build(otherParams), + }; + + return this.params(params); + } + + withLdapConfig(otherParams?: DeepPartial): this { + const params: DeepPartial = { + type: SystemTypeEnum.LDAP, + ldapConfig: systemLdapConfigEntityFactory.build(otherParams), + }; + + return this.params(params); + } + + withOidcConfig(otherParams?: DeepPartial): this { + const params = { + type: SystemTypeEnum.OIDC, + oidcConfig: systemOidcConfigEntityFactory.build(otherParams), + }; + + return this.params(params); + } +} + +export const systemEntityFactory = SystemEntityFactory.define(SystemEntity, ({ sequence }) => { + return { + type: 'oauth', + url: 'https://mock.de', + alias: `system #${sequence}`, + displayName: `system #${sequence}DisplayName`, + provisioningStrategy: SystemProvisioningStrategy.OIDC, + provisioningUrl: 'https://provisioningurl.de/', + }; +}); diff --git a/apps/server/src/modules/management/seed-data/federalstates.ts b/apps/server/src/modules/management/seed-data/federalstates.ts index 403814e9c0e..ef59e6cf309 100644 --- a/apps/server/src/modules/management/seed-data/federalstates.ts +++ b/apps/server/src/modules/management/seed-data/federalstates.ts @@ -1,7 +1,7 @@ -import { CountyEmbeddable, FederalStateProperties } from '@shared/domain/entity/federal-state.entity'; -import { federalStateFactory } from '@shared/testing/factory/federal-state.factory'; import { ObjectId } from '@mikro-orm/mongodb'; +import { CountyEmbeddable, FederalStateProperties } from '@shared/domain/entity/federal-state.entity'; import { DeepPartial } from 'fishery'; +import { federalStateFactory } from './factory/federal-state.factory'; type SeedFederalStateProperties = Omit & { id: string; diff --git a/apps/server/src/modules/management/seed-data/roles.ts b/apps/server/src/modules/management/seed-data/roles.ts index 810533204fa..a563fc61f39 100644 --- a/apps/server/src/modules/management/seed-data/roles.ts +++ b/apps/server/src/modules/management/seed-data/roles.ts @@ -2,8 +2,8 @@ import { Role, RoleProperties } from '@shared/domain/entity'; import { Permission, RoleName } from '@shared/domain/interface'; -import { roleFactory } from '@shared/testing'; import { DeepPartial } from 'fishery'; +import { roleFactory } from './factory/role.factory'; type SeedRoleProperties = Omit & { id: string; diff --git a/apps/server/src/modules/management/seed-data/schools.ts b/apps/server/src/modules/management/seed-data/schools.ts index 3a6e6ce4bb6..ca2ccacbcf4 100644 --- a/apps/server/src/modules/management/seed-data/schools.ts +++ b/apps/server/src/modules/management/seed-data/schools.ts @@ -4,9 +4,10 @@ import { SystemEntity } from '@modules/system/entity'; import { FederalStateEntity, SchoolProperties, SchoolRoles, SchoolYearEntity } from '@shared/domain/entity'; import { LanguageType } from '@shared/domain/interface'; import { SchoolFeature, SchoolPurpose } from '@shared/domain/types'; -import { federalStateFactory, schoolEntityFactory } from '@shared/testing'; import { FileStorageType } from '@src/modules/school/domain/type/file-storage-type.enum'; import { DeepPartial } from 'fishery'; +import { federalStateFactory } from './factory/federal-state.factory'; +import { schoolEntityFactory } from './factory/school.entity.factory'; import { EFederalState } from './federalstates'; import { SeedSchoolYearEnum } from './schoolyears'; diff --git a/apps/server/src/modules/management/seed-data/schoolyears.ts b/apps/server/src/modules/management/seed-data/schoolyears.ts index 0198a00a5bd..3561bcc5157 100644 --- a/apps/server/src/modules/management/seed-data/schoolyears.ts +++ b/apps/server/src/modules/management/seed-data/schoolyears.ts @@ -1,6 +1,6 @@ import { SchoolYearProperties } from '@shared/domain/entity'; -import { schoolYearFactory } from '@shared/testing/factory/schoolyear.factory'; import { DeepPartial } from 'fishery'; +import { schoolYearFactory } from './factory/schoolyear.factory'; type SeedSchoolYearProperties = Pick & { id: string; diff --git a/apps/server/src/modules/management/seed-data/systems.ts b/apps/server/src/modules/management/seed-data/systems.ts index 1a9c531d870..f50ff4d0837 100644 --- a/apps/server/src/modules/management/seed-data/systems.ts +++ b/apps/server/src/modules/management/seed-data/systems.ts @@ -1,8 +1,8 @@ /* eslint-disable no-template-curly-in-string */ import { SystemEntityProps } from '@modules/system/entity'; import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; -import { systemEntityFactory } from '@shared/testing'; import { DeepPartial } from 'fishery'; +import { systemEntityFactory } from './factory/system.entity.factory'; type SystemPartial = DeepPartial & { id?: string; From c44e7d0b641586e2f12ef71dd4d406bb0b06823a Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 12:40:12 +0100 Subject: [PATCH 05/24] Remove any imports from testing folders in production code --- .../board/uc/media-board/media-available-line.uc.spec.ts | 3 ++- .../loggable/school-external-tool-created.loggable.spec.ts | 2 +- .../schulconnex-license-provisioning.service.spec.ts | 3 +-- .../service/schulconnex-tool-provisioning.service.spec.ts | 3 ++- apps/server/src/modules/rocketchat-user/domain/index.ts | 1 - apps/server/src/modules/room/index.ts | 1 - apps/server/src/modules/synchronization/domain/index.ts | 1 - .../service/tool-configuration-status.service.spec.ts | 3 ++- apps/server/src/modules/user-license/index.ts | 6 ------ 9 files changed, 8 insertions(+), 15 deletions(-) diff --git a/apps/server/src/modules/board/uc/media-board/media-available-line.uc.spec.ts b/apps/server/src/modules/board/uc/media-board/media-available-line.uc.spec.ts index 534e5b133c0..6b5ca8c85f2 100644 --- a/apps/server/src/modules/board/uc/media-board/media-available-line.uc.spec.ts +++ b/apps/server/src/modules/board/uc/media-board/media-available-line.uc.spec.ts @@ -4,7 +4,8 @@ import { Action, AuthorizationService } from '@modules/authorization'; import { ExternalTool } from '@modules/tool/external-tool/domain'; import { SchoolExternalTool } from '@modules/tool/school-external-tool/domain'; import { schoolExternalToolFactory } from '@modules/tool/school-external-tool/testing'; -import { MediaUserLicense, mediaUserLicenseFactory, MediaUserLicenseService } from '@modules/user-license'; +import { MediaUserLicense, MediaUserLicenseService } from '@modules/user-license'; +import { mediaUserLicenseFactory } from '@modules/user-license/testing'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { FeatureDisabledLoggableException } from '@shared/common/loggable-exception'; diff --git a/apps/server/src/modules/provisioning/loggable/school-external-tool-created.loggable.spec.ts b/apps/server/src/modules/provisioning/loggable/school-external-tool-created.loggable.spec.ts index 8cfbe2a5677..843b6cdfe52 100644 --- a/apps/server/src/modules/provisioning/loggable/school-external-tool-created.loggable.spec.ts +++ b/apps/server/src/modules/provisioning/loggable/school-external-tool-created.loggable.spec.ts @@ -1,5 +1,5 @@ import { schoolExternalToolFactory } from '@modules/tool/school-external-tool/testing'; -import { mediaUserLicenseFactory } from '@modules/user-license'; +import { mediaUserLicenseFactory } from '@modules/user-license/testing'; import { SchoolExternalToolCreatedLoggable } from './school-external-tool-created.loggable'; describe('SchoolExternalToolCreatedLoggable', () => { diff --git a/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-license-provisioning.service.spec.ts b/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-license-provisioning.service.spec.ts index 74f5d254ecb..bab4878c087 100644 --- a/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-license-provisioning.service.spec.ts +++ b/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-license-provisioning.service.spec.ts @@ -1,13 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { MediaSource, - mediaSourceFactory, MediaSourceService, MediaUserLicense, - mediaUserLicenseFactory, MediaUserLicenseService, UserLicenseType, } from '@modules/user-license'; +import { mediaSourceFactory, mediaUserLicenseFactory } from '@modules/user-license/testing'; import { Test, TestingModule } from '@nestjs/testing'; import { User as UserEntity } from '@shared/domain/entity'; import { setupEntities, userFactory } from '@shared/testing'; diff --git a/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-tool-provisioning.service.spec.ts b/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-tool-provisioning.service.spec.ts index 9492425822a..524183b036d 100644 --- a/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-tool-provisioning.service.spec.ts +++ b/apps/server/src/modules/provisioning/strategy/schulconnex/service/schulconnex-tool-provisioning.service.spec.ts @@ -7,7 +7,8 @@ import { customParameterFactory, externalToolFactory } from '@modules/tool/exter import { SchoolExternalToolService } from '@modules/tool/school-external-tool'; import { SchoolExternalTool } from '@modules/tool/school-external-tool/domain'; import { schoolExternalToolFactory } from '@modules/tool/school-external-tool/testing'; -import { MediaUserLicense, mediaUserLicenseFactory, MediaUserLicenseService } from '@modules/user-license'; +import { MediaUserLicense, MediaUserLicenseService } from '@modules/user-license'; +import { mediaUserLicenseFactory } from '@modules/user-license/testing'; import { Test, TestingModule } from '@nestjs/testing'; import { schoolSystemOptionsFactory } from '@shared/testing'; import { Logger } from '@src/core/logger'; diff --git a/apps/server/src/modules/rocketchat-user/domain/index.ts b/apps/server/src/modules/rocketchat-user/domain/index.ts index 441baa69c52..0246dd0f0f9 100644 --- a/apps/server/src/modules/rocketchat-user/domain/index.ts +++ b/apps/server/src/modules/rocketchat-user/domain/index.ts @@ -1,2 +1 @@ export * from './rocket-chat-user.do'; -export * from './testing'; diff --git a/apps/server/src/modules/room/index.ts b/apps/server/src/modules/room/index.ts index 31c66bccfac..7be3bdc7474 100644 --- a/apps/server/src/modules/room/index.ts +++ b/apps/server/src/modules/room/index.ts @@ -2,4 +2,3 @@ export * from './domain'; export { RoomConfig } from './room.config'; export * from './room.module'; export * from './repo/entity'; -export { roomFactory } from './testing'; diff --git a/apps/server/src/modules/synchronization/domain/index.ts b/apps/server/src/modules/synchronization/domain/index.ts index ea6c26e614e..2285cbd6829 100644 --- a/apps/server/src/modules/synchronization/domain/index.ts +++ b/apps/server/src/modules/synchronization/domain/index.ts @@ -1,4 +1,3 @@ export * from './do'; export * from './service'; export * from './types'; -export * from './testing'; diff --git a/apps/server/src/modules/tool/context-external-tool/service/tool-configuration-status.service.spec.ts b/apps/server/src/modules/tool/context-external-tool/service/tool-configuration-status.service.spec.ts index 587d9731b6f..c618eb9ad05 100644 --- a/apps/server/src/modules/tool/context-external-tool/service/tool-configuration-status.service.spec.ts +++ b/apps/server/src/modules/tool/context-external-tool/service/tool-configuration-status.service.spec.ts @@ -1,7 +1,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { MediaBoardConfig } from '@modules/board/media-board.config'; -import { MediaUserLicense, mediaUserLicenseFactory, MediaUserLicenseService } from '@modules/user-license'; +import { MediaUserLicense, MediaUserLicenseService } from '@modules/user-license'; +import { mediaUserLicenseFactory } from '@modules/user-license/testing'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { ValidationError } from '@shared/common'; diff --git a/apps/server/src/modules/user-license/index.ts b/apps/server/src/modules/user-license/index.ts index 7a37a14200c..b5b149ee446 100644 --- a/apps/server/src/modules/user-license/index.ts +++ b/apps/server/src/modules/user-license/index.ts @@ -2,10 +2,4 @@ export { AnyUserLicense, MediaSource, MediaSourceProps, MediaUserLicense, MediaU export { MediaSourceEntity } from './entity'; export { UserLicenseType } from './enum/user-license-type'; export { MediaSourceService, MediaUserLicenseService } from './service'; -export { - mediaSourceEntityFactory, - mediaSourceFactory, - mediaUserLicenseEntityFactory, - mediaUserLicenseFactory, -} from './testing'; export { UserLicenseModule } from './user-license.module'; From 400290213a441ed01f48a36bd3a11e2c77091d4a Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 12:40:22 +0100 Subject: [PATCH 06/24] Exclude testing folders from build --- apps/server/tsconfig.app.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/server/tsconfig.app.json b/apps/server/tsconfig.app.json index 14752374a7c..3851b1ce3c5 100644 --- a/apps/server/tsconfig.app.json +++ b/apps/server/tsconfig.app.json @@ -11,6 +11,7 @@ "node_modules", "dist", "test", - "**/*spec.ts" + "**/*spec.ts", + "**/testing" ] } \ No newline at end of file From af07dc5c3559422bd5941d431d386be01d47b013 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 15:23:53 +0100 Subject: [PATCH 07/24] Add pruning of dev dependencies in Dockerfile --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 98a1f7fb8f4..0c405828072 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,15 @@ COPY --from=git /app/serverversion /schulcloud-server/apps/server/static-assets COPY scripts/ldapSync.sh /schulcloud-server/scripts/ RUN npm run build +# Remove dev dependencies. The modules transpiled by esbuild are pruned too and must be copied separately. +RUN mkdir temp +COPY node_modules/@keycloak/keycloak-admin-client-cjs temp +COPY node_modules/file-type-cjs temp +RUN npm prune --omit=dev +COPY temp/keycloak-admin-client-cjs node_modules/@keycloak +COPY temp/file-type-cjs node_modules +RUN rm -rf temp + ENV NODE_ENV=production ENV NO_COLOR="true" CMD npm run start From a359451d02c42fa844ac263efa8189ff72b49373 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Tue, 7 Jan 2025 16:04:07 +0100 Subject: [PATCH 08/24] Update commands in Dockerfile --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c405828072..8677bbc68cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,11 +24,11 @@ RUN npm run build # Remove dev dependencies. The modules transpiled by esbuild are pruned too and must be copied separately. RUN mkdir temp -COPY node_modules/@keycloak/keycloak-admin-client-cjs temp -COPY node_modules/file-type-cjs temp +RUN cp -r node_modules/@keycloak/keycloak-admin-client-cjs temp +RUN cp -r node_modules/file-type-cjs temp RUN npm prune --omit=dev -COPY temp/keycloak-admin-client-cjs node_modules/@keycloak -COPY temp/file-type-cjs node_modules +RUN cp -r temp/keycloak-admin-client-cjs node_modules/@keycloak +RUN cp -r temp/file-type-cjs node_modules RUN rm -rf temp ENV NODE_ENV=production From 4ce6e08b4d08382e1d7ae4cf95a7875c8794fc9b Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 9 Jan 2025 11:40:40 +0100 Subject: [PATCH 09/24] Fix comment in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8677bbc68cc..884a42accf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ COPY --from=git /app/serverversion /schulcloud-server/apps/server/static-assets COPY scripts/ldapSync.sh /schulcloud-server/scripts/ RUN npm run build -# Remove dev dependencies. The modules transpiled by esbuild are pruned too and must be copied separately. +# Remove devDependencies. The modules transpiled by esbuild are pruned too and must be added again after pruning. RUN mkdir temp RUN cp -r node_modules/@keycloak/keycloak-admin-client-cjs temp RUN cp -r node_modules/file-type-cjs temp From f8baf47ed3f9f0c9d85bd63362ff9fb2b059a830 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 9 Jan 2025 11:42:14 +0100 Subject: [PATCH 10/24] Simplify some paths in Dockerfile --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 884a42accf3..816e5b2c07d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,14 +12,14 @@ RUN apk add --no-cache git make python3 RUN apk add --no-cache curl WORKDIR /schulcloud-server COPY tsconfig.json tsconfig.build.json package.json package-lock.json .eslintrc.js .eslintignore nest-cli.json ./ -COPY esbuild ./esbuild +COPY esbuild esbuild RUN npm ci && npm cache clean --force -COPY config /schulcloud-server/config -COPY backup /schulcloud-server/backup -COPY src /schulcloud-server/src -COPY apps /schulcloud-server/apps -COPY --from=git /app/serverversion /schulcloud-server/apps/server/static-assets -COPY scripts/ldapSync.sh /schulcloud-server/scripts/ +COPY config config +COPY backup backup +COPY src src +COPY apps apps +COPY --from=git /app/serverversion apps/server/static-assets +COPY scripts/ldapSync.sh scripts/ RUN npm run build # Remove devDependencies. The modules transpiled by esbuild are pruned too and must be added again after pruning. From 5a305d938aa059193617f84168b46e2b88044b00 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 9 Jan 2025 11:45:56 +0100 Subject: [PATCH 11/24] Add blank line at end of tsconfig.app.json --- apps/server/tsconfig.app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/tsconfig.app.json b/apps/server/tsconfig.app.json index 3851b1ce3c5..735c8530c91 100644 --- a/apps/server/tsconfig.app.json +++ b/apps/server/tsconfig.app.json @@ -14,4 +14,4 @@ "**/*spec.ts", "**/testing" ] -} \ No newline at end of file +} From 499964c365e53046d7ffbaf5ed75da449c5c2544 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Fri, 10 Jan 2025 11:30:35 +0100 Subject: [PATCH 12/24] Move all npm commands in single RUN instruction --- Dockerfile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 816e5b2c07d..b00cf8c85bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,26 +10,28 @@ ENV TZ=Europe/Berlin RUN apk add --no-cache git make python3 # to run ldap sync as script curl is needed RUN apk add --no-cache curl + WORKDIR /schulcloud-server COPY tsconfig.json tsconfig.build.json package.json package-lock.json .eslintrc.js .eslintignore nest-cli.json ./ COPY esbuild esbuild -RUN npm ci && npm cache clean --force COPY config config COPY backup backup COPY src src COPY apps apps COPY --from=git /app/serverversion apps/server/static-assets COPY scripts/ldapSync.sh scripts/ -RUN npm run build -# Remove devDependencies. The modules transpiled by esbuild are pruned too and must be added again after pruning. -RUN mkdir temp -RUN cp -r node_modules/@keycloak/keycloak-admin-client-cjs temp -RUN cp -r node_modules/file-type-cjs temp -RUN npm prune --omit=dev -RUN cp -r temp/keycloak-admin-client-cjs node_modules/@keycloak -RUN cp -r temp/file-type-cjs node_modules -RUN rm -rf temp +RUN npm ci \ + && npm run build \ + # Remove dev dependencies. The modules transpiled by esbuild are removed too and must be added again after pruning. + && mkdir temp \ + && cp -r node_modules/@keycloak/keycloak-admin-client-cjs temp \ + && cp -r node_modules/file-type-cjs temp \ + && npm prune --omit=dev \ + && cp -r temp/keycloak-admin-client-cjs node_modules/@keycloak \ + && cp -r temp/file-type-cjs node_modules \ + && rm -rf temp \ + && npm cache clean --force ENV NODE_ENV=production ENV NO_COLOR="true" From 365a015b733f6fbd0e9a5754ad1620386d772561 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Fri, 10 Jan 2025 12:18:38 +0100 Subject: [PATCH 13/24] Update Dockerfile to use multi-stage build --- Dockerfile | 61 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index b00cf8c85bb..e77973cf387 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,45 @@ -FROM docker.io/node:22 AS git +FROM docker.io/node:22-alpine AS builder -RUN mkdir /app && chown -R node:node /app WORKDIR /app -COPY .git . -RUN git config --global --add safe.directory /app && echo "{\"sha\": \"$(git rev-parse HEAD)\", \"version\": \"$(git describe --tags --abbrev=0)\", \"commitDate\": \"$(git log -1 --format=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ')\", \"birthdate\": \"$(date +%Y-%m-%dT%H:%M:%SZ)\"}" > /app/serverversion +RUN apk add --no-cache git +COPY .git ./.git + +RUN git config --global --add safe.directory /app \ + && echo "{\"sha\": \"$(git rev-parse HEAD)\", \"version\": \"$(git describe --tags --abbrev=0)\", \"commitDate\": \"$(git log -1 --format=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ')\", \"birthdate\": \"$(date +%Y-%m-%dT%H:%M:%SZ)\"}" > /app/serverversion + +COPY package.json package-lock.json tsconfig.json tsconfig.build.json ./ +COPY esbuild ./esbuild +COPY src ./src +COPY config ./config +COPY backup ./backup +COPY apps ./apps +COPY scripts ./scripts + +RUN npm ci && npm cache clean --force +RUN npm run build + FROM docker.io/node:22-alpine + ENV TZ=Europe/Berlin -RUN apk add --no-cache git make python3 -# to run ldap sync as script curl is needed -RUN apk add --no-cache curl +RUN apk add --no-cache git make python3 curl WORKDIR /schulcloud-server -COPY tsconfig.json tsconfig.build.json package.json package-lock.json .eslintrc.js .eslintignore nest-cli.json ./ -COPY esbuild esbuild -COPY config config -COPY backup backup -COPY src src -COPY apps apps -COPY --from=git /app/serverversion apps/server/static-assets -COPY scripts/ldapSync.sh scripts/ - -RUN npm ci \ - && npm run build \ - # Remove dev dependencies. The modules transpiled by esbuild are removed too and must be added again after pruning. - && mkdir temp \ - && cp -r node_modules/@keycloak/keycloak-admin-client-cjs temp \ - && cp -r node_modules/file-type-cjs temp \ - && npm prune --omit=dev \ - && cp -r temp/keycloak-admin-client-cjs node_modules/@keycloak \ - && cp -r temp/file-type-cjs node_modules \ - && rm -rf temp \ - && npm cache clean --force + +COPY --from=builder /app/package.json /app/package-lock.json ./ +COPY --from=builder /app/esbuild ./esbuild +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/config ./config +COPY --from=builder /app/backup ./backup +COPY --from=builder /app/apps/server/static-assets ./apps/server/static-assets +COPY --from=builder /app/scripts/ldapSync.sh ./scripts/ + +# The postinstall script must be disabled, because esbuild is a dev dependency and not installed here. +RUN npm pkg delete scripts.postinstall \ + && npm ci --omit=dev \ + && npm cache clean --force ENV NODE_ENV=production ENV NO_COLOR="true" + CMD npm run start From e442a573a3d8c363791b790238837ac36ec44093 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Fri, 10 Jan 2025 14:35:21 +0100 Subject: [PATCH 14/24] Fix copying of files in Dockerfile --- Dockerfile | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index e77973cf387..574ed46f9e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,16 +7,15 @@ COPY .git ./.git RUN git config --global --add safe.directory /app \ && echo "{\"sha\": \"$(git rev-parse HEAD)\", \"version\": \"$(git describe --tags --abbrev=0)\", \"commitDate\": \"$(git log -1 --format=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ')\", \"birthdate\": \"$(date +%Y-%m-%dT%H:%M:%SZ)\"}" > /app/serverversion -COPY package.json package-lock.json tsconfig.json tsconfig.build.json ./ -COPY esbuild ./esbuild -COPY src ./src -COPY config ./config -COPY backup ./backup -COPY apps ./apps -COPY scripts ./scripts - -RUN npm ci && npm cache clean --force -RUN npm run build +COPY package.json package-lock.json tsconfig.json tsconfig.build.json nest-cli.json ./ +COPY apps apps +COPY config config +COPY esbuild esbuild +COPY src src + +RUN npm ci \ + && npm run build\ + && npm cache clean --force FROM docker.io/node:22-alpine @@ -26,20 +25,25 @@ RUN apk add --no-cache git make python3 curl WORKDIR /schulcloud-server -COPY --from=builder /app/package.json /app/package-lock.json ./ -COPY --from=builder /app/esbuild ./esbuild -COPY --from=builder /app/dist ./dist -COPY --from=builder /app/config ./config -COPY --from=builder /app/backup ./backup -COPY --from=builder /app/apps/server/static-assets ./apps/server/static-assets -COPY --from=builder /app/scripts/ldapSync.sh ./scripts/ +COPY package.json package-lock.json ./ +COPY backup backup +COPY config config +COPY scripts/ldapSync.sh scripts/ +COPY src src + +COPY --from=builder /app/dist dist +COPY --from=builder /app/apps/server/static-assets apps/server/static-assets # The postinstall script must be disabled, because esbuild is a dev dependency and not installed here. RUN npm pkg delete scripts.postinstall \ && npm ci --omit=dev \ && npm cache clean --force +# The modules transpiled by esbuild need to be copied manually from the build stage. +COPY --from=builder /app/node_modules/@keycloak/keycloak-admin-client-cjs node_modules/@keycloak/keycloak-admin-client-cjs +COPY --from=builder /app/node_modules/file-type-cjs node_modules/file-type-cjs + ENV NODE_ENV=production ENV NO_COLOR="true" -CMD npm run start +CMD npm start From 036e93f5de6baf849ee89cefe431887e270f92d7 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Mon, 13 Jan 2025 10:09:45 +0100 Subject: [PATCH 15/24] Remove cleaning of cache in first stage of Dockerfile --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 574ed46f9e4..ba38fafa5db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,7 @@ COPY config config COPY esbuild esbuild COPY src src -RUN npm ci \ - && npm run build\ - && npm cache clean --force +RUN npm ci && npm run build FROM docker.io/node:22-alpine From f4a3de86b29faa7d66b0420ae80bff31787bb9fd Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 15:09:17 +0100 Subject: [PATCH 16/24] Order dependencies in package.json alphabetically --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 51d728a825c..bd4cd82bfe2 100644 --- a/package.json +++ b/package.json @@ -255,8 +255,6 @@ "yaml": "^2.5.0" }, "devDependencies": { - "cross-env": "^7.0.0", - "freeport": "^1.0.5", "@aws-sdk/client-s3": "^3.617.0", "@faker-js/faker": "^8.0.2", "@feathersjs/adapter-tests": "^5.0.29", @@ -293,6 +291,7 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "chai-http": "^4.2.0", + "cross-env": "^7.0.0", "esbuild": "^0.17.10", "esbuild-plugin-d.ts": "^1.3.0", "eslint": "^8.57.0", @@ -307,6 +306,7 @@ "eslint-plugin-no-only-tests": "^3.3.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-promise": "^7.1.0", + "freeport": "^1.0.5", "jest": "^29.2.2", "jwt-decode": "^3.1.2", "mocha": "^9.1.3", From 3bfe3630cec9d37c22d6e2416ef56af7f8b985a1 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 15:32:57 +0100 Subject: [PATCH 17/24] Fix imports overlooked in merge --- apps/server/src/modules/management/seed-data/schools.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/server/src/modules/management/seed-data/schools.ts b/apps/server/src/modules/management/seed-data/schools.ts index 470f36382f9..ca2ccacbcf4 100644 --- a/apps/server/src/modules/management/seed-data/schools.ts +++ b/apps/server/src/modules/management/seed-data/schools.ts @@ -5,8 +5,6 @@ import { FederalStateEntity, SchoolProperties, SchoolRoles, SchoolYearEntity } f import { LanguageType } from '@shared/domain/interface'; import { SchoolFeature, SchoolPurpose } from '@shared/domain/types'; import { FileStorageType } from '@src/modules/school/domain/type/file-storage-type.enum'; -import { federalStateFactory } from '@testing/factory/federal-state.factory'; -import { schoolEntityFactory } from '@testing/factory/school-entity.factory'; import { DeepPartial } from 'fishery'; import { federalStateFactory } from './factory/federal-state.factory'; import { schoolEntityFactory } from './factory/school.entity.factory'; From c80b29248b2bbb3cc8a425c266390a9ad9d0920b Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 15:42:29 +0100 Subject: [PATCH 18/24] Conigure Sonarcloud to ignore duplication in seed-data factories --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 9a61e473c22..d256ea8e2f1 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,6 +5,6 @@ sonar.tests=. sonar.test.inclusions=**/*.spec.ts sonar.exclusions=**/*.js,jest.config.ts,globalSetup.ts,globalTeardown.ts,**/*.app.ts,**/seed-data/*.ts,**/migrations/mikro-orm/*.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,**/cards-api-client/**/*.ts,**/lessons-api-client/**/*.ts sonar.coverage.exclusions=**/board-management.uc.ts,**/*.module.ts,**/*.factory.ts,**/testing/**/*.ts,**/migrations/mikro-orm/*.ts,**/globalSetup.ts,**/globalTeardown.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,apps/server/src/console/console.ts -sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts +sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts,apps/server/src/modules/management/seed-data/factory sonar.javascript.lcov.reportPaths=merged-lcov.info sonar.typescript.tsconfigPaths=tsconfig.json,src/apps/server/tsconfig.app.json From af558edd5f124ee6f4e35968acfcf562265c3781 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 16:13:30 +0100 Subject: [PATCH 19/24] Fix path in sonar config --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index d256ea8e2f1..59f04a04665 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,6 +5,6 @@ sonar.tests=. sonar.test.inclusions=**/*.spec.ts sonar.exclusions=**/*.js,jest.config.ts,globalSetup.ts,globalTeardown.ts,**/*.app.ts,**/seed-data/*.ts,**/migrations/mikro-orm/*.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,**/cards-api-client/**/*.ts,**/lessons-api-client/**/*.ts sonar.coverage.exclusions=**/board-management.uc.ts,**/*.module.ts,**/*.factory.ts,**/testing/**/*.ts,**/migrations/mikro-orm/*.ts,**/globalSetup.ts,**/globalTeardown.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,apps/server/src/console/console.ts -sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts,apps/server/src/modules/management/seed-data/factory +sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts,apps/server/src/modules/management/seed-data/factory/* sonar.javascript.lcov.reportPaths=merged-lcov.info sonar.typescript.tsconfigPaths=tsconfig.json,src/apps/server/tsconfig.app.json From a6ce2949bdf037e85bd24895111faeee5aae09a5 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 16:14:39 +0100 Subject: [PATCH 20/24] Update sonar exclusions --- sonar-project.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 59f04a04665..e84901bbb48 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,8 +3,8 @@ sonar.projectKey=hpi-schul-cloud_schulcloud-server sonar.sources=. sonar.tests=. sonar.test.inclusions=**/*.spec.ts -sonar.exclusions=**/*.js,jest.config.ts,globalSetup.ts,globalTeardown.ts,**/*.app.ts,**/seed-data/*.ts,**/migrations/mikro-orm/*.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,**/cards-api-client/**/*.ts,**/lessons-api-client/**/*.ts +sonar.exclusions=**/*.js,jest.config.ts,globalSetup.ts,globalTeardown.ts,**/*.app.ts,**/seed-data/**/*.ts,**/migrations/mikro-orm/*.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,**/cards-api-client/**/*.ts,**/lessons-api-client/**/*.ts sonar.coverage.exclusions=**/board-management.uc.ts,**/*.module.ts,**/*.factory.ts,**/testing/**/*.ts,**/migrations/mikro-orm/*.ts,**/globalSetup.ts,**/globalTeardown.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,apps/server/src/console/console.ts -sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts,apps/server/src/modules/management/seed-data/factory/* +sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts, sonar.javascript.lcov.reportPaths=merged-lcov.info sonar.typescript.tsconfigPaths=tsconfig.json,src/apps/server/tsconfig.app.json From 1223c3204c5d74239bc5b811ee6fdd6138f6db9b Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 16:30:42 +0100 Subject: [PATCH 21/24] Remove forgotten comma in sonar config --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index e84901bbb48..317500cae17 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,6 +5,6 @@ sonar.tests=. sonar.test.inclusions=**/*.spec.ts sonar.exclusions=**/*.js,jest.config.ts,globalSetup.ts,globalTeardown.ts,**/*.app.ts,**/seed-data/**/*.ts,**/migrations/mikro-orm/*.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,**/cards-api-client/**/*.ts,**/lessons-api-client/**/*.ts sonar.coverage.exclusions=**/board-management.uc.ts,**/*.module.ts,**/*.factory.ts,**/testing/**/*.ts,**/migrations/mikro-orm/*.ts,**/globalSetup.ts,**/globalTeardown.ts,**/etherpad-api-client/**/*.ts,**/authorization-api-client/**/*.ts,**/board-api-client/**/*.ts,**/generated/**/*.ts,**/room-api-client/**/*.ts,apps/server/src/console/console.ts -sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts, +sonar.cpd.exclusions=**/controller/dto/**/*.ts,**/api/dto/**/*.ts,**/testing/factory/*.factory.ts sonar.javascript.lcov.reportPaths=merged-lcov.info sonar.typescript.tsconfigPaths=tsconfig.json,src/apps/server/tsconfig.app.json From 692f3fa78531dccc4634aaa65da453e3f30924b9 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 16:42:16 +0100 Subject: [PATCH 22/24] Fix copying of serverversion in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ba38fafa5db..fa496e6a47e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ COPY scripts/ldapSync.sh scripts/ COPY src src COPY --from=builder /app/dist dist -COPY --from=builder /app/apps/server/static-assets apps/server/static-assets +COPY --from=builder /app/serverversion apps/server/static-assets # The postinstall script must be disabled, because esbuild is a dev dependency and not installed here. RUN npm pkg delete scripts.postinstall \ From ff6d72eff3b14d8aebdcadfda573abe0ebf7bf8d Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 16 Jan 2025 17:02:16 +0100 Subject: [PATCH 23/24] Fix copying of serverversion in Dockerfile once more --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fa496e6a47e..fc6bddec245 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ COPY scripts/ldapSync.sh scripts/ COPY src src COPY --from=builder /app/dist dist -COPY --from=builder /app/serverversion apps/server/static-assets +COPY --from=builder /app/serverversion apps/server/static-assets/serverversion # The postinstall script must be disabled, because esbuild is a dev dependency and not installed here. RUN npm pkg delete scripts.postinstall \ From 05b10f7463fcfad2c467b5a952d79cd037e10215 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Fri, 17 Jan 2025 12:46:50 +0100 Subject: [PATCH 24/24] Fix copying of serverversion in Dockerfile once more --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fc6bddec245..ff33f053c21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ COPY scripts/ldapSync.sh scripts/ COPY src src COPY --from=builder /app/dist dist -COPY --from=builder /app/serverversion apps/server/static-assets/serverversion +COPY --from=builder /app/serverversion dist/apps/server/static-assets/serverversion # The postinstall script must be disabled, because esbuild is a dev dependency and not installed here. RUN npm pkg delete scripts.postinstall \