Skip to content

Commit 002bcc8

Browse files
authored
Merge pull request #1 from 1Cor125/project_structure
chore: init proj structure of crate within plugin
2 parents 0525282 + d77ddcc commit 002bcc8

28 files changed

Lines changed: 6144 additions & 1 deletion

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[alias]
2+
lint-clippy = "clippy --all-targets --all-features -- -D warnings"
3+
fix-clippy = "clippy --all-targets --all-features --fix --allow-dirty --allow-staged"
4+
lint-fmt = "fmt --all -- --check"
5+
fix-fmt = "fmt --all"

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./node_modules/@silvermine/standardization/.editorconfig

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push: # Runs on push to any branch
5+
pull_request:
6+
branches: [ "master" ]
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
ci:
13+
name: Continuous Integration
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc'
24+
cache: 'npm'
25+
26+
- name: Install system dependencies
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
30+
31+
- name: Setup Rust toolchain
32+
uses: actions-rust-lang/setup-rust-toolchain@v1
33+
with:
34+
toolchain: '1.89.0'
35+
components: rustfmt, clippy
36+
cache: true
37+
38+
- name: Install npm dependencies
39+
run: npm ci
40+
41+
- name: Run standards checks
42+
run: npm run standards
43+
44+
- name: Run cargo check
45+
run: cargo check --workspace --all-targets
46+
47+
- name: Run cargo tests
48+
run: cargo test --workspace

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Rust
2+
/target/
3+
Cargo.lock
4+
5+
# Node
6+
node_modules/
7+
dist-js/
8+
*.log
9+
10+
# IDE
11+
.vscode/
12+
.idea/
13+
*.swp
14+
*.swo
15+
*~
16+
17+
# OS
18+
.DS_Store
19+
Thumbs.db
20+
21+
# Tauri
22+
/gen/

