Skip to content

Commit bfa3b6b

Browse files
committedFeb 25, 2024··
Migrated to angular + vite
1 parent 5e10225 commit bfa3b6b

22 files changed

+421
-809
lines changed
 

‎.github/dependabot.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
8+
updates:
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "daily"
13+
14+
- package-ecosystem: "docker"
15+
directory: "/"
16+
schedule:
17+
interval: "daily"

‎.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Presence
22

3-
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.1.4.
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.2.1.
44

55
## Development server
66

‎angular.json

+10-69
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
},
2828
"architect": {
2929
"build": {
30-
"builder": "@angular-devkit/build-angular:browser",
30+
"builder": "@angular-devkit/build-angular:application",
3131
"options": {
32-
"outputPath": "dist/presence/browser",
32+
"outputPath": "dist/presence",
3333
"index": "src/index.html",
34-
"main": "src/main.ts",
34+
"browser": "src/main.ts",
3535
"polyfills": [
3636
"zone.js"
3737
],
@@ -55,7 +55,12 @@
5555
"node_modules/@feel/style/global",
5656
"src/scss/global"
5757
]
58-
}
58+
},
59+
"server": "src/main.server.ts",
60+
"ssr": {
61+
"entry": "src/main.ssr.ts"
62+
},
63+
"prerender": false
5964
},
6065
"configurations": {
6166
"production": {
@@ -74,12 +79,9 @@
7479
"outputHashing": "all"
7580
},
7681
"development": {
77-
"buildOptimizer": false,
7882
"optimization": false,
79-
"vendorChunk": true,
8083
"extractLicenses": false,
81-
"sourceMap": true,
82-
"namedChunks": true
84+
"sourceMap": true
8385
}
8486
},
8587
"defaultConfiguration": "production"
@@ -131,67 +133,6 @@
131133
]
132134
}
133135
}
134-
},
135-
"server": {
136-
"builder": "@angular-devkit/build-angular:server",
137-
"options": {
138-
"outputPath": "dist/presence/server",
139-
"main": "src/main.server.ts",
140-
"tsConfig": "tsconfig.server.json",
141-
"inlineStyleLanguage": "scss",
142-
"stylePreprocessorOptions": {
143-
"includePaths": [
144-
"node_modules/@feel/style/global",
145-
"src/scss/global"
146-
]
147-
}
148-
},
149-
"configurations": {
150-
"production": {
151-
"outputHashing": "media"
152-
},
153-
"development": {
154-
"buildOptimizer": false,
155-
"optimization": false,
156-
"sourceMap": true,
157-
"extractLicenses": false,
158-
"vendorChunk": true
159-
}
160-
},
161-
"defaultConfiguration": "production"
162-
},
163-
"serve-ssr": {
164-
"builder": "@angular-devkit/build-angular:ssr-dev-server",
165-
"configurations": {
166-
"development": {
167-
"browserTarget": "presence:build:development",
168-
"serverTarget": "presence:server:development"
169-
},
170-
"production": {
171-
"browserTarget": "presence:build:production",
172-
"serverTarget": "presence:server:production"
173-
}
174-
},
175-
"defaultConfiguration": "development"
176-
},
177-
"prerender": {
178-
"builder": "@angular-devkit/build-angular:prerender",
179-
"options": {
180-
"routes": [
181-
"/"
182-
]
183-
},
184-
"configurations": {
185-
"production": {
186-
"browserTarget": "presence:build:production",
187-
"serverTarget": "presence:server:production"
188-
},
189-
"development": {
190-
"browserTarget": "presence:build:development",
191-
"serverTarget": "presence:server:development"
192-
}
193-
},
194-
"defaultConfiguration": "production"
195136
}
196137
}
197138
}

‎flake.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix

