create-m5kdev 0.23.0 → 0.25.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/package.json +1 -1
- package/templates/minimal-app/AGENTS.md.tpl +4 -0
- package/templates/minimal-app/apps/server/src/app.ts.tpl +2 -0
- package/templates/minimal-app/apps/shared/src/modules/app/roles.constants.ts.tpl +17 -0
- package/templates/minimal-app/apps/webapp/src/Providers.tsx.tpl +4 -0
- package/templates/minimal-app/apps/webapp/src/Router.tsx.tpl +2 -3
- package/templates/minimal-app/apps/webapp/translations/app.json.tpl +7 -0
package/package.json
CHANGED
|
@@ -26,5 +26,9 @@
|
|
|
26
26
|
- Keep the app shell shape: `NuqsAdapter` + `BrowserRouter` + `Providers`.
|
|
27
27
|
- Compose global providers only in `apps/webapp/src/Providers.tsx`.
|
|
28
28
|
- Use `AppConfigProvider` and `AppTrpcQueryProvider` from `@m5kdev/frontend`; use `@m5kdev/web-ui` for web-only UI.
|
|
29
|
+
- Define app roles in `apps/shared/src/modules/app/roles.constants.ts` and pass `roles: APP_ROLES_CONFIG` through `AppConfigProvider` and `createBackendApp` metadata.
|
|
30
|
+
- Add role display labels in `apps/webapp/translations/app.json` using keys like `organization.role.editor` (resolved as `app:organization.role.editor`).
|
|
31
|
+
- When adding custom roles, also extend module grants (for example `*.grants.ts`) so permissions match the new role keys.
|
|
32
|
+
- For upgrading existing apps, see the docs site guide `apps/docs/docs/guides/custom-app-roles-migration.md`.
|
|
29
33
|
- Use `nuqs` for URL state, React Router for routing, HeroUI for UI primitives, and Tailwind v4 for styling.
|
|
30
34
|
- Prefer shared framework utilities from `@m5kdev/frontend` and `@m5kdev/web-ui` before adding local duplicates.
|
|
@@ -8,6 +8,7 @@ import { templates } from "{{PACKAGE_SCOPE}}/email";
|
|
|
8
8
|
import { emailResources } from "{{PACKAGE_SCOPE}}/email/resources";
|
|
9
9
|
import { APP_NAME } from "{{PACKAGE_SCOPE}}/shared/modules/app/app.constants";
|
|
10
10
|
import { AUTH_LOCALE_CONFIG } from "{{PACKAGE_SCOPE}}/shared/modules/app/locale.constants";
|
|
11
|
+
import { APP_ROLES_CONFIG } from "{{PACKAGE_SCOPE}}/shared/modules/app/roles.constants";
|
|
11
12
|
import { USER_LOCALE_HEADER } from "@m5kdev/commons/modules/auth/auth.constants";
|
|
12
13
|
import cors from "cors";
|
|
13
14
|
import express from "express";
|
|
@@ -66,6 +67,7 @@ export const builtBackendApp = createBackendApp(
|
|
|
66
67
|
api: serverUrl,
|
|
67
68
|
},
|
|
68
69
|
locales: AUTH_LOCALE_CONFIG,
|
|
70
|
+
roles: APP_ROLES_CONFIG,
|
|
69
71
|
},
|
|
70
72
|
i18n: {
|
|
71
73
|
resources: emailResources,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineAuthRoles } from "@m5kdev/commons/modules/auth/auth.roles";
|
|
2
|
+
|
|
3
|
+
export const APP_ROLES_CONFIG = defineAuthRoles({
|
|
4
|
+
user: {
|
|
5
|
+
roles: ["user", "admin"],
|
|
6
|
+
},
|
|
7
|
+
organization: {
|
|
8
|
+
roles: ["member", "admin", "owner"],
|
|
9
|
+
managerRoles: ["admin", "owner"],
|
|
10
|
+
assignableRoles: ["member", "admin", "owner"],
|
|
11
|
+
defaultRole: "member",
|
|
12
|
+
},
|
|
13
|
+
team: {
|
|
14
|
+
roles: ["owner"],
|
|
15
|
+
defaultRole: "owner",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -5,6 +5,8 @@ import { DialogProvider } from "@m5kdev/web-ui/components/DialogProvider";
|
|
|
5
5
|
import { ThemeProvider } from "@m5kdev/web-ui/components/theme-provider";
|
|
6
6
|
import { AppLoader } from "@m5kdev/web-ui/modules/app/components/AppLoader";
|
|
7
7
|
import { APP_NAME } from "{{PACKAGE_SCOPE}}/shared/modules/app/app.constants";
|
|
8
|
+
import { AUTH_LOCALE_CONFIG } from "{{PACKAGE_SCOPE}}/shared/modules/app/locale.constants";
|
|
9
|
+
import { APP_ROLES_CONFIG } from "{{PACKAGE_SCOPE}}/shared/modules/app/roles.constants";
|
|
8
10
|
import { Toaster } from "sonner";
|
|
9
11
|
import { Router } from "./Router";
|
|
10
12
|
|
|
@@ -15,6 +17,8 @@ export function Providers() {
|
|
|
15
17
|
appName: APP_NAME,
|
|
16
18
|
appUrl: import.meta.env.VITE_APP_URL,
|
|
17
19
|
serverUrl: import.meta.env.VITE_SERVER_URL,
|
|
20
|
+
locales: AUTH_LOCALE_CONFIG,
|
|
21
|
+
roles: APP_ROLES_CONFIG,
|
|
18
22
|
}}
|
|
19
23
|
>
|
|
20
24
|
<ThemeProvider defaultTheme="light" storageKey="m5kdev-theme">
|
|
@@ -80,11 +80,11 @@ export function Router() {
|
|
|
80
80
|
<Route path="posts" element={<PostsRoute />} />
|
|
81
81
|
<Route
|
|
82
82
|
path="organization/members"
|
|
83
|
-
element={<AuthOrganizationMembersRoute
|
|
83
|
+
element={<AuthOrganizationMembersRoute />}
|
|
84
84
|
/>
|
|
85
85
|
<Route
|
|
86
86
|
path="organization/manage"
|
|
87
|
-
element={<AuthOrganizationChildOrganizationsRoute
|
|
87
|
+
element={<AuthOrganizationChildOrganizationsRoute />}
|
|
88
88
|
/>
|
|
89
89
|
<Route
|
|
90
90
|
path="organization/preferences"
|
|
@@ -92,7 +92,6 @@ export function Router() {
|
|
|
92
92
|
<AuthOrganizationPreferences
|
|
93
93
|
schema={preferenceSchema}
|
|
94
94
|
controls={preferenceControls}
|
|
95
|
-
managerRoles={["admin", "owner"]}
|
|
96
95
|
/>
|
|
97
96
|
}
|
|
98
97
|
/>
|