@lastbrain/app 0.1.45 → 0.1.47

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.
@@ -37,7 +37,7 @@ export async function addModule(moduleName: string, targetDir: string) {
37
37
  const moduleMeta = AVAILABLE_MODULES.find((m) => m.name === moduleName);
38
38
  if (!moduleMeta) {
39
39
  console.error(
40
- chalk.red(`❌ Module "${moduleName}" non trouvé. Modules disponibles:`),
40
+ chalk.red(`❌ Module "${moduleName}" non trouvé. Modules disponibles:`)
41
41
  );
42
42
  AVAILABLE_MODULES.forEach((m) => {
43
43
  console.log(chalk.gray(` - ${m.emoji} ${m.name}: ${m.description}`));
@@ -99,8 +99,8 @@ export async function addModule(moduleName: string, targetDir: string) {
99
99
  if (!fs.existsSync(path.join(workspaceRoot, "pnpm-workspace.yaml"))) {
100
100
  console.log(
101
101
  chalk.gray(
102
- " ℹ️ Impossible de localiser la racine du monorepo, build ignoré",
103
- ),
102
+ " ℹ️ Impossible de localiser la racine du monorepo, build ignoré"
103
+ )
104
104
  );
105
105
  } else {
106
106
  execSync(`pnpm --filter ${module.package} build`, {
@@ -113,7 +113,7 @@ export async function addModule(moduleName: string, targetDir: string) {
113
113
  console.log(
114
114
  chalk.yellow(" ⚠️ Build du module échoué, essayez: pnpm --filter"),
115
115
  module.package,
116
- "build",
116
+ "build"
117
117
  );
118
118
  }
119
119
 
@@ -126,12 +126,12 @@ export async function addModule(moduleName: string, targetDir: string) {
126
126
  const modulePackagePath = path.join(
127
127
  targetDir,
128
128
  "node_modules",
129
- ...module.package.split("/"),
129
+ ...module.package.split("/")
130
130
  );
131
131
 
132
132
  const moduleMigrationsDir = path.join(
133
133
  modulePackagePath,
134
- module.migrationsPath || "supabase/migrations",
134
+ module.migrationsPath || "supabase/migrations"
135
135
  );
136
136
 
137
137
  const projectMigrationsDir = path.join(targetDir, "supabase", "migrations");
@@ -153,19 +153,19 @@ export async function addModule(moduleName: string, targetDir: string) {
153
153
 
154
154
  // 6. Demander comment appliquer les migrations
155
155
  console.log(
156
- chalk.yellow("\n🗄️ Application des migrations à la base de données\n"),
156
+ chalk.yellow("\n🗄️ Application des migrations à la base de données\n")
157
157
  );
158
158
 
159
159
  console.log("Choisissez une option:");
160
160
  console.log(
161
161
  chalk.cyan(
162
- " 1) 🔄 Reset complet (supabase db reset) - Recommandé en dev",
163
- ),
162
+ " 1) 🔄 Reset complet (supabase db reset) - Recommandé en dev"
163
+ )
164
164
  );
165
165
  console.log(
166
166
  chalk.cyan(
167
- " 2) ⬆️ Push uniquement les nouvelles migrations (supabase migration up)",
168
- ),
167
+ " 2) ⬆️ Push uniquement les nouvelles migrations (supabase migration up)"
168
+ )
169
169
  );
170
170
  console.log(chalk.cyan(" 3) ⏭️ Ignorer pour l'instant"));
171
171
  console.log("");
@@ -202,7 +202,7 @@ export async function addModule(moduleName: string, targetDir: string) {
202
202
  }
203
203
  } else if (migrationAction === "push") {
204
204
  console.log(
205
- chalk.yellow("\n⬆️ Application des nouvelles migrations..."),
205
+ chalk.yellow("\n⬆️ Application des nouvelles migrations...")
206
206
  );
207
207
 
208
208
  // Appliquer directement avec psql au lieu de supabase migration up
@@ -215,7 +215,7 @@ export async function addModule(moduleName: string, targetDir: string) {
215
215
 
216
216
  if (migrationFiles.length === 0) {
217
217
  console.log(
218
- chalk.yellow("⚠️ Aucune nouvelle migration à appliquer"),
218
+ chalk.yellow("⚠️ Aucune nouvelle migration à appliquer")
219
219
  );
220
220
  } else {
221
221
  try {
@@ -234,25 +234,25 @@ export async function addModule(moduleName: string, targetDir: string) {
234
234
 
235
235
  console.log(
236
236
  chalk.green(
237
- `✓ ${migrationFiles.length} migration(s) appliquée(s)`,
238
- ),
237
+ `✓ ${migrationFiles.length} migration(s) appliquée(s)`
238
+ )
239
239
  );
240
240
  } catch (error: any) {
241
241
  console.error(
242
- chalk.red("❌ Erreur lors de l'application des migrations"),
242
+ chalk.red("❌ Erreur lors de l'application des migrations")
243
243
  );
244
244
  console.log(
245
245
  chalk.gray(
246
- "\nVous pouvez essayer manuellement:\n supabase db reset\n",
247
- ),
246
+ "\nVous pouvez essayer manuellement:\n supabase db reset\n"
247
+ )
248
248
  );
249
249
  }
250
250
  }
251
251
  } else {
252
252
  console.log(
253
253
  chalk.gray(
254
- "\n⚠️ N'oubliez pas d'appliquer les migrations avec:\n supabase db reset ou supabase migration up\n",
255
- ),
254
+ "\n⚠️ N'oubliez pas d'appliquer les migrations avec:\n supabase db reset ou supabase migration up\n"
255
+ )
256
256
  );
257
257
  }
258
258
  } else {
@@ -280,7 +280,7 @@ export async function addModule(moduleName: string, targetDir: string) {
280
280
  // Initialiser tous les modules disponibles s'ils n'existent pas
281
281
  for (const availableModule of AVAILABLE_MODULES) {
282
282
  const exists = modulesConfig.modules.find(
283
- (m) => m.package === availableModule.package,
283
+ (m) => m.package === availableModule.package
284
284
  );
285
285
  if (!exists) {
286
286
  modulesConfig.modules.push({
@@ -292,7 +292,7 @@ export async function addModule(moduleName: string, targetDir: string) {
292
292
  }
293
293
 
294
294
  const existingModuleIndex = modulesConfig.modules.findIndex(
295
- (m) => m.package === module.package,
295
+ (m) => m.package === module.package
296
296
  );
297
297
 
298
298
  const migrationsList = copiedMigrationFiles;
@@ -314,7 +314,7 @@ export async function addModule(moduleName: string, targetDir: string) {
314
314
  await fs.writeJson(modulesConfigPath, modulesConfig, { spaces: 2 });
315
315
 
316
316
  console.log(
317
- chalk.green(`\n✅ Module ${module.displayName} ajouté avec succès!\n`),
317
+ chalk.green(`\n✅ Module ${module.displayName} ajouté avec succès!\n`)
318
318
  );
319
319
 
320
320
  // 7. Générer automatiquement les routes du module
@@ -326,12 +326,12 @@ export async function addModule(moduleName: string, targetDir: string) {
326
326
  console.error(chalk.red("❌ Erreur lors de la génération des routes"));
327
327
  console.error(
328
328
  chalk.gray(
329
- "Vous pouvez les générer manuellement avec: cd apps/<votre-app> && pnpm run build:modules",
330
- ),
329
+ "Vous pouvez les générer manuellement avec: cd apps/<votre-app> && pnpm run build:modules"
330
+ )
331
331
  );
332
332
  }
333
333
 
334
334
  console.log(
335
- chalk.gray("\nLe serveur de développement redémarrera automatiquement.\n"),
335
+ chalk.gray("\nLe serveur de développement redémarrera automatiquement.\n")
336
336
  );
337
337
  }
@@ -62,7 +62,7 @@ async function loadModuleConfigs(): Promise<ModuleBuildConfig[]> {
62
62
  try {
63
63
  // Résoudre le chemin du module depuis l'application
64
64
  const modulePath = projectRequire.resolve(
65
- `${packageName}/${configName}`,
65
+ `${packageName}/${configName}`
66
66
  );
67
67
  // Convertir en URL file:// pour l'import dynamique
68
68
  const moduleUrl = `file://${modulePath}`;
@@ -197,7 +197,7 @@ function buildPage(moduleConfig: ModuleBuildConfig, page: ModulePageConfig) {
197
197
  isDebugMode
198
198
  ) {
199
199
  console.log(
200
- `🏠 Auth module in auth section, no prefix needed: ${page.path}`,
200
+ `🏠 Auth module in auth section, no prefix needed: ${page.path}`
201
201
  );
202
202
  }
203
203
 
@@ -218,7 +218,7 @@ function buildPage(moduleConfig: ModuleBuildConfig, page: ModulePageConfig) {
218
218
 
219
219
  // Vérifier si la route a des paramètres dynamiques (segments avec [])
220
220
  const hasDynamicParams = segments.some(
221
- (seg) => seg.startsWith("[") && seg.endsWith("]"),
221
+ (seg) => seg.startsWith("[") && seg.endsWith("]")
222
222
  );
223
223
 
224
224
  // Pour les pages publiques (signin, signup, etc.), utiliser dynamic import sans SSR
@@ -341,7 +341,7 @@ function generateMenuConfig(moduleConfigs: ModuleBuildConfig[]) {
341
341
  ...moduleConfig.menu.public.map((item) => ({
342
342
  ...item,
343
343
  moduleName: moduleConfig.moduleName,
344
- })),
344
+ }))
345
345
  );
346
346
  }
347
347
  if (moduleConfig.menu.auth) {
@@ -349,7 +349,7 @@ function generateMenuConfig(moduleConfigs: ModuleBuildConfig[]) {
349
349
  ...moduleConfig.menu.auth.map((item) => ({
350
350
  ...item,
351
351
  moduleName: moduleConfig.moduleName,
352
- })),
352
+ }))
353
353
  );
354
354
  }
355
355
  if (moduleConfig.menu.admin) {
@@ -357,7 +357,7 @@ function generateMenuConfig(moduleConfigs: ModuleBuildConfig[]) {
357
357
  ...moduleConfig.menu.admin.map((item) => ({
358
358
  ...item,
359
359
  moduleName: moduleConfig.moduleName,
360
- })),
360
+ }))
361
361
  );
362
362
  }
363
363
  if (moduleConfig.menu.account) {
@@ -365,7 +365,7 @@ function generateMenuConfig(moduleConfigs: ModuleBuildConfig[]) {
365
365
  ...moduleConfig.menu.account.map((item) => ({
366
366
  ...item,
367
367
  moduleName: moduleConfig.moduleName,
368
- })),
368
+ }))
369
369
  );