-9
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@
2727
presence = package;
2828
default = package;
2929
};
30-
31-
devShells.default = pkgs.mkShell {
32-
nativeBuildInputs = (with packages.default; nativeBuildInputs ++ buildInputs) ++ [
33-
# python for running test scripts
34-
(pkgs.python3.withPackages (p: with p; [
35-
requests
36-
]))
37-
];
38-
};
3930
}
4031
) // {
4132
overlays.default = final: prev: {

‎package.json

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
{
22
"name": "presence",
33
"version": "0.0.0",
4-
"packageManager": "pnpm@8.6.10",
4+
"packageManager": "pnpm@8.10.2",
55
"scripts": {
66
"ng": "ng",
77
"start": "ng serve",
88
"build": "ng build --output-path ./dist",
9-
"build:ci": "ng build --output-path ./dist/browser --localize && ng run presence:server --output-path ./dist/server --localize && rollup -c rollup.config.mjs",
9+
"build:ci": "ng build --output-path ./dist --localize && rollup -c rollup.config.mjs",
1010
"watch": "ng build --watch --configuration development",
1111
"test": "ng test",
1212
"test:ci": "ng test --no-watch --no-progress --browsers=ChromeHeadless",
13-
"dev:ssr": "ng run presence:serve-ssr",
14-
"serve:ssr": "node dist/presence/server/main.js",
15-
"build:ssr": "ng build && ng run presence:server",
16-
"prerender": "ng run presence:prerender",
13+
"serve:ssr": "node dist/server/server.mjs",
1714
"extract-i18n": "ng extract-i18n --out-file src/locales/en_devel.xlf --format xlif"
1815
},
1916
"private": true,
2017
"dependencies": {
21-
"@angular/animations": "^17.2.1",
22-
"@angular/cdk": "17.2.0",
23-
"@angular/common": "^17.2.1",
24-
"@angular/compiler": "^17.2.1",
25-
"@angular/core": "^17.2.1",
26-
"@angular/forms": "^17.2.1",
27-
"@angular/platform-browser": "^17.2.1",
28-
"@angular/platform-browser-dynamic": "^17.2.1",
29-
"@angular/platform-server": "^17.2.1",
30-
"@angular/router": "^17.2.1",
31-
"@angular/ssr": "^17.2.0",
18+
"@angular/animations": "^17.2.2",
19+
"@angular/common": "^17.2.2",
20+
"@angular/compiler": "^17.2.2",
21+
"@angular/core": "^17.2.2",
22+
"@angular/forms": "^17.2.2",
23+
"@angular/platform-browser": "^17.2.2",
24+
"@angular/platform-browser-dynamic": "^17.2.2",
25+
"@angular/platform-server": "^17.2.2",
26+
"@angular/router": "^17.2.2",
27+
"@angular/ssr": "^17.2.1",
3228
"@feel/form": "^0.0.14",
3329
"@feel/notification": "^0.0.14",
3430
"@feel/style": "^0.0.14",
@@ -39,24 +35,24 @@
3935
"zone.js": "~0.14.4"
4036
},
4137
"devDependencies": {
42-
"@angular-devkit/build-angular": "^17.2.0",
43-
"@angular/cli": "~17.2.0",
44-
"@angular/compiler-cli": "^17.2.1",
45-
"@angular/localize": "17.2.1",
38+
"@angular-devkit/build-angular": "^17.2.1",
39+
"@angular/cli": "^17.2.1",
40+
"@angular/compiler-cli": "^17.2.2",
41+
"@angular/localize": "17.2.2",
4642
"@rollup/plugin-commonjs": "^25.0.7",
4743
"@rollup/plugin-json": "^6.1.0",
4844
"@rollup/plugin-node-resolve": "^15.2.3",
4945
"@rollup/plugin-typescript": "^11.1.6",
5046
"@types/express": "^4.17.21",
51-
"@types/node": "^20.11.19",
52-
"browser-sync": "^3.0.2",
47+
"@types/jasmine": "~5.1.4",
48+
"@types/node": "^18.19.18",
5349
"jasmine-core": "~5.1.2",
54-
"karma": "~6.4.2",
50+
"karma": "~6.4.3",
5551
"karma-chrome-launcher": "~3.2.0",
5652
"karma-coverage": "~2.2.1",
5753
"karma-jasmine": "~5.1.0",
5854
"karma-jasmine-html-reporter": "~2.1.0",
5955
"rollup": "^4.12.0",
60-
"typescript": "~5.2.2"
56+
"typescript": "~5.3.3"
6157
}
62-
}
58+
}

‎pnpm-lock.yaml

+250-553
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {resolve} from 'path';
44
async function app(appDir: string, lang: string): Promise<express.Express> {
55
const serverFolder = resolve(`${appDir}/server/${lang}`);
66

7-
const {default: module} = await import(`${serverFolder}/main.js`);
7+
const {app}: { app: (appDir: string, lang: string) => express.Express } = await import(`${serverFolder}/server.mjs`);
88

9-
return module.app(appDir, lang);
9+
return app(appDir, lang);
1010
}
1111

