@ramme-io/create-app 1.2.6 β†’ 1.2.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramme-io/create-app",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-ramme-app": "./index.js"
@@ -5,7 +5,6 @@ import { ThemeProvider } from '@ramme-io/ui';
5
5
  import { AuthProvider } from './features/auth/AuthContext';
6
6
  import { MqttProvider } from './engine/runtime/MqttContext';
7
7
 
8
-
9
8
  // --- 1. IMPORT AUTH CLUSTER ---
10
9
  import { AuthLayout } from './features/auth/pages/AuthLayout';
11
10
  import LoginPage from './features/auth/pages/LoginPage';
@@ -30,7 +29,6 @@ import { initializeDataLake } from './engine/runtime/data-seeder';
30
29
  import ScrollToTop from './components/ScrollToTop';
31
30
  import HashLinkScroll from './components/HashLinkScroll';
32
31
 
33
-
34
32
  function App() {
35
33
 
36
34
  // Trigger data seeding on mount
@@ -41,7 +39,6 @@ function App() {
41
39
  const liveDashboardRoutes = useDynamicSitemap(dashboardSitemap);
42
40
 
43
41
  console.log("πŸ—ΊοΈ ROUTER MAP:", liveDashboardRoutes.map(r => ({ path: r.path, id: r.id })));
44
-
45
42
 
46
43
  return (
47
44
  <ThemeProvider>
@@ -61,6 +58,9 @@ function App() {
61
58
 
62
59
  {/* Fallback for legacy /login access */}
63
60
  <Route path="/login" element={<Navigate to="/auth/login" replace />} />
61
+
62
+ {/* βœ… FIX: Redirect legacy /signup to the new location */}
63
+ <Route path="/signup" element={<Navigate to="/auth/signup" replace />} />
64
64
 
65
65
  {/* --- PROTECTED APP ROUTES --- */}
66
66
  <Route element={<ProtectedRoute />}>
@@ -68,7 +68,7 @@ function App() {
68
68
 
69
69
  {/* Dashboard Template */}
70
70
  <Route path="/dashboard/*" element={<DashboardLayout />}>
71
- <Route index element={<Navigate to="welcome" replace />} />
71
+ <Route index element={<Navigate to="welcome" replace />} />
72
72
  {generateRoutes(liveDashboardRoutes)}
73
73
  </Route>
74
74
 
@@ -1,5 +1,4 @@
1
- // βœ… Match the export from your new mockData.ts
2
- import { DATA_REGISTRY } from '../../data/mockData';
1
+ import { DATA_REGISTRY } from '../../data/mockData';
3
2
 
4
3
  /**
5
4
  * @file data-seeder.ts
@@ -10,16 +9,15 @@ import { DATA_REGISTRY } from '../../data/mockData';
10
9
  * from `mockData.ts` into the browser's storage.
11
10
  */
12
11
 
13
- // πŸ”’ SHARED CONSTANT: Ensure everyone uses the same key format
14
- const DB_PREFIX = 'ramme_mock_';
12
+ // πŸ”’ CRITICAL FIX: Changed from 'ramme_mock_' to 'ramme_db_' to match AuthContext
13
+ const DB_PREFIX = 'ramme_db_';
15
14
 
16
15
  export const initializeDataLake = () => {
17
16
  if (typeof window === 'undefined') return;
18
17
 
19
18
  console.groupCollapsed('🌊 [Data Lake] Initialization');
20
-
21
19
  Object.entries(DATA_REGISTRY).forEach(([key, seedData]) => {
22
- // βœ… FIX: Use the prefix so getMockData() can find it
20
+ // This now generates 'ramme_db_users', matching AuthContext
23
21
  const storageKey = `${DB_PREFIX}${key}`;
24
22
  const existing = localStorage.getItem(storageKey);
25
23
 
@@ -30,7 +28,6 @@ export const initializeDataLake = () => {
30
28
  console.log(`βœ… Collection exists: ${key}`);
31
29
  }
32
30
  });
33
-
34
31
  console.groupEnd();
35
32
  };
36
33
 
@@ -1,6 +1,9 @@
1
1
  import React, { createContext, useContext, useState, useEffect } from 'react';
2
2
  // Import the User type from your mock data to ensure shape consistency
3
- import type { User } from '../../data/mockData';
3
+ import type { User } from '../../data/mockData';
4
+ // βœ… IMPORT SEEDER AND DATA (Required for Self-Healing)
5
+ import { initializeDataLake } from '../../engine/runtime/data-seeder';
6
+ import { SEED_USERS } from '../../data/mockData';
4
7
 
5
8
  /**
6
9
  * @file AuthContext.tsx
@@ -12,9 +15,9 @@ import type { User } from '../../data/mockData';
12
15
  * 1. **Session Persistence:** Checks localStorage on boot.
13
16
  * 2. **Data Lake Connection:** Reads from 'ramme_db_users' to validate real accounts.
14
17
  * 3. **Simulation:** Adds artificial latency to test loading states.
18
+ * 4. **Self-Healing:** Automatically re-seeds data if the database is found empty during login.
15
19
  */
16
20
 
17
- // βœ… CRITICAL FIX: Match the key used by useCrudLocalStorage and data-seeder
18
21
  const USER_DB_KEY = 'ramme_db_users';
19
22
  const SESSION_KEY = 'ramme_session';
20
23
 
@@ -49,8 +52,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
49
52
  const login = async (email: string, password: string) => {
50
53
  setIsLoading(true);
51
54
 
52
- // βœ… FIX: We now use the 'password' variable to satisfy TypeScript (ts(6133))
53
- // This also adds a layer of realism to the mock validation.
55
+ // 1. Validation
54
56
  if (!password || password.length < 3) {
55
57
  setIsLoading(false);
56
58
  throw new Error("Password must be at least 3 characters");
@@ -61,19 +63,20 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
61
63
  // Simulate API Delay
62
64
  await new Promise(resolve => setTimeout(resolve, 600));
63
65
 
64
- // βœ… READ FROM THE CORRECT DATA LAKE
65
- const storedUsers = localStorage.getItem(USER_DB_KEY);
66
+ // 2. READ DATA LAKE
67
+ let storedUsers = localStorage.getItem(USER_DB_KEY);
66
68
 
67
- // Debugging: See what is actually in storage
68
- if (!storedUsers) {
69
- console.warn(`⚠️ Data Lake '${USER_DB_KEY}' is empty! Did you run the seeder or signup?`);
70
- } else {
71
- // Optional: Log count for debugging (remove in production)
72
- // console.log(`βœ… Data Lake found. Users in DB:`, JSON.parse(storedUsers).length);
69
+ // πŸ›‘οΈ SELF-HEALING LOGIC: If DB is empty/missing, re-seed it NOW.
70
+ // This fixes the "User not found" error on fresh installs.
71
+ if (!storedUsers || JSON.parse(storedUsers).length === 0) {
72
+ console.warn("⚠️ Data Lake empty during login. Triggering emergency re-seed...");
73
+ initializeDataLake(); // Force the seed
74
+ storedUsers = localStorage.getItem(USER_DB_KEY); // Read it again immediately
73
75
  }
74
76
 
75
77
  const users: User[] = storedUsers ? JSON.parse(storedUsers) : [];
76
78
 
79
+ // 3. Authenticate
77
80
  // Case-insensitive email check
78
81
  const foundUser = users.find(u => u.email.toLowerCase() === email.toLowerCase());
79
82
 
@@ -83,6 +86,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
83
86
  localStorage.setItem(SESSION_KEY, JSON.stringify(foundUser));
84
87
  setIsLoading(false);
85
88
  } else {
89
+ // Debugging help: List available users if login fails
86
90
  console.error("❌ User NOT found. Available emails:", users.map(u => u.email));
87
91
  setIsLoading(false);
88
92
  throw new Error("Invalid email or password");
@@ -34,11 +34,7 @@ const LoginPage: React.FC = () => {
34
34
  return (
35
35
  <div className="flex min-h-screen items-center justify-center bg-background p-4 transition-colors duration-300">
36
36
 
37
- {/* 2. REPLACED <Card> with a native <div>
38
- - Removes conflicting library styles (border-border vs border-t-primary).
39
- - Adds 'sm:w-[400px]' for better mobile responsiveness.
40
- - Adds 'bg-card' explicitly for theme support.
41
- */}
37
+ {/* 2. REPLACED <Card> with a native <div> */}
42
38
  <div className="w-full sm:w-[400px] p-8 rounded-xl shadow-2xl border-t-4 border-t-primary bg-card ring-1 ring-black/5 dark:ring-white/10">
43
39
 
44
40
  {/* Header */}
@@ -68,7 +64,6 @@ const LoginPage: React.FC = () => {
68
64
  autoComplete="email"
69
65
  value={formData.email}
70
66
  onChange={handleChange}
71
- // Explicit background to prevent transparency issues
72
67
  className="bg-background"
73
68
  />
74
69
 
@@ -94,7 +89,8 @@ const LoginPage: React.FC = () => {
94
89
  {/* Footer */}
95
90
  <div className="mt-8 pt-6 border-t border-border text-center text-sm">
96
91
  <span className="text-muted-foreground">Don't have an account? </span>
97
- <Link to="/signup" className="font-semibold text-primary hover:text-primary/80 transition-colors">
92
+ [cite_start]{/* βœ… CRITICAL FIX: Updated path to /auth/signup [cite: 1937] */}
93
+ <Link to="/auth/signup" className="font-semibold text-primary hover:text-primary/80 transition-colors">
98
94
  Create one
99
95
  </Link>
100
96
  </div>