Skip to content

Commit

Permalink
Merge pull request #1070 from geonetwork/migrate-ng-19
Browse files Browse the repository at this point in the history
Migration to Angular 18
  • Loading branch information
jahow authored Jan 23, 2025
2 parents 8ebef57 + f707913 commit 271bc7b
Show file tree
Hide file tree
Showing 132 changed files with 13,692 additions and 17,959 deletions.
32 changes: 24 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"allow": [
"^.+/jest.setup",
"^.+/translations/.*.json$",
"^.+/tools/e2e/.+$",
"^.+/package.json"
],
"depConstraints": [
{
"sourceTag": "type:feature",
Expand All @@ -23,12 +28,10 @@
],
"bannedExternalImports": ["*app-config"]
},
// data-access libs should only depend on data-access libs
{
"sourceTag": "type:data-access",
"onlyDependOnLibsWithTags": ["type:data-access"]
},
// ui libs should only depend on ui libs and shared & i18n utils
{
"sourceTag": "type:ui",
"onlyDependOnLibsWithTags": [
Expand All @@ -37,12 +40,10 @@
"scope:shared"
]
},
// util libs should only depend on util libs
{
"sourceTag": "type:util",
"onlyDependOnLibsWithTags": ["type:util"]
},
// apps should depend on all kind of libs
{
"sourceTag": "type:app",
"onlyDependOnLibsWithTags": [
Expand All @@ -53,7 +54,6 @@
"type:api"
]
},
// api libs should only depend on api libs
{
"sourceTag": "type:api",
"onlyDependOnLibsWithTags": ["type:api", "scope:shared"],
Expand All @@ -67,12 +67,28 @@
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
"rules": {
"@typescript-eslint/no-unused-expressions": [
"error",
{
"allowShortCircuit": true,
"allowTernary": true
}
]
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
"rules": {
"@typescript-eslint/no-unused-expressions": [
"error",
{
"allowShortCircuit": true,
"allowTernary": true
}
]
}
},
{
"files": ["*.spec.ts", "*.cy.ts"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:
cancel-in-progress: true

env:
NODE_VERSION: 18.16.1
NODE_VERSION: 20.18.1
# a list of apps to build and publish on releases
APP_NAMES: datafeeder,datahub,metadata-editor

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Checks
run-name: 🩺 Quality assurance checks on ${{ github.event_name == 'pull_request' && 'PR' || '🌱' }} ${{ github.event_name == 'pull_request' && github.event.number || github.ref_name }}

env:
NODE_VERSION: 18.16.1
NODE_VERSION: 20.18.1
TEST_HIDE_CONSOLE: true

# This workflow runs for Pull Requests which are not draft,
Expand Down Expand Up @@ -117,12 +117,12 @@ jobs:

- name: Compute affected projects
run: |
echo "AFFECTED_LIBS=$(npx nx print-affected --type=lib --select=projects | awk 'BEGIN {RS = ", "; ORS = ", "} \
echo "AFFECTED_LIBS=$(npx nx show projects --affected --type=lib | awk 'BEGIN {RS = ", "; ORS = ", "} \
{ print "`"$1"`" }')" >> $GITHUB_ENV
- name: Compute affected apps
run: |
echo "AFFECTED_APPS=$(npx nx print-affected --type=app --select=projects | awk 'BEGIN {RS = ", "; ORS = ", "} \
echo "AFFECTED_APPS=$(npx nx show projects --affected --type=app | awk 'BEGIN {RS = ", "; ORS = ", "} \
{ print "`"$1"`" }')" >> $GITHUB_ENV
- name: add PR comment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy
run-name: 🚀 Deploy to GitHub Pages for ${{ github.event_name == 'issue_comment' && 'PR' || '🌱' }} ${{github.event_name == 'issue_comment' && github.event.issue.number || github.ref_name}}

env:
NODE_VERSION: 18.16.1
NODE_VERSION: 20.18.1

# This workflow runs whenever the "deploy affected apps" checkbox is checked (for PR)
# or on every push to main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/webcomponents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
cancel-in-progress: true

env:
NODE_VERSION: 18.16.1
NODE_VERSION: 20.18.1
PUBLISH_BRANCH: wc-dist

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
# OpenAPI generated specs
**/spec.yaml
/.nx

/.nx/cache
/.nx/workspace-data
15 changes: 4 additions & 11 deletions apps/data-platform/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/data-platform/src",
"projectType": "application",
"tags": ["type:app"],
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
Expand Down Expand Up @@ -37,7 +38,7 @@
}
},
"lint": {
"executor": "@nx/linter:eslint",
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/data-platform/**/*.ts"]
Expand All @@ -47,14 +48,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/data-platform/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "apps/data-platform/jest.config.ts"
}
},
"docker-build": {
Expand All @@ -66,6 +60,5 @@
]
}
}
},
"tags": ["type:app"]
}
}
17 changes: 8 additions & 9 deletions apps/datafeeder/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"projectType": "application",
"sourceRoot": "apps/datafeeder/src",
"prefix": "gn-ui",
"tags": ["type:app", "published"],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
Expand Down Expand Up @@ -72,23 +73,23 @@
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "datafeeder:build:production"
"buildTarget": "datafeeder:build:production"
},
"development": {
"browserTarget": "datafeeder:build:development",
"proxyConfig": "proxy-config.js"
"proxyConfig": "proxy-config.js",
"buildTarget": "datafeeder:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "datafeeder:build"
"buildTarget": "datafeeder:build"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": [
"apps/datafeeder/src/**/*.ts",
Expand All @@ -101,8 +102,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/datafeeder"],
"options": {
"jestConfig": "apps/datafeeder/jest.config.ts",
"passWithNoTests": true
"jestConfig": "apps/datafeeder/jest.config.ts"
}
},
"docker-build": {
Expand All @@ -115,6 +115,5 @@
"parallel": false
}
}
},
"tags": ["type:app", "published"]
}
}
4 changes: 3 additions & 1 deletion apps/datafeeder/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export function apiConfigurationFactory() {
StoreModule.forRoot({
[DATAFEEDER_STATE_KEY]: reducer,
}),
!environment.production ? StoreDevtoolsModule.instrument() : [],
!environment.production
? StoreDevtoolsModule.instrument({ connectInZone: true })
: [],
ProgressBarComponent,
],
providers: [importProvidersFrom(FeatureAuthModule)],
Expand Down
15 changes: 2 additions & 13 deletions apps/datafeeder/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import 'jest-preset-angular/setup-jest'
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'
import '../../../jest.setup'

