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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kyro",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Interactive scaffolding for Kyro CMS projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,82 +1,19 @@
1
1
  import type { Answers } from "../prompts.js";
2
2
 
3
3
  export function generateAstroConfig(answers: Answers): string {
4
- const integrations: string[] = [];
5
- const vitePlugins: string[] = [];
6
- const vitePluginsLength = vitePlugins.length;
7
-
8
- if (answers.styling === "tailwind") {
9
- integrations.push(" react(),");
10
- vitePlugins.push(" tailwindcss(),");
11
- }
12
-
13
- const adapter = answers.admin
14
- ? `
15
- adapter: node({
16
- mode: 'standalone'
17
- }),`
18
- : "";
19
-
20
- const nativeExternals = `
21
- ssr: {
22
- external: [
23
- 'better-sqlite3',
24
- 'sharp',
25
- 'ssh2',
26
- 'cpu-features',
27
- 'ssh2-sftp-client',
28
- 'ioredis',
29
- 'nodemailer',
30
- 'jsonwebtoken',
31
- '@mapbox/node-pre-gyp',
32
- 'mock-aws-s3',
33
- 'aws-sdk',
34
- 'nock',
35
- ],
36
- },
37
- optimizeDeps: {
38
- exclude: [
39
- 'better-sqlite3',
40
- 'sharp',
41
- 'ssh2',
42
- 'cpu-features',
43
- 'ssh2-sftp-client',
44
- 'ioredis',
45
- 'nodemailer',
46
- 'jsonwebtoken',
47
- '@mapbox/node-pre-gyp',
48
- 'mock-aws-s3',
49
- 'aws-sdk',
50
- 'nock',
51
- ],
52
- },`;
53
-
54
- const config = `import { defineConfig } from 'astro/config';
55
- import node from '@astrojs/node';
56
- ${answers.styling === "tailwind" ? "import react from '@astrojs/react';\nimport tailwindcss from '@tailwindcss/vite';" : ""}
4
+ return `import { defineConfig } from 'astro/config';
5
+ import kyro from '@kyro-cms/core';
6
+ import { kyroAdmin } from '@kyro-cms/admin';
57
7
 
58
8
  export default defineConfig({
59
- output: 'server',${adapter}
60
-
9
+ output: 'server',
61
10
  integrations: [
62
- ${integrations.join("\n")}
63
- ],${
64
- vitePluginsLength > 0
65
- ? `
66
- vite: {
67
- plugins: [
68
- ${vitePlugins.join("\n")}
69
- ],${nativeExternals}
70
- },`
71
- : `
72
- vite: {${nativeExternals}
73
- },`
74
- }
11
+ kyro({ adminPath: '/admin', apiPath: '/api' }),
12
+ kyroAdmin({ basePath: '/admin', apiPath: '/api' }),
13
+ ],
75
14
  server: {
76
15
  port: 4321,
77
16
  host: true,
78
17
  },
79
18
  });`;
80
-
81
- return config;
82
19
  }
@@ -2,66 +2,59 @@ import type { Answers } from "../prompts.js";
2
2
 
3
3
  export function generateKyroConfig(answers: Answers): string {
4
4
  const imports: string[] = ["import { defineConfig } from '@kyro-cms/core';"];
5
- const adapterLines: string[] = [];
6
5
 
7
6
  if (answers.database === "sqlite") {
8
7
  imports.push("import { createLocalAdapter } from '@kyro-cms/core';");
9
- adapterLines.push(` adapter: createLocalAdapter({ path: './data.db' }),`);
10
8
  } else if (answers.database === "postgres") {
11
9
  imports.push("import { createDrizzleAdapter } from '@kyro-cms/core';");
12
- adapterLines.push(` adapter: createDrizzleAdapter({`);
13
- adapterLines.push(` connectionString: process.env.DATABASE_URL,`);
14
- adapterLines.push(` }),`);
15
10
  } else if (answers.database === "mysql") {
16
11
  imports.push("import { createDrizzleAdapter } from '@kyro-cms/core';");
12
+ } else if (answers.database === "mongodb") {
13
+ imports.push("import { createMongoDBAdapter } from '@kyro-cms/core';");
14
+ }
15
+
16
+ const adapterLines: string[] = [];
17
+ if (answers.database === "sqlite") {
18
+ adapterLines.push(` adapter: createLocalAdapter({ path: './data.db' }),`);
19
+ } else if (answers.database === "postgres" || answers.database === "mysql") {
17
20
  adapterLines.push(` adapter: createDrizzleAdapter({`);
18
21
  adapterLines.push(` connectionString: process.env.DATABASE_URL,`);
19
22
  adapterLines.push(` }),`);
20
23
  } else if (answers.database === "mongodb") {
21
- imports.push("import { createMongoDBAdapter } from '@kyro-cms/core';");
22
24
  adapterLines.push(` adapter: createMongoDBAdapter({`);
23
25
  adapterLines.push(` connectionString: process.env.MONGODB_URI,`);
24
26
  adapterLines.push(` }),`);
25
27
  }
26
28
 
27
- const apiConfig = [
28
- " rest: true,",
29
- " graphql: true,",
30
- " trpc: true,",
31
- " websocket: true,",
32
- ];
33
-
34
- const features: string[] = [];
35
- if (answers.auth) {
36
- features.push(" auth: true,");
37
- }
38
- if (answers.versioning) {
39
- features.push(" versioning: true,");
40
- }
41
-
42
29
  let templateCollections = "";
43
30
  let templateGlobals = "";
44
31
 
45
32
  switch (answers.template) {
46
33
  case "minimal":
47
34
  templateCollections =
48
- "import { minimalCollections } from '@kyro-cms/core';";
35
+ "import { minimalCollections } from '@kyro-cms/core/templates';";
36
+ templateGlobals =
37
+ "import { coreSettingsGlobals } from '@kyro-cms/core/templates';";
49
38
  break;
50
39
  case "blog":
51
- templateCollections = "import { blogCollections } from '@kyro-cms/core';";
40
+ templateCollections = "import { blogCollections } from '@kyro-cms/core/templates';";
41
+ templateGlobals =
42
+ "import { allSettingsGlobals } from '@kyro-cms/core/templates';";
52
43
  break;
53
44
  case "ecommerce":
54
- templateCollections =
55
- "import { ecommerceCollections } from '@kyro-cms/core';";
45
+ templateCollections = "import { ecommerceCollections } from '@kyro-cms/core/templates';";
46
+ templateGlobals =
47
+ "import { allSettingsGlobals, ecommerceSettingsGlobals } from '@kyro-cms/core/templates';";
56
48
  break;
57
49
  case "kitchen-sink":
58
- templateCollections = `import { minimalCollections, blogCollections, ecommerceCollections, kitchenSinkCollections } from '@kyro-cms/core';`;
50
+ templateCollections = `import { minimalCollections, blogCollections, ecommerceCollections, kitchenSinkCollections } from '@kyro-cms/core/templates';`;
51
+ templateGlobals =
52
+ "import { allSettingsGlobals, ecommerceSettingsGlobals } from '@kyro-cms/core/templates';";
59
53
  break;
60
54
  }
61
55
 
62
- if (templateCollections) {
63
- imports.push(templateCollections);
64
- }
56
+ if (templateCollections) imports.push(templateCollections);
57
+ if (templateGlobals) imports.push(templateGlobals);
65
58
 
66
59
  let collectionsConfig = "";
67
60
  if (answers.template === "minimal") {
@@ -79,17 +72,25 @@ export function generateKyroConfig(answers: Answers): string {
79
72
  ],`;
