create-kyro 0.9.0 → 0.9.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/dist/index.js CHANGED
@@ -206,7 +206,10 @@ function formatPackageJson(pkg) {
206
206
 
207
207
  // src/generators/config.ts
208
208
  function generateKyroConfig(answers) {
209
- const imports = ["import { defineConfig } from '@kyro-cms/core';"];
209
+ const imports = [
210
+ "import { defineKyroConfig } from '@kyro-cms/core';",
211
+ "import { templateCollections } from '@kyro-cms/core/templates';"
212
+ ];
210
213
  if (answers.database === "sqlite") {
211
214
  imports.push("import { createLocalAdapter } from '@kyro-cms/core';");
212
215
  } else if (answers.database === "postgres") {
@@ -226,66 +229,27 @@ function generateKyroConfig(answers) {
226
229
  adapterLines.push(` connectionString: process.env.MONGODB_URI,`);
227
230
  adapterLines.push(` }),`);
228
231
  }
229
- let templateCollections = "";
230
232
  let templateGlobals = "";
231
233
  switch (answers.template) {
232
234
  case "minimal":
233
- templateCollections = "import { minimalCollections } from '@kyro-cms/core/templates';";
234
235
  templateGlobals = "import { siteSettingsGlobal, seoSettingsGlobal } from '@kyro-cms/core/templates';";
235
236
  break;
236
237
  case "starter":
237
- templateCollections = "import { starterCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
238
238
  templateGlobals = "import { coreSettingsGlobals } from '@kyro-cms/core/templates';";
239
239
  break;
240
240
  case "blog":
241
- templateCollections = "import { blogCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
242
241
  templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
243
242
  break;
244
243
  case "ecommerce":
245
- templateCollections = "import { ecommerceCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
246
244
  templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
247
245
  break;
248
246
  case "kitchen-sink":
249
- templateCollections = `import { minimalCollections, starterCollections, blogCollections, ecommerceCollections, kitchenSinkCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';`;
250
247
  templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
251
248
  break;
252
249
  }
253
- if (templateCollections) imports.push(templateCollections);
254
250
  if (templateGlobals) imports.push(templateGlobals);
255
- let collectionsConfig = "";
256
- if (answers.template === "minimal") {
257
- collectionsConfig = ` collections: [
258
- ...Object.values(minimalCollections),
259
- ],`;
260
- } else if (answers.template === "starter") {
261
- collectionsConfig = ` collections: [
262
- ...Object.values(starterCollections),
263
- ...Object.values(mediaCollections),
264
- ...Object.values(authCollections),
265
- ],`;
266
- } else if (answers.template === "blog") {
267
- collectionsConfig = ` collections: [
268
- ...Object.values(blogCollections),
269
- ...Object.values(mediaCollections),
270
- ...Object.values(authCollections),
271
- ],`;
272
- } else if (answers.template === "ecommerce") {
273
- collectionsConfig = ` collections: [
274
- ...Object.values(ecommerceCollections),
275
- ...Object.values(mediaCollections),
276
- ...Object.values(authCollections),
277
- ],`;
278
- } else if (answers.template === "kitchen-sink") {
279
- collectionsConfig = ` collections: [
280
- ...Object.values(minimalCollections),
281
- ...Object.values(starterCollections),
282
- ...Object.values(blogCollections),
283
- ...Object.values(ecommerceCollections),
284
- ...Object.values(kitchenSinkCollections),
285
- ...Object.values(mediaCollections),
286
- ...Object.values(authCollections),
287
- ],`;
288
- }
251
+ const collectionKey = answers.template === "kitchen-sink" ? '["kitchen-sink"]' : `.${answers.template}`;
252
+ const collectionsConfig = ` collections: templateCollections${collectionKey},`;
289
253
  let globalsConfig = "";
290
254
  if (answers.template === "minimal") {
291
255
  globalsConfig = ` globals: [siteSettingsGlobal, seoSettingsGlobal],`;
@@ -296,9 +260,9 @@ function generateKyroConfig(answers) {
296
260
  }
297
261
  return `${imports.join("\n")}
298
262
 
299
- export default defineConfig({
300
- name: '${answers.projectName}',
301
- prefix: '/api',
263
+ export default defineKyroConfig({
264
+ // name: '${answers.projectName}',
265
+ // prefix: '/api',
302
266
  ${adapterLines.join("\n")}
303
267
  ${collectionsConfig}
304
268
  ${globalsConfig}
@@ -320,7 +284,26 @@ export default defineConfig({
320
284
  output: 'server',
321
285
  integrations: [react(), kyro({ adminPath: '/admin', apiPath: '/api' }), kyroAdmin({ basePath: '/admin', apiPath: '/api' })],
322
286
  vite: {
323
- plugins: [tailwind()],
287
+ plugins: [
288
+ tailwind(),
289
+ {
290
+ name: 'use-sync-external-store-shim-fix',
291
+ enforce: 'pre',
292
+ resolveId(id) {
293
+ if (
294
+ id === 'use-sync-external-store/shim' ||
295
+ id === 'use-sync-external-store/shim/index.js'
296
+ ) {
297
+ return '\\0virtual:use-sync-external-store-shim';
298
+ }
299
+ },
300
+ load(id) {
301
+ if (id === '\\0virtual:use-sync-external-store-shim') {
302
+ return \`export { useSyncExternalStore } from 'react';\`;
303
+ }
304
+ },
305
+ },
306
+ ],
324
307
  },
325
308
  server: {
326
309
  port: 4321,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kyro",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Interactive scaffolding for Kyro CMS projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,7 +11,26 @@ export default defineConfig({
11
11
  output: 'server',
12
12
  integrations: [react(), kyro({ adminPath: '/admin', apiPath: '/api' }), kyroAdmin({ basePath: '/admin', apiPath: '/api' })],
13
13
  vite: {
14
- plugins: [tailwind()],
14
+ plugins: [
15
+ tailwind(),
16
+ {
17
+ name: 'use-sync-external-store-shim-fix',
18
+ enforce: 'pre',
19
+ resolveId(id) {
20
+ if (
21
+ id === 'use-sync-external-store/shim' ||
22
+ id === 'use-sync-external-store/shim/index.js'
23
+ ) {
24
+ return '\\0virtual:use-sync-external-store-shim';
25
+ }
26
+ },
27
+ load(id) {
28
+ if (id === '\\0virtual:use-sync-external-store-shim') {
29
+ return \`export { useSyncExternalStore } from 'react';\`;
30
+ }
31
+ },
32
+ },
33
+ ],
15
34
  },
16
35
  server: {
17
36
  port: 4321,
@@ -1,7 +1,10 @@
1
1
  import type { Answers } from "../prompts.js";
2
2
 
3
3
  export function generateKyroConfig(answers: Answers): string {
4
- const imports: string[] = ["import { defineConfig } from '@kyro-cms/core';"];
4
+ const imports: string[] = [
5
+ "import { defineKyroConfig } from '@kyro-cms/core';",
6
+ "import { templateCollections } from '@kyro-cms/core/templates';",
7
+ ];
5
8
 
6
9
  if (answers.database === "sqlite") {
7
10
  imports.push("import { createLocalAdapter } from '@kyro-cms/core';");
@@ -24,69 +27,33 @@ export function generateKyroConfig(answers: Answers): string {
24
27
  adapterLines.push(` }),`);
25
28
  }
26
29
 
27
- let templateCollections = "";
28
30
  let templateGlobals = "";
29
-
30
31
  switch (answers.template) {
31
32
  case "minimal":
32
- templateCollections = "import { minimalCollections } from '@kyro-cms/core/templates';";
33
33
  templateGlobals = "import { siteSettingsGlobal, seoSettingsGlobal } from '@kyro-cms/core/templates';";
34
34
  break;
35
35
  case "starter":
36
- templateCollections = "import { starterCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
37
36
  templateGlobals = "import { coreSettingsGlobals } from '@kyro-cms/core/templates';";
38
37
  break;
39
38
  case "blog":
40
- templateCollections = "import { blogCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
41
39
  templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
42
40
  break;
43
41
  case "ecommerce":
44
- templateCollections = "import { ecommerceCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';";
45
42
  templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
46
43
  break;
47
44
  case "kitchen-sink":
48
- templateCollections = `import { minimalCollections, starterCollections, blogCollections, ecommerceCollections, kitchenSinkCollections, mediaCollections, authCollections } from '@kyro-cms/core/templates';`;
49
45
  templateGlobals = "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
50
46
  break;
51
47
  }
52
48
 
53
- if (templateCollections) imports.push(templateCollections);
54
49
  if (templateGlobals) imports.push(templateGlobals);
55
50
 
56
- let collectionsConfig = "";
57
- if (answers.template === "minimal") {
58
- collectionsConfig = ` collections: [
59
- ...Object.values(minimalCollections),
60
- ],`;
61
- } else if (answers.template === "starter") {
62
- collectionsConfig = ` collections: [
63
- ...Object.values(starterCollections),
64
- ...Object.values(mediaCollections),
65
- ...Object.values(authCollections),
66
- ],`;
67
- } else if (answers.template === "blog") {
68
- collectionsConfig = ` collections: [
69
- ...Object.values(blogCollections),
70
- ...Object.values(mediaCollections),
71
- ...Object.values(authCollections),
72
- ],`;
73
- } else if (answers.template === "ecommerce") {
74
- collectionsConfig = ` collections: [
75
- ...Object.values(ecommerceCollections),
76
- ...Object.values(mediaCollections),
77
- ...Object.values(authCollections),
78
- ],`;
79
- } else if (answers.template === "kitchen-sink") {
80
- collectionsConfig = ` collections: [
81
- ...Object.values(minimalCollections),
82
- ...Object.values(starterCollections),
83
- ...Object.values(blogCollections),
84
- ...Object.values(ecommerceCollections),
85
- ...Object.values(kitchenSinkCollections),
86
- ...Object.values(mediaCollections),
87
- ...Object.values(authCollections),
88
- ],`;
89
- }
51
+ const collectionKey =
52
+ answers.template === "kitchen-sink"
53
+ ? '["kitchen-sink"]'
54
+ : `.${answers.template}`;
55
+
56
+ const collectionsConfig = ` collections: templateCollections${collectionKey},`;
90
57
 
91
58
  let globalsConfig = "";
92
59
  if (answers.template === "minimal") {
@@ -99,9 +66,9 @@ export function generateKyroConfig(answers: Answers): string {
99
66
 
100
67
  return `${imports.join("\n")}
101
68
 
102
- export default defineConfig({
103
- name: '${answers.projectName}',
104
- prefix: '/api',
69
+ export default defineKyroConfig({
70
+ // name: '${answers.projectName}',
71
+ // prefix: '/api',
105
72
  ${adapterLines.join("\n")}
106
73
  ${collectionsConfig}
107
74
  ${globalsConfig}
@@ -55,42 +55,29 @@ describe("generators", () => {
55
55
  ...baseAnswers,
56
56
  template: "minimal",
57
57
  });
58
- expect(minimal).toContain("minimalCollections");
59
- expect(minimal).not.toContain("mediaCollections");
60
- expect(minimal).not.toContain("authCollections");
58
+ expect(minimal).toContain("templateCollections.minimal");
59
+ expect(minimal).not.toContain("templateCollections.starter");
61
60
 
62
61
  const starter = generateKyroConfig({
63
62
  ...baseAnswers,
64
63
  template: "starter",
65
64
  });
66
- expect(starter).toContain("starterCollections");
67
- expect(starter).toContain("mediaCollections");
68
- expect(starter).toContain("authCollections");
65
+ expect(starter).toContain("templateCollections.starter");
69
66
 
70
67
  const blog = generateKyroConfig({ ...baseAnswers, template: "blog" });
71
- expect(blog).toContain("blogCollections");
72
- expect(blog).toContain("mediaCollections");
73
- expect(blog).toContain("authCollections");
68
+ expect(blog).toContain("templateCollections.blog");
74
69
 
75
70
  const ecommerce = generateKyroConfig({
76
71
  ...baseAnswers,
77
72
  template: "ecommerce",
78
73
  });
79
- expect(ecommerce).toContain("ecommerceCollections");
80
- expect(ecommerce).toContain("mediaCollections");
81
- expect(ecommerce).toContain("authCollections");
74
+ expect(ecommerce).toContain("templateCollections.ecommerce");
82
75
 
83
76
  const kitchen = generateKyroConfig({
84
77
  ...baseAnswers,
85
78
  template: "kitchen-sink",
86
79
  });
87
- expect(kitchen).toContain("minimalCollections");
88
- expect(kitchen).toContain("starterCollections");
89
- expect(kitchen).toContain("blogCollections");
90
- expect(kitchen).toContain("ecommerceCollections");
91
- expect(kitchen).toContain("kitchenSinkCollections");
92
- expect(kitchen).toContain("mediaCollections");
93
- expect(kitchen).toContain("authCollections");
80
+ expect(kitchen).toContain('templateCollections["kitchen-sink"]');
94
81
  });
95
82
 
96
83
  it("imports settings globals per template", () => {
@@ -133,7 +120,8 @@ describe("generators", () => {
133
120
 
134
121
  it("uses correct template imports path", () => {
135
122
  const config = generateKyroConfig(baseAnswers);
136
- expect(config).toContain("@kyro-cms/core/templates");
123
+ expect(config).toContain("import { templateCollections } from '@kyro-cms/core/templates'");
124
+ expect(config).toContain("defineKyroConfig");
137
125
  });
138
126
  });
139
127