1212
async function main() {

‎shell.nix

-11
This file was deleted.

‎src/app/app.component.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
import {ChangeDetectionStrategy, Component, HostListener, Inject, LOCALE_ID} from '@angular/core';
22
import {routingAnimation} from "./animation/routing.animation";
3-
import {ActivatedRoute, NavigationEnd, Router} from "@angular/router";
4-
import {DOCUMENT, Location, PlatformLocation} from "@angular/common";
3+
import {ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive, RouterOutlet} from "@angular/router";
4+
import {AsyncPipe, DOCUMENT, Location, NgIf, PlatformLocation} from "@angular/common";
55
import {BehaviorSubject, delay, filter, map, take} from "rxjs";
66
import {Meta, Title} from "@angular/platform-browser";
77
import {Language} from "./api/api.domain";
8+
import {IconLogoComponent} from "./icons/icon-logo/icon-logo.component";
9+
import {IconMenuComponent} from "./icons/icon-menu/icon-menu.component";
10+
import {NotificationListComponent} from "@feel/notification";
811

912
@Component({
1013
selector: 'app-root',
1114
templateUrl: './app.component.html',
1215
styleUrls: ['./app.component.scss'],
1316
changeDetection: ChangeDetectionStrategy.OnPush,
1417
animations: [routingAnimation],
18+
standalone: true,
19+
imports: [
20+
AsyncPipe,
21+
RouterLink,
22+
IconLogoComponent,
23+
RouterLinkActive,
24+
IconMenuComponent,
25+
RouterOutlet,
26+
NotificationListComponent,
27+
NgIf
28+
]
1529
})
1630
export class AppComponent {
1731

‎src/app/app.config.server.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
2+
import { provideServerRendering } from '@angular/platform-server';
3+
import { appConfig } from './app.config';
4+
5+
const serverConfig: ApplicationConfig = {
6+
providers: [
7+
provideServerRendering()
8+
]
9+
};
10+
11+
export const config = mergeApplicationConfig(appConfig, serverConfig);

‎src/app/app.config.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ApplicationConfig } from '@angular/core';
2+
import { provideRouter } from '@angular/router';
3+
4+
import { routes } from './app.routes';
5+
import { provideClientHydration } from '@angular/platform-browser';
6+
import {provideHttpClient, withFetch} from "@angular/common/http";
7+
import {provideAnimationsAsync} from "@angular/platform-browser/animations/async";
8+
9+
export const appConfig: ApplicationConfig = {
10+
providers: [
11+
provideRouter(routes),
12+
provideClientHydration(),
13+
provideHttpClient(withFetch()),
14+
provideAnimationsAsync()
15+
]
16+
};

‎src/app/app.module.ts

-38
This file was deleted.

‎src/app/app-routing.module.ts ‎src/app/app.routes.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {NgModule} from '@angular/core';
2-
import {RouterModule, Routes} from '@angular/router';
1+
import { Routes } from '@angular/router';
32

4-
const routes: Routes = [
3+
export const routes: Routes = [
54
{path: '', loadComponent: () => import('./pages/home/home.component').then(c => c.HomeComponent)},
65
{
76
path: 'news',
@@ -44,12 +43,3 @@ const routes: Routes = [
4443
loadComponent: () => import('./pages/not-found/not-found.component').then(c => c.NotFoundComponent)
4544
},
4645
];
47-
48-
@NgModule({
49-
imports: [RouterModule.forRoot(routes, {
50-
initialNavigation: 'enabledBlocking'
51-
})],
52-
exports: [RouterModule]
53-
})
54-
export class AppRoutingModule {
55-
}

‎src/app/app.server.module.ts

-14
This file was deleted.

‎src/main.server.ts

+5-41
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,7 @@
1-
import 'zone.js/node';
2-
import {AppServerModule} from './app/app.server.module';
1+
import { bootstrapApplication } from '@angular/platform-browser';
2+
import { AppComponent } from './app/app.component';
3+
import { config } from './app/app.config.server';
34

4-
import {APP_BASE_HREF} from '@angular/common';
5-
import {CommonEngine} from '@angular/ssr';
6-
import * as express from 'express';
7-
import {join, resolve} from 'node:path';
8-
import {LOCALE_ID} from "@angular/core";
5+
const bootstrap = () => bootstrapApplication(AppComponent, config);
96

10-
export function app(appDir: string, lang: string): express.Express {
11-
const app = express();
12-
13-
const browserFolder = resolve(`${appDir}/browser/${lang}`);
14-
const indexHtml = join(browserFolder, 'index.html');
15-
16-
const commonEngine = new CommonEngine();
17-
18-
app.set('view engine', 'html');
19-
app.set('views', browserFolder);
20-
21-
app.get('*.*', express.static(browserFolder, {
22-
maxAge: '1y'
23-
}));
24-
25-
// All regular routes use the Angular engine
26-
app.get('*', (req, res, next) =>
27-
commonEngine
28-
.render({
29-
bootstrap: AppServerModule,
30-
documentFilePath: indexHtml,
31-
url: `${req.protocol}://${req.headers.host}${req.originalUrl}`,
32-
publicPath: browserFolder,
33-
providers: [
34-
{provide: APP_BASE_HREF, useValue: req.baseUrl},
35-
{provide: LOCALE_ID, useValue: lang}
36-
],
37-
})
38-
.then((html) => res.send(html))
39-
.catch((err) => next(err))
40-
);
41-
42-
return app;
43-
}
7+
export default bootstrap;

‎src/main.ssr.ts

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {APP_BASE_HREF} from '@angular/common';
2+
import {CommonEngine} from '@angular/ssr';
3+
import express from 'express';
4+
import {fileURLToPath} from 'node:url';
5+
import {dirname, join, resolve} from 'node:path';
6+
import bootstrap from './main.server';
7+
import {LOCALE_ID} from "@angular/core";
8+
9+
export function app(appDir: string, lang: string): express.Express {
10+
const server = express();
11+
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
12+
const browserDistFolder = resolve(appDir, 'browser', lang);
13+
const indexHtml = join(serverDistFolder, 'index.server.html');
14+
15+
const commonEngine = new CommonEngine();
16+
17+
server.set('view engine', 'html');
18+
server.set('views', browserDistFolder);
19+
20+
// Example Express Rest API endpoints
21+
// server.get('/api/**', (req, res) => { });
22+
// Serve static files from /browser
23+
server.get('*.*', express.static(browserDistFolder, {
24+
maxAge: '1y'
25+
}));
26+
27+
// All regular routes use the Angular engine
28+
server.get('*', (req, res, next) => {
29+
const {protocol, originalUrl, baseUrl, headers} = req;
30+
31+
commonEngine
32+
.render({
33+
bootstrap,
34+
documentFilePath: indexHtml,
35+
url: `${protocol}://${headers.host}${originalUrl}`,
36+
publicPath: browserDistFolder,
37+
providers: [
38+
{provide: APP_BASE_HREF, useValue: baseUrl},
39+
{provide: LOCALE_ID, useValue: lang},
40+
],
41+
})
42+
.then((html) => res.send(html))
43+
.catch((err) => next(err));
44+
});
45+
46+
return server;
47+
}

‎src/main.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/// <reference types="@angular/localize" />
22

3-
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
4-
import {AppModule} from './app/app.module';
3+
import { bootstrapApplication } from '@angular/platform-browser';
4+
import { appConfig } from './app/app.config';
5+
import { AppComponent } from './app/app.component';
56

6-
platformBrowserDynamic().bootstrapModule(AppModule)
7-
.catch(err => console.error(err));
7+
bootstrapApplication(AppComponent, appConfig)
8+
.catch((err) => console.error(err));

‎tsconfig.app.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"compilerOptions": {
55
"outDir": "./out-tsc/app",
66
"types": [
7+
"node",
78
"@angular/localize"
89
]
910
},
1011
"files": [
11-
"src/main.ts"
12+
"src/main.ts",
13+
"src/main.server.ts",
14+
"src/main.ssr.ts",
15+
"server.ts"
1216
],
1317
"include": [
1418
"src/**/*.d.ts"

‎tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
{
33
"compileOnSave": false,
44
"compilerOptions": {
5-
"baseUrl": "./",
65
"outDir": "./dist/out-tsc",
76
"forceConsistentCasingInFileNames": true,
87
"strict": true,
98
"noImplicitOverride": true,
109
"noPropertyAccessFromIndexSignature": true,
1110
"noImplicitReturns": true,
1211
"noFallthroughCasesInSwitch": true,
12+
"skipLibCheck": true,
13+
"esModuleInterop": true,
1314
"sourceMap": true,
1415
"declaration": false,
15-
"downlevelIteration": true,
1616
"experimentalDecorators": true,
1717
"moduleResolution": "node",
1818
"importHelpers": true,

‎tsconfig.server.json

-14
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.