import { getTestBed } from '@angular/core/testing'
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing'

getTestBed().resetTestEnvironment()
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
)
setupZoneTestEnv({ teardown: { destroyAfterEach: false } })
8 changes: 4 additions & 4 deletions apps/datahub-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/datahub-e2e/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["datahub", "database-dump"],
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
Expand All @@ -25,13 +27,11 @@
}
},
"lint": {
"executor": "@nx/linter:eslint",
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/datahub-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["datahub", "database-dump"]
}
}
2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('datasets', () => {
const hasDuplicates = options.some(
(text, index) => options.indexOf(text) !== index
)
expect(hasDuplicates).to.be.false
expect(hasDuplicates).to.eql(false)
}

beforeEach(() => {
Expand Down
17 changes: 8 additions & 9 deletions apps/datahub/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"projectType": "application",
"sourceRoot": "apps/datahub/src",
"prefix": "datahub",
"tags": ["type:app", "published"],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
Expand Down Expand Up @@ -88,23 +89,23 @@
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "datahub:build:production"
"buildTarget": "datahub:build:production"
},
"development": {
"browserTarget": "datahub:build:development",
"proxyConfig": "proxy-config.js"
"proxyConfig": "proxy-config.js",
"buildTarget": "datahub:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "datahub:build"
"buildTarget": "datahub:build"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": [
"apps/datahub/src/**/*.ts",
Expand All @@ -117,8 +118,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/datahub"],
"options": {
"jestConfig": "apps/datahub/jest.config.ts",
"passWithNoTests": true
"jestConfig": "apps/datahub/jest.config.ts"
}
},
"docker-build": {
Expand All @@ -131,6 +131,5 @@
"parallel": false
}
}
},
"tags": ["type:app", "published"]
}
}
9 changes: 7 additions & 2 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
},
}
),
!environment.production ? StoreDevtoolsModule.instrument() : [],
!environment.production
? StoreDevtoolsModule.instrument({ connectInZone: true })
: [],
EffectsModule.forRoot(),
UtilI18nModule,
TranslateModule.forRoot(TRANSLATE_WITH_OVERRIDES_CONFIG),
Expand Down Expand Up @@ -266,7 +268,10 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
bootstrap: [AppComponent],
})
export class AppModule {
constructor(router: Router, @Inject(DOCUMENT) private document: Document) {
constructor(
router: Router,
@Inject(DOCUMENT) private document: Document
) {
ThemeService.applyCssVariables(
getThemeConfig().PRIMARY_COLOR,
getThemeConfig().SECONDARY_COLOR,
Expand Down
Loading

0 comments on commit 271bc7b

Please sign in to comment.