create-kyro 0.1.3 → 0.1.5

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
@@ -86,12 +86,14 @@ async function promptUser() {
86
86
  {
87
87
  title: "tRPC",
88
88
  description: "End-to-end typesafe APIs, great for TypeScript",
89
- value: "trpc"
89
+ value: "trpc",
90
+ selected: true
90
91
  },
91
92
  {
92
93
  title: "WebSocket",
93
94
  description: "Real-time bidirectional communication",
94
- value: "websocket"
95
+ value: "websocket",
96
+ selected: true
95
97
  }
96
98
  ]
97
99
  },
@@ -494,18 +496,15 @@ Visit [https://kyro.cms](https://kyro.cms) for full documentation.
494
496
 
495
497
  ${answers.database === "sqlite" ? "# SQLite (local) - no additional config needed" : answers.database === "postgres" || answers.database === "mysql" ? "# Database connection (PostgreSQL/MySQL)\nDATABASE_URL=postgresql://user:password@localhost:5432/kyro_cms\nDATABASE_SSL=false" : "# MongoDB connection\nMONGODB_URI=mongodb://localhost:27017/kyro_cms"}
496
498
 
497
- ${answers.auth ? `# Authentication (required for auth)
499
+ ${answers.auth ? `# Authentication (uses SQLite at ./data/auth.db - no Redis needed)
498
500
  JWT_SECRET=change-this-to-a-random-32-character-string
499
501
  JWT_EXPIRES_IN=24h
500
502
 
501
- # Bootstrap admin user (creates on first run)
502
- KYRO_ADMIN_EMAIL=admin@example.com
503
- KYRO_ADMIN_PASSWORD=SecurePass123!
504
- KYRO_ADMIN_ROLE=super_admin
503
+ # Registration control (set to false to disable public registration after first user)
504
+ KYRO_ALLOW_REGISTRATION=true
505
505
 
506
- # Optional: Redis for sessions (recommended for production)
507
- # REDIS_URL=redis://localhost:6379
508
- # REDIS_TLS=false
506
+ # Optional: Custom auth database path (default: ./data/auth.db)
507
+ # KYRO_AUTH_DB_PATH=./data/auth.db
509
508
 
510
509
  # Optional: SMTP for emails
511
510
  # SMTP_HOST=smtp.example.com
@@ -626,20 +625,15 @@ import config from '../../../kyro.config';
626
625
  }
627
626
  }
628
627
  function generateLoginEndpoint(database) {
629
- const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
630
- const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
631
- url: process.env.REDIS_URL || "redis://localhost:6379",
632
- tls: process.env.REDIS_TLS === "true",
633
- });`;
634
628
  return `import type { APIRoute } from "astro";
635
- ${adapterImport}
629
+ import { SQLiteAuthAdapter } from "@kyro-cms/core";
636
630
  import jwt from "jsonwebtoken";
637
631
 
638
632
  const JWT_SECRET = process.env.JWT_SECRET || "change-me-in-production";
639
633
  const JWT_EXPIRES_IN = process.env.JWT_EXPIRES_IN || "24h";
640
634
 
641
635
  async function getAuthApi() {
642
- ${adapterInit}
636
+ return new SQLiteAuthAdapter({ path: "./data/auth.db" });
643
637
  }
644
638
 
645
639
  export const POST: APIRoute = async ({ request }) => {
@@ -721,28 +715,8 @@ export const POST: APIRoute = async ({ request }) => {
721
715
  `;
722
716
  }
723
717
  function generateRegisterEndpoint(database) {
724
- const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
725
- const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
726
- url: process.env.REDIS_URL || "redis://localhost:6379",
727
- tls: process.env.REDIS_TLS === "true",
728
- });`;
729
- const isFirstUserCheck = database === "sqlite" ? ` const isFirstUser = !(await adapter.hasAnyUsers());` : ` const isFirstUser = await checkIsFirstUser(adapter);`;
730
- const isFirstUserFn = database === "sqlite" ? "" : `
731
-
732
- async function checkIsFirstUser(adapter: RedisAuthAdapter): Promise<boolean> {
733
- try {
734
- const redis = (adapter as any).redis;
735
- if (!redis) return true;
736
- const pattern = "kyro:auth:users:email:*";
737
- const result = await redis.scan("0", "MATCH", pattern, "COUNT", "1");
738
- const keys = result[1];
739
- return keys.length === 0;
740
- } catch {
741
- return true;
742
- }
743
- }`;
744
718
  return `import type { APIRoute } from "astro";
745
- ${adapterImport}
719
+ import { SQLiteAuthAdapter } from "@kyro-cms/core";
746
720
  import jwt from "jsonwebtoken";
747
721
 
748
722
  const JWT_SECRET = process.env.JWT_SECRET || "change-me-in-production";
@@ -750,7 +724,7 @@ const JWT_EXPIRES_IN = process.env.JWT_EXPIRES_IN || "24h";
750
724
  const ALLOW_REGISTRATION = process.env.KYRO_ALLOW_REGISTRATION !== "false";
751
725
 
752
726
  async function getAuthApi() {
753
- ${adapterInit}
727
+ return new SQLiteAuthAdapter({ path: "./data/auth.db" });
754
728
  }
755
729
 
756
730
  export const POST: APIRoute = async ({ request }) => {
@@ -802,7 +776,7 @@ export const POST: APIRoute = async ({ request }) => {
802
776
  );
803
777
  }
804
778
 
805
- ${isFirstUserCheck}
779
+ const isFirstUser = !(await adapter.hasAnyUsers());
806
780
 
807
781
  if (!isFirstUser && !ALLOW_REGISTRATION) {
808
782
  await adapter.disconnect();
@@ -863,20 +837,15 @@ ${isFirstUserCheck}
863
837
  headers: { "Content-Type": "application/json" },
864
838
  });
865
839
  }
866
- };${isFirstUserFn}
840
+ };
867
841
  `;
868
842
  }
869
843
  function generateLogoutEndpoint(database) {
870
- const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
871
- const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
872
- url: process.env.REDIS_URL || "redis://localhost:6379",
873
- tls: process.env.REDIS_TLS === "true",
874
- });`;
875
844
  return `import type { APIRoute } from "astro";