80
73
  }
81
74
 
82
- const config = `${imports.join("\n")}
75
+ let globalsConfig = "";
76
+ if (answers.template === "minimal") {
77
+ globalsConfig = ` globals: coreSettingsGlobals,`;
78
+ } else if (answers.template === "blog" || answers.template === "ecommerce") {
79
+ globalsConfig = answers.template === "ecommerce"
80
+ ? ` globals: [...allSettingsGlobals, ...ecommerceSettingsGlobals],`
81
+ : ` globals: allSettingsGlobals,`;
82
+ } else if (answers.template === "kitchen-sink") {
83
+ globalsConfig = ` globals: [...allSettingsGlobals, ...ecommerceSettingsGlobals],`;
84
+ }
85
+
86
+ return `${imports.join("\n")}
83
87
 
84
88
  export default defineConfig({
85
89
  name: '${answers.projectName}',
86
- prefix: '/api',${adapterLines.length > 0 ? "\n" + adapterLines.join("\n") : ""}
87
- ${collectionsConfig ? collectionsConfig : ""}${features.length > 0 ? "\n" + features.join("\n") : ""}
88
-
89
- api: {
90
- ${apiConfig.join("\n")}
91
- },
90
+ prefix: '/api',
91
+ ${adapterLines.join("\n")}
92
+ ${collectionsConfig}
93
+ ${globalsConfig}
94
+ auth: true,
92
95
  });`;
93
-
94
- return config;
95
96
  }