Fix: Ensure all skills are tracked as files, not submodules

This commit is contained in:
sck_0
2026-01-14 18:48:48 +01:00
parent 7f46ed8ca1
commit 8bd204708b
1113 changed files with 82065 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
import Database from 'better-sqlite3';
import path from 'path';
const dbPath = path.join(__dirname, '../../todos.db');
// Create database connection
let db: Database.Database | null = null;
export function getDatabase(): Database.Database {
if (!db) {
db = new Database(dbPath);
db.pragma('journal_mode = WAL');
console.log(`Connected to SQLite database at ${dbPath}`);
}
return db;
}
export function closeDatabase(): void {
if (db) {
db.close();
db = null;
console.log('Database connection closed');
}
}

View File

@@ -0,0 +1,35 @@
import sqlite3 from 'sqlite3';
import path from 'path';
const dbPath = path.join(__dirname, '../../todos.db');
const db = new sqlite3.Database(dbPath, (err: Error | null) => {
if (err) {
console.error('Database connection error:', err);
} else {
console.log('Connected to SQLite database');
}
});
// Initialize database schema
export const initDatabase = (): Promise<void> => {
return new Promise((resolve, reject) => {
db.run(`
CREATE TABLE IF NOT EXISTS todos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
completed BOOLEAN DEFAULT 0,
createdAt TEXT DEFAULT CURRENT_TIMESTAMP
)
`, (err: Error | null) => {
if (err) {
reject(err);
} else {
console.log('Database schema initialized');
resolve();
}
});
});
};
export default db;

View File

@@ -0,0 +1,2 @@
export { getDatabase, closeDatabase } from './database';
export { runMigrations, initializeDatabase } from './migrations';

View File

@@ -0,0 +1,31 @@
import { getDatabase } from './database';
import fs from 'fs';
import path from 'path';
const schemaPath = path.join(__dirname, './schema.sql');
export function runMigrations(): void {
try {
const db = getDatabase();
const schema = fs.readFileSync(schemaPath, 'utf-8');
// Execute the schema SQL
db.exec(schema);
console.log('Database migrations completed successfully');
} catch (error) {
console.error('Error running migrations:', error);
throw error;
}
}
export function initializeDatabase(): void {
try {
runMigrations();
console.log('Database initialized and ready for use');
} catch (error) {
console.error('Failed to initialize database:', error);
throw error;
}
}

View File

@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS todos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
description TEXT,
completed INTEGER DEFAULT 0,
createdAt TEXT,
updatedAt TEXT
);