stackkit 0.1.3 → 0.1.5
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/README.md +5 -3
- package/dist/cli/add.d.ts +2 -1
- package/dist/cli/add.js +325 -102
- package/dist/cli/create.d.ts +2 -2
- package/dist/cli/create.js +96 -30
- package/dist/cli/doctor.js +25 -17
- package/dist/cli/list.js +14 -2
- package/dist/index.js +22 -3
- package/dist/lib/conversion/js-conversion.js +2 -2
- package/dist/lib/discovery/module-discovery.d.ts +0 -1
- package/dist/lib/discovery/module-discovery.js +35 -35
- package/dist/lib/env/env-editor.js +1 -1
- package/dist/lib/framework/framework-utils.d.ts +1 -1
- package/dist/lib/framework/framework-utils.js +3 -3
- package/dist/lib/generation/code-generator.d.ts +18 -4
- package/dist/lib/generation/code-generator.js +212 -147
- package/dist/lib/generation/generator-utils.d.ts +11 -0
- package/dist/lib/generation/generator-utils.js +124 -0
- package/dist/lib/git-utils.js +20 -0
- package/dist/lib/project/detect.js +2 -4
- package/dist/lib/utils/package-root.js +2 -2
- package/dist/types/index.d.ts +0 -10
- package/modules/auth/authjs/generator.json +10 -0
- package/modules/auth/authjs/module.json +0 -9
- package/modules/auth/better-auth/files/lib/auth.ts +38 -31
- package/modules/auth/better-auth/files/prisma/schema.prisma +3 -3
- package/modules/auth/better-auth/generator.json +58 -28
- package/modules/auth/better-auth/module.json +0 -24
- package/modules/database/mongoose/files/models/health.ts +34 -0
- package/modules/database/mongoose/generator.json +27 -8
- package/modules/database/mongoose/module.json +1 -2
- package/modules/database/prisma/files/lib/prisma.ts +27 -21
- package/modules/database/prisma/files/prisma.config.ts +17 -0
- package/modules/database/prisma/generator.json +79 -15
- package/modules/database/prisma/module.json +1 -4
- package/package.json +1 -1
- package/templates/express/src/server.ts +9 -3
- package/templates/express/tsconfig.json +2 -23
- package/templates/nextjs/lib/env.ts +1 -1
- package/dist/lib/database/database-config.d.ts +0 -6
- package/dist/lib/database/database-config.js +0 -9
- package/modules/database/mongoose/files/models/User.ts +0 -34
- /package/modules/database/mongoose/files/lib/{db.ts → mongoose.ts} +0 -0
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { PrismaClient } from './generated/prisma/client'
|
|
2
3
|
|
|
3
4
|
const globalForPrisma = globalThis as unknown as {
|
|
4
5
|
prisma: PrismaClient | undefined
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
{{#
|
|
8
|
-
|
|
8
|
+
{{#switch prismaProvider}}
|
|
9
|
+
{{#case postgresql}}
|
|
10
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
9
11
|
|
|
10
|
-
const
|
|
11
|
-
connectionString: process.env.DATABASE_URL!,
|
|
12
|
-
});
|
|
12
|
+
const connectionString = `${process.env.DATABASE_URL}`
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
14
|
+
const adapter = new PrismaPg({ connectionString })
|
|
15
|
+
const prisma = new PrismaClient({ adapter })
|
|
16
|
+
|
|
17
|
+
export { prisma }
|
|
18
|
+
{{/case}}
|
|
19
|
+
{{#case mongodb}}
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
export const prisma = globalForPrisma.prisma ?? new PrismaClient();
|
|
21
|
-
{{/if}}
|
|
21
|
+
const prisma = new PrismaClient()
|
|
22
22
|
|
|
23
|
-
{
|
|
23
|
+
export { prisma }
|
|
24
|
+
{{/case}}
|
|
25
|
+
{{#case mysql}}
|
|
24
26
|
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
|
|
25
27
|
|
|
26
28
|
const adapter = new PrismaMariaDb({
|
|
@@ -30,16 +32,20 @@ const adapter = new PrismaMariaDb({
|
|
|
30
32
|
database: process.env.DATABASE_NAME,
|
|
31
33
|
connectionLimit: 5
|
|
32
34
|
});
|
|
35
|
+
const prisma = new PrismaClient({ adapter });
|
|
33
36
|
|
|
34
|
-
export
|
|
35
|
-
{{/
|
|
36
|
-
|
|
37
|
-
{{#if prismaProvider == "sqlite"}}
|
|
37
|
+
export { prisma }
|
|
38
|
+
{{/case}}
|
|
39
|
+
{{#case sqlite}}
|
|
38
40
|
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
|
|
39
41
|
|
|
40
|
-
const
|
|
42
|
+
const connectionString = `${process.env.DATABASE_URL}`;
|
|
43
|
+
|
|
44
|
+
const adapter = new PrismaBetterSqlite3({ url: connectionString });
|
|
45
|
+
const prisma = new PrismaClient({ adapter });
|
|
41
46
|
|
|
42
|
-
export
|
|
43
|
-
{{/
|
|
47
|
+
export { prisma };
|
|
48
|
+
{{/case}}
|
|
49
|
+
{{/switch}}
|
|
44
50
|
|
|
45
51
|
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
|
+
{{#switch prismaProvider}}
|
|
3
|
+
{{#case mongodb}}
|
|
4
|
+
import { defineConfig, env } from "prisma/config";
|
|
5
|
+
{{/case}}
|
|
6
|
+
{{#case default}}
|
|
2
7
|
import { defineConfig } from "prisma/config";
|
|
8
|
+
{{/case}}
|
|
9
|
+
{{/switch}}
|
|
3
10
|
|
|
4
11
|
export default defineConfig({
|
|
5
12
|
schema: "prisma/schema.prisma",
|
|
6
13
|
migrations: {
|
|
7
14
|
path: "prisma/migrations",
|
|
8
15
|
},
|
|
16
|
+
{{#switch prismaProvider}}
|
|
17
|
+
{{#case mongodb}}
|
|
18
|
+
engine: "classic",
|
|
19
|
+
datasource: {
|
|
20
|
+
url: env('DATABASE_URL'),
|
|
21
|
+
},
|
|
22
|
+
{{/case}}
|
|
23
|
+
{{#case default}}
|
|
9
24
|
datasource: {
|
|
10
25
|
url: process.env["DATABASE_URL"],
|
|
11
26
|
},
|
|
27
|
+
{{/case}}
|
|
28
|
+
{{/switch}}
|
|
12
29
|
});
|
|
@@ -16,28 +16,92 @@
|
|
|
16
16
|
{
|
|
17
17
|
"type": "create-file",
|
|
18
18
|
"source": "lib/prisma.ts",
|
|
19
|
-
"destination": "lib/prisma.ts"
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
"destination": "lib/prisma.ts"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "add-dependency",
|
|
23
|
+
"condition": { "prismaProvider": "postgresql" },
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@prisma/adapter-pg": "^7.0.0",
|
|
26
|
+
"@prisma/client": "^7.2.0",
|
|
27
|
+
"pg": "^8.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"prisma": "^7.2.0"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "add-dependency",
|
|
35
|
+
"condition": { "prismaProvider": "mysql" },
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@prisma/adapter-mariadb": "^7.0.0",
|
|
38
|
+
"@prisma/client": "^7.2.0",
|
|
39
|
+
"mysql2": "^3.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"prisma": "^7.2.0"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "add-dependency",
|
|
47
|
+
"condition": { "prismaProvider": "sqlite" },
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@prisma/adapter-better-sqlite3": "^7.0.0",
|
|
50
|
+
"@prisma/client": "^7.2.0",
|
|
51
|
+
"better-sqlite3": "^9.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"prisma": "^7.2.0"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "add-dependency",
|
|
59
|
+
"condition": { "prismaProvider": "mongodb" },
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@prisma/client": "^6.19.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"prisma": "^6.19.0"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "add-env",
|
|
69
|
+
"condition": { "prismaProvider": "postgresql" },
|
|
70
|
+
"envVars": {
|
|
71
|
+
"DATABASE_URL": "postgresql://username:password@localhost:5432/database_name"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"type": "add-env",
|
|
76
|
+
"condition": { "prismaProvider": "mysql" },
|
|
77
|
+
"envVars": {
|
|
78
|
+
"DATABASE_URL": "mysql://username:password@localhost:3306/database_name"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "add-env",
|
|
83
|
+
"condition": { "prismaProvider": "sqlite" },
|
|
84
|
+
"envVars": {
|
|
85
|
+
"DATABASE_URL": "file:./dev.db"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"type": "add-env",
|
|
90
|
+
"condition": { "prismaProvider": "mongodb" },
|
|
91
|
+
"envVars": {
|
|
92
|
+
"DATABASE_URL": "mongodb://localhost:27017/database_name"
|
|
22
93
|
}
|
|
23
94
|
}
|
|
24
95
|
],
|
|
25
96
|
"dependencies": {
|
|
26
|
-
"prisma": "^7.2.0",
|
|
27
|
-
"@prisma/client": "^7.2.0",
|
|
28
97
|
"dotenv": "^17.2.3"
|
|
29
98
|
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"prisma": "^7.2.0"
|
|
32
|
-
},
|
|
99
|
+
"devDependencies": {},
|
|
33
100
|
"scripts": {
|
|
34
|
-
"db:generate": "prisma generate",
|
|
35
|
-
"db:push": "prisma db push",
|
|
101
|
+
"db:generate": "npx prisma generate",
|
|
102
|
+
"db:push": "npx prisma db push",
|
|
36
103
|
"db:seed": "tsx prisma/seed.ts",
|
|
37
|
-
"db:migrate": "prisma migrate dev",
|
|
38
|
-
"db:studio": "prisma studio"
|
|
39
|
-
},
|
|
40
|
-
"envVars": {
|
|
41
|
-
"DATABASE_URL": "postgresql://username:password@localhost:5432/database_name"
|
|
104
|
+
"db:migrate": "npx prisma migrate dev",
|
|
105
|
+
"db:studio": "npx prisma studio"
|
|
42
106
|
}
|
|
43
107
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma",
|
|
3
3
|
"displayName": "Prisma",
|
|
4
|
-
"description": "Prisma ORM",
|
|
5
4
|
"category": "database",
|
|
6
5
|
"provider": "prisma",
|
|
7
6
|
"supportedFrameworks": ["nextjs", "express"],
|
|
@@ -11,7 +10,5 @@
|
|
|
11
10
|
"languages": ["typescript", "javascript"],
|
|
12
11
|
"packageManagers": ["npm", "yarn", "pnpm", "bun"]
|
|
13
12
|
},
|
|
14
|
-
"postInstall": [
|
|
15
|
-
"npx prisma generate"
|
|
16
|
-
]
|
|
13
|
+
"postInstall": ["npx prisma generate"]
|
|
17
14
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import app from "./app";
|
|
2
2
|
import { env } from "./config/env";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
async function startServer() {
|
|
5
|
+
const port = env.port;
|
|
6
|
+
app.listen(port, () => {
|
|
7
|
+
console.log(`Server is running on http://localhost:${port}`);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
console.
|
|
11
|
+
startServer().catch((err) => {
|
|
12
|
+
console.error("Failed to start server:", err);
|
|
13
|
+
process.exit(1);
|
|
8
14
|
});
|
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"outDir": "./dist",
|
|
4
3
|
"module": "ESNext",
|
|
5
4
|
"moduleResolution": "node",
|
|
6
5
|
"target": "ES2023",
|
|
7
|
-
"lib": ["ES2023"],
|
|
8
6
|
"strict": true,
|
|
9
|
-
"esModuleInterop": true
|
|
10
|
-
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"declaration": false,
|
|
16
|
-
"declarationMap": false,
|
|
17
|
-
"removeComments": false,
|
|
18
|
-
"noImplicitAny": true,
|
|
19
|
-
"noImplicitReturns": true,
|
|
20
|
-
"noImplicitThis": true,
|
|
21
|
-
"noUnusedLocals": true,
|
|
22
|
-
"noUnusedParameters": true,
|
|
23
|
-
"exactOptionalPropertyTypes": true,
|
|
24
|
-
"noEmitOnError": true,
|
|
25
|
-
"incremental": false,
|
|
26
|
-
"ignoreDeprecations": "5.0"
|
|
27
|
-
},
|
|
28
|
-
"include": ["src/**/*"],
|
|
29
|
-
"exclude": ["node_modules", "dist"]
|
|
7
|
+
"esModuleInterop": true
|
|
8
|
+
}
|
|
30
9
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const DATABASE_CONNECTION_STRINGS: {
|
|
2
|
-
readonly postgresql: "postgresql://user:password@localhost:5432/mydb?schema=public";
|
|
3
|
-
readonly mongodb: "mongodb://localhost:27017/mydb";
|
|
4
|
-
readonly mysql: "mysql://user:password@localhost:3306/mydb";
|
|
5
|
-
readonly sqlite: "file:./dev.db";
|
|
6
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DATABASE_CONNECTION_STRINGS = void 0;
|
|
4
|
-
exports.DATABASE_CONNECTION_STRINGS = {
|
|
5
|
-
postgresql: "postgresql://user:password@localhost:5432/mydb?schema=public",
|
|
6
|
-
mongodb: "mongodb://localhost:27017/mydb",
|
|
7
|
-
mysql: "mysql://user:password@localhost:3306/mydb",
|
|
8
|
-
sqlite: "file:./dev.db",
|
|
9
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import mongoose, { Document, Schema } from "mongoose";
|
|
2
|
-
|
|
3
|
-
export interface IUser extends Document {
|
|
4
|
-
name: string;
|
|
5
|
-
email: string;
|
|
6
|
-
createdAt: Date;
|
|
7
|
-
updatedAt: Date;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const UserSchema: Schema = new Schema(
|
|
11
|
-
{
|
|
12
|
-
name: {
|
|
13
|
-
type: String,
|
|
14
|
-
required: true,
|
|
15
|
-
trim: true,
|
|
16
|
-
},
|
|
17
|
-
email: {
|
|
18
|
-
type: String,
|
|
19
|
-
required: true,
|
|
20
|
-
unique: true,
|
|
21
|
-
lowercase: true,
|
|
22
|
-
trim: true,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
timestamps: true,
|
|
27
|
-
},
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
// Add indexes for better performance
|
|
31
|
-
UserSchema.index({ email: 1 });
|
|
32
|
-
UserSchema.index({ createdAt: -1 });
|
|
33
|
-
|
|
34
|
-
export default mongoose.models.User || mongoose.model<IUser>("User", UserSchema);
|
|
File without changes
|