370
370
  }
371
371
  }
@@ -394,7 +394,7 @@ function generateMenuConfig(moduleConfigs: ModuleBuildConfig[]) {
394
394
  if (menu.componentExport && menu.moduleName) {
395
395
  const componentName = `MenuComponent${index}`;
396
396
  componentImports.push(
397
- `const ${componentName} = dynamic(() => import("${menu.moduleName}").then(mod => ({ default: mod.${menu.componentExport} })), { ssr: false });`,
397
+ `const ${componentName} = dynamic(() => import("${menu.moduleName}").then(mod => ({ default: mod.${menu.componentExport} })), { ssr: false });`
398
398
  );
399
399
  // Ajouter une référence au composant
400
400
  (menu as any).__componentRef = componentName;
@@ -467,7 +467,7 @@ function copyModuleMigrations(moduleConfigs: ModuleBuildConfig[]) {
467
467
  const supabaseMigrationsDir = path.join(
468
468
  projectRoot,
469
469
  "supabase",
470
- "migrations",
470
+ "migrations"
471
471
  );
472
472
 
473
473
  // S'assurer que le dossier migrations existe
@@ -502,7 +502,7 @@ function copyModuleMigrations(moduleConfigs: ModuleBuildConfig[]) {
502
502
  "..",
503
503
  "..",
504
504
  "packages",
505
- moduleName.replace("@lastbrain/", ""),
505
+ moduleName.replace("@lastbrain/", "")
506
506
  ),
507
507
  ];
508
508
 
@@ -522,7 +522,7 @@ function copyModuleMigrations(moduleConfigs: ModuleBuildConfig[]) {
522
522
  const moduleMigrationsDir = path.join(
523
523
  moduleBasePath,
524
524
  "supabase",
525
- "migrations",
525
+ "migrations"
526
526
  );
527
527
 
528
528
  if (fs.existsSync(moduleMigrationsDir)) {
@@ -546,7 +546,7 @@ function copyModuleMigrations(moduleConfigs: ModuleBuildConfig[]) {
546
546
  // Mettre à jour modules.json avec les migrations
547
547
  if (copiedMigrations.length > 0) {
548
548
  const moduleIndex = modulesConfig.modules.findIndex(
549
- (m) => m.package === moduleName,
549
+ (m) => m.package === moduleName
550
550
  );
551
551
 
552
552
  if (moduleIndex >= 0) {
@@ -561,7 +561,7 @@ function copyModuleMigrations(moduleConfigs: ModuleBuildConfig[]) {
561
561
  } catch (error) {
562
562
  console.warn(
563
563
  `⚠️ Could not copy migrations from ${moduleConfig.moduleName}:`,
564
- error,
564
+ error
565
565
  );
566
566
  }
567
567
  });
@@ -612,7 +612,7 @@ function generateDocsPage(moduleConfigs: ModuleBuildConfig[]) {
612
612
 
613
613
  // Trouver la config du module pour obtenir la description
614
614
  const moduleConfig = moduleConfigs.find(
615
- (mc) => mc.moduleName === moduleName,
615
+ (mc) => mc.moduleName === moduleName
616
616
  );
617
617
  const description = moduleConfig
618
618
  ? getModuleDescription(moduleConfig)
@@ -662,7 +662,7 @@ ${moduleConfigurations.join(",\n")}
662
662
 
663
663
  function buildGroupedApi(
664
664
  apis: Array<{ moduleConfig: ModuleBuildConfig; api: ModuleApiConfig }>,
665
- routePath: string,
665
+ routePath: string
666
666
  ) {
667
667
  const segments = routePath.replace(/^\/+/, "").split("/").filter(Boolean);
668
668
  const sanitizedSegments =
@@ -743,7 +743,7 @@ function cleanGeneratedFiles() {
743
743
  (protectedPath) =>
744
744
  (protectedPath.endsWith("/") ||
745
745
  ["lib", "config", "api/storage"].includes(protectedPath)) &&
746
- relativePath.startsWith(protectedPath),
746
+ relativePath.startsWith(protectedPath)
747
747
  );
748
748
  };
749
749
 
@@ -926,7 +926,7 @@ export default function AdminLayout({
926
926
  fs.writeFileSync(adminLayoutPath, adminLayoutContent, "utf-8");
927
927
  if (isDebugMode) {
928
928
  console.log(
929
- `✅ Generated admin layout with sidebar: ${adminLayoutPath}`,
929
+ `✅ Generated admin layout with sidebar: ${adminLayoutPath}`
930
930
  );
931
931
  }
932
932
  } catch (error) {
@@ -987,7 +987,7 @@ export default realtimeConfig;
987
987
  // Afficher un résumé
988
988
  realtimeConfigs.forEach((module) => {
989
989
  console.log(
990
- ` - ${module.moduleId}: ${module.tables.length} table(s)`,
990
+ ` - ${module.moduleId}: ${module.tables.length} table(s)`
991
991
  );
992
992
  module.tables.forEach((table) => {
993
993
  console.log(` • ${table.schema}.${table.table} (${table.event})`);
@@ -1008,7 +1008,7 @@ async function generateUserTabsConfig(moduleConfigs: ModuleBuildConfig[]) {
1008
1008
  config.userTabs!.map((tab) => ({
1009
1009
  ...tab,
1010
1010
  moduleName: config.moduleName,
1011
- })),
1011
+ }))
1012
1012
  )
1013
1013
  .sort((a, b) => (a.order || 0) - (b.order || 0));
1014
1014
 
@@ -1021,7 +1021,7 @@ async function generateUserTabsConfig(moduleConfigs: ModuleBuildConfig[]) {
1021
1021
  const importsForApp = userTabsConfigs
1022
1022
  .map(
1023
1023
  (tab) =>
1024
- `const ${tab.componentExport} = dynamic(() => import("${tab.moduleName}").then(mod => ({ default: mod.${tab.componentExport} })), { ssr: true });`,
1024
+ `const ${tab.componentExport} = dynamic(() => import("${tab.moduleName}").then(mod => ({ default: mod.${tab.componentExport} })), { ssr: true });`
1025
1025
  )
1026
1026
  .join("\n");
1027
1027
 
@@ -1033,7 +1033,7 @@ async function generateUserTabsConfig(moduleConfigs: ModuleBuildConfig[]) {
1033
1033
  title: "${tab.title}",
1034
1034
  icon: "${tab.icon || ""}",
1035
1035
  component: ${tab.componentExport},
1036
- }`,
1036
+ }`
1037
1037
  )
1038
1038
  .join(",\n");
1039
1039
 
@@ -1073,8 +1073,7 @@ async function generateBucketsConfig(moduleConfigs: ModuleBuildConfig[]) {
1073
1073
  // Extraire les configurations storage des modules
1074
1074
  const allBuckets = moduleConfigs
1075
1075
  .filter(
1076
- (config) =>
1077
- config.storage?.buckets && config.storage.buckets.length > 0,
1076
+ (config) => config.storage?.buckets && config.storage.buckets.length > 0
1078
1077
  )
1079
1078
  .flatMap((config) => config.storage!.buckets);
1080
1079
 
@@ -1210,8 +1209,7 @@ async function generateStorageProxyApi(moduleConfigs: ModuleBuildConfig[]) {
1210
1209
  // Extraire les configurations storage des modules
1211
1210
  const allBuckets = moduleConfigs
1212
1211
  .filter(
1213
- (config) =>
1214
- config.storage?.buckets && config.storage.buckets.length > 0,
1212
+ (config) => config.storage?.buckets && config.storage.buckets.length > 0
1215
1213
  )
1216
1214
  .flatMap((config) => config.storage!.buckets);
1217
1215
 
@@ -1337,7 +1335,7 @@ export async function GET(
1337
1335
  "storage",
1338
1336
  "[bucket]",
1339
1337
  "[...path]",
1340
- "route.ts",
1338
+ "route.ts"
1341
1339
  );
1342
1340
  const outputDir = path.dirname(outputPath);
1343
1341
 
@@ -1352,10 +1350,10 @@ export async function GET(
1352
1350
  if (isDebugMode) {
1353
1351
  console.log(`✅ Generated storage proxy API: ${outputPath}`);
1354
1352
  console.log(
1355
- `📊 Public buckets: ${publicBuckets.map((b) => b.name).join(", ") || "none"}`,
1353
+ `📊 Public buckets: ${publicBuckets.map((b) => b.name).join(", ") || "none"}`
1356
1354
  );
1357
1355
  console.log(
1358
- `📊 Private buckets: ${privateBuckets.map((b) => b.name).join(", ") || "none"}`,
1356
+ `📊 Private buckets: ${privateBuckets.map((b) => b.name).join(", ") || "none"}`
1359
1357
  );
1360
1358
  }
1361
1359
  } catch (error) {
@@ -1372,7 +1370,7 @@ async function generateFooterConfig(moduleConfigs: ModuleBuildConfig[]) {
1372
1370
 
1373
1371
  if (allFooterLinks.length === 0) {
1374
1372
  console.log(
1375
- "⏭️ No footer links found, skipping footer config generation",
1373
+ "⏭️ No footer links found, skipping footer config generation"
1376
1374
  );
1377
1375
  return;
1378
1376
  }
@@ -1438,7 +1436,7 @@ export async function runModuleBuild() {
1438
1436
  moduleConfigs.forEach((moduleConfig) => {
1439
1437
  if (isDebugMode) {
1440
1438
  console.log(
1441
- `📦 Processing module: ${moduleConfig.moduleName} with ${moduleConfig.pages.length} pages`,
1439
+ `📦 Processing module: ${moduleConfig.moduleName} with ${moduleConfig.pages.length} pages`
1442
1440
  );
1443
1441
  }
1444
1442
  moduleConfig.pages.forEach((page) => buildPage(moduleConfig, page));