@poadio/starter-angular 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +9 -0
- package/.env.example +7 -0
- package/Dockerfile +20 -0
- package/README.md +91 -2
- package/angular.json +119 -0
- package/bun.lock +1057 -0
- package/docker/40-env-json.sh +39 -0
- package/docker/nginx.conf +24 -0
- package/package.json +86 -4
- package/public/logo.svg +1 -0
- package/public/providers/google.svg +1 -0
- package/public/providers/keycloak.svg +1 -0
- package/scripts/dev.mjs +30 -0
- package/scripts/env.mjs +96 -0
- package/scripts/routes.mjs +155 -0
- package/src/app/app.config.ts +16 -0
- package/src/app/app.meta.ts +43 -0
- package/src/app/app.routes.gen.ts +7 -0
- package/src/app/app.routes.ts +32 -0
- package/src/app/app.ts +17 -0
- package/src/app/core/auth.service.ts +117 -0
- package/src/app/core/captcha.ts +94 -0
- package/src/app/core/config.ts +17 -0
- package/src/app/core/env.ts +27 -0
- package/src/app/core/guards.ts +33 -0
- package/src/app/core/messages.ts +38 -0
- package/src/app/core/poad.ts +46 -0
- package/src/app/core/providers.ts +32 -0
- package/src/app/core/theme.service.ts +37 -0
- package/src/app/layout/_layout.scss +799 -0
- package/src/app/layout/app-layout.ts +263 -0
- package/src/app/layout/app-menu.ts +68 -0
- package/src/app/layout/app-menuitem.ts +105 -0
- package/src/app/layout/brand.ts +50 -0
- package/src/app/layout/canvas-head.ts +78 -0
- package/src/app/layout/layout.service.ts +159 -0
- package/src/app/pages/(auth)/login.html +128 -0
- package/src/app/pages/(auth)/login.ts +194 -0
- package/src/app/pages/(auth)/mfa.ts +61 -0
- package/src/app/pages/(auth)/reset.ts +53 -0
- package/src/app/pages/app/_layout.ts +5 -0
- package/src/app/pages/app/account.html +233 -0
- package/src/app/pages/app/account.ts +262 -0
- package/src/app/pages/app/hello/[name].ts +35 -0
- package/src/app/pages/app/index.ts +82 -0
- package/src/app/pages/app/public.ts +33 -0
- package/src/app/pages/index.ts +280 -0
- package/src/app/pages/setup.ts +51 -0
- package/src/index.html +13 -0
- package/src/main.ts +9 -0
- package/src/styles.scss +151 -0
- package/tsconfig.app.json +15 -0
- package/tsconfig.json +31 -0
package/.dockerignore
ADDED
package/.env.example
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Variables du front, à copier dans .env (partagé) ou .env.local (machine, non versionné).
|
|
2
|
+
# Seules PUBLIC_* et POAD_URL / POAD_ANON_KEY / POAD_MAIL_URL arrivent dans le navigateur.
|
|
3
|
+
# Sans POAD_URL ni POAD_ANON_KEY, bun start les lit dans poad/config.toml et poad/secrets.toml.
|
|
4
|
+
|
|
5
|
+
# POAD_URL=https://mon-projet.example.com
|
|
6
|
+
# POAD_ANON_KEY=eyJ...
|
|
7
|
+
PUBLIC_APP_ENV=development
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Image du front : compilée une fois, configurée au démarrage.
|
|
2
|
+
# docker build -t mon-app .
|
|
3
|
+
# docker run -p 8080:80 -e POAD_URL=https://... -e POAD_ANON_KEY=... -e PUBLIC_APP_ENV=prod mon-app
|
|
4
|
+
# Les variables PUBLIC_* et POAD_* deviennent /env.json, lu par l'application au chargement.
|
|
5
|
+
|
|
6
|
+
FROM node:22-alpine AS build
|
|
7
|
+
# bun installe les dépendances et lance les scripts ; Node exécute Angular
|
|
8
|
+
COPY --from=oven/bun:1.4.4-alpine /usr/local/bin/bun /usr/local/bin/bun
|
|
9
|
+
WORKDIR /app
|
|
10
|
+
COPY package.json bun.lock ./
|
|
11
|
+
COPY scripts ./scripts
|
|
12
|
+
RUN bun install --frozen-lockfile
|
|
13
|
+
COPY . .
|
|
14
|
+
RUN bun run build
|
|
15
|
+
|
|
16
|
+
FROM nginx:1.27-alpine
|
|
17
|
+
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
|
18
|
+
COPY --chmod=755 docker/40-env-json.sh /docker-entrypoint.d/40-env-json.sh
|
|
19
|
+
COPY --from=build /app/dist/starter/browser /usr/share/nginx/html
|
|
20
|
+
EXPOSE 80
|
package/README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
|
1
|
-
#
|
|
1
|
+
# poad · starter Angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Application Angular prête à brancher sur un projet poad : page de démarrage,
|
|
4
|
+
écran de connexion, cadre d'application et compte utilisateur, sur
|
|
5
|
+
`@cadriciel/ui` et `@poadio/auth-js`.
|
|
6
|
+
|
|
7
|
+
## Démarrer
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
poad init && poad start # projet poad dans ce dossier (poad/config.toml)
|
|
11
|
+
bun install
|
|
12
|
+
bun start # variables (public/env.json), routes, puis ng serve
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Variables d'environnement (lues au démarrage, pas compilées)
|
|
16
|
+
|
|
17
|
+
Comme Next.js : `.env`, `.env.<mode>`, `.env.local`, `.env.<mode>.local`, puis
|
|
18
|
+
l'environnement du processus (voir `.env.example`). Seules les variables
|
|
19
|
+
`PUBLIC_*` et `POAD_URL`, `POAD_ANON_KEY`, `POAD_MAIL_URL` arrivent dans le
|
|
20
|
+
navigateur, via `/env.json`, chargé avant l'application. Sans `POAD_URL` ni
|
|
21
|
+
`POAD_ANON_KEY`, `bun start` les lit dans `poad/config.toml` et `poad/secrets.toml`.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { env } from './core/env';
|
|
25
|
+
env('PUBLIC_API_URL');
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Image Docker
|
|
29
|
+
|
|
30
|
+
Compilée une fois, configurée au démarrage : le conteneur écrit `env.json` à
|
|
31
|
+
partir de ses variables (`docker/40-env-json.sh`), puis nginx sert l'application.
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
docker build -t mon-app .
|
|
35
|
+
docker run -p 8080:80 -e POAD_URL=https://mon-projet.example.com -e POAD_ANON_KEY=eyJ... -e PUBLIC_APP_ENV=prod mon-app
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Deux modes de routage
|
|
39
|
+
|
|
40
|
+
Dans `package.json` : `"poad": { "routing": "classic" | "files" }`.
|
|
41
|
+
|
|
42
|
+
- **classic** (défaut) : `src/app/app.routes.ts`, écrit à la main.
|
|
43
|
+
- **files**, à la Next.js : les routes sont générées depuis `src/app/pages`
|
|
44
|
+
(`scripts/routes.mjs`, relancé à chaque ajout de page pendant `bun start`).
|
|
45
|
+
|
|
46
|
+
| Fichier | Route |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `pages/index.ts` | `/` |
|
|
49
|
+
| `pages/app/account.ts` | `/app/account` |
|
|
50
|
+
| `pages/app/hello/[name].ts` | `/app/hello/:name` (paramètre en `input()`) |
|
|
51
|
+
| `pages/docs/[...slug].ts` | `/docs/**` |
|
|
52
|
+
| `pages/(auth)/login.ts` | `/login` (dossier entre parenthèses : groupe sans segment) |
|
|
53
|
+
| `pages/app/_layout.ts` | cadre de toutes les pages de `app/` |
|
|
54
|
+
|
|
55
|
+
Une page exporte son composant par défaut, et ses options en littéral :
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
export const route = { title: 'Mon compte', auth: true }; // connecté
|
|
59
|
+
export const route = { auth: { roles: ['admin'], mfa: false } }; // rôle
|
|
60
|
+
export const route = { guest: true }; // pages de connexion
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Les pages du starter suivent cette arborescence : passer d'un mode à l'autre
|
|
64
|
+
ne demande aucun déplacement.
|
|
65
|
+
|
|
66
|
+
## Ce qu'il y a dedans
|
|
67
|
+
|
|
68
|
+
| Route | Page | Accès |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `/` | Démarrage | tous |
|
|
71
|
+
| `/login` | Mot de passe, inscription, lien magique, oubli, fournisseurs OAuth, sans compte | déconnecté |
|
|
72
|
+
| `/mfa`, `/reset` | Double authentification, nouveau mot de passe | session |
|
|
73
|
+
| `/app` | Tableau de bord, dans le cadre (barre + menu) | connecté |
|
|
74
|
+
| `/app/public` | Page du cadre ouverte à tous | tous |
|
|
75
|
+
| `/app/account` | Profil, sécurité, MFA (TOTP), identités, sessions | connecté |
|
|
76
|
+
| `/app/hello/:name` | Exemple de route dynamique | tous |
|
|
77
|
+
|
|
78
|
+
Les boutons de connexion suivent ce que le projet poad propose (`/settings`) :
|
|
79
|
+
ajoutez un fournisseur côté poad (`poad run kc` pour un Keycloak local) et son
|
|
80
|
+
bouton apparaît.
|
|
81
|
+
|
|
82
|
+
## Adapter
|
|
83
|
+
|
|
84
|
+
- **Nom, description, version** : `package.json` (`title`, `description`, `version`).
|
|
85
|
+
- **Logo** : `public/logo.svg` ; couleurs et thème sombre : `src/styles.scss`.
|
|
86
|
+
- **Menu** : `src/app/app.meta.ts`.
|
|
87
|
+
- **Pages** : `src/app/pages` ; routes dans `src/app/app.routes.ts` (mode classic) ou générées (mode files).
|
|
88
|
+
- **Gardes** : `signedIn()` (session + MFA si l'utilisateur a un facteur),
|
|
89
|
+
`signedIn({ roles: ['admin'] })` (rôle dans `app_metadata.roles`),
|
|
90
|
+
`signedIn({ mfa: false })`, `signedOut`.
|
|
91
|
+
- **Session** : `AuthService` (signaux `session`, `user`, `claims`, `displayName`)
|
|
92
|
+
et `auth.auth`, le client `@poadio/auth-js`.
|
package/angular.json
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"cli": {
|
|
5
|
+
"packageManager": "bun",
|
|
6
|
+
"analytics": "e7d6beaa-3d23-4804-9bcc-fd8452c4251c"
|
|
7
|
+
},
|
|
8
|
+
"newProjectRoot": "projects",
|
|
9
|
+
"projects": {
|
|
10
|
+
"starter": {
|
|
11
|
+
"projectType": "application",
|
|
12
|
+
"schematics": {
|
|
13
|
+
"@schematics/angular:component": {
|
|
14
|
+
"style": "scss",
|
|
15
|
+
"skipTests": true
|
|
16
|
+
},
|
|
17
|
+
"@schematics/angular:class": {
|
|
18
|
+
"skipTests": true
|
|
19
|
+
},
|
|
20
|
+
"@schematics/angular:directive": {
|
|
21
|
+
"skipTests": true
|
|
22
|
+
},
|
|
23
|
+
"@schematics/angular:guard": {
|
|
24
|
+
"skipTests": true
|
|
25
|
+
},
|
|
26
|
+
"@schematics/angular:interceptor": {
|
|
27
|
+
"skipTests": true
|
|
28
|
+
},
|
|
29
|
+
"@schematics/angular:pipe": {
|
|
30
|
+
"skipTests": true
|
|
31
|
+
},
|
|
32
|
+
"@schematics/angular:resolver": {
|
|
33
|
+
"skipTests": true
|
|
34
|
+
},
|
|
35
|
+
"@schematics/angular:service": {
|
|
36
|
+
"skipTests": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"root": "",
|
|
40
|
+
"sourceRoot": "src",
|
|
41
|
+
"prefix": "app",
|
|
42
|
+
"architect": {
|
|
43
|
+
"build": {
|
|
44
|
+
"builder": "@angular/build:application",
|
|
45
|
+
"options": {
|
|
46
|
+
"browser": "src/main.ts",
|
|
47
|
+
"tsConfig": "tsconfig.app.json",
|
|
48
|
+
"inlineStyleLanguage": "scss",
|
|
49
|
+
"assets": [
|
|
50
|
+
{
|
|
51
|
+
"glob": "**/*",
|
|
52
|
+
"input": "public"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"styles": [
|
|
56
|
+
"src/styles.scss"
|
|
57
|
+
],
|
|
58
|
+
"externalDependencies": [
|
|
59
|
+
"@editorjs/editorjs",
|
|
60
|
+
"@editorjs/header",
|
|
61
|
+
"@editorjs/underline",
|
|
62
|
+
"@editorjs/delimiter",
|
|
63
|
+
"@calumk/editorjs-codecup",
|
|
64
|
+
"editorjs-alert",
|
|
65
|
+
"monaco-editor",
|
|
66
|
+
"maplibre-gl",
|
|
67
|
+
"chart.js",
|
|
68
|
+
"chart.js/auto"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"configurations": {
|
|
72
|
+
"production": {
|
|
73
|
+
"budgets": [
|
|
74
|
+
{
|
|
75
|
+
"type": "initial",
|
|
76
|
+
"maximumWarning": "1MB",
|
|
77
|
+
"maximumError": "2MB"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "anyComponentStyle",
|
|
81
|
+
"maximumWarning": "4kB",
|
|
82
|
+
"maximumError": "8kB"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"outputHashing": "all",
|
|
86
|
+
"assets": [
|
|
87
|
+
{
|
|
88
|
+
"glob": "**/*",
|
|
89
|
+
"input": "public",
|
|
90
|
+
"ignore": [
|
|
91
|
+
"env.json"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"development": {
|
|
97
|
+
"optimization": false,
|
|
98
|
+
"extractLicenses": false,
|
|
99
|
+
"sourceMap": true
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"defaultConfiguration": "production"
|
|
103
|
+
},
|
|
104
|
+
"serve": {
|
|
105
|
+
"builder": "@angular/build:dev-server",
|
|
106
|
+
"configurations": {
|
|
107
|
+
"production": {
|
|
108
|
+
"buildTarget": "starter:build:production"
|
|
109
|
+
},
|
|
110
|
+
"development": {
|
|
111
|
+
"buildTarget": "starter:build:development"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"defaultConfiguration": "development"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|