stackkit 0.1.6 → 0.1.7

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/dist/cli/add.js CHANGED
@@ -49,10 +49,10 @@ async function getAddConfig(module, options, projectInfo) {
49
49
  if (module === "database" || module === "auth") {
50
50
  if (!options?.provider) {
51
51
  if (module === "database") {
52
- throw new Error('Provider is required for database. Use: `npx stackkit add database --provider <provider>`');
52
+ throw new Error("Provider is required for database. Use: `npx stackkit add database --provider <provider>`");
53
53
  }
54
54
  else {
55
- throw new Error('Provider is required for auth. Use: `npx stackkit add auth --provider <provider>`');
55
+ throw new Error("Provider is required for auth. Use: `npx stackkit add auth --provider <provider>`");
56
56
  }
57
57
  }
58
58
  if (module === "database") {
@@ -306,7 +306,8 @@ async function processGeneratorEnvVars(config, targetDir) {
306
306
  const generator = await fs_extra_1.default.readJson(dbGeneratorPath);
307
307
  if (generator.operations) {
308
308
  for (const operation of generator.operations) {
309
- if (operation.type === "add-env" && (!operation.condition || checkCondition(operation.condition, config))) {
309
+ if (operation.type === "add-env" &&
310
+ (!operation.condition || checkCondition(operation.condition, config))) {
310
311
  for (const [key, value] of Object.entries(operation.envVars)) {
311
312
  envVars.push({
312
313
  key,
@@ -326,7 +327,8 @@ async function processGeneratorEnvVars(config, targetDir) {
326
327
  const generator = await fs_extra_1.default.readJson(authGeneratorPath);
327
328
  if (generator.operations) {
328
329
  for (const operation of generator.operations) {
329
- if (operation.type === "add-env" && (!operation.condition || checkCondition(operation.condition, config))) {
330
+ if (operation.type === "add-env" &&
331
+ (!operation.condition || checkCondition(operation.condition, config))) {
330
332
  for (const [key, value] of Object.entries(operation.envVars)) {
331
333
  envVars.push({
332
334
  key,
package/dist/index.js CHANGED
@@ -7,11 +7,14 @@ const add_1 = require("./cli/add");
7
7
  const doctor_1 = require("./cli/doctor");
8
8
  const list_1 = require("./cli/list");
9
9
  const logger_1 = require("./lib/ui/logger");
10
+ const fs_1 = require("fs");
11
+ const path_1 = require("path");
12
+ const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, "../package.json"), "utf-8"));
10
13
  const program = new commander_1.Command();
11
14
  program
12
15
  .name("stackkit")
13
16
  .description("CLI for creating and managing StackKit projects")
14
- .version("0.1.6")
17
+ .version(packageJson.version)
15
18
  .configureHelp({
16
19
  subcommandTerm: (cmd) => {
17
20
  const name = cmd.name();
@@ -175,7 +175,7 @@ class AdvancedCodeGenerator {
175
175
  conditionMet = typeof actualVal === "string" && actualVal.endsWith(cleanExpectedVal);
176
176
  break;
177
177
  }
178
- const contentToProcess = conditionMet ? blockContent : (elseContent || "");
178
+ const contentToProcess = conditionMet ? blockContent : elseContent || "";
179
179
  return this.processTemplateRecursive(contentToProcess, context)
180
180
  .replace(/^\n+/, "")
181
181
  .replace(/\n+$/, "");
@@ -185,7 +185,7 @@ class AdvancedCodeGenerator {
185
185
  const conditionParts = condition.split("==");
186
186
  if (conditionParts.length === 2) {
187
187
  const [varName, expectedValue] = conditionParts.map((s) => s.trim().replace(/['"]/g, ""));
188
- const contentToProcess = context[varName] === expectedValue ? blockContent : (elseContent || "");
188
+ const contentToProcess = context[varName] === expectedValue ? blockContent : elseContent || "";
189
189
  return this.processTemplateRecursive(contentToProcess, context)
190
190
  .replace(/^\n+/, "")
191
191
  .replace(/\n+$/, "");
@@ -195,7 +195,7 @@ class AdvancedCodeGenerator {
195
195
  const [arrayName, item] = conditionFunc[0].split("(");
196
196
  const itemValue = item.replace(")", "").replace(/['"]/g, "");
197
197
  const array = context[arrayName] || [];
198
- const contentToProcess = Array.isArray(array) && array.includes(itemValue) ? blockContent : (elseContent || "");
198
+ const contentToProcess = Array.isArray(array) && array.includes(itemValue) ? blockContent : elseContent || "";
199
199
  return this.processTemplateRecursive(contentToProcess, context)
200
200
  .replace(/^\n+/, "")
201
201
  .replace(/\n+$/, "");
@@ -1,6 +1,2 @@
1
- import NextAuth from "next-auth";
2
- import { authOptions } from "@/lib/auth";
3
-
4
- const handler = NextAuth(authOptions);
5
-
6
- export { handler as GET, handler as POST };
1
+ import { handlers } from "@/auth"
2
+ export const { GET, POST } = handlers
@@ -1,36 +1,22 @@
1
- import { NextAuthOptions } from "next-auth";
2
- import { PrismaAdapter } from "@auth/prisma-adapter";
3
- import { prisma } from "@/lib/prisma";
4
- import GoogleProvider from "next-auth/providers/google";
1
+ import NextAuth from "next-auth"
2
+ import { PrismaAdapter } from "@auth/prisma-adapter"
3
+ import prisma from "@/lib/prisma"
4
+ import Google from "next-auth/providers/google"
5
+ import { encode, decode } from 'next-auth/jwt';
5
6
 
6
- export const authOptions: NextAuthOptions = {
7
+ export const { handlers, signIn, signOut, auth } = NextAuth({
7
8
  adapter: PrismaAdapter(prisma),
8
9
  providers: [
9
- GoogleProvider({
10
- clientId: process.env.GOOGLE_CLIENT_ID!,
11
- clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
10
+ Google({
11
+ clientId: process.env.AUTH_GOOGLE_ID,
12
+ clientSecret: process.env.AUTH_GOOGLE_SECRET,
12
13
  }),
13
14
  ],
14
- session: {
15
- strategy: "jwt",
16
- },
17
- callbacks: {
18
- async jwt({ token, user }) {
19
- if (user) {
20
- token.id = user.id;
21
- }
22
- return token;
23
- },
24
- async session({ session, token }) {
25
- if (token) {
26
- session.user.id = token.id as string;
27
- }
28
- return session;
29
- },
30
- },
15
+ session: { strategy: "jwt" },
16
+ secret: process.env.AUTH_SECRET,
17
+ jwt: { encode, decode },
31
18
  pages: {
32
- signIn: "/auth/signin",
33
- signOut: "/auth/signout",
34
- error: "/auth/error",
19
+ signIn: '/sign-in',
20
+ error: '/error',
35
21
  },
36
- };
22
+ })
@@ -1,10 +1,10 @@
1
-
1
+ {{#var defaultId = {{#if prismaProvider == "mongodb"}}@default(auto()) @map("_id") @db.ObjectId{{else}}@default(cuid()){{/if}}}}
2
2
  model Account {
3
- id String @id {{idDefault}}
4
- userId String {{userIdType}}
3
+ id String @id {{defaultId}}
4
+ userId String @map("user_id")
5
5
  type String
6
6
  provider String
7
- providerAccountId String
7
+ providerAccountId String @map("provider_account_id")
8
8
  refresh_token String? @db.Text
9
9
  access_token String? @db.Text
10
10
  expires_at Int?
@@ -16,30 +16,36 @@ model Account {
16
16
  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
17
17
 
18
18
  @@unique([provider, providerAccountId])
19
+ @@map("accounts")
19
20
  }
20
21
 
21
22
  model Session {
22
- id String @id {{idDefault}}
23
- sessionToken String @unique
24
- userId String {{userIdType}}
23
+ id String @id {{defaultId}}
24
+ sessionToken String @unique @map("session_token")
25
+ userId String {{#if prismaProvider == "mongodb"}} @db.ObjectId{{/if}} @map("user_id")
25
26
  expires DateTime
26
27
  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
28
+
29
+ @@map("sessions")
27
30
  }
28
31
 
29
32
  model User {
30
- id String @id {{idDefault}}
33
+ id String @id {{defaultId}}
31
34
  name String?
32
- email String @unique
33
- emailVerified DateTime?
35
+ email String? @unique
36
+ emailVerified DateTime? @map("email_verified")
34
37
  image String?
35
38
  accounts Account[]
36
39
  sessions Session[]
40
+
41
+ @@map("users")
37
42
  }
38
43
 
39
44
  model VerificationToken {
40
45
  identifier String
41
- token String @unique
46
+ token String
42
47
  expires DateTime
43
48
 
44
49
  @@unique([identifier, token])
50
+ @@map("verification_tokens")
45
51
  }
@@ -2,8 +2,53 @@
2
2
  "name": "authjs",
3
3
  "type": "auth",
4
4
  "priority": 10,
5
- "operations": [],
6
- "dependencies": {},
5
+ "operations": [
6
+ {
7
+ "type": "create-file",
8
+ "source": "lib/auth.ts",
9
+ "destination": "lib/auth.ts"
10
+ },
11
+ {
12
+ "type": "create-file",
13
+ "source": "api/auth/[...nextauth]/route.ts",
14
+ "destination": "app/api/auth/[...nextauth]/route.ts"
15
+ },
16
+ {
17
+ "type": "create-file",
18
+ "destination": "proxy.ts",
19
+ "content": "export { auth as middleware } from \"@/auth\""
20
+ },
21
+ {
22
+ "type": "patch-file",
23
+ "destination": "prisma/schema.prisma",
24
+ "condition": { "database": "prisma" },
25
+ "operations": [
26
+ {
27
+ "type": "add-to-bottom",
28
+ "source": "prisma/schema.prisma"
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "type": "add-dependency",
34
+ "condition": { "database": "prisma" },
35
+ "dependencies": {
36
+ "@auth/prisma-adapter": "^0.5.0"
37
+ },
38
+ "devDependencies": {}
39
+ },
40
+ {
41
+ "type": "add-env",
42
+ "envVars": {
43
+ "AUTH_SECRET": "",
44
+ "AUTH_GOOGLE_ID": "",
45
+ "AUTH_GOOGLE_SECRET": ""
46
+ }
47
+ }
48
+ ],
49
+ "dependencies": {
50
+ "next-auth": "^5.0.0-beta.30"
51
+ },
7
52
  "devDependencies": {},
8
53
  "scripts": {}
9
54
  }
@@ -1,4 +1,4 @@
1
- {{#var defaultId = {{#if prismaProvider == mongodb}}@default(auto()) @map("_id") @db.ObjectId{{else}}@default(cuid()){{/if}}}}
1
+ {{#var defaultId = {{#if prismaProvider == "mongodb"}}@default(auto()) @map("_id") @db.ObjectId{{else}}@default(cuid()){{/if}}}}
2
2
  model User {
3
3
  id String @id {{defaultId}}
4
4
  name String
@@ -23,7 +23,7 @@ model Session {
23
23
  updatedAt DateTime @updatedAt
24
24
  ipAddress String?
25
25
  userAgent String?
26
- userId String {{#if prismaProvider == mongodb}} @db.ObjectId{{/if}}
26
+ userId String {{#if prismaProvider == "mongodb"}} @db.ObjectId{{/if}}
27
27
  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
28
28
 
29
29
  @@index([userId])
@@ -34,7 +34,7 @@ model Account {
34
34
  id String @id {{defaultId}}
35
35
  accountId String
36
36
  providerId String
37
- userId String {{#if prismaProvider == mongodb}} @db.ObjectId{{/if}}
37
+ userId String {{#if prismaProvider == "mongodb"}} @db.ObjectId{{/if}}
38
38
  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
39
39
  accessToken String?
40
40
  refreshToken String?
@@ -6,7 +6,7 @@ const globalForPrisma = globalThis as unknown as {
6
6
  }
7
7
 
8
8
  {{#switch prismaProvider}}
9
- {{#case postgresql}}
9
+ {{#case "postgresql"}}
10
10
  import { PrismaPg } from '@prisma/adapter-pg'
11
11
 
12
12
  const connectionString = `${process.env.DATABASE_URL}`
@@ -16,13 +16,13 @@ const prisma = new PrismaClient({ adapter })
16
16
 
17
17
  export { prisma }
18
18
  {{/case}}
19
- {{#case mongodb}}
19
+ {{#case "mongodb"}}
20
20
 
21
21
  const prisma = new PrismaClient()
22
22
 
23
23
  export { prisma }
24
24
  {{/case}}
25
- {{#case mysql}}
25
+ {{#case "mysql"}}
26
26
  import { PrismaMariaDb } from '@prisma/adapter-mariadb';
27
27
 
28
28
  const adapter = new PrismaMariaDb({
@@ -36,7 +36,7 @@ const prisma = new PrismaClient({ adapter });
36
36
 
37
37
  export { prisma }
38
38
  {{/case}}
39
- {{#case sqlite}}
39
+ {{#case "sqlite"}}
40
40
  import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
41
41
 
42
42
  const connectionString = `${process.env.DATABASE_URL}`;
@@ -1,6 +1,6 @@
1
1
  import "dotenv/config";
2
2
  {{#switch prismaProvider}}
3
- {{#case mongodb}}
3
+ {{#case "mongodb"}}
4
4
  import { defineConfig, env } from "prisma/config";
5
5
  {{/case}}
6
6
  {{#case default}}
@@ -14,7 +14,7 @@ export default defineConfig({
14
14
  path: "prisma/migrations",
15
15
  },
16
16
  {{#switch prismaProvider}}
17
- {{#case mongodb}}
17
+ {{#case "mongodb"}}
18
18
  engine: "classic",
19
19
  datasource: {
20
20
  url: env('DATABASE_URL'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackkit",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Production-ready CLI to create and extend JavaScript or TypeScript apps with modular stacks.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,11 +0,0 @@
1
- import { getServerSession } from "next-auth/next";
2
- import { authOptions } from "@/lib/auth";
3
-
4
- export async function getSession() {
5
- return await getServerSession(authOptions);
6
- }
7
-
8
- export async function getCurrentUser() {
9
- const session = await getSession();
10
- return session?.user;
11
- }