.markdownlint-cli2.cjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
const sharedStandards = require('@silvermine/standardization/.markdownlint-cli2.shared.cjs');
4+
5+
module.exports = {
6+
...sharedStandards,
7+
globs: [
8+
...sharedStandards.globs,
9+
],
10+
ignores: [
11+
...sharedStandards.ignores,
12+
'**/dist-js',
13+
'**/permissions/autogenerated',
14+
],
15+
};

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.12.2

Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"crates/sqlx-sqlite-conn-mgr",
5+
]
6+
7+
[package]
8+
name = "tauri-plugin-sqlite"
9+
version = "0.1.0"
10+
description = "A Tauri plugin for SQLite database access with connection management"
11+
license = "MIT"
12+
edition = "2024"
13+
rust-version = "1.89"
14+
links = "tauri-plugin-sqlite"
15+
16+
[dependencies]
17+
tauri = "2.5.1"
18+
serde = { version = "1", features = ["derive"] }
19+
thiserror = "1"
20+
21+
[build-dependencies]
22+
tauri-plugin = { version = "2.5.1", features = ["build"] }

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Jeremy Thomerson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,155 @@
1-
# tauri-plugin-sqlite
1+
# Tauri SQLite Plugin
2+
3+
[![CI][ci-badge]][ci-url]
4+
5+
A Tauri plugin for SQLite database access with connection management. This plugin
6+
depends on [SQLx](https://github.com/launchbadge/sqlx) and enforces pragmatic policies
7+
for connection management.
8+
9+
[ci-badge]: https://github.com/silvermine/tauri-plugin-sqlite/actions/workflows/ci.yml/badge.svg
10+
[ci-url]: https://github.com/silvermine/tauri-plugin-sqlite/actions/workflows/ci.yml
11+
12+
## Project Structure
13+
14+
This project is organized as a Cargo workspace with the following structure:
15+
16+
```text
17+
tauri-plugin-sqlite/
18+
├── crates/
19+
│ └── sqlx-sqlite-conn-mgr/ # SQLx SQLite connection pool manager
20+
│ ├── src/
21+
│ │ └── lib.rs
22+
│ └── Cargo.toml
23+
├── src/ # Tauri plugin implementation
24+
│ ├── commands.rs # Plugin commands
25+
│ ├── error.rs # Error types
26+
│ ├── lib.rs # Main plugin code
27+
│ └── models.rs # Data models
28+
├── guest-js/ # JavaScript/TypeScript bindings
29+
│ ├── index.ts
30+
│ └── tsconfig.json
31+
├── permissions/ # Permission definitions (mostly generated)
32+
├── dist-js/ # Compiled JS (generated)
33+
├── Cargo.toml # Workspace configuration
34+
├── package.json # NPM package configuration
35+
└── build.rs # Build script
36+
```
37+
38+
## Crates
39+
40+
### sqlx-sqlite-conn-mgr
41+
42+
A pure Rust module with no dependencies on Tauri or its plugin architecture. It
43+
provides connection management for SQLite databases using SQLx. It's designed to be
44+
published as a standalone crate in the future with minimal changes.
45+
46+
See [`crates/sqlx-sqlite-conn-mgr/README.md`](crates/sqlx-sqlite-conn-mgr/README.md)
47+
for more details.
48+
49+
### Tauri Plugin
50+
51+
The main plugin provides a Tauri integration layer that exposes SQLite functionality
52+
to Tauri applications. It uses the `sqlx-sqlite-conn-mgr` module internally.
53+
54+
## Getting Started
55+
56+
### Installation
57+
58+
1. Install NPM dependencies:
59+
60+
```bash
61+
npm install
62+
```
63+
64+
2. Build the TypeScript bindings:
65+
66+
```bash
67+
npm run build
68+
```
69+
70+
3. Build the Rust plugin:
71+
72+
```bash
73+
cargo build
74+
```
75+
76+
### Tests
77+
78+
Run Rust tests:
79+
80+
```bash
81+
cargo test
82+
```
83+
84+
### Linting and standards checks
85+
86+
```bash
87+
npm run standards
88+
```
89+
90+
## Usage
91+
92+
### In a Tauri Application
93+
94+
Add the plugin to your Tauri application's `Cargo.toml`:
95+
96+
```toml
97+
[dependencies]
98+
tauri-plugin-sqlite = { path = "../path/to/tauri-plugin-sqlite" }
99+
```
100+
101+
Initialize the plugin in your Tauri app:
102+
103+
```rust
104+
fn main() {
105+
tauri::Builder::default()
106+
.plugin(tauri_plugin_sqlite::init())
107+
.run(tauri::generate_context!())
108+
.expect("error while running tauri application");
109+
}
110+
```
111+
112+
### JavaScript/TypeScript API
113+
114+
Install the JavaScript package in your frontend:
115+
116+
```bash
117+
npm install @silvermine/tauri-plugin-sqlite
118+
```
119+
120+
Use the plugin from JavaScript:
121+
122+
```typescript
123+
// TODO: Add real examples once we have decided on the plugin API
124+
import { hello } from '@silvermine/tauri-plugin-sqlite';
125+
126+
// Call the hello command
127+
const greeting = await hello('World');
128+
console.log(greeting); // "Hello, World! This is the SQLite plugin."
129+
```
130+
131+
## Development Standards
132+
133+
This project follows the
134+
[Silvermine standardization](https://github.com/silvermine/standardization)
135+
guidelines. Key standards include:
136+
137+
* **EditorConfig**: Consistent editor settings across the team
138+
* **Markdownlint**: Markdown linting for documentation
139+
* **Commitlint**: Conventional commit message format
140+
* **Code Style**: 3-space indentation, LF line endings
141+
142+
### Running Standards Checks
143+
144+
```bash
145+
npm run standards
146+
```
147+
148+
## License
149+
150+
MIT
151+
152+
## Contributing
153+
154+
Contributions are welcome! Please follow the established coding standards and commit
155+
message conventions.

0 commit comments

Comments
 (0)