@primstack/cli 0.0.6 → 0.0.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.
@@ -0,0 +1 @@
1
+ enable-pre-post-scripts=true
@@ -5,6 +5,6 @@ export default defineConfig({
5
5
  out: './src/db/migrations',
6
6
  dialect: 'sqlite',
7
7
  dbCredentials: {
8
- url: process.env.DATABASE_URL ?? 'file:./local.db',
8
+ url: process.env.DATABASE_URL ?? './local.db',
9
9
  },
10
10
  });
@@ -7,6 +7,7 @@ const nextConfig: NextConfig = {
7
7
  '@primstack/tokens',
8
8
  '@primstack/core',
9
9
  ],
10
+ serverExternalPackages: ['better-sqlite3'],
10
11
  images: {
11
12
  unoptimized: true,
12
13
  },
@@ -34,5 +34,8 @@
34
34
  "postcss": "^8.4.0",
35
35
  "tailwindcss": "^3.4.0",
36
36
  "typescript": "^5.7.0"
37
+ },
38
+ "pnpm": {
39
+ "onlyBuiltDependencies": ["better-sqlite3", "esbuild", "sharp"]
37
40
  }
38
41
  }
@@ -0,0 +1,3 @@
1
+ import { handlers } from '@/lib/auth';
2
+
3
+ export const { GET, POST } = handlers;
@@ -1,5 +1,6 @@
1
1
  import type { Metadata } from 'next';
2
2
  import { ThemeProvider } from '@primstack/theme';
3
+ import { personalities } from '@primstack/tokens';
3
4
  import './globals.css';
4
5
 
