create-appraisejs 0.2.0-alpha.3 → 0.2.0-alpha.4

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": "create-appraisejs",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.2.0-alpha.4",
4
4
  "description": "Scaffold a new AppraiseJS app in your directory",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hasnat Jamil",
@@ -44,7 +44,6 @@
44
44
  "sync-templates": "tsx scripts/sync-templates.ts",
45
45
  "test": "vitest run",
46
46
  "test:e2e": "vitest run --config vitest.e2e.config.ts",
47
- "publish": "npm publish",
48
47
  "publish:alpha": "npm publish --tag alpha",
49
48
  "publish:beta": "npm publish --tag beta",
50
49
  "bump:alpha": "npm version prerelease --preid alpha",
@@ -1,5 +1,5 @@
1
1
  {
2
- "preparedAt": "2026-03-23T20:15:15.041Z",
2
+ "preparedAt": "2026-03-24T10:58:54.969Z",
3
3
  "inputHash": "596a28d2c5dc408d39926068711127354f3752a92c086cd0df27e8cf85eb5990",
4
4
  "databasePath": "prisma/dev.db"
5
5
  }
Binary file
@@ -156,10 +156,9 @@ export default function RootLayout({
156
156
  },
157
157
  ]}
158
158
  />
159
- {/* <NavLink href="/settings" icon={<Settings2 className="h-5 w-5 text-primary" />}>
159
+ <NavLink href="/settings" icon={<Settings2 className="h-5 w-5 text-primary" />}>
160
160
  Settings
161
161
  </NavLink>
162
- */}
163
162
  <NavCommand className="ml-auto" />
164
163
  </div>
165
164
  </nav>
@@ -1,9 +1,70 @@
1
- import { PrismaClient } from '@prisma/client'
2
-
3
- const globalForPrisma = global as unknown as {
4
- prisma: PrismaClient | undefined
5
- }
6
- const prisma = globalForPrisma.prisma ?? new PrismaClient()
1
+ import fs from 'fs'
2
+ import { createRequire } from 'module'
3
+ import path from 'path'
4
+
5
+ function readProjectDatabaseUrl(): string | null {
6
+ const envPath = path.join(process.cwd(), '.env')
7
+ if (!fs.existsSync(envPath)) {
8
+ return null
9
+ }
10
+
11
+ const envContent = fs.readFileSync(envPath, 'utf8')
12
+ const match = envContent.match(/^\s*DATABASE_URL\s*=\s*(?:"([^"]*)"|'([^']*)'|([^#\r\n]+))\s*$/m)
13
+ const rawValue = match?.[1] ?? match?.[2] ?? match?.[3]
14
+ const normalizedValue = rawValue?.trim()
15
+
16
+ return normalizedValue ? normalizedValue : null
17
+ }
18
+
19
+ function normalizeDatabaseUrl(databaseUrl: string): string {
20
+ if (!databaseUrl.startsWith('file:')) {
21
+ return databaseUrl
22
+ }
23
+
24
+ const sqlitePathWithQuery = databaseUrl.slice('file:'.length)
25
+ if (!sqlitePathWithQuery || sqlitePathWithQuery === ':memory:') {
26
+ return databaseUrl
27
+ }
28
+
29
+ const queryStartIndex = sqlitePathWithQuery.indexOf('?')
30
+ const sqlitePath = queryStartIndex >= 0 ? sqlitePathWithQuery.slice(0, queryStartIndex) : sqlitePathWithQuery
31
+ const query = queryStartIndex >= 0 ? sqlitePathWithQuery.slice(queryStartIndex) : ''
32
+
33
+ if (path.isAbsolute(sqlitePath)) {
34
+ return databaseUrl
35
+ }
36
+
37
+ // Prisma resolves relative SQLite paths from the schema directory. The app's schema
38
+ // lives in `<project>/prisma`, so normalize local file URLs to that location.
39
+ const absolutePath = path.resolve(process.cwd(), 'prisma', sqlitePath)
40
+ return `file:${absolutePath}${query}`
41
+ }
42
+
43
+ function ensureProjectDatabaseUrl(): void {
44
+ if (process.env.DATABASE_URL) {
45
+ return
46
+ }
47
+
48
+ const projectDatabaseUrl = readProjectDatabaseUrl()
49
+ if (!projectDatabaseUrl) {
50
+ return
51
+ }
52
+
53
+ process.env.DATABASE_URL = normalizeDatabaseUrl(projectDatabaseUrl)
54
+ }
55
+
56
+ ensureProjectDatabaseUrl()
57
+
58
+ type PrismaClientInstance = import('@prisma/client').PrismaClient
59
+ const require = createRequire(import.meta.url)
60
+ const { PrismaClient } = require('@prisma/client') as {
61
+ PrismaClient: new () => PrismaClientInstance
62
+ }
63
+
64
+ const globalForPrisma = global as unknown as {
65
+ prisma: PrismaClientInstance | undefined
66
+ }
67
+ const prisma = globalForPrisma.prisma ?? new PrismaClient()
7
68
 
8
69
  if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
9
70