create-kyro 0.4.0 → 0.4.2
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 +1 -1
- package/dist/index.js +7 -15
- package/package.json +1 -1
- package/src/generators/config.ts +1 -3
- package/src/generators/files.ts +7 -3
- package/src/generators/packagejson.ts +0 -6
- package/src/prompts.ts +1 -6
- package/test/generators.test.ts +0 -21
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ npx create-kyro
|
|
|
18
18
|
|
|
19
19
|
1. **Interactive Setup** - Prompts for:
|
|
20
20
|
- Project name
|
|
21
|
-
- Database (SQLite, PostgreSQL,
|
|
21
|
+
- Database (SQLite, PostgreSQL, MongoDB)
|
|
22
22
|
- Starting template (Minimal, Blog, E-commerce, Kitchen Sink)
|
|
23
23
|
|
|
24
24
|
2. **Project Generation** - Creates:
|
package/dist/index.js
CHANGED
|
@@ -52,11 +52,6 @@ async function promptUser() {
|
|
|
52
52
|
description: "Recommended for production. Robust and scalable.",
|
|
53
53
|
value: "postgres"
|
|
54
54
|
},
|
|
55
|
-
{
|
|
56
|
-
title: "MySQL",
|
|
57
|
-
description: "Popular choice for web applications.",
|
|
58
|
-
value: "mysql"
|
|
59
|
-
},
|
|
60
55
|
{
|
|
61
56
|
title: "MongoDB",
|
|
62
57
|
description: "Best for flexible, document-based schemas.",
|
|
@@ -162,11 +157,6 @@ function generatePackageJson(answers) {
|
|
|
162
157
|
const devDeps = {
|
|
163
158
|
"typescript": "^5.7.3"
|
|
164
159
|
};
|
|
165
|
-
if (answers.database === "postgres") {
|
|
166
|
-
deps["pg"] = "^8.13.1";
|
|
167
|
-
} else if (answers.database === "mysql") {
|
|
168
|
-
deps["mysql2"] = "^3.12.0";
|
|
169
|
-
}
|
|
170
160
|
const scripts = {
|
|
171
161
|
"dev": "astro dev",
|
|
172
162
|
"build": "astro build",
|
|
@@ -198,15 +188,13 @@ function generateKyroConfig(answers) {
|
|
|
198
188
|
imports.push("import { createLocalAdapter } from '@kyro-cms/core';");
|
|
199
189
|
} else if (answers.database === "postgres") {
|
|
200
190
|
imports.push("import { createDrizzleAdapter } from '@kyro-cms/core';");
|
|
201
|
-
} else if (answers.database === "mysql") {
|
|
202
|
-
imports.push("import { createDrizzleAdapter } from '@kyro-cms/core';");
|
|
203
191
|
} else if (answers.database === "mongodb") {
|
|
204
192
|
imports.push("import { createMongoDBAdapter } from '@kyro-cms/core';");
|
|
205
193
|
}
|
|
206
194
|
const adapterLines = [];
|
|
207
195
|
if (answers.database === "sqlite") {
|
|
208
196
|
adapterLines.push(` adapter: createLocalAdapter({ path: './data.db' }),`);
|
|
209
|
-
} else if (answers.database === "postgres"
|
|
197
|
+
} else if (answers.database === "postgres") {
|
|
210
198
|
adapterLines.push(` adapter: createDrizzleAdapter({`);
|
|
211
199
|
adapterLines.push(` connectionString: process.env.DATABASE_URL,`);
|
|
212
200
|
adapterLines.push(` }),`);
|
|
@@ -301,7 +289,11 @@ function generateProjectFiles(answers, projectDir) {
|
|
|
301
289
|
mkdirSync(pagesDir, { recursive: true });
|
|
302
290
|
mkdirSync(publicDir, { recursive: true });
|
|
303
291
|
if (answers.database === "sqlite") {
|
|
304
|
-
|
|
292
|
+
envDbSection = "# SQLite (local) - no additional config needed";
|
|
293
|
+
} else if (answers.database === "postgres") {
|
|
294
|
+
envDbSection = "# Database connection (PostgreSQL)\nDATABASE_URL=postgresql://user:password@localhost:5432/kyro_cms";
|
|
295
|
+
} else {
|
|
296
|
+
envDbSection = "# MongoDB connection\nMONGODB_URI=mongodb://localhost:27017/kyro_cms";
|
|
305
297
|
}
|
|
306
298
|
const tsconfig = `{
|
|
307
299
|
"extends": "astro/tsconfigs/strict",
|
|
@@ -348,7 +340,7 @@ Visit [https://kyro.dev](https://kyro.dev) for full documentation.
|
|
|
348
340
|
const envExample = `# Kyro CMS Configuration
|
|
349
341
|
# Copy this file to .env and fill in your values
|
|
350
342
|
|
|
351
|
-
${answers.database === "sqlite" ? "# SQLite (local) - no additional config needed" : answers.database === "postgres"
|
|
343
|
+
${answers.database === "sqlite" ? "# SQLite (local) - no additional config needed" : answers.database === "postgres" ? "# Database connection (PostgreSQL)\nDATABASE_URL=postgresql://user:password@localhost:5432/kyro_cms" : "# MongoDB connection\nMONGODB_URI=mongodb://localhost:27017/kyro_cms"}
|
|
352
344
|
|
|
353
345
|
# JWT secret for authentication tokens
|
|
354
346
|
JWT_SECRET=change-this-to-a-random-64-character-string
|
package/package.json
CHANGED
package/src/generators/config.ts
CHANGED
|
@@ -7,8 +7,6 @@ export function generateKyroConfig(answers: Answers): string {
|
|
|
7
7
|
imports.push("import { createLocalAdapter } from '@kyro-cms/core';");
|
|
8
8
|
} else if (answers.database === "postgres") {
|
|
9
9
|
imports.push("import { createDrizzleAdapter } from '@kyro-cms/core';");
|
|
10
|
-
} else if (answers.database === "mysql") {
|
|
11
|
-
imports.push("import { createDrizzleAdapter } from '@kyro-cms/core';");
|
|
12
10
|
} else if (answers.database === "mongodb") {
|
|
13
11
|
imports.push("import { createMongoDBAdapter } from '@kyro-cms/core';");
|
|
14
12
|
}
|
|
@@ -16,7 +14,7 @@ export function generateKyroConfig(answers: Answers): string {
|
|
|
16
14
|
const adapterLines: string[] = [];
|
|
17
15
|
if (answers.database === "sqlite") {
|
|
18
16
|
adapterLines.push(` adapter: createLocalAdapter({ path: './data.db' }),`);
|
|
19
|
-
} else if (answers.database === "postgres"
|
|
17
|
+
} else if (answers.database === "postgres") {
|
|
20
18
|
adapterLines.push(` adapter: createDrizzleAdapter({`);
|
|
21
19
|
adapterLines.push(` connectionString: process.env.DATABASE_URL,`);
|
|
22
20
|
adapterLines.push(` }),`);
|
package/src/generators/files.ts
CHANGED
|
@@ -14,7 +14,11 @@ export function generateProjectFiles(
|
|
|
14
14
|
mkdirSync(publicDir, { recursive: true });
|
|
15
15
|
|
|
16
16
|
if (answers.database === "sqlite") {
|
|
17
|
-
|
|
17
|
+
envDbSection = "# SQLite (local) - no additional config needed";
|
|
18
|
+
} else if (answers.database === "postgres") {
|
|
19
|
+
envDbSection = "# Database connection (PostgreSQL)\nDATABASE_URL=postgresql://user:password@localhost:5432/kyro_cms";
|
|
20
|
+
} else {
|
|
21
|
+
envDbSection = "# MongoDB connection\nMONGODB_URI=mongodb://localhost:27017/kyro_cms";
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
const tsconfig = `{
|
|
@@ -71,8 +75,8 @@ Visit [https://kyro.dev](https://kyro.dev) for full documentation.
|
|
|
71
75
|
${
|
|
72
76
|
answers.database === "sqlite"
|
|
73
77
|
? "# SQLite (local) - no additional config needed"
|
|
74
|
-
: answers.database === "postgres"
|
|
75
|
-
? "# Database connection (PostgreSQL
|
|
78
|
+
: answers.database === "postgres"
|
|
79
|
+
? "# Database connection (PostgreSQL)\nDATABASE_URL=postgresql://user:password@localhost:5432/kyro_cms"
|
|
76
80
|
: "# MongoDB connection\nMONGODB_URI=mongodb://localhost:27017/kyro_cms"
|
|
77
81
|
}
|
|
78
82
|
|
|
@@ -23,12 +23,6 @@ export function generatePackageJson(
|
|
|
23
23
|
"typescript": "^5.7.3",
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
if (answers.database === "postgres") {
|
|
27
|
-
deps["pg"] = "^8.13.1";
|
|
28
|
-
} else if (answers.database === "mysql") {
|
|
29
|
-
deps["mysql2"] = "^3.12.0";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
26
|
const scripts: Record<string, string> = {
|
|
33
27
|
"dev": "astro dev",
|
|
34
28
|
"build": "astro build",
|
package/src/prompts.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { validateProjectName } from "./validators.js";
|
|
|
3
3
|
|
|
4
4
|
export interface Answers {
|
|
5
5
|
projectName: string;
|
|
6
|
-
database: "sqlite" | "postgres" | "
|
|
6
|
+
database: "sqlite" | "postgres" | "mongodb";
|
|
7
7
|
template: "minimal" | "blog" | "ecommerce" | "kitchen-sink";
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -34,11 +34,6 @@ export async function promptUser(): Promise<Answers> {
|
|
|
34
34
|
description: "Recommended for production. Robust and scalable.",
|
|
35
35
|
value: "postgres",
|
|
36
36
|
},
|
|
37
|
-
{
|
|
38
|
-
title: "MySQL",
|
|
39
|
-
description: "Popular choice for web applications.",
|
|
40
|
-
value: "mysql",
|
|
41
|
-
},
|
|
42
37
|
{
|
|
43
38
|
title: "MongoDB",
|
|
44
39
|
description: "Best for flexible, document-based schemas.",
|
package/test/generators.test.ts
CHANGED
|
@@ -28,12 +28,6 @@ describe("generators", () => {
|
|
|
28
28
|
expect(config).toContain("DATABASE_URL");
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it("generates config with MySQL adapter", () => {
|
|
32
|
-
const answers = { ...baseAnswers, database: "mysql" as const };
|
|
33
|
-
const config = generateKyroConfig(answers);
|
|
34
|
-
expect(config).toContain("createDrizzleAdapter");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
31
|
it("generates config with MongoDB adapter", () => {
|
|
38
32
|
const answers = { ...baseAnswers, database: "mongodb" as const };
|
|
39
33
|
const config = generateKyroConfig(answers);
|
|
@@ -107,21 +101,6 @@ describe("generators", () => {
|
|
|
107
101
|
expect(pkg.dependencies["astro"]).toBeDefined();
|
|
108
102
|
});
|
|
109
103
|
|
|
110
|
-
it("includes database-specific peer dependencies", () => {
|
|
111
|
-
const pg = generatePackageJson({ ...baseAnswers, database: "postgres" });
|
|
112
|
-
expect(pg.dependencies["pg"]).toBeDefined();
|
|
113
|
-
|
|
114
|
-
const mysql = generatePackageJson({ ...baseAnswers, database: "mysql" });
|
|
115
|
-
expect(mysql.dependencies["mysql2"]).toBeDefined();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("includes SQLite scripts for SQLite database", () => {
|
|
119
|
-
const pkg = generatePackageJson(baseAnswers);
|
|
120
|
-
expect(pkg.scripts["db:generate"]).toBeDefined();
|
|
121
|
-
expect(pkg.scripts["db:push"]).toBeDefined();
|
|
122
|
-
expect(pkg.scripts["db:studio"]).toBeDefined();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
104
|
it("has correct project name", () => {
|
|
126
105
|
const pkg = generatePackageJson(baseAnswers);
|
|
127
106
|
expect(pkg.name).toBe("test-project");
|