Skip to content

Commit c14b1d1

Browse files
committed
added readme.md
1 parent f9c8ec2 commit c14b1d1

File tree

1 file changed

+59
-50
lines changed

1 file changed

+59
-50
lines changed

readme.md

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

2+
23
# ReactronBase
34

4-
ReactronBase is a boilerplate for building desktop applications using Electron and Vite. This template sets up a development environment with TypeScript, Tailwind CSS, and Electron, providing essential configurations for building and packaging your application.
5+
ReactronBase is a boilerplate for building desktop applications using Electron and Vite. This template sets up a development environment with TypeScript, Tailwind CSS, and Electron, providing essential configurations for building and packaging your application. It is designed to accelerate development by offering a streamlined setup, rapid build processes, and powerful tooling for both the main and renderer processes.
56

67
## 📁 Project Structure
78

@@ -111,10 +112,10 @@ npm run rebuild-sql
111112

112113
## 🛠️ Development Tools
113114

114-
- **Vite**: Fast build tool and development server for the renderer process.
115-
- **Electron**: Framework for building cross-platform desktop applications with web technologies.
116-
- **TypeScript**: Adds static types to JavaScript for improved developer experience.
117-
- **Tailwind CSS**: Utility-first CSS framework for building modern UIs.
115+
- **Vite**: Fast build tool and development server for the renderer process, providing a modern and efficient development experience.
116+
- **Electron**: Framework for building cross-platform desktop applications with web technologies, enabling seamless integration between web and native functionalities.
117+
- **TypeScript**: Adds static types to JavaScript for improved developer experience and robust code quality.
118+
- **Tailwind CSS**: Utility-first CSS framework for building modern UIs, allowing rapid design and customization.
118119

119120
## 💡 Tips and Tricks
120121

@@ -141,9 +142,36 @@ npm run rebuild-sql
141142

142143
## 🎨 Customizing the Application
143144

144-
- **Styles**: Modify `src/renderer/styles.css` to adjust the appearance of your application.
145+
- **Styles**: Modify `src/renderer/styles.css` to adjust the appearance of your application. Utilize Tailwind CSS for utility-first styling.
145146
- **Configuration**: Update `electron-windows-store-config.json` for custom Windows Store packaging settings.
146147

148+
## 📦 Creating Components and Pages
149+
150+
### Creating Components
151+
152+
To create a new component, run:
153+
154+
```bash
155+
npm run create:component <component-name>
156+
```
157+
158+
Replace `<component-name>` with the desired name for your component. This command will:
159+
- Generate a new component file in `src/renderer/components/`.
160+
- Create a corresponding SCSS file for styling.
161+
162+
### Creating Pages
163+
164+
To create a new page, run:
165+
166+
```bash
167+
npm run create:page <page-name>
168+
```
169+
170+
Replace `<page-name>` with the desired name for your page. This command will:
171+
- Create a new folder in `src/renderer/pages/` with the page name.
172+
- Generate a TypeScript file and SCSS file for the page.
173+
- Automatically update your routing configuration to include the new page.
174+
147175
## ❓ FAQ
148176

149177
**Q: What is ReactronBase?**
@@ -175,62 +203,43 @@ To seed your database with initial data, create a seeding script. You can add th
175203
Example seeding script (`seed.ts`):
176204

177205
```typescript
178-
import sqlite3 from 'sqlite3';
179-
import { open } from 'sqlite';
206+
import { Database } from 'sqlite3';
180207

181-
async function seedDatabase() {
182-
const db = await open({
183-
filename: 'db/dev.db',
184-
driver: sqlite3.Database,
185-
});
208+
const db = new Database('db/dev.db');
186209

187-
// Add seed data
188-
await db.run('INSERT INTO users (name, email) VALUES (?, ?)', ['John Doe', 'john@example.com']);
210+
db.serialize(() => {
211+
db.run('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
189212

190-
console.log('Database seeded successfully.');
191-
await db.close();
192-
}
213+
const stmt = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
214+
stmt.run('John Doe', 'john@example.com');
215+
stmt.finalize();
216+
});
193217

194-
seedDatabase().catch((error) => console.error('Failed to seed database:', error));
218+
db.close();
195219
```
196220

197-
Run the seeding script as part of your application setup or manually execute it.
221+
Run the seeding script:
198222

199-
### Resetting the Database
223+
```bash
224+
npx ts-node src/main/seed.ts
225+
```
200226

201-
To reset your database, you can delete the existing `db/dev.db` file and let your application recreate it. This can be done manually or through a script.
227+
### Resetting the Database
202228

203-
Example reset script (`reset-db.ts`):
229+
To reset your database, you can drop existing tables and re-run the seeding script. Modify your seeding script to include table dropping commands:
204230

205231
```typescript
206-
import { unlink } from 'fs';
207-
import { open } from 'sqlite';
208-
import sqlite3 from 'sqlite3';
209-
210-
async function resetDatabase() {
211-
try {
212-
// Delete the existing database file
213-
unlink('db/dev.db', async (err) => {
214-
if (err) throw err;
215-
216-
// Recreate the database and initialize schema
217-
const db = await open({
218-
filename: 'db/dev.db',
219-
driver: sqlite3.Database,
220-
});
221-
222-
// Initialize schema
223-
await db.run('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
224-
225-
console.log('Database reset and schema initialized.');
226-
await db.close();
227-
});
228-
} catch (error) {
229-
console.error('Failed to reset database:', error);
230-
}
231-
}
232+
db.serialize(() => {
233+
db.run('DROP TABLE IF EXISTS users');
234+
db.run('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
235+
// Re-run seeding
236+
});
237+
```
232238

233-
resetDatabase();
239+
Run the script to reset the database:
240+
241+
```bash
242+
npx ts-node src/main/seed.ts
234243
```
235244

236245
## 🚀 Upcoming Features

0 commit comments

Comments
 (0)