5
6
  export const metadata: Metadata = {
@@ -7,6 +8,8 @@ export const metadata: Metadata = {
7
8
  description: 'Built with Primstack',
8
9
  };
9
10
 
11
+ const personality = personalities['{{PERSONALITY}}'] || personalities['evergreen'];
12
+
10
13
  export default function RootLayout({
11
14
  children,
12
15
  }: {
@@ -15,7 +18,7 @@ export default function RootLayout({
15
18
  return (
16
19
  <html lang="en" suppressHydrationWarning>
17
20
  <body className="min-h-screen antialiased">
18
- <ThemeProvider personality="{{PERSONALITY}}">
21
+ <ThemeProvider personality={personality}>
19
22
  {children}
20
23
  </ThemeProvider>
21
24
  </body>
@@ -2,6 +2,7 @@ import { sqliteTable, text, integer, uniqueIndex } from 'drizzle-orm/sqlite-core
2
2
  import { sql } from 'drizzle-orm';
3
3
 
4
4
  // ── Auth.js tables ─────────────────────────────────────────────────
5
+ // Column property names must match @auth/drizzle-adapter expectations (snake_case).
5
6
 
6
7
  export const authUsers = sqliteTable('auth_users', {
7
8
  id: text('id').primaryKey(),
@@ -17,20 +18,19 @@ export const accounts = sqliteTable('accounts', {
17
18
  type: text('type').notNull(),
18
19
  provider: text('provider').notNull(),
19
20
  providerAccountId: text('provider_account_id').notNull(),
20
- refreshToken: text('refresh_token'),
21
- accessToken: text('access_token'),
22
- expiresAt: integer('expires_at'),
23
- tokenType: text('token_type'),
21
+ refresh_token: text('refresh_token'),
22
+ access_token: text('access_token'),
23
+ expires_at: integer('expires_at'),
24
+ token_type: text('token_type'),
24
25
  scope: text('scope'),
25
- idToken: text('id_token'),
26
- sessionState: text('session_state'),
26
+ id_token: text('id_token'),
27
+ session_state: text('session_state'),
27
28
  }, (table) => [
28
29
  uniqueIndex('accounts_provider_idx').on(table.provider, table.providerAccountId),
29
30
  ]);
30
31
 
31
32
  export const sessions = sqliteTable('sessions', {
32
- id: text('id').primaryKey(),
33
- sessionToken: text('session_token').notNull().unique(),
33
+ sessionToken: text('session_token').primaryKey(),
34
34
  userId: text('user_id').notNull().references(() => authUsers.id, { onDelete: 'cascade' }),
35
35
  expires: integer('expires', { mode: 'timestamp' }).notNull(),
36
36
  });
@@ -0,0 +1,21 @@
1
+ import GitHub from 'next-auth/providers/github';
2
+ import type { NextAuthConfig } from 'next-auth';
3
+
4
+ /**
5
+ * Auth.js config — edge-compatible (no Node.js dependencies).
6
+ * Used by middleware for JWT session checks.
7
+ */
8
+ export default {
9
+ providers: [
10
+ GitHub({
11
+ clientId: process.env.GITHUB_CLIENT_ID!,
12
+ clientSecret: process.env.GITHUB_CLIENT_SECRET!,
13
+ }),
14
+ ],
15
+ session: {
16
+ strategy: 'jwt',
17
+ },
18
+ pages: {
19
+ signIn: '/auth/login',
20
+ },
21
+ } satisfies NextAuthConfig;
@@ -1,25 +1,18 @@
1
1
  import NextAuth from 'next-auth';
2
- import GitHub from 'next-auth/providers/github';
3
2
  import { DrizzleAdapter } from '@auth/drizzle-adapter';
4
3
  import { getDatabase } from './db';
5
4
  import { authUsers, accounts, sessions } from '../db/schema';
5
+ import authConfig from './auth.config';
6
6
 
7
+ /**
8
+ * Full Auth.js configuration with Drizzle adapter.
9
+ * Only used in Node.js server context (not middleware/edge).
10
+ */
7
11
  export const { handlers, signIn, signOut, auth } = NextAuth({
12
+ ...authConfig,
8
13
  adapter: DrizzleAdapter(getDatabase(), {
9
14
  usersTable: authUsers,
10
15
  accountsTable: accounts,
11
16
  sessionsTable: sessions,
12
17
  }),
13
- providers: [
14
- GitHub({
15
- clientId: process.env.GITHUB_CLIENT_ID!,
16
- clientSecret: process.env.GITHUB_CLIENT_SECRET!,
17
- }),
18
- ],
19
- session: {
20
- strategy: 'jwt',
21
- },
22
- pages: {
23
- signIn: '/auth/login',
24
- },
25
18
  });
@@ -1,9 +1,9 @@
1
- import { drizzle } from 'drizzle-orm/better-sqlite3';
1
+ import { drizzle, type BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
2
  import Database from 'better-sqlite3';
3
3
  import * as schema from '../db/schema';
4
4
  import path from 'path';
5
5
 
6
- export type AppDb = ReturnType<typeof getDatabase>;
6
+ export type AppDb = BetterSQLite3Database<typeof schema>;
7
7
 
8
8
  let _db: AppDb | null = null;
9
9
 
@@ -13,7 +13,7 @@ let _db: AppDb | null = null;
13
13
  * Uses better-sqlite3 with a local SQLite file.
14
14
  * In production (Primstack hosting), D1 bindings are injected at deploy time.
15
15
  */
16
- export function getDatabase() {
16
+ export function getDatabase(): AppDb {
17
17
  if (!_db) {
18
18
  const dbPath = process.env.DATABASE_URL || path.join(process.cwd(), 'local.db');
19
19
  const sqlite = new Database(dbPath);
@@ -1,6 +1,10 @@
1
- export { auth as middleware } from '@/lib/auth';
1
+ import NextAuth from 'next-auth';
2
+ import authConfig from '@/lib/auth.config';
3
+
4
+ const { auth } = NextAuth(authConfig);
5
+
6
+ export default auth;
2
7
 
3
8
  export const config = {
4
- // Protect all routes under /dashboard, /api (except health and auth)
5
9
  matcher: ['/dashboard/:path*'],
6
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primstack/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "CLI for Primstack component library",
5
5
  "type": "module",
6
6
  "bin": {