create-kyro 0.3.1 → 0.4.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/README.md +15 -12
- package/dist/index.js +62 -651
- package/package.json +1 -1
- package/src/generators/astro.ts +7 -70
- package/src/generators/config.ts +39 -38
- package/src/generators/files.ts +12 -507
- package/src/generators/packagejson.ts +6 -29
- package/src/index.ts +5 -5
- package/src/prompts.ts +0 -56
- package/test/generators.test.ts +17 -83
- package/test/validators.test.ts +0 -1
package/src/prompts.ts
CHANGED
|
@@ -4,10 +4,6 @@ import { validateProjectName } from "./validators.js";
|
|
|
4
4
|
export interface Answers {
|
|
5
5
|
projectName: string;
|
|
6
6
|
database: "sqlite" | "postgres" | "mysql" | "mongodb";
|
|
7
|
-
styling: "tailwind" | "cssmodules" | "styled" | "none";
|
|
8
|
-
auth: boolean;
|
|
9
|
-
versioning: boolean;
|
|
10
|
-
admin: boolean;
|
|
11
7
|
template: "minimal" | "blog" | "ecommerce" | "kitchen-sink";
|
|
12
8
|
}
|
|
13
9
|
|
|
@@ -50,58 +46,6 @@ export async function promptUser(): Promise<Answers> {
|
|
|
50
46
|
},
|
|
51
47
|
],
|
|
52
48
|
},
|
|
53
|
-
{
|
|
54
|
-
type: "select",
|
|
55
|
-
name: "styling",
|
|
56
|
-
message: "Styling:",
|
|
57
|
-
hint: " ",
|
|
58
|
-
choices: [
|
|
59
|
-
{
|
|
60
|
-
title: "Tailwind CSS",
|
|
61
|
-
description: "Utility-first CSS framework, excellent DX",
|
|
62
|
-
value: "tailwind",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
title: "CSS Modules",
|
|
66
|
-
description: "Scoped CSS, no extra dependencies",
|
|
67
|
-
value: "cssmodules",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
title: "Styled Components",
|
|
71
|
-
description: "CSS-in-JS with tagged template literals",
|
|
72
|
-
value: "styled",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
title: "None",
|
|
76
|
-
description: "Bring your own styling solution",
|
|
77
|
-
value: "none",
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
type: "toggle",
|
|
83
|
-
name: "auth",
|
|
84
|
-
message: "Add authentication (JWT)?",
|
|
85
|
-
initial: true,
|
|
86
|
-
active: "Yes",
|
|
87
|
-
inactive: "No",
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
type: "toggle",
|
|
91
|
-
name: "versioning",
|
|
92
|
-
message: "Add versioning/drafts?",
|
|
93
|
-
initial: true,
|
|
94
|
-
active: "Yes",
|
|
95
|
-
inactive: "No",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
type: "toggle",
|
|
99
|
-
name: "admin",
|
|
100
|
-
message: "Include admin dashboard?",
|
|
101
|
-
initial: true,
|
|
102
|
-
active: "Yes",
|
|
103
|
-
inactive: "No",
|
|
104
|
-
},
|
|
105
49
|
{
|
|
106
50
|
type: "select",
|
|
107
51
|
name: "template",
|
package/test/generators.test.ts
CHANGED
|
@@ -10,10 +10,6 @@ import {
|
|
|
10
10
|
const baseAnswers: Answers = {
|
|
11
11
|
projectName: "test-project",
|
|
12
12
|
database: "sqlite",
|
|
13
|
-
styling: "tailwind",
|
|
14
|
-
auth: true,
|
|
15
|
-
versioning: true,
|
|
16
|
-
admin: true,
|
|
17
13
|
template: "blog",
|
|
18
14
|
};
|
|
19
15
|
|
|
@@ -45,21 +41,11 @@ describe("generators", () => {
|
|
|
45
41
|
expect(config).toContain("MONGODB_URI");
|
|
46
42
|
});
|
|
47
43
|
|
|
48
|
-
it("includes auth
|
|
49
|
-
const config = generateKyroConfig(
|
|
44
|
+
it("includes auth (always enabled)", () => {
|
|
45
|
+
const config = generateKyroConfig(baseAnswers);
|
|
50
46
|
expect(config).toContain("auth: true");
|
|
51
47
|
});
|
|
52
48
|
|
|
53
|
-
it("omits auth when disabled", () => {
|
|
54
|
-
const config = generateKyroConfig({ ...baseAnswers, auth: false });
|
|
55
|
-
expect(config).not.toContain("auth: true");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("includes versioning when enabled", () => {
|
|
59
|
-
const config = generateKyroConfig({ ...baseAnswers, versioning: true });
|
|
60
|
-
expect(config).toContain("versioning: true");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
49
|
it("imports correct template collections", () => {
|
|
64
50
|
const minimal = generateKyroConfig({
|
|
65
51
|
...baseAnswers,
|
|
@@ -86,14 +72,6 @@ describe("generators", () => {
|
|
|
86
72
|
expect(kitchen).toContain("kitchenSinkCollections");
|
|
87
73
|
});
|
|
88
74
|
|
|
89
|
-
it("includes all API protocols", () => {
|
|
90
|
-
const config = generateKyroConfig(baseAnswers);
|
|
91
|
-
expect(config).toContain("rest: true");
|
|
92
|
-
expect(config).toContain("graphql: true");
|
|
93
|
-
expect(config).toContain("trpc: true");
|
|
94
|
-
expect(config).toContain("websocket: true");
|
|
95
|
-
});
|
|
96
|
-
|
|
97
75
|
it("uses project name in config", () => {
|
|
98
76
|
const config = generateKyroConfig(baseAnswers);
|
|
99
77
|
expect(config).toContain("name: 'test-project'");
|
|
@@ -101,100 +79,56 @@ describe("generators", () => {
|
|
|
101
79
|
});
|
|
102
80
|
|
|
103
81
|
describe("generateAstroConfig", () => {
|
|
104
|
-
it("includes
|
|
82
|
+
it("includes kyro integration", () => {
|
|
105
83
|
const config = generateAstroConfig(baseAnswers);
|
|
106
|
-
expect(config).toContain("@
|
|
107
|
-
expect(config).toContain("
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("includes node adapter when admin enabled", () => {
|
|
111
|
-
const config = generateAstroConfig(baseAnswers);
|
|
112
|
-
expect(config).toContain("@astrojs/node");
|
|
113
|
-
expect(config).toContain("standalone");
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("includes SSR externals for native modules", () => {
|
|
117
|
-
const config = generateAstroConfig(baseAnswers);
|
|
118
|
-
expect(config).toContain("better-sqlite3");
|
|
119
|
-
expect(config).toContain("sharp");
|
|
120
|
-
expect(config).toContain("ssr");
|
|
121
|
-
expect(config).toContain("optimizeDeps");
|
|
84
|
+
expect(config).toContain("@kyro-cms/core");
|
|
85
|
+
expect(config).toContain("kyroAdmin");
|
|
122
86
|
});
|
|
123
87
|
|
|
124
88
|
it("sets correct server port", () => {
|
|
125
89
|
const config = generateAstroConfig(baseAnswers);
|
|
126
90
|
expect(config).toContain("port: 4321");
|
|
127
91
|
});
|
|
128
|
-
|
|
129
|
-
it("excludes react when not using tailwind", () => {
|
|
130
|
-
const answers = { ...baseAnswers, styling: "none" as const };
|
|
131
|
-
const config = generateAstroConfig(answers);
|
|
132
|
-
expect(config).not.toContain("@astrojs/react");
|
|
133
|
-
});
|
|
134
92
|
});
|
|
135
93
|
|
|
136
94
|
describe("generatePackageJson", () => {
|
|
137
95
|
it("includes core dependency", () => {
|
|
138
|
-
const pkg = generatePackageJson(baseAnswers
|
|
96
|
+
const pkg = generatePackageJson(baseAnswers);
|
|
139
97
|
expect(pkg.dependencies["@kyro-cms/core"]).toBeDefined();
|
|
140
98
|
});
|
|
141
99
|
|
|
142
|
-
it("includes admin
|
|
143
|
-
const pkg = generatePackageJson(baseAnswers
|
|
100
|
+
it("includes admin dependency", () => {
|
|
101
|
+
const pkg = generatePackageJson(baseAnswers);
|
|
144
102
|
expect(pkg.dependencies["@kyro-cms/admin"]).toBeDefined();
|
|
145
|
-
expect(pkg.dependencies["@astrojs/node"]).toBeDefined();
|
|
146
103
|
});
|
|
147
104
|
|
|
148
|
-
it("
|
|
149
|
-
const pkg = generatePackageJson(
|
|
150
|
-
|
|
151
|
-
"/test",
|
|
152
|
-
);
|
|
153
|
-
expect(pkg.dependencies["@kyro-cms/admin"]).toBeUndefined();
|
|
105
|
+
it("includes astro dependency", () => {
|
|
106
|
+
const pkg = generatePackageJson(baseAnswers);
|
|
107
|
+
expect(pkg.dependencies["astro"]).toBeDefined();
|
|
154
108
|
});
|
|
155
109
|
|
|
156
|
-
it("includes database-specific dependencies", () => {
|
|
157
|
-
const pg = generatePackageJson(
|
|
158
|
-
{ ...baseAnswers, database: "postgres" },
|
|
159
|
-
"/test",
|
|
160
|
-
);
|
|
110
|
+
it("includes database-specific peer dependencies", () => {
|
|
111
|
+
const pg = generatePackageJson({ ...baseAnswers, database: "postgres" });
|
|
161
112
|
expect(pg.dependencies["pg"]).toBeDefined();
|
|
162
113
|
|
|
163
|
-
const mysql = generatePackageJson(
|
|
164
|
-
{ ...baseAnswers, database: "mysql" },
|
|
165
|
-
"/test",
|
|
166
|
-
);
|
|
114
|
+
const mysql = generatePackageJson({ ...baseAnswers, database: "mysql" });
|
|
167
115
|
expect(mysql.dependencies["mysql2"]).toBeDefined();
|
|
168
|
-
|
|
169
|
-
const mongo = generatePackageJson(
|
|
170
|
-
{ ...baseAnswers, database: "mongodb" },
|
|
171
|
-
"/test",
|
|
172
|
-
);
|
|
173
|
-
expect(mongo.dependencies["mongodb"]).toBeDefined();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("includes auth bootstrap script when auth enabled", () => {
|
|
177
|
-
const pkg = generatePackageJson({ ...baseAnswers, auth: true }, "/test");
|
|
178
|
-
expect(pkg.scripts["db:bootstrap"]).toBeDefined();
|
|
179
116
|
});
|
|
180
117
|
|
|
181
118
|
it("includes SQLite scripts for SQLite database", () => {
|
|
182
|
-
const pkg = generatePackageJson(
|
|
183
|
-
{ ...baseAnswers, database: "sqlite" },
|
|
184
|
-
"/test",
|
|
185
|
-
);
|
|
119
|
+
const pkg = generatePackageJson(baseAnswers);
|
|
186
120
|
expect(pkg.scripts["db:generate"]).toBeDefined();
|
|
187
121
|
expect(pkg.scripts["db:push"]).toBeDefined();
|
|
188
122
|
expect(pkg.scripts["db:studio"]).toBeDefined();
|
|
189
123
|
});
|
|
190
124
|
|
|
191
125
|
it("has correct project name", () => {
|
|
192
|
-
const pkg = generatePackageJson(baseAnswers
|
|
126
|
+
const pkg = generatePackageJson(baseAnswers);
|
|
193
127
|
expect(pkg.name).toBe("test-project");
|
|
194
128
|
});
|
|
195
129
|
|
|
196
130
|
it("formats as valid JSON string", () => {
|
|
197
|
-
const pkg = generatePackageJson(baseAnswers
|
|
131
|
+
const pkg = generatePackageJson(baseAnswers);
|
|
198
132
|
const formatted = formatPackageJson(pkg);
|
|
199
133
|
expect(() => JSON.parse(formatted)).not.toThrow();
|
|
200
134
|
});
|