miolo 3.0.0-beta.151 → 3.0.0-beta.153

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.
@@ -153,8 +153,8 @@ export function copyTemplate(sourcePath, destPath, appName, options = {}) {
153
153
  fs.copyFileSync(srcPath, destItemPath)
154
154
  }
155
155
  } else if (stat.isDirectory()) {
156
- // Only copy src/ and docker/ directories
157
- if (item === 'src' || item === 'docker') {
156
+ // Only copy src/, db/ and docker/ directories
157
+ if (item === 'src' || item === 'docker'|| item === 'db') {
158
158
  copyDirectory(srcPath, destItemPath, appName, options)
159
159
  }
160
160
  }
@@ -100,6 +100,35 @@ export default async function create(appName, options = {}) {
100
100
  console.warn('[miolo] Please run "npm install" manually in the project directory')
101
101
  }
102
102
 
103
+ // Initialize database
104
+ const dbInitScript = path.join(destPath, 'db/init.sh')
105
+ if (fs.existsSync(dbInitScript)) {
106
+ console.log('')
107
+ console.log('[miolo] Database initialization')
108
+ console.log('[miolo] ⚠️ Note: This step may require sudo password if your user doesn\'t have CREATEDB permission')
109
+ console.log('[miolo] Database name will be:', appName)
110
+
111
+ // Make script executable
112
+ try {
113
+ fs.chmodSync(dbInitScript, 0o755)
114
+ } catch (_error) {
115
+ // Ignore chmod errors
116
+ }
117
+
118
+ try {
119
+ execSync(`${dbInitScript} ${appName}`, {
120
+ cwd: destPath,
121
+ stdio: 'inherit'
122
+ })
123
+ console.log('[miolo] ✅ Database initialized successfully')
124
+ } catch (_error) {
125
+ console.warn('[miolo] ⚠️ Warning: Database initialization failed or was skipped')
126
+ console.warn('[miolo] You can initialize it manually later by running:')
127
+ console.warn(`[miolo] cd ${dest} && ./db/init.sh ${appName}`)
128
+ }
129
+ }
130
+
131
+ console.log('')
103
132
  console.log('[miolo] ✅ App created successfully!')
104
133
  console.log('[miolo] To get started:')
105
134
  console.log(` cd ${dest}`)
@@ -43,7 +43,7 @@ const filesToCopy = [
43
43
  { src: 'package.json', dest: 'package.json' },
44
44
  { src: 'eslint.config.js', dest: 'eslint.config.js' },
45
45
  { src: 'postcss.config.js', dest: 'postcss.config.js' },
46
- { src: 'vite.config.mjs', dest: 'vite.config.mjs' }
46
+ //{ src: 'vite.config.mjs', dest: 'vite.config.mjs' }
47
47
  ]
48
48
 
49
49
  // Copy individual files
@@ -60,7 +60,7 @@ for (const { src, dest } of filesToCopy) {
60
60
  }
61
61
 
62
62
  // Copy directories
63
- const dirsToCopy = ['src', 'docker']
63
+ const dirsToCopy = ['src', 'docker', 'db']
64
64
 
65
65
  for (const dir of dirsToCopy) {
66
66
  const srcDir = path.join(mioloSamplePath, dir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miolo",
3
- "version": "3.0.0-beta.151",
3
+ "version": "3.0.0-beta.153",
4
4
  "description": "all-in-one koa-based server",
5
5
  "author": "Donato Lorenzo <donato@afialapis.com>",
6
6
  "contributors": [
@@ -0,0 +1,89 @@
1
+ #!/bin/bash
2
+
3
+ # Database initialization script for miolo-sample
4
+ # Usage: ./db/init.sh <database_name>
5
+
6
+ set -e # Exit on error
7
+
8
+ # Colors for output
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ NC='\033[0m' # No Color
13
+
14
+ DB_NAME=$1
15
+
16
+ if [ -z "$DB_NAME" ]; then
17
+ echo -e "${RED}Error: Database name is required${NC}"
18
+ echo "Usage: $0 <database_name>"
19
+ exit 1
20
+ fi
21
+
22
+ echo -e "${GREEN}[miolo-sample] Database initialization${NC}"
23
+ echo "Database: $DB_NAME"
24
+
25
+ # Get the directory where this script is located
26
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27
+ SQL_DIR="$SCRIPT_DIR/sql"
28
+
29
+ # Check if PostgreSQL is installed
30
+ if ! command -v psql &> /dev/null; then
31
+ echo -e "${RED}Error: PostgreSQL client (psql) not found${NC}"
32
+ echo "Please install PostgreSQL first"
33
+ exit 1
34
+ fi
35
+
36
+ # Ask for confirmation
37
+ echo ""
38
+ read -p "Do you want to create/recreate database '$DB_NAME'? (y/N): " -n 1 -r
39
+ echo
40
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
41
+ echo "Database creation skipped"
42
+ echo "Proceeding with SQL execution only..."
43
+ else
44
+ # Try to create database with sudo
45
+ echo -e "${YELLOW}Creating database as postgres user (requires sudo)...${NC}"
46
+
47
+ if sudo -u postgres createdb "$DB_NAME" 2>/dev/null; then
48
+ echo -e "${GREEN}✓ Database '$DB_NAME' created${NC}"
49
+ else
50
+ # Database creation failed - probably already exists, continue anyway
51
+ echo -e "${YELLOW}⚠ Database creation failed (database may already exist)${NC}"
52
+ echo -e "${YELLOW}Continuing with SQL execution...${NC}"
53
+ fi
54
+ fi
55
+
56
+ # Execute SQL files in order
57
+ echo ""
58
+ echo -e "${YELLOW}Executing SQL files...${NC}"
59
+
60
+ if [ ! -d "$SQL_DIR" ]; then
61
+ echo -e "${RED}Error: SQL directory not found: $SQL_DIR${NC}"
62
+ exit 1
63
+ fi
64
+
65
+ # Find all .sql files and sort them
66
+ SQL_FILES=$(find "$SQL_DIR" -name "*.sql" -type f | sort)
67
+
68
+ if [ -z "$SQL_FILES" ]; then
69
+ echo -e "${YELLOW}No SQL files found in $SQL_DIR${NC}"
70
+ else
71
+ for sql_file in $SQL_FILES; do
72
+ filename=$(basename "$sql_file")
73
+ echo -ne " Executing $filename... "
74
+
75
+ if psql -d "$DB_NAME" -f "$sql_file" -q 2>&1 | grep -q "ERROR"; then
76
+ echo -e "${RED}✗ Failed${NC}"
77
+ exit 1
78
+ else
79
+ echo -e "${GREEN}✓${NC}"
80
+ fi
81
+ done
82
+ fi
83
+
84
+ echo ""
85
+ echo -e "${GREEN}✓ Database initialization complete!${NC}"
86
+ echo ""
87
+ echo "Connection info:"
88
+ echo " Database: $DB_NAME"
89
+ echo " Connect: psql -d $DB_NAME"
@@ -0,0 +1,2 @@
1
+ DROP TABLE todo;
2
+ DROP TABLE u_user;
@@ -0,0 +1,30 @@
1
+ CREATE TABLE u_user (
2
+ --sqlite
3
+ --id INTEGER PRIMARY KEY AUTOINCREMENT,
4
+ id serial,
5
+ username text,
6
+ password text,
7
+ name text,
8
+ email text,
9
+ active integer,
10
+
11
+ admin boolean,
12
+
13
+ last_login_date integer,
14
+ last_login_ip text,
15
+ login_count integer DEFAULT 0,
16
+
17
+ last_conn_at integer,
18
+ created_at integer,
19
+ last_update_at integer
20
+ );
21
+
22
+
23
+ INSERT INTO u_user
24
+ (username, password, name, email)
25
+ VALUES
26
+ ('miolo-sample@miolo-sample.com',
27
+ '3dc91ce0dd374a6daf9ccaa4f64c5e0972eb2e7c9857a6aa524174897c0f7c55a3853e696ef8b4c3156f5fd39d65a49496a929f278ae96577e948fb85546e222',
28
+ 'miolo-sample',
29
+ 'miolo-sample@miolo-sample.com')
30
+ ;
@@ -0,0 +1,20 @@
1
+ create table todo (
2
+ --sqlite
3
+ --id INTEGER PRIMARY KEY AUTOINCREMENT,
4
+ id serial,
5
+ description text,
6
+ done boolean,
7
+ --sqlite
8
+ --created_at INTEGER DEFAULT (strftime('%s', 'now')),
9
+ --last_update_at INTEGER DEFAULT (strftime('%s', 'now')),
10
+ created_At int default extract(epoch from now()),
11
+ last_update_At int default extract(epoch from now()),
12
+ created_by int,
13
+ last_update_by int
14
+ );
15
+
16
+ INSERT INTO todo (description, done) VALUES ('Buy milk', false);
17
+ INSERT INTO todo (description, done) VALUES ('Buy eggs', true);
18
+ INSERT INTO todo (description, done) VALUES ('Buy bread', false);
19
+ INSERT INTO todo (description, done) VALUES ('Buy butter', true);
20
+ INSERT INTO todo (description, done) VALUES ('Buy cheese', false);
@@ -45,8 +45,8 @@
45
45
  "intre": "^3.0.0-beta.3",
46
46
  "joi": "^18.0.2",
47
47
  "lucide-react": "^0.563.0",
48
- "miolo-cli": "^3.0.0-beta.151",
49
- "miolo-react": "^3.0.0-beta.151",
48
+ "miolo-cli": "^3.0.0-beta.153",
49
+ "miolo-react": "^3.0.0-beta.153",
50
50
  "next-themes": "^0.4.6",
51
51
  "radix-ui": "^1.4.3",
52
52
  "react": "^19.2.4",
@@ -60,7 +60,7 @@
60
60
  "tw-animate-css": "^1.4.0"
61
61
  },
62
62
  "devDependencies": {
63
- "miolo": "^3.0.0-beta.151",
63
+ "miolo": "^3.0.0-beta.153",
64
64
  "sass-embedded": "^1.97.3",
65
65
  "xeira": "^2.0.0-beta.10"
66
66
  },