Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quality of life configurations, and add border to the plugin lists #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DATABASE_URL=postgres://postgres:devpasswd@localhost:5432/passwdmanager
USE_MINIO=true
MINIO_ADDRESS=https://localhost:9000
AWS_SECRET_ACCESS_KEY=....
AWS_ACCESS_KEY_ID=....
GITHUB_CLIENT_ID=....
GITHUB_CLIENT_SECRET=....
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Lapce volts
This is the source code for the software running on https://plugins.lapce.dev, it allows the users to upload, search and download plugins using the lapce UI.

# Setup a development environment

1. Start database and min.io with docker-compose: `docker-compose up -d`
2. Copy `.env.example` to `.env`, and fill the variables
3. Run the backend with `cargo run --bin volts-server`
4. In another terminal, install trunk if you hadn't installed yet with `cargo install trunk`.
5. Build and serve the frontend: `cd volts-front && trunk serve`
6. Open a browser at https://localhost:3000
7. Be happy coding :tada:!
2 changes: 1 addition & 1 deletion diesel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# see https://diesel.rs/guides/configuring-diesel-cli

[print_schema]
file = "src/db/schema.rs"
file = "volts-core/src/db/schema.rs"

[migrations_directory]
dir = "migrations"
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.4'

services:
minio_dev:
image: minio/minio
ports:
- 9000:9000
- 9001:9001
command: server /data --console-address ":9001"
volumes:
- minio_data:/data/
environment:
MINIO_ROOT_USER: admin
MINIO_ROOT_PASSWORD: password
postgres_dev:
image: postgres
environment:
POSTGRES_PASSWORD: devpasswd
POSTGRES_DB: passwdmanager
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
ports:
- '5432:5432'
volumes:
- postgres_data:/data/postgres
restart: unless-stopped
volumes:
minio_data:
postgres_data:
5 changes: 5 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "stable"
targets = ["wasm32-unknown-unknown"]
profile = "minimal"
components = ["rustfmt", "clippy"]
15 changes: 13 additions & 2 deletions volts-back/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,19 @@ impl AppState {
let db_pool = crate::db::DbPool::new();
let bucket = Bucket::new(
"lapce-plugins",
Region::R2 {
account_id: env::var("R2_ACCOUNT_ID").unwrap(),
if !std::env::var("USE_MINIO")
.unwrap()
.parse::<bool>()
.unwrap_or_default()
{
Region::R2 {
account_id: env::var("R2_ACCOUNT_ID").unwrap(),
}
} else {
Region::Custom {
region: "".into(),
endpoint: std::env::var("MINIO_ADDRESS").unwrap(),
}
},
Credentials::from_env().unwrap(),
)
Expand Down
13 changes: 9 additions & 4 deletions volts-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ use toml_edit::easy as toml;
use zstd::Encoder;

use crate::{auth_token, Cli, IconTheme};

pub(crate) fn get_base_url() -> String {
std::env::var("LAPCE_PLUGIN_CLI_BASE_URL").unwrap_or_else(|_| "https://plugins.lapce.dev".into())
}
pub(crate) fn get_full_url(endpoint: impl Into<String>) -> String {
format!("{}{}", get_base_url(), endpoint.into())
}
pub(crate) fn publish(cli: &Cli) {
let token = auth_token(cli);

Expand Down Expand Up @@ -124,7 +129,7 @@ pub(crate) fn publish(cli: &Cli) {
}

let resp = reqwest::blocking::Client::new()
.request(Method::PUT, "https://plugins.lapce.dev/api/v1/plugins/new")
.request(Method::PUT, get_full_url("/api/v1/plugins/new"))
.bearer_auth(token.trim())
.body(File::open(&archive_path).unwrap())
.send()
Expand All @@ -143,7 +148,7 @@ pub(crate) fn yank(cli: &Cli, name: &String, version: &String) {
let resp = reqwest::blocking::Client::new()
.request(
Method::PUT,
format!("https://plugins.lapce.dev/api/v1/plugins/me/{name}/{version}/yank"),
format!("{}/api/v1/plugins/me/{name}/{version}/yank", get_base_url()),
)
.bearer_auth(token.trim())
.send()
Expand All @@ -161,7 +166,7 @@ pub(crate) fn unyank(cli: &Cli, name: &String, version: &String) {
let resp = reqwest::blocking::Client::new()
.request(
Method::PUT,
format!("https://plugins.lapce.dev/api/v1/plugins/me/{name}/{version}/unyank"),
format!("{}/api/v1/plugins/me/{name}/{version}/unyank", get_base_url()),
)
.bearer_auth(token.trim())
.send()
Expand Down
2 changes: 1 addition & 1 deletion volts-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
chrono = "0.4.22"
diesel = { version = "2.0.2", features = ["postgres", "chrono"] }
diesel = { version = "2.0.2", features = ["postgres_backend", "chrono"] }
anyhow = "1.0.66"
url = "2.3.1"
serde = { version = "1.0", features = ["derive"] }
1 change: 0 additions & 1 deletion volts-core/src/db/api.rs

This file was deleted.

1 change: 0 additions & 1 deletion volts-core/src/db/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod api;
pub mod models;
pub mod schema;
4 changes: 4 additions & 0 deletions volts-front/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
node_modules/
pnpm-lock.yaml
package.json
Loading