@20baht/cli 0.2.0 → 0.3.1
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/README.md +95 -41
- package/dist/application/create.js +8 -4
- package/dist/application/generate.js +27 -21
- package/dist/application/update.js +104 -0
- package/dist/args.js +3 -0
- package/dist/cli.js +56 -22
- package/dist/domain/create-plan.js +4 -3
- package/dist/domain/form-dsl.js +1 -1
- package/dist/domain/generate-plan.js +3 -3
- package/dist/domain/update-plan.js +93 -0
- package/dist/infrastructure/fs-reader.js +34 -2
- package/dist/infrastructure/npm-registry.js +28 -0
- package/package.json +10 -7
- package/templates/angular/apps/server/package.json +2 -0
- package/templates/angular/apps/server/src/app.ts +10 -0
- package/templates/angular/apps/server/src/forms/contact.form.ts +34 -0
- package/templates/angular/apps/server/test/app.test.ts +29 -0
- package/templates/angular/package.json.hbs +1 -1
- package/templates/create/apps/web/package.json.hbs +1 -1
- package/templates/{angular → federation}/README.md.hbs +2 -2
- package/templates/{angular → federation}/_dependency-cruiser.mjs +1 -1
- package/templates/{angular → federation}/apps/shell/package.json +3 -3
- package/templates/{angular → federation}/apps/shell/src/app/modules/home/home.component.ts.hbs +1 -1
- package/templates/{angular → federation}/apps/shell/src/environments/environment.development.ts +1 -1
- package/templates/{angular → federation}/eslint.config.ts.hbs +1 -1
- package/templates/new/README.md.hbs +1 -1
- package/templates/new/package.json.hbs +1 -1
- package/templates/remote/package.json.hbs +3 -3
- package/templates/standalone/README.md.hbs +44 -0
- package/templates/standalone/_dependency-cruiser.mjs +29 -0
- package/templates/standalone/apps/web/_editorconfig +17 -0
- package/templates/standalone/apps/web/angular.json +72 -0
- package/templates/standalone/apps/web/package.json +39 -0
- package/templates/standalone/apps/web/src/app/app.config.ts +14 -0
- package/templates/standalone/apps/web/src/app/app.css +4 -0
- package/templates/standalone/apps/web/src/app/app.html.hbs +16 -0
- package/templates/standalone/apps/web/src/app/app.routes.ts.hbs +23 -0
- package/templates/standalone/apps/web/src/app/app.ts +43 -0
- package/templates/standalone/apps/web/src/app/core/navigation/navigation.spec.ts +26 -0
- package/templates/standalone/apps/web/src/app/core/navigation/navigation.ts +14 -0
- package/templates/standalone/apps/web/src/app/modules/contact/contact.component.ts.hbs +87 -0
- package/templates/standalone/apps/web/src/app/modules/home/home.component.ts.hbs +37 -0
- package/templates/standalone/apps/web/src/app/modules/not-found/not-found.component.ts +36 -0
- package/templates/standalone/apps/web/src/app/services/contact.service.ts.hbs +19 -0
- package/templates/standalone/apps/web/src/app/services/hello.service.ts.hbs +14 -0
- package/templates/standalone/apps/web/src/index.html.hbs +12 -0
- package/templates/standalone/apps/web/src/main.ts +10 -0
- package/templates/standalone/apps/web/src/styles.css +19 -0
- package/templates/standalone/apps/web/tsconfig.app.json +10 -0
- package/templates/standalone/apps/web/tsconfig.json.hbs +39 -0
- package/templates/standalone/apps/web/tsconfig.spec.json +9 -0
- package/templates/standalone/bahtui.json +6 -0
- package/templates/standalone/eslint.config.ts.hbs +24 -0
- package/templates/standalone/knip.ts +23 -0
- /package/templates/{angular → federation}/apps/shell/_editorconfig +0 -0
- /package/templates/{angular → federation}/apps/shell/angular.json +0 -0
- /package/templates/{angular → federation}/apps/shell/federation.config.mjs +0 -0
- /package/templates/{angular → federation}/apps/shell/public/federation.manifest.json +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/app.config.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/app.css +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/app.html.hbs +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/app.routes.ts.hbs +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/app.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/core/federation/load-remote.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/core/federation/manifest.spec.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/core/federation/manifest.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/core/federation/remote-loader.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/core/federation/timeout.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/app/modules/unavailable/unavailable.component.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/bootstrap.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/environments/environment.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/index.html.hbs +0 -0
- /package/templates/{angular → federation}/apps/shell/src/main.ts +0 -0
- /package/templates/{angular → federation}/apps/shell/src/styles.css +0 -0
- /package/templates/{angular → federation}/apps/shell/tsconfig.app.json +0 -0
- /package/templates/{angular → federation}/apps/shell/tsconfig.federation.json +0 -0
- /package/templates/{angular → federation}/apps/shell/tsconfig.json.hbs +0 -0
- /package/templates/{angular → federation}/apps/shell/tsconfig.spec.json +0 -0
- /package/templates/{angular → federation}/bahtui.json +0 -0
- /package/templates/{angular → federation}/knip.ts +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "web",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"ng": "ng",
|
|
7
|
+
"dev": "ng serve",
|
|
8
|
+
"build": "ng build",
|
|
9
|
+
"test": "ng test",
|
|
10
|
+
"test:coverage": "ng test --watch=false --coverage",
|
|
11
|
+
"typecheck": "tsc -b --noEmit",
|
|
12
|
+
"pretypecheck": "bun run --filter server build:types",
|
|
13
|
+
"prebuild": "bun run --filter server build:types"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@angular/common": "^22.2.0",
|
|
17
|
+
"@angular/compiler": "^22.2.0",
|
|
18
|
+
"@angular/core": "^22.2.0",
|
|
19
|
+
"@angular/platform-browser": "^22.2.0",
|
|
20
|
+
"@angular/router": "^22.2.0",
|
|
21
|
+
"@20baht/ui": "0.3.0",
|
|
22
|
+
"@20baht/angular": "0.3.0",
|
|
23
|
+
"dompurify": "3.4.17",
|
|
24
|
+
"flatpickr": "4.6.13",
|
|
25
|
+
"marked": "18.1.3",
|
|
26
|
+
"@20baht/ngx-eden": "^0.1.0",
|
|
27
|
+
"rxjs": "~7.8.0",
|
|
28
|
+
"tslib": "^2.3.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@angular/build": "^22.2.0",
|
|
32
|
+
"@angular/cli": "^22.2.0",
|
|
33
|
+
"@angular/compiler-cli": "^22.2.0",
|
|
34
|
+
"@vitest/coverage-v8": "^4.0.8",
|
|
35
|
+
"jsdom": "^30.0.0",
|
|
36
|
+
"typescript": "~6.0.2",
|
|
37
|
+
"vitest": "^4.0.8"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApplicationConfig } from '@angular/core'
|
|
2
|
+
import { provideBrowserGlobalErrorListeners } from '@angular/core'
|
|
3
|
+
import { provideHttpClient } from '@angular/common/http'
|
|
4
|
+
import { provideRouter, withComponentInputBinding } from '@angular/router'
|
|
5
|
+
import { routes } from './app.routes'
|
|
6
|
+
|
|
7
|
+
/** The router and the `HttpClient` the kit's typed API client (`Api`) sends through. */
|
|
8
|
+
export const appConfig: ApplicationConfig = {
|
|
9
|
+
providers: [
|
|
10
|
+
provideBrowserGlobalErrorListeners(),
|
|
11
|
+
provideRouter(routes, withComponentInputBinding()),
|
|
12
|
+
provideHttpClient(),
|
|
13
|
+
],
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<baht-app-shell
|
|
2
|
+
brand="{{name}}"
|
|
3
|
+
brand-href="/"
|
|
4
|
+
label="{{name}}"
|
|
5
|
+
[items]="items"
|
|
6
|
+
[value]="current()"
|
|
7
|
+
(baht-nav)="navigate($event)"
|
|
8
|
+
>
|
|
9
|
+
<div data-slot="actions">
|
|
10
|
+
<baht-theme-toggle default="system"></baht-theme-toggle>
|
|
11
|
+
</div>
|
|
12
|
+
<main class="shell-main">
|
|
13
|
+
<router-outlet />
|
|
14
|
+
</main>
|
|
15
|
+
</baht-app-shell>
|
|
16
|
+
<baht-toast></baht-toast>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Routes } from '@angular/router'
|
|
2
|
+
|
|
3
|
+
/** One lazy page per route. A new page also gets a line in `core/navigation/navigation.ts`. */
|
|
4
|
+
export const routes: Routes = [
|
|
5
|
+
{
|
|
6
|
+
path: '',
|
|
7
|
+
pathMatch: 'full',
|
|
8
|
+
title: '{{name}}',
|
|
9
|
+
loadComponent: () => import('./modules/home/home.component').then((m) => m.HomeComponent),
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
path: 'contact',
|
|
13
|
+
title: 'Contact · {{name}}',
|
|
14
|
+
loadComponent: () =>
|
|
15
|
+
import('./modules/contact/contact.component').then((m) => m.ContactComponent),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: '**',
|
|
19
|
+
title: 'Not found · {{name}}',
|
|
20
|
+
loadComponent: () =>
|
|
21
|
+
import('./modules/not-found/not-found.component').then((m) => m.NotFoundComponent),
|
|
22
|
+
},
|
|
23
|
+
]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'
|
|
2
|
+
import { toSignal } from '@angular/core/rxjs-interop'
|
|
3
|
+
import { NavigationEnd, Router, RouterOutlet } from '@angular/router'
|
|
4
|
+
import { BAHT_UI } from '@20baht/angular'
|
|
5
|
+
import { filter, map } from 'rxjs'
|
|
6
|
+
import { NAV, currentKey } from './core/navigation/navigation'
|
|
7
|
+
|
|
8
|
+
/** The frame every page sits in: brand, the navigator, the page. */
|
|
9
|
+
@Component({
|
|
10
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
11
|
+
imports: [RouterOutlet, BAHT_UI],
|
|
12
|
+
selector: 'app-root',
|
|
13
|
+
templateUrl: './app.html',
|
|
14
|
+
styleUrl: './app.css',
|
|
15
|
+
})
|
|
16
|
+
export class App {
|
|
17
|
+
private readonly router = inject(Router)
|
|
18
|
+
|
|
19
|
+
private readonly url = toSignal(
|
|
20
|
+
this.router.events.pipe(
|
|
21
|
+
filter((event) => event instanceof NavigationEnd),
|
|
22
|
+
map((event) => event.urlAfterRedirects),
|
|
23
|
+
),
|
|
24
|
+
{ initialValue: this.router.url },
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
protected readonly items = NAV
|
|
28
|
+
|
|
29
|
+
protected readonly current = computed(() =>
|
|
30
|
+
currentKey(
|
|
31
|
+
this.url(),
|
|
32
|
+
NAV.map((item) => item.key),
|
|
33
|
+
),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
/** Route in place instead of letting the link reload the page. */
|
|
37
|
+
protected navigate(event: Event): void {
|
|
38
|
+
const { href } = (event as CustomEvent<{ href: string | undefined }>).detail
|
|
39
|
+
if (href === undefined) return
|
|
40
|
+
event.preventDefault()
|
|
41
|
+
void this.router.navigateByUrl(href)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NAV, currentKey } from './navigation'
|
|
2
|
+
|
|
3
|
+
describe('currentKey', () => {
|
|
4
|
+
const keys = ['', 'orders', 'orders/archive', 'order']
|
|
5
|
+
|
|
6
|
+
it('is the entry the URL sits under', () => {
|
|
7
|
+
expect(currentKey('/orders', keys)).toBe('orders')
|
|
8
|
+
expect(currentKey('/orders/42?tab=lines#top', keys)).toBe('orders')
|
|
9
|
+
expect(currentKey('/order/1', keys)).toBe('order')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('prefers the longest entry', () => {
|
|
13
|
+
expect(currentKey('/orders/archive/2024', keys)).toBe('orders/archive')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('is Home for the root and for a URL no entry owns', () => {
|
|
17
|
+
expect(currentKey('/', keys)).toBe('')
|
|
18
|
+
expect(currentKey('/ordersx', keys)).toBe('')
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
describe('NAV', () => {
|
|
23
|
+
it('starts with Home at the root', () => {
|
|
24
|
+
expect(NAV[0]).toEqual({ key: '', label: 'Home', href: '/' })
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ShellNavItem } from '@20baht/ui'
|
|
2
|
+
|
|
3
|
+
/** The navigator: one entry per page. `key` is the page's path, without the leading slash. */
|
|
4
|
+
export const NAV: ShellNavItem[] = [
|
|
5
|
+
{ key: '', label: 'Home', href: '/' },
|
|
6
|
+
{ key: 'contact', label: 'Contact', href: '/contact' },
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
/** The key of the entry `url` sits under, the longest one first; `''` (Home) when none does. */
|
|
10
|
+
export const currentKey = (url: string, keys: string[]): string => {
|
|
11
|
+
const path = (url.split(/[?#]/)[0] ?? '').replace(/^\//, '')
|
|
12
|
+
const under = keys.filter((key) => key !== '' && (path === key || path.startsWith(`${key}/`)))
|
|
13
|
+
return under.sort((a, b) => b.length - a.length)[0] ?? ''
|
|
14
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core'
|
|
2
|
+
import { describeError } from '@{{name}}/kit'
|
|
3
|
+
import { BAHT_UI } from '@20baht/angular'
|
|
4
|
+
import { ContactService } from '../../services/contact.service'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A form from a schema: `<baht-form>` renders and checks it in the browser, the server checks
|
|
8
|
+
* the same schema again. This is the whole of "a form" in this app; nothing else is needed.
|
|
9
|
+
*/
|
|
10
|
+
@Component({
|
|
11
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12
|
+
imports: [BAHT_UI],
|
|
13
|
+
selector: 'web-contact',
|
|
14
|
+
styles: `
|
|
15
|
+
.actions {
|
|
16
|
+
display: flex;
|
|
17
|
+
gap: var(--baht-space-3);
|
|
18
|
+
margin-top: var(--baht-space-4);
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
template: `
|
|
22
|
+
<div class="app-page">
|
|
23
|
+
<baht-page-header
|
|
24
|
+
heading="Contact"
|
|
25
|
+
description="One schema: rendered here, validated again on the server."
|
|
26
|
+
></baht-page-header>
|
|
27
|
+
<baht-card heading="Send a message">
|
|
28
|
+
@if (schema.error(); as error) {
|
|
29
|
+
<baht-error-state
|
|
30
|
+
heading="The form could not be loaded"
|
|
31
|
+
[message]="describeError(error)"
|
|
32
|
+
retry-label="Try again"
|
|
33
|
+
(bahtRetry)="schema.reload()"
|
|
34
|
+
></baht-error-state>
|
|
35
|
+
} @else if (schema.value(); as form) {
|
|
36
|
+
<baht-form
|
|
37
|
+
#contact="bahtForm"
|
|
38
|
+
[form]="form"
|
|
39
|
+
[busy]="sending()"
|
|
40
|
+
submit-on-enter
|
|
41
|
+
(bahtSubmit)="send($event.data)"
|
|
42
|
+
></baht-form>
|
|
43
|
+
<div class="actions">
|
|
44
|
+
<baht-button [loading]="sending()" (click)="contact.element.submit()">Send</baht-button>
|
|
45
|
+
</div>
|
|
46
|
+
} @else {
|
|
47
|
+
<baht-skeleton variant="text"></baht-skeleton>
|
|
48
|
+
}
|
|
49
|
+
</baht-card>
|
|
50
|
+
@if (failed(); as message) {
|
|
51
|
+
<baht-alert tone="danger" [message]="message"></baht-alert>
|
|
52
|
+
}
|
|
53
|
+
@if (received(); as text) {
|
|
54
|
+
<baht-card heading="What the server kept">
|
|
55
|
+
<pre [textContent]="text"></pre>
|
|
56
|
+
</baht-card>
|
|
57
|
+
}
|
|
58
|
+
</div>
|
|
59
|
+
`,
|
|
60
|
+
})
|
|
61
|
+
export class ContactComponent {
|
|
62
|
+
private readonly contact = inject(ContactService)
|
|
63
|
+
protected readonly schema = this.contact.form()
|
|
64
|
+
protected readonly describeError = describeError
|
|
65
|
+
protected readonly sending = signal(false)
|
|
66
|
+
protected readonly failed = signal<string | null>(null)
|
|
67
|
+
private readonly kept = signal<Record<string, unknown> | null>(null)
|
|
68
|
+
protected readonly received = computed(() => {
|
|
69
|
+
const kept = this.kept()
|
|
70
|
+
return kept === null ? null : JSON.stringify(kept, null, 2)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
protected send(data: Record<string, unknown>): void {
|
|
74
|
+
this.sending.set(true)
|
|
75
|
+
this.failed.set(null)
|
|
76
|
+
this.contact.send(data).subscribe({
|
|
77
|
+
next: (answer) => {
|
|
78
|
+
this.kept.set(answer.received)
|
|
79
|
+
this.sending.set(false)
|
|
80
|
+
},
|
|
81
|
+
error: (error: unknown) => {
|
|
82
|
+
this.failed.set(describeError(error))
|
|
83
|
+
this.sending.set(false)
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
|
|
2
|
+
import { describeError } from '@{{name}}/kit'
|
|
3
|
+
import { BAHT_UI } from '@20baht/angular'
|
|
4
|
+
import { HelloService } from '../../services/hello.service'
|
|
5
|
+
|
|
6
|
+
/** The landing page: what the server says at `GET /api/hello`. */
|
|
7
|
+
@Component({
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
imports: [BAHT_UI],
|
|
10
|
+
selector: 'web-home',
|
|
11
|
+
template: `
|
|
12
|
+
<div class="app-page">
|
|
13
|
+
<baht-page-header
|
|
14
|
+
heading="{{name}}"
|
|
15
|
+
description="An Angular app on @20baht/ui, talking to an Elysia server through a typed client."
|
|
16
|
+
></baht-page-header>
|
|
17
|
+
<baht-card heading="From the server">
|
|
18
|
+
@if (hello.error(); as error) {
|
|
19
|
+
<baht-error-state
|
|
20
|
+
heading="The server did not answer"
|
|
21
|
+
[message]="describeError(error)"
|
|
22
|
+
retry-label="Try again"
|
|
23
|
+
(bahtRetry)="hello.reload()"
|
|
24
|
+
></baht-error-state>
|
|
25
|
+
} @else if (hello.value(); as body) {
|
|
26
|
+
<p [textContent]="body.message"></p>
|
|
27
|
+
} @else {
|
|
28
|
+
<baht-skeleton variant="text"></baht-skeleton>
|
|
29
|
+
}
|
|
30
|
+
</baht-card>
|
|
31
|
+
</div>
|
|
32
|
+
`,
|
|
33
|
+
})
|
|
34
|
+
export class HomeComponent {
|
|
35
|
+
protected readonly hello = inject(HelloService).hello()
|
|
36
|
+
protected readonly describeError = describeError
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
|
|
2
|
+
import { Router } from '@angular/router'
|
|
3
|
+
import { BAHT_UI } from '@20baht/angular'
|
|
4
|
+
|
|
5
|
+
/** Shown for a URL no route owns. */
|
|
6
|
+
@Component({
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
imports: [BAHT_UI],
|
|
9
|
+
selector: 'web-not-found',
|
|
10
|
+
styles: `
|
|
11
|
+
:host {
|
|
12
|
+
display: grid;
|
|
13
|
+
place-content: center;
|
|
14
|
+
min-height: 60dvh;
|
|
15
|
+
padding: var(--baht-space-4);
|
|
16
|
+
}
|
|
17
|
+
baht-error-state {
|
|
18
|
+
max-width: 440px;
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
template: `
|
|
22
|
+
<baht-error-state
|
|
23
|
+
heading="Page not found"
|
|
24
|
+
message="Nothing lives at this address."
|
|
25
|
+
retry-label="Go home"
|
|
26
|
+
(bahtRetry)="home()"
|
|
27
|
+
></baht-error-state>
|
|
28
|
+
`,
|
|
29
|
+
})
|
|
30
|
+
export class NotFoundComponent {
|
|
31
|
+
private readonly router = inject(Router)
|
|
32
|
+
|
|
33
|
+
protected home(): void {
|
|
34
|
+
void this.router.navigateByUrl('/')
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Injectable, inject } from '@angular/core'
|
|
2
|
+
import { Api } from '@{{name}}/kit'
|
|
3
|
+
import { edenResource } from '@20baht/ngx-eden'
|
|
4
|
+
|
|
5
|
+
/** The contact form: its schema from the server, and a submission back to it. */
|
|
6
|
+
@Injectable({ providedIn: 'root' })
|
|
7
|
+
export class ContactService {
|
|
8
|
+
private readonly api = inject(Api).client.api
|
|
9
|
+
|
|
10
|
+
/** `GET /api/contact/form` as a resource; create it in an injection context (a field initializer). */
|
|
11
|
+
form() {
|
|
12
|
+
return edenResource(() => this.api.contact.form.get.$request())
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** `POST /api/contact`: the server validates with the schema the form was rendered from. */
|
|
16
|
+
send(data: Record<string, unknown>) {
|
|
17
|
+
return this.api.contact.post(data)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Injectable, inject } from '@angular/core'
|
|
2
|
+
import { Api } from '@{{name}}/kit'
|
|
3
|
+
import { edenResource } from '@20baht/ngx-eden'
|
|
4
|
+
|
|
5
|
+
/** Everything the home page asks the server. */
|
|
6
|
+
@Injectable({ providedIn: 'root' })
|
|
7
|
+
export class HelloService {
|
|
8
|
+
private readonly api = inject(Api).client.api
|
|
9
|
+
|
|
10
|
+
/** `GET /api/hello` as a resource; create it in an injection context (a field initializer). */
|
|
11
|
+
hello() {
|
|
12
|
+
return edenResource(() => this.api.hello.get.$request())
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { bootstrapApplication } from '@angular/platform-browser'
|
|
2
|
+
import { App } from './app/app'
|
|
3
|
+
import { appConfig } from './app/app.config'
|
|
4
|
+
|
|
5
|
+
// Registers the <baht-*> custom elements in their own chunk; they upgrade in place once it lands.
|
|
6
|
+
void import('@20baht/ui')
|
|
7
|
+
|
|
8
|
+
bootstrapApplication(App, appConfig).catch((err: unknown) => {
|
|
9
|
+
console.error(err)
|
|
10
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* @20baht/ui's tokens.css comes first (angular.json); this file only sets the page up. */
|
|
2
|
+
html,
|
|
3
|
+
body {
|
|
4
|
+
margin: 0;
|
|
5
|
+
min-height: 100dvh;
|
|
6
|
+
background: var(--baht-color-bg);
|
|
7
|
+
color: var(--baht-color-text);
|
|
8
|
+
font-family: var(--baht-font-family);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* The width every routed page keeps to inside the shell. */
|
|
12
|
+
.app-page {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: var(--baht-space-5);
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
max-width: 1200px;
|
|
18
|
+
padding: var(--baht-space-5);
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"types": []
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*.ts"],
|
|
9
|
+
"exclude": ["src/**/*.spec.ts"]
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"compileOnSave": false,
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noUncheckedIndexedAccess": true,
|
|
8
|
+
"exactOptionalPropertyTypes": true,
|
|
9
|
+
"verbatimModuleSyntax": true,
|
|
10
|
+
"noImplicitOverride": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
12
|
+
"noImplicitReturns": true,
|
|
13
|
+
"noFallthroughCasesInSwitch": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"experimentalDecorators": true,
|
|
17
|
+
"importHelpers": true,
|
|
18
|
+
"target": "ES2022",
|
|
19
|
+
"module": "preserve",
|
|
20
|
+
"paths": {
|
|
21
|
+
"@{{name}}/kit": ["../../packages/kit/src/index.ts"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"angularCompilerOptions": {
|
|
25
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
26
|
+
"strictInjectionParameters": true,
|
|
27
|
+
"strictTemplates": true,
|
|
28
|
+
"strictInputAccessModifiers": true
|
|
29
|
+
},
|
|
30
|
+
"files": [],
|
|
31
|
+
"references": [
|
|
32
|
+
{
|
|
33
|
+
"path": "./tsconfig.app.json"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "./tsconfig.spec.json"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"types": ["vitest/globals"]
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*.d.ts", "src/**/*.spec.ts"]
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config'
|
|
2
|
+
|
|
3
|
+
import { angular, bahtui, base } from '@20baht/strict/eslint'
|
|
4
|
+
|
|
5
|
+
/** The web app and the kit it compiles in. */
|
|
6
|
+
const WEB = ['apps/web/src/**', 'packages/kit/src/**']
|
|
7
|
+
|
|
8
|
+
// Every rule is an error. Add app overrides below, each with a reason:
|
|
9
|
+
// // eslint-disable-next-line <rule> -- <why>
|
|
10
|
+
export default defineConfig([
|
|
11
|
+
...base,
|
|
12
|
+
...angular({
|
|
13
|
+
files: WEB,
|
|
14
|
+
restrictedImports: [
|
|
15
|
+
{
|
|
16
|
+
name: 'server',
|
|
17
|
+
allowTypeImports: true,
|
|
18
|
+
message:
|
|
19
|
+
'The web app shares the server only as types (the eden App type); no server runtime code in a bundle.',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
}),
|
|
23
|
+
...bahtui({ files: WEB, tokenFiles: ['apps/web/src/styles.css'] }),
|
|
24
|
+
])
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { knip } from '@20baht/strict/knip'
|
|
2
|
+
|
|
3
|
+
const SRC = ['src/**/*.ts']
|
|
4
|
+
|
|
5
|
+
/** A workspace tested with `bun test`: the tests are its entries. */
|
|
6
|
+
const tested = { entry: ['test/**/*.test.ts'], project: [...SRC, 'test/**/*.ts'] }
|
|
7
|
+
|
|
8
|
+
export default knip({
|
|
9
|
+
ignoreDependencies: [
|
|
10
|
+
// Angular's compiler emits tslib helpers (importHelpers).
|
|
11
|
+
'tslib',
|
|
12
|
+
// Optional peers of @20baht/ui, which imports them on demand (date and markdown fields).
|
|
13
|
+
'dompurify',
|
|
14
|
+
'flatpickr',
|
|
15
|
+
'marked',
|
|
16
|
+
],
|
|
17
|
+
workspaces: {
|
|
18
|
+
'.': { entry: ['scripts/*.ts'], project: ['scripts/**/*.ts'] },
|
|
19
|
+
'apps/server': tested,
|
|
20
|
+
'apps/web': { project: SRC },
|
|
21
|
+
'packages/kit': tested,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{angular → federation}/apps/shell/src/app/core/federation/manifest.spec.ts
RENAMED
|
File without changes
|
|
File without changes
|
/package/templates/{angular → federation}/apps/shell/src/app/core/federation/remote-loader.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|