@ramme-io/create-app 3.1.0 → 3.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/index.js +80 -4
- package/package.json +1 -4
- package/template/.env.example +6 -0
- package/template/CHANGELOG.md +68 -0
- package/template/gitignore +6 -0
- package/template/index.html +4 -2
- package/template/package.json +3 -2
- package/template/public/rocket.svg +18 -0
- package/template/src/components/AddItemsModal.tsx +0 -1
- package/template/src/components/AppFooter.tsx +2 -1
- package/template/src/components/AppHeader.tsx +2 -1
- package/template/src/components/PageTitleUpdater.tsx +8 -4
- package/template/src/components/ProtectedAppShell.tsx +10 -5
- package/template/src/components/SettingsModal.tsx +1 -1
- package/template/src/config/app.config.ts +36 -0
- package/template/src/config/app.manifest.ts +5 -4
- package/template/src/features/about/pages/AboutPage.tsx +0 -2
- package/template/src/features/config/AppConfigContext.tsx +24 -9
- package/template/src/pages/SettingsPage.tsx +0 -2
- package/template/src/templates/dashboard/DashboardLayout.tsx +2 -1
- package/template/src/tests/smoke.test.tsx +0 -1
- package/template/public/orange.png +0 -0
- package/template/src/assets/orange.png +0 -0
package/index.js
CHANGED
|
@@ -26,6 +26,21 @@ if (!projectName) {
|
|
|
26
26
|
const templatePath = path.resolve(__dirname, 'template');
|
|
27
27
|
const destinationPath = path.resolve(process.cwd(), projectName);
|
|
28
28
|
|
|
29
|
+
// What the new app calls itself, in package.json and on screen.
|
|
30
|
+
//
|
|
31
|
+
// `projectName` is a destination path — `my-app`, `./apps/my-app`, or something
|
|
32
|
+
// with a capital and a space in it. An npm name may be none of those, so the
|
|
33
|
+
// last segment is lowercased and stripped to the characters npm accepts. This
|
|
34
|
+
// is also what the tab title and the header wordmark say, which is why it is
|
|
35
|
+
// derived once here rather than twice with different rules.
|
|
36
|
+
const appSlug =
|
|
37
|
+
path
|
|
38
|
+
.basename(projectName)
|
|
39
|
+
.trim()
|
|
40
|
+
.toLowerCase()
|
|
41
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
42
|
+
.replace(/^[-_.]+|[-_.]+$/g, '') || 'app';
|
|
43
|
+
|
|
29
44
|
// THE STABILITY PACT: pinned target ranges for the public release.
|
|
30
45
|
//
|
|
31
46
|
// One shared constant used to cover all three packages, which silently broke
|
|
@@ -41,7 +56,7 @@ const destinationPath = path.resolve(process.cwd(), projectName);
|
|
|
41
56
|
// a stale pin builds fine, it just ships the wrong framework.
|
|
42
57
|
const RELEASE_VERSIONS = {
|
|
43
58
|
'@ramme-io/ui': '^4.1.0',
|
|
44
|
-
'@ramme-io/kernel': '^
|
|
59
|
+
'@ramme-io/kernel': '^7.0.0',
|
|
45
60
|
'@ramme-io/shared': '^3.1.2',
|
|
46
61
|
};
|
|
47
62
|
|
|
@@ -80,11 +95,72 @@ try {
|
|
|
80
95
|
}
|
|
81
96
|
}
|
|
82
97
|
|
|
98
|
+
// The copied template is named after the template ("ramme-starter"), which
|
|
99
|
+
// is the monorepo's workspace name and has nothing to do with the app being
|
|
100
|
+
// created. Left alone, every scaffolded app on earth shares one name.
|
|
101
|
+
pkg.name = appSlug;
|
|
102
|
+
|
|
83
103
|
fs.writeJsonSync(targetPkgPath, pkg, { spaces: 2 });
|
|
84
104
|
console.log('✅ Supply chain hardened. Workspace dependencies stripped.');
|
|
85
105
|
}
|
|
86
106
|
|
|
87
|
-
// 4.
|
|
107
|
+
// 4. IDENTITY — the app is called what the user named it.
|
|
108
|
+
//
|
|
109
|
+
// The template is branded for the monorepo it lives in: index.html carries
|
|
110
|
+
// the framework's own title, and vercel.json installs and builds from three
|
|
111
|
+
// directories up through a turbo filter naming this template's workspace.
|
|
112
|
+
// None of that is true of the app being created, and the title is visible
|
|
113
|
+
// before React has even mounted.
|
|
114
|
+
//
|
|
115
|
+
// src/config/app.config.ts is the one place the running app reads its name
|
|
116
|
+
// from, so setting it here is what makes `pnpm dev` show the right name with
|
|
117
|
+
// no .env file and no edit.
|
|
118
|
+
const identity = [
|
|
119
|
+
{
|
|
120
|
+
file: 'index.html',
|
|
121
|
+
find: /<title>[\s\S]*?<\/title>/,
|
|
122
|
+
replace: `<title>${appSlug}</title>`,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
file: 'src/config/app.config.ts',
|
|
126
|
+
find: /name: import\.meta\.env\.VITE_APP_NAME \?\? '[^']*'/,
|
|
127
|
+
replace: `name: import.meta.env.VITE_APP_NAME ?? '${appSlug}'`,
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
for (const { file, find, replace } of identity) {
|
|
132
|
+
const target = path.join(destinationPath, file);
|
|
133
|
+
if (!fs.existsSync(target)) continue;
|
|
134
|
+
|
|
135
|
+
const before = fs.readFileSync(target, 'utf8');
|
|
136
|
+
const after = before.replace(find, replace);
|
|
137
|
+
|
|
138
|
+
// Loud rather than silent. If a template edit moves one of these lines, the
|
|
139
|
+
// substitution stops matching and every app scaffolded after it is called
|
|
140
|
+
// "App Name" — which looks like a design choice rather than a bug.
|
|
141
|
+
if (after === before) {
|
|
142
|
+
console.warn(` ⚠️ Could not set the app name in ${file} — its name line has moved.`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
fs.writeFileSync(target, after);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// The monorepo's build commands cannot work in a standalone repo: there is no
|
|
149
|
+
// directory three levels up and no turbo filter to resolve. Removing them
|
|
150
|
+
// lets Vercel use the app's own `build` script. Deliberately NO
|
|
151
|
+
// ignoreCommand — see deploy-ignore.test.ts; it would ship a turborepo
|
|
152
|
+
// assumption into a repo that has no turbo.json.
|
|
153
|
+
const vercelPath = path.join(destinationPath, 'vercel.json');
|
|
154
|
+
if (fs.existsSync(vercelPath)) {
|
|
155
|
+
const vercel = fs.readJsonSync(vercelPath);
|
|
156
|
+
delete vercel.installCommand;
|
|
157
|
+
delete vercel.buildCommand;
|
|
158
|
+
fs.writeJsonSync(vercelPath, vercel, { spaces: 2 });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
console.log(` 🏷️ App name set to "${appSlug}"`);
|
|
162
|
+
|
|
163
|
+
// 5. AGENT RULES — one file, under every name an agent looks for.
|
|
88
164
|
//
|
|
89
165
|
// The monorepo does this with symlinks (.clinerules -> AGENTS.md, git mode
|
|
90
166
|
// 120000), which is drift-proof and completely useless here: npm pack DROPS
|
|
@@ -119,13 +195,13 @@ try {
|
|
|
119
195
|
console.warn(' ⚠️ AGENTS.md missing from the template — no agent rules were written.');
|
|
120
196
|
}
|
|
121
197
|
|
|
122
|
-
//
|
|
198
|
+
// 6. Handle Gitignore
|
|
123
199
|
const gitignorePath = path.join(destinationPath, 'gitignore');
|
|
124
200
|
if (fs.existsSync(gitignorePath)) {
|
|
125
201
|
fs.renameSync(gitignorePath, path.join(destinationPath, '.gitignore'));
|
|
126
202
|
}
|
|
127
203
|
|
|
128
|
-
//
|
|
204
|
+
// 7. ONBOARDING INSTRUCTIONS — Premium Unboxing Experience
|
|
129
205
|
console.log('\n╔═══════════════════════════════════════╗');
|
|
130
206
|
console.log('║ ║');
|
|
131
207
|
console.log('║ ✨ Your project is ready! ║');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramme-io/create-app",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "The official CLI to create Ramme applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,8 +22,5 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"fs-extra": "^11.2.0"
|
|
25
|
-
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
28
25
|
}
|
|
29
26
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Copy to .env and edit. Vite only exposes variables prefixed VITE_.
|
|
2
|
+
|
|
3
|
+
# What the app calls itself: tab title, header wordmark, footer, assistant.
|
|
4
|
+
# Unset falls back to the `name` in src/config/app.config.ts, which the
|
|
5
|
+
# scaffolder already set to your project name.
|
|
6
|
+
VITE_APP_NAME="App Name"
|
package/template/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# ramme-starter
|
|
2
2
|
|
|
3
|
+
## 2.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [1342f1c]
|
|
8
|
+
- @ramme-io/shared@3.3.1
|
|
9
|
+
- @ramme-io/kernel@7.3.1
|
|
10
|
+
- @ramme-io/ui@4.2.3
|
|
11
|
+
|
|
12
|
+
## 2.0.15
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [73306a0]
|
|
17
|
+
- Updated dependencies [e543c11]
|
|
18
|
+
- @ramme-io/shared@3.3.0
|
|
19
|
+
- @ramme-io/kernel@7.3.0
|
|
20
|
+
- @ramme-io/ui@4.2.2
|
|
21
|
+
|
|
22
|
+
## 2.0.14
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [94f9b84]
|
|
27
|
+
- @ramme-io/kernel@7.2.0
|
|
28
|
+
|
|
29
|
+
## 2.0.13
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [304992d]
|
|
34
|
+
- Updated dependencies [82add86]
|
|
35
|
+
- @ramme-io/shared@3.2.0
|
|
36
|
+
- @ramme-io/kernel@7.1.0
|
|
37
|
+
- @ramme-io/ui@4.2.1
|
|
38
|
+
|
|
39
|
+
## 2.0.12
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [185bca7]
|
|
44
|
+
- Updated dependencies [a153685]
|
|
45
|
+
- @ramme-io/ui@4.2.0
|
|
46
|
+
- @ramme-io/kernel@7.0.0
|
|
47
|
+
|
|
48
|
+
## 2.0.11
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [9b17f09]
|
|
53
|
+
- @ramme-io/kernel@6.0.3
|
|
54
|
+
|
|
55
|
+
## 2.0.10
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [e5b42ef]
|
|
60
|
+
- Updated dependencies [61d9ab7]
|
|
61
|
+
- @ramme-io/ui@4.1.1
|
|
62
|
+
- @ramme-io/kernel@6.0.2
|
|
63
|
+
|
|
64
|
+
## 2.0.9
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Updated dependencies [bbe9654]
|
|
69
|
+
- @ramme-io/kernel@6.0.1
|
|
70
|
+
|
|
3
71
|
## 2.0.8
|
|
4
72
|
|
|
5
73
|
### Patch Changes
|
package/template/gitignore
CHANGED
package/template/index.html
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/rocket.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
|
|
7
|
+
<!-- Replaced with the project name by `npm create @ramme-io/app <name>`.
|
|
8
|
+
Once React mounts, PageTitleUpdater owns this. -->
|
|
9
|
+
<title>App Name</title>
|
|
8
10
|
</head>
|
|
9
11
|
<body>
|
|
10
12
|
<div id="root"></div>
|
package/template/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ramme-starter",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.16",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
8
|
"dev:agent": "pnpm build && pnpm lint && pnpm test",
|
|
9
|
-
"build": "tsc && vite build",
|
|
9
|
+
"build": "tsc --noEmit -p tsconfig.app.json && vite build",
|
|
10
|
+
"typecheck": "tsc --noEmit -p tsconfig.app.json",
|
|
10
11
|
"lint": "eslint . --max-warnings 0",
|
|
11
12
|
"preview": "vite preview",
|
|
12
13
|
"test": "vitest run",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" role="img" aria-label="Rocket">
|
|
2
|
+
<!--
|
|
3
|
+
The scaffolded app's default mark. Deliberately generic: a new app should not
|
|
4
|
+
ship somebody else's logo in the browser tab.
|
|
5
|
+
|
|
6
|
+
Drawn rather than an emoji in a <text> node, because an emoji favicon renders
|
|
7
|
+
as whatever the viewer's platform font decides — different on every OS, and
|
|
8
|
+
absent where no emoji font is installed. Flat fills with a dark outline so the
|
|
9
|
+
silhouette survives being scaled to 16px on both light and dark tab bars.
|
|
10
|
+
-->
|
|
11
|
+
<g fill="none" stroke="#2a3142" stroke-width="1.6" stroke-linejoin="round" stroke-linecap="round">
|
|
12
|
+
<path d="M16 2c4 4.2 6 9 6 14v4H10v-4c0-5 2-9.8 6-14z" fill="#e9ecf4" />
|
|
13
|
+
<path d="M10 16l-4 5v4l4-3z" fill="#9aa4bd" />
|
|
14
|
+
<path d="M22 16l4 5v4l-4-3z" fill="#9aa4bd" />
|
|
15
|
+
<path d="M13 22h6l-3 7z" fill="#ff8a3d" />
|
|
16
|
+
<circle cx="16" cy="12" r="3" fill="#5b8def" />
|
|
17
|
+
</g>
|
|
18
|
+
</svg>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// src/components/AppFooter.tsx
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { APP } from '../config/app.config';
|
|
3
4
|
|
|
4
5
|
const AppFooter: React.FC = () => {
|
|
5
6
|
return (
|
|
6
7
|
<footer className="py-6 text-center text-muted-foreground">
|
|
7
|
-
<p>© {new Date().getFullYear()}
|
|
8
|
+
<p>© {new Date().getFullYear()} {APP.name}. All rights reserved.</p>
|
|
8
9
|
</footer>
|
|
9
10
|
);
|
|
10
11
|
};
|
|
@@ -17,6 +17,7 @@ import React from 'react';
|
|
|
17
17
|
import { useNavigate } from 'react-router-dom';
|
|
18
18
|
import { Icon, UserNav, ButtonItem } from '@ramme-io/ui';
|
|
19
19
|
import { useAuth, useSettingsStore } from '@ramme-io/kernel';
|
|
20
|
+
import { APP } from '../config/app.config';
|
|
20
21
|
|
|
21
22
|
interface AppHeaderProps {
|
|
22
23
|
title?: string;
|
|
@@ -78,7 +79,7 @@ const AppHeader: React.FC<AppHeaderProps> = ({
|
|
|
78
79
|
<UserNav
|
|
79
80
|
user={{
|
|
80
81
|
name: user?.name ?? 'Demo Operator',
|
|
81
|
-
email: user?.email ??
|
|
82
|
+
email: user?.email ?? APP.supportEmail,
|
|
82
83
|
}}
|
|
83
84
|
trigger={
|
|
84
85
|
<div className="flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted/50 transition-colors">
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import React, { useEffect } from 'react';
|
|
8
8
|
import { useLocation } from 'react-router-dom';
|
|
9
9
|
import { useSitemap, type SitemapEntry } from '@ramme-io/kernel'; // Import our context hook
|
|
10
|
+
import { useAppConfig } from '../features/config/AppConfigContext';
|
|
10
11
|
|
|
11
12
|
// Helper function to recursively find a route by path
|
|
12
13
|
const findRouteByPath = (
|
|
@@ -39,6 +40,9 @@ const findRouteByPath = (
|
|
|
39
40
|
const PageTitleUpdater: React.FC = () => {
|
|
40
41
|
const location = useLocation();
|
|
41
42
|
const sitemap = useSitemap(); // Get the sitemap from the current layout's context
|
|
43
|
+
// The app's own name — seeded from src/config/app.config.ts, and re-read here
|
|
44
|
+
// so renaming the app at runtime retitles the tab without a reload.
|
|
45
|
+
const { appName } = useAppConfig();
|
|
42
46
|
|
|
43
47
|
useEffect(() => {
|
|
44
48
|
// Determine the base path prefix based on the current top-level route
|
|
@@ -54,13 +58,13 @@ const PageTitleUpdater: React.FC = () => {
|
|
|
54
58
|
const currentRoute = findRouteByPath(sitemap, location.pathname, baseRoutePrefix);
|
|
55
59
|
|
|
56
60
|
if (currentRoute) {
|
|
57
|
-
document.title =
|
|
61
|
+
document.title = `${appName} — ${currentRoute.title}`;
|
|
58
62
|
} else {
|
|
59
63
|
// Fallback title if no route is matched (e.g., for 404 or base layout path)
|
|
60
|
-
document.title =
|
|
64
|
+
document.title = appName;
|
|
61
65
|
}
|
|
62
|
-
// Rerun effect whenever the pathname
|
|
63
|
-
}, [location.pathname, sitemap]);
|
|
66
|
+
// Rerun effect whenever the pathname, the sitemap context or the name changes
|
|
67
|
+
}, [location.pathname, sitemap, appName]);
|
|
64
68
|
|
|
65
69
|
return null; // This component doesn't render anything itself
|
|
66
70
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Outlet } from 'react-router-dom';
|
|
2
|
-
import { ChatFAB, AppShell
|
|
2
|
+
import { ChatFAB, AppShell } from '@ramme-io/ui';
|
|
3
3
|
import {
|
|
4
4
|
useWorkflowEngine,
|
|
5
5
|
useSettingsStore,
|
|
@@ -9,10 +9,15 @@ import {
|
|
|
9
9
|
RammeInspector,
|
|
10
10
|
AIChatPanel
|
|
11
11
|
} from '@ramme-io/kernel';
|
|
12
|
+
import { APP } from '../config/app.config';
|
|
12
13
|
|
|
14
|
+
// The assistant introduces itself as this app, not as the framework underneath
|
|
15
|
+
// it. Rewrite this for what your app actually does — the more specific it is,
|
|
16
|
+
// the more useful the answers.
|
|
13
17
|
const SYSTEM_PROMPT = `
|
|
14
|
-
You are the
|
|
15
|
-
|
|
18
|
+
You are the assistant embedded in ${APP.name}.
|
|
19
|
+
Help the user operate this app: explain what a screen shows, and answer
|
|
20
|
+
questions about the data in front of them.
|
|
16
21
|
`.trim();
|
|
17
22
|
|
|
18
23
|
export const ProtectedAppShell = () => {
|
|
@@ -34,7 +39,7 @@ export const ProtectedAppShell = () => {
|
|
|
34
39
|
const { mode, toggle } = useSpatialStore();
|
|
35
40
|
|
|
36
41
|
return (
|
|
37
|
-
<
|
|
42
|
+
<AppShell
|
|
38
43
|
isInspectorOpen={isInspectorOpen}
|
|
39
44
|
setInspectorOpen={setInspectorOpen}
|
|
40
45
|
inspectorWidth={inspectorWidth}
|
|
@@ -65,6 +70,6 @@ export const ProtectedAppShell = () => {
|
|
|
65
70
|
isOpen={isSettingsOpen}
|
|
66
71
|
onClose={() => toggleSettings(false)}
|
|
67
72
|
/>
|
|
68
|
-
</
|
|
73
|
+
</AppShell>
|
|
69
74
|
);
|
|
70
75
|
};
|
|
@@ -121,7 +121,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, o
|
|
|
121
121
|
value={keyInput}
|
|
122
122
|
onChange={(e) => { setKeyInput(e.target.value); setError(''); }}
|
|
123
123
|
placeholder="AIzaSy..."
|
|
124
|
-
className="w-full px-3 py-2.5 rounded-md border border-border bg-background text-foreground
|
|
124
|
+
className="w-full px-3 py-2.5 rounded-md border border-border bg-background text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary transition-colors"
|
|
125
125
|
onKeyDown={(e) => e.key === 'Enter' && handleSave()}
|
|
126
126
|
autoFocus
|
|
127
127
|
/>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who this app says it is.
|
|
3
|
+
*
|
|
4
|
+
* One constant, read by every piece of chrome: the header wordmark, the footer,
|
|
5
|
+
* the browser tab, the manifest meta and the assistant's persona. Renaming the
|
|
6
|
+
* app is this file, not a search across nine components.
|
|
7
|
+
*
|
|
8
|
+
* `npm create @ramme-io/app <name>` rewrites `name` below to the project name,
|
|
9
|
+
* so a freshly scaffolded app is already itself. `VITE_APP_NAME` overrides it at
|
|
10
|
+
* build time, which is what a deploy uses when the same source ships under more
|
|
11
|
+
* than one name.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately not a hook and not React state: a build-time constant cannot
|
|
14
|
+
* flicker on first paint the way a value read from localStorage can. The
|
|
15
|
+
* runtime-editable name lives in AppConfigContext and seeds from here.
|
|
16
|
+
*/
|
|
17
|
+
export const APP = {
|
|
18
|
+
/** Wordmark, tab title, footer, and the name the assistant calls itself. */
|
|
19
|
+
name: import.meta.env.VITE_APP_NAME ?? 'App Name',
|
|
20
|
+
|
|
21
|
+
/** One line under the name where a layout offers room for it. */
|
|
22
|
+
tagline: 'Your tagline goes here',
|
|
23
|
+
|
|
24
|
+
/** Fallback shown in the user menu before a real session exists. */
|
|
25
|
+
supportEmail: 'operator@example.com',
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Prefix for this app's localStorage keys.
|
|
29
|
+
*
|
|
30
|
+
* Unscoped keys ('app_name') collide between two apps served from the same
|
|
31
|
+
* origin — a real failure mode on localhost, where every dev server is
|
|
32
|
+
* http://localhost. Change this and the app forgets its saved preferences,
|
|
33
|
+
* which is the correct trade for not reading another app's.
|
|
34
|
+
*/
|
|
35
|
+
storageNamespace: 'app',
|
|
36
|
+
} as const;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AppSpecification } from '@ramme-io/kernel';
|
|
2
|
+
import { APP } from './app.config';
|
|
2
3
|
|
|
3
4
|
export const appManifest: AppSpecification = {
|
|
4
5
|
meta: {
|
|
5
|
-
name:
|
|
6
|
-
version: "
|
|
7
|
-
description: "
|
|
8
|
-
author: "
|
|
6
|
+
name: APP.name,
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
description: "A starter app — KPI dashboard, CRUD, charts and onboarding, ready to rename.",
|
|
9
|
+
author: "Your Team",
|
|
9
10
|
},
|
|
10
11
|
config: {
|
|
11
12
|
theme: 'dark',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, useContext, useState, useEffect, ReactNode } from 'react';
|
|
2
|
+
import { APP } from '../../config/app.config';
|
|
2
3
|
|
|
3
4
|
interface AppConfigContextType {
|
|
4
5
|
appName: string;
|
|
@@ -9,24 +10,38 @@ interface AppConfigContextType {
|
|
|
9
10
|
|
|
10
11
|
const AppConfigContext = createContext<AppConfigContextType | undefined>(undefined);
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Keys are namespaced per app.
|
|
15
|
+
*
|
|
16
|
+
* Two apps served from http://localhost on different ports share one origin and
|
|
17
|
+
* therefore one localStorage, so a bare 'app_name' means the second app you run
|
|
18
|
+
* inherits the first one's settings.
|
|
19
|
+
*/
|
|
20
|
+
const key = (name: string) => `${APP.storageNamespace}:${name}`;
|
|
21
|
+
|
|
12
22
|
export const AppConfigProvider = ({ children }: { children: ReactNode }) => {
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
// Seeded from the build-time constant, then editable at runtime. A saved name
|
|
24
|
+
// wins, because someone typed it.
|
|
25
|
+
const [appName, setAppName] = useState(() => localStorage.getItem(key('app_name')) || APP.name);
|
|
26
|
+
|
|
15
27
|
const [enableCRT, setEnableCRT] = useState(() => {
|
|
16
|
-
const stored = localStorage.getItem('
|
|
28
|
+
const stored = localStorage.getItem(key('enable_crt'));
|
|
17
29
|
// Default to false for clean marketing site clarity
|
|
18
|
-
return stored !== null ? JSON.parse(stored) : false;
|
|
30
|
+
return stored !== null ? JSON.parse(stored) : false;
|
|
19
31
|
});
|
|
20
32
|
|
|
33
|
+
// Note: this does NOT write document.title. PageTitleUpdater owns the tab,
|
|
34
|
+
// because it is the only one that knows the current route — when both wrote
|
|
35
|
+
// it, whichever effect ran last won and the title flickered between
|
|
36
|
+
// "<app>" and "<app> — <page>".
|
|
21
37
|
useEffect(() => {
|
|
22
|
-
localStorage.setItem('app_name', appName);
|
|
23
|
-
document.title = appName;
|
|
38
|
+
localStorage.setItem(key('app_name'), appName);
|
|
24
39
|
}, [appName]);
|
|
25
40
|
|
|
26
41
|
// Sync state to LocalStorage and DOM
|
|
27
42
|
useEffect(() => {
|
|
28
|
-
localStorage.setItem('
|
|
29
|
-
|
|
43
|
+
localStorage.setItem(key('enable_crt'), JSON.stringify(enableCRT));
|
|
44
|
+
|
|
30
45
|
if (enableCRT) {
|
|
31
46
|
document.body.classList.add('crt-mode');
|
|
32
47
|
} else {
|
|
@@ -9,6 +9,7 @@ import { sitemap } from '../../config/sitemap';
|
|
|
9
9
|
import PageTitleUpdater from '../../components/PageTitleUpdater';
|
|
10
10
|
import AppChromeHost from '../../components/layout/AppChromeHost';
|
|
11
11
|
import AppHeader from '../../components/AppHeader';
|
|
12
|
+
import { APP } from '../../config/app.config';
|
|
12
13
|
|
|
13
14
|
const DashboardLayout: React.FC = () => {
|
|
14
15
|
const navigate = useNavigate();
|
|
@@ -73,7 +74,7 @@ const DashboardLayout: React.FC = () => {
|
|
|
73
74
|
<AppChromeHost
|
|
74
75
|
header={
|
|
75
76
|
<AppHeader
|
|
76
|
-
title=
|
|
77
|
+
title={APP.name}
|
|
77
78
|
onMobileMenuClick={() => setIsMobileMenuOpen(true)}
|
|
78
79
|
/>
|
|
79
80
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
|
-
import React from 'react';
|
|
5
4
|
import { BrowserRouter } from 'react-router-dom';
|
|
6
5
|
import { ManifestProvider, AuthProvider, MqttProvider } from '@ramme-io/kernel';
|
|
7
6
|
import { ThemeProvider, ToastProvider } from '@ramme-io/ui';
|
|
Binary file
|
|
Binary file
|