create-kyro 0.6.0 → 0.8.0
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/index.js +4 -1
- package/package.json +1 -1
- package/src/generators/config.ts +19 -17
- package/src/generators/packagejson.ts +4 -0
- package/src/prompts.ts +13 -6
- package/test/generators.test.ts +28 -5
- package/test/integration.test.ts +7 -1
package/dist/index.js
CHANGED
|
@@ -189,7 +189,10 @@ function generatePackageJson(answers) {
|
|
|
189
189
|
private: true,
|
|
190
190
|
scripts,
|
|
191
191
|
dependencies: deps,
|
|
192
|
-
devDependencies: devDeps
|
|
192
|
+
devDependencies: devDeps,
|
|
193
|
+
overrides: {
|
|
194
|
+
"vite": "^7"
|
|
195
|
+
}
|
|
193
196
|
};
|
|
194
197
|
}
|
|
195
198
|
function formatPackageJson(pkg) {
|
package/package.json
CHANGED
package/src/generators/config.ts
CHANGED
|
@@ -29,25 +29,24 @@ export function generateKyroConfig(answers: Answers): string {
|
|
|
29
29
|
|
|
30
30
|
switch (answers.template) {
|
|
31
31
|
case "minimal":
|
|
32
|
-
templateCollections =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
templateCollections = "import { minimalCollections } from '@kyro-cms/core/templates';";
|
|
33
|
+
templateGlobals = "import { siteSettingsGlobal, seoSettingsGlobal } from '@kyro-cms/core/templates';";
|
|
34
|
+
break;
|
|
35
|
+
case "starter":
|
|
36
|
+
templateCollections = "import { starterCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
|
|
37
|
+
templateGlobals = "import { coreSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
36
38
|
break;
|
|
37
39
|
case "blog":
|
|
38
40
|
templateCollections = "import { blogCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
|
|
39
|
-
templateGlobals =
|
|
40
|
-
"import { allSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
41
|
+
templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
41
42
|
break;
|
|
42
43
|
case "ecommerce":
|
|
43
44
|
templateCollections = "import { ecommerceCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
|
|
44
|
-
templateGlobals =
|
|
45
|
-
"import { allSettingsGlobals, ecommerceSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
45
|
+
templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
46
46
|
break;
|
|
47
47
|
case "kitchen-sink":
|
|
48
|
-
templateCollections = `import { minimalCollections, blogCollections, ecommerceCollections, kitchenSinkCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';`;
|
|
49
|
-
templateGlobals =
|
|
50
|
-
"import { allSettingsGlobals, ecommerceSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
48
|
+
templateCollections = `import { minimalCollections, starterCollections, blogCollections, ecommerceCollections, kitchenSinkCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';`;
|
|
49
|
+
templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
51
50
|
break;
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -58,6 +57,10 @@ export function generateKyroConfig(answers: Answers): string {
|
|
|
58
57
|
if (answers.template === "minimal") {
|
|
59
58
|
collectionsConfig = ` collections: [
|
|
60
59
|
...Object.values(minimalCollections),
|
|
60
|
+
],`;
|
|
61
|
+
} else if (answers.template === "starter") {
|
|
62
|
+
collectionsConfig = ` collections: [
|
|
63
|
+
...Object.values(starterCollections),
|
|
61
64
|
...Object.values(mediaCollections),
|
|
62
65
|
...Object.values(authCollections),
|
|
63
66
|
],`;
|
|
@@ -76,6 +79,7 @@ export function generateKyroConfig(answers: Answers): string {
|
|
|
76
79
|
} else if (answers.template === "kitchen-sink") {
|
|
77
80
|
collectionsConfig = ` collections: [
|
|
78
81
|
...Object.values(minimalCollections),
|
|
82
|
+
...Object.values(starterCollections),
|
|
79
83
|
...Object.values(blogCollections),
|
|
80
84
|
...Object.values(ecommerceCollections),
|
|
81
85
|
...Object.values(kitchenSinkCollections),
|
|
@@ -86,13 +90,11 @@ export function generateKyroConfig(answers: Answers): string {
|
|
|
86
90
|
|
|
87
91
|
let globalsConfig = "";
|
|
88
92
|
if (answers.template === "minimal") {
|
|
93
|
+
globalsConfig = ` globals: [siteSettingsGlobal, seoSettingsGlobal],`;
|
|
94
|
+
} else if (answers.template === "starter") {
|
|
89
95
|
globalsConfig = ` globals: coreSettingsGlobals,`;
|
|
90
|
-
} else if (answers.template === "blog" || answers.template === "ecommerce") {
|
|
91
|
-
globalsConfig =
|
|
92
|
-
? ` globals: [...allSettingsGlobals, ...ecommerceSettingsGlobals],`
|
|
93
|
-
: ` globals: allSettingsGlobals,`;
|
|
94
|
-
} else if (answers.template === "kitchen-sink") {
|
|
95
|
-
globalsConfig = ` globals: [...allSettingsGlobals, ...ecommerceSettingsGlobals],`;
|
|
96
|
+
} else if (answers.template === "blog" || answers.template === "ecommerce" || answers.template === "kitchen-sink") {
|
|
97
|
+
globalsConfig = ` globals: allSettingsGlobals,`;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
return `${imports.join("\n")}
|
|
@@ -8,6 +8,7 @@ export interface PackageJson {
|
|
|
8
8
|
scripts: Record<string, string>;
|
|
9
9
|
dependencies: Record<string, string>;
|
|
10
10
|
devDependencies: Record<string, string>;
|
|
11
|
+
overrides?: Record<string, string>;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function generatePackageJson(
|
|
@@ -52,6 +53,9 @@ export function generatePackageJson(
|
|
|
52
53
|
scripts,
|
|
53
54
|
dependencies: deps,
|
|
54
55
|
devDependencies: devDeps,
|
|
56
|
+
overrides: {
|
|
57
|
+
"vite": "^7",
|
|
58
|
+
},
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
|
package/src/prompts.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { validateProjectName } from "./validators.js";
|
|
|
4
4
|
export interface Answers {
|
|
5
5
|
projectName: string;
|
|
6
6
|
database: "sqlite" | "postgres" | "mongodb";
|
|
7
|
-
template: "minimal" | "blog" | "ecommerce" | "kitchen-sink";
|
|
7
|
+
template: "minimal" | "starter" | "blog" | "ecommerce" | "kitchen-sink";
|
|
8
8
|
adminEmail: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -47,29 +47,36 @@ export async function promptUser(): Promise<Answers> {
|
|
|
47
47
|
name: "template",
|
|
48
48
|
message: "Starting template:",
|
|
49
49
|
hint: " ",
|
|
50
|
-
initial:
|
|
50
|
+
initial: 0,
|
|
51
51
|
choices: [
|
|
52
52
|
{
|
|
53
53
|
title: "Minimal",
|
|
54
54
|
description:
|
|
55
|
-
"
|
|
55
|
+
"Single Posts collection — just title & content. Perfect for getting started fast.",
|
|
56
56
|
value: "minimal",
|
|
57
57
|
},
|
|
58
|
+
{
|
|
59
|
+
title: "Starter",
|
|
60
|
+
description:
|
|
61
|
+
"Pages, Posts, Categories, Menu + core settings. Great for blogs and small sites.",
|
|
62
|
+
value: "starter",
|
|
63
|
+
},
|
|
58
64
|
{
|
|
59
65
|
title: "Blog",
|
|
60
|
-
description:
|
|
66
|
+
description:
|
|
67
|
+
"Posts, categories, media library + all settings. Full blog setup.",
|
|
61
68
|
value: "blog",
|
|
62
69
|
},
|
|
63
70
|
{
|
|
64
71
|
title: "E-commerce",
|
|
65
72
|
description:
|
|
66
|
-
"Products, orders, customers, coupons +
|
|
73
|
+
"Products, orders, customers, coupons + all settings. Online store ready.",
|
|
67
74
|
value: "ecommerce",
|
|
68
75
|
},
|
|
69
76
|
{
|
|
70
77
|
title: "Kitchen Sink",
|
|
71
78
|
description:
|
|
72
|
-
"Everything:
|
|
79
|
+
"Everything: all collections + all settings. Maximum feature set.",
|
|
73
80
|
value: "kitchen-sink",
|
|
74
81
|
},
|
|
75
82
|
],
|
package/test/generators.test.ts
CHANGED
|
@@ -15,7 +15,7 @@ const baseAnswers: Answers = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const allDatabases = ["sqlite", "postgres", "mongodb"] as const;
|
|
18
|
-
const allTemplates = ["minimal", "blog", "ecommerce", "kitchen-sink"] as const;
|
|
18
|
+
const allTemplates = ["minimal", "starter", "blog", "ecommerce", "kitchen-sink"] as const;
|
|
19
19
|
|
|
20
20
|
describe("generators", () => {
|
|
21
21
|
describe("generateKyroConfig", () => {
|
|
@@ -56,8 +56,16 @@ describe("generators", () => {
|
|
|
56
56
|
template: "minimal",
|
|
57
57
|
});
|
|
58
58
|
expect(minimal).toContain("minimalCollections");
|
|
59
|
-
expect(minimal).toContain("mediaCollections");
|
|
60
|
-
expect(minimal).toContain("authCollections");
|
|
59
|
+
expect(minimal).not.toContain("mediaCollections");
|
|
60
|
+
expect(minimal).not.toContain("authCollections");
|
|
61
|
+
|
|
62
|
+
const starter = generateKyroConfig({
|
|
63
|
+
...baseAnswers,
|
|
64
|
+
template: "starter",
|
|
65
|
+
});
|
|
66
|
+
expect(starter).toContain("starterCollections");
|
|
67
|
+
expect(starter).toContain("mediaCollections");
|
|
68
|
+
expect(starter).toContain("authCollections");
|
|
61
69
|
|
|
62
70
|
const blog = generateKyroConfig({ ...baseAnswers, template: "blog" });
|
|
63
71
|
expect(blog).toContain("blogCollections");
|
|
@@ -77,6 +85,7 @@ describe("generators", () => {
|
|
|
77
85
|
template: "kitchen-sink",
|
|
78
86
|
});
|
|
79
87
|
expect(kitchen).toContain("minimalCollections");
|
|
88
|
+
expect(kitchen).toContain("starterCollections");
|
|
80
89
|
expect(kitchen).toContain("blogCollections");
|
|
81
90
|
expect(kitchen).toContain("ecommerceCollections");
|
|
82
91
|
expect(kitchen).toContain("kitchenSinkCollections");
|
|
@@ -86,14 +95,22 @@ describe("generators", () => {
|
|
|
86
95
|
|
|
87
96
|
it("imports settings globals per template", () => {
|
|
88
97
|
const minimal = generateKyroConfig({ ...baseAnswers, template: "minimal" });
|
|
89
|
-
expect(minimal).toContain("
|
|
98
|
+
expect(minimal).toContain("siteSettingsGlobal");
|
|
99
|
+
expect(minimal).toContain("seoSettingsGlobal");
|
|
100
|
+
expect(minimal).not.toContain("coreSettingsGlobals");
|
|
101
|
+
|
|
102
|
+
const starter = generateKyroConfig({ ...baseAnswers, template: "starter" });
|
|
103
|
+
expect(starter).toContain("coreSettingsGlobals");
|
|
90
104
|
|
|
91
105
|
const blog = generateKyroConfig({ ...baseAnswers, template: "blog" });
|
|
92
106
|
expect(blog).toContain("allSettingsGlobals");
|
|
93
107
|
|
|
94
108
|
const ecommerce = generateKyroConfig({ ...baseAnswers, template: "ecommerce" });
|
|
95
109
|
expect(ecommerce).toContain("allSettingsGlobals");
|
|
96
|
-
expect(ecommerce).toContain("ecommerceSettingsGlobals");
|
|
110
|
+
expect(ecommerce).not.toContain("ecommerceSettingsGlobals");
|
|
111
|
+
|
|
112
|
+
const kitchen = generateKyroConfig({ ...baseAnswers, template: "kitchen-sink" });
|
|
113
|
+
expect(kitchen).toContain("allSettingsGlobals");
|
|
97
114
|
});
|
|
98
115
|
|
|
99
116
|
it("uses project name in config", () => {
|
|
@@ -234,6 +251,12 @@ describe("generators", () => {
|
|
|
234
251
|
expect(pkg.dependencies["@tailwindcss/vite"]).toBeDefined();
|
|
235
252
|
});
|
|
236
253
|
|
|
254
|
+
it("includes vite override for Astro compatibility", () => {
|
|
255
|
+
const pkg = generatePackageJson(baseAnswers);
|
|
256
|
+
expect(pkg.overrides).toBeDefined();
|
|
257
|
+
expect(pkg.overrides!["vite"]).toBe("^7");
|
|
258
|
+
});
|
|
259
|
+
|
|
237
260
|
it("never includes manual auth bootstrap script", () => {
|
|
238
261
|
const pkg = generatePackageJson(baseAnswers);
|
|
239
262
|
expect(pkg.scripts["db:bootstrap"]).toBeUndefined();
|
package/test/integration.test.ts
CHANGED
|
@@ -17,7 +17,7 @@ const baseAnswers: Answers = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const allDatabases = ["sqlite", "postgres", "mongodb"] as const;
|
|
20
|
-
const allTemplates = ["minimal", "blog", "ecommerce", "kitchen-sink"] as const;
|
|
20
|
+
const allTemplates = ["minimal", "starter", "blog", "ecommerce", "kitchen-sink"] as const;
|
|
21
21
|
|
|
22
22
|
describe("file generation", () => {
|
|
23
23
|
let tmpDir: string;
|
|
@@ -107,6 +107,12 @@ describe("file generation", () => {
|
|
|
107
107
|
expect(deps).not.toContain("lucide-react");
|
|
108
108
|
expect(deps).not.toContain("mysql2");
|
|
109
109
|
});
|
|
110
|
+
|
|
111
|
+
it("includes vite override for Astro compatibility", () => {
|
|
112
|
+
const pkg = JSON.parse(pkgContent);
|
|
113
|
+
expect(pkg.overrides).toBeDefined();
|
|
114
|
+
expect(pkg.overrides["vite"]).toBe("^7");
|
|
115
|
+
});
|
|
110
116
|
});
|
|
111
117
|
|
|
112
118
|
describe("kyro.config.ts", () => {
|