876
- ${adapterImport}
845
+ import { SQLiteAuthAdapter } from "@kyro-cms/core";
877
846
 
878
847
  async function getAuthApi() {
879
- ${adapterInit}
848
+ return new SQLiteAuthAdapter({ path: "./data/auth.db" });
880
849
  }
881
850
 
882
851
  export const POST: APIRoute = async ({ request }) => {
@@ -945,29 +914,11 @@ export const GET: APIRoute = async ({ request }) => {
945
914
  `;
946
915
  }
947
916
  function generateUsersEndpoint(database) {
948
- const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
949
- const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
950
- url: process.env.REDIS_URL || "redis://localhost:6379",
951
- tls: process.env.REDIS_TLS === "true",
952
- });`;
953
- const hasUsersCheck = database === "sqlite" ? ` const hasUsers = await adapter.hasAnyUsers();` : ` const redis = (adapter as any).redis;
954
- if (!redis) {
955
- await adapter.disconnect();
956
- return new Response(JSON.stringify({ hasUsers: false }), {
957
- status: 200,
958
- headers: { "Content-Type": "application/json" },
959
- });
960
- }
961
-
962
- const pattern = "kyro:auth:users:email:*";
963
- const result = await redis.scan("0", "MATCH", pattern, "COUNT", "1");
964
- const keys = result[1];
965
- const hasUsers = keys.length > 0;`;
966
917
  return `import type { APIRoute } from "astro";
967
- ${adapterImport}
918
+ import { SQLiteAuthAdapter } from "@kyro-cms/core";
968
919
 
969
920
  async function getAuthApi() {
970
- ${adapterInit}
921
+ return new SQLiteAuthAdapter({ path: "./data/auth.db" });
971
922
  }
972
923
 
973
924
  export const GET: APIRoute = async () => {
@@ -975,7 +926,7 @@ export const GET: APIRoute = async () => {
975
926
  const adapter = await getAuthApi();
976
927
  await adapter.connect();
977
928
 
978
- ${hasUsersCheck}
929
+ const hasUsers = await adapter.hasAnyUsers();
979
930
 
980
931
  await adapter.disconnect();
981
932
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kyro",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Interactive scaffolding for Kyro CMS projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,4 +37,4 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  }
40
- }
40
+ }
@@ -1,14 +0,0 @@
1
- # my-kyro-app
2
-
3
- A Kyro CMS project.
4
-
5
- ## Getting Started
6
-
7
- ```bash
8
- npm install
9
- npm run dev
10
- ```
11
-
12
- ## Documentation
13
-
14
- Visit [https://kyro.cms](https://kyro.cms) for full documentation.
@@ -1,21 +0,0 @@
1
- # my-kyro-app
2
-
3
- ## Overview
4
-
5
- This project uses Kyro CMS - an Astro-native headless CMS.
6
-
7
- ## Configuration
8
-
9
- - **Database**: SQLite (local-first)
10
- - **APIs**: rest, graphql
11
- - **Styling**: tailwind
12
- - **Auth**: Disabled
13
- - **Versioning**: Enabled
14
- - **Admin**: Included
15
- - **Template**: blog
16
-
17
- ## Collections
18
-
19
- - Posts
20
- - Categories
21
- - Media
@@ -1,20 +0,0 @@
1
- import { defineConfig } from "astro/config";
2
- import react from "@astrojs/react";
3
- import tailwindcss from "@tailwindcss/vite";
4
- import node from "@astrojs/node";
5
-
6
- export default defineConfig({
7
- output: "server",
8
- adapter: node({
9
- mode: "standalone",
10
- }),
11
-
12
- integrations: [react()],
13
- vite: {
14
- plugins: [tailwindcss()],
15
- },
16
- server: {
17
- port: 4321,
18
- host: true,
19
- },
20
- });
@@ -1,15 +0,0 @@
1
- import { defineConfig } from "@kyro-cms/core";
2
- import { createLocalAdapter } from "@kyro-cms/core";
3
- import { blogCollections } from "@kyro-cms/core";
4
-
5
- export default defineConfig({
6
- name: "my-kyro-app",
7
- prefix: "/api",
8
- adapter: createLocalAdapter({ path: "./data.db" }),
9
-
10
- collections: Object.values(blogCollections),
11
-
12
- api: {
13
- rest: true,
14
- },
15
- });