kempo 4.5.5 → 4.5.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/db/index.js +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo",
3
- "version": "4.5.5",
3
+ "version": "4.5.6",
4
4
  "type": "module",
5
5
  "description": "A fullstack CMS framework for creating websites with user authentication",
6
6
  "scripts": {
@@ -34,6 +34,20 @@ if(process.env.KEMPO_DB === 'pglite'){
34
34
  import('drizzle-orm/pglite'),
35
35
  import('drizzle-kit/api')
36
36
  ]);
37
+ /*
38
+ A project's drizzle.config.js lists every schema its database holds (its own, kempo's and any
39
+ extensions it sits on), because `drizzle-kit push` needs the same list. Use it, so the in-memory
40
+ database is exactly what a push would have made.
41
+ */
42
+ const configPath = join(process.cwd(), 'drizzle.config.js');
43
+ if(existsSync(configPath)){
44
+ const { default: config } = await import(pathToFileURL(configPath).href);
45
+ for(const entry of [config?.schema].flat().filter(Boolean)){
46
+ const file = join(process.cwd(), entry);
47
+ if(existsSync(file)) Object.assign(schema, await import(pathToFileURL(realpathSync(file)).href));
48
+ }
49
+ }
50
+
37
51
  const client = new PGlite();
38
52
  db = drizzlePglite(client, { schema });
39
53