initialize boilerplate with examples
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
yarn-error.log
|
18
README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Tea UI Workspace
|
||||
This repository includes the tea GUI/Desktop App.
|
||||
|
||||
# Requirements
|
||||
* [pnpm@^7.8](https://pnpm.io/)
|
||||
* [node@16](https://github.com/tj/n)
|
||||
* [rust@^1.62](https://www.rust-lang.org/)
|
||||
* [cargo@^1.62](https://crates.io/)
|
||||
|
||||
# Development
|
||||
Setting up the workspace just run here:
|
||||
```
|
||||
$ pnpm install
|
||||
```
|
||||
|
||||
Refer to each package README.md for instructions on how to setup and contribue to them:
|
||||
|
||||
* [tea/gui](./packages/gui/README.md)
|
10
package.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "@tea/workspace",
|
||||
"author": "neil molina <neil@tea.xyz>",
|
||||
"private": true,
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
"packages/*"
|
||||
]
|
||||
}
|
||||
}
|
13
packages/gui/.eslintignore
Normal file
|
@ -0,0 +1,13 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
20
packages/gui/.eslintrc.cjs
Normal file
|
@ -0,0 +1,20 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
|
||||
plugins: ['svelte3', '@typescript-eslint'],
|
||||
ignorePatterns: ['*.cjs'],
|
||||
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
|
||||
settings: {
|
||||
'svelte3/typescript': () => require('typescript')
|
||||
},
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 2020
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
es2017: true,
|
||||
node: true
|
||||
}
|
||||
};
|
8
packages/gui/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
1
packages/gui/.npmrc
Normal file
|
@ -0,0 +1 @@
|
|||
engine-strict=true
|
13
packages/gui/.prettierignore
Normal file
|
@ -0,0 +1,13 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
9
packages/gui/.prettierrc
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"useTabs": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"printWidth": 100,
|
||||
"plugins": ["prettier-plugin-svelte"],
|
||||
"pluginSearchDirs": ["."],
|
||||
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
|
||||
}
|
4
packages/gui/.tauriignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
*
|
||||
|
||||
!src/**/*
|
||||
!src-tauri/**/*
|
29
packages/gui/README.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
# @tea/gui
|
||||
Desktop app of [tea](https://tea.xyz) for installing packages/softwares
|
||||
|
||||
## Developing
|
||||
|
||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||
|
||||
```bash
|
||||
pnpm tauri dev
|
||||
|
||||
# or start the server and open the app in a new browser tab
|
||||
pnpm run dev -- --open
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To create a production version of your app:
|
||||
|
||||
```bash
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
You can preview the production build with `npm run preview`.
|
||||
|
||||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
||||
|
||||
## Intuition Building Links
|
||||
|
||||
* [Rust module system is weird?](https://www.sheshbabu.com/posts/rust-module-system/)
|
41
packages/gui/package.json
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "@tea/gui",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"tauri": "tauri",
|
||||
"dev": "vite dev --port 8080",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "playwright test",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
||||
"format": "prettier --plugin-search-dir . --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.25.0",
|
||||
"@sveltejs/adapter-auto": "next",
|
||||
"@sveltejs/adapter-static": "1.0.0-next.48",
|
||||
"@sveltejs/kit": "next",
|
||||
"@tauri-apps/cli": "1.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||
"@typescript-eslint/parser": "^5.27.0",
|
||||
"eslint": "^8.16.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
"prettier": "^2.6.2",
|
||||
"prettier-plugin-svelte": "^2.7.0",
|
||||
"svelte": "^3.49.0",
|
||||
"svelte-check": "^2.8.0",
|
||||
"svelte-preprocess": "^4.10.7",
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "^4.7.4",
|
||||
"vite": "^3.1.0"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.2.0",
|
||||
"buffer": "^6.0.3"
|
||||
}
|
||||
}
|
10
packages/gui/playwright.config.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import type { PlaywrightTestConfig } from '@playwright/test';
|
||||
|
||||
const config: PlaywrightTestConfig = {
|
||||
webServer: {
|
||||
command: 'npm run build && npm run preview',
|
||||
port: 4173
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
3
packages/gui/src-tauri/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
3747
packages/gui/src-tauri/Cargo.lock
generated
Normal file
33
packages/gui/src-tauri/Cargo.toml
Normal file
|
@ -0,0 +1,33 @@
|
|||
[package]
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
default-run = "app"
|
||||
edition = "2021"
|
||||
rust-version = "1.59"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "1.2.0", features = [] }
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "1.2.0", features = ["http-all"] }
|
||||
uuid = "1.2.1"
|
||||
reqwest = { version = "0.11", features = ["json", "blocking"] }
|
||||
hyper = { version = "0.14", features = ["full"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
futures = "0.3"
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||
default = [ "custom-protocol" ]
|
||||
# this feature is used for production builds where `devPath` points to the filesystem
|
||||
# DO NOT remove this
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
3
packages/gui/src-tauri/build.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
BIN
packages/gui/src-tauri/icons/128x128.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
packages/gui/src-tauri/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
packages/gui/src-tauri/icons/32x32.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
packages/gui/src-tauri/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
packages/gui/src-tauri/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
packages/gui/src-tauri/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
packages/gui/src-tauri/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
packages/gui/src-tauri/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
packages/gui/src-tauri/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
packages/gui/src-tauri/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
packages/gui/src-tauri/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
packages/gui/src-tauri/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
packages/gui/src-tauri/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
packages/gui/src-tauri/icons/icon.icns
Normal file
BIN
packages/gui/src-tauri/icons/icon.ico
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
packages/gui/src-tauri/icons/icon.png
Normal file
After Width: | Height: | Size: 14 KiB |
1
packages/gui/src-tauri/src/handlers/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod packages;
|
4
packages/gui/src-tauri/src/handlers/packages.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
#[tauri::command]
|
||||
pub fn install_package(package: String) {
|
||||
println!("installing: {}", package);
|
||||
}
|
15
packages/gui/src-tauri/src/main.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
#![cfg_attr(
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
mod handlers;
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
handlers::packages::install_package,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
70
packages/gui/src-tauri/tauri.conf.json
Normal file
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"$schema": "../../../node_modules/@tauri-apps/cli/schema.json",
|
||||
"build": {
|
||||
"beforeBuildCommand": "pnpm build",
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
"devPath": "http://localhost:8080",
|
||||
"distDir": "../dist"
|
||||
},
|
||||
"package": {
|
||||
"productName": "gui",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
"http": {
|
||||
"all": true,
|
||||
"request": true,
|
||||
"scope": ["https://api.tea.xyz/v1/*"]
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"category": "DeveloperTool",
|
||||
"copyright": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"externalBin": [],
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"identifier": "com.tauri.dev",
|
||||
"longDescription": "",
|
||||
"macOS": {
|
||||
"entitlements": null,
|
||||
"exceptionDomain": "",
|
||||
"frameworks": [],
|
||||
"providerShortName": null,
|
||||
"signingIdentity": null
|
||||
},
|
||||
"resources": [],
|
||||
"shortDescription": "",
|
||||
"targets": "all",
|
||||
"windows": {
|
||||
"certificateThumbprint": null,
|
||||
"digestAlgorithm": "sha256",
|
||||
"timestampUrl": ""
|
||||
}
|
||||
},
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"updater": {
|
||||
"active": false
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"fullscreen": false,
|
||||
"height": 600,
|
||||
"resizable": true,
|
||||
"title": "gui",
|
||||
"width": 800
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
9
packages/gui/src/app.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
// See https://kit.svelte.dev/docs/types#app
|
||||
// for information about these interfaces
|
||||
// and what to do when importing types
|
||||
declare namespace App {
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface Error {}
|
||||
// interface Platform {}
|
||||
}
|
12
packages/gui/src/app.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body>
|
||||
<div>%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
32
packages/gui/src/libs/api.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { getClient } from '@tauri-apps/api/http';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
|
||||
const username = 'user';
|
||||
const password = 'password';
|
||||
const auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
|
||||
|
||||
const base = 'https://api.tea.xyz/v1';
|
||||
|
||||
export async function get<T>(path: string){
|
||||
const client = await getClient();
|
||||
const uri = join(base, path);
|
||||
const { data } = await client.get<T>(uri.toString(), {
|
||||
headers: {
|
||||
Authorization: auth
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
const join = function(...paths: string[]){
|
||||
return paths.map(function(path){
|
||||
if(path[0] === "/"){
|
||||
path = path.slice(1);
|
||||
}
|
||||
if(path[path.length - 1] === "/"){
|
||||
path = path.slice(0, path.length - 1);
|
||||
}
|
||||
return path;
|
||||
}).join("/");
|
||||
}
|
10
packages/gui/src/libs/types.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
export interface S3Package {
|
||||
slug: string,
|
||||
version: string,
|
||||
full_name: string,
|
||||
name: string,
|
||||
maintainer: string,
|
||||
homepage: string,
|
||||
// key: string,
|
||||
last_modified: Date | string,
|
||||
}
|
27
packages/gui/src/routes/+page.svelte
Normal file
|
@ -0,0 +1,27 @@
|
|||
<script lang="ts">
|
||||
import { get } from '../libs/api';
|
||||
import type { S3Package } from '../libs/types';
|
||||
|
||||
let packages: S3Package[] = []
|
||||
async function loadPackages(){
|
||||
const data = await get<S3Package[]>('/packages');
|
||||
console.log(data);
|
||||
if (packages) {
|
||||
packages = data;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<a href="/others">Go to install package</a>
|
||||
<button on:click={loadPackages}>Load Packages</button>
|
||||
<ul>
|
||||
{#each packages as p}
|
||||
<li>{p.full_name}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<style>
|
||||
ul {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
12
packages/gui/src/routes/others/+page.svelte
Normal file
|
@ -0,0 +1,12 @@
|
|||
<script lang="ts">
|
||||
import { invoke } from '@tauri-apps/api/tauri'
|
||||
let pkg = '';
|
||||
async function installPackage(){
|
||||
await invoke('install_package', { package: pkg });
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1>Others</h1>
|
||||
<input bind:value={pkg}>
|
||||
<button on:click={installPackage}>install package</button>
|
||||
<a href="/">Back</a>
|
BIN
packages/gui/static/favicon.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
21
packages/gui/svelte.config.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import adapter from '@sveltejs/adapter-static';
|
||||
import preprocess from 'svelte-preprocess';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||
// for more information about preprocessors
|
||||
preprocess: preprocess(),
|
||||
kit: {
|
||||
adapter: adapter({
|
||||
pages: 'build',
|
||||
assets: 'build',
|
||||
fallback: 'app.html',
|
||||
}),
|
||||
// ssr: false,
|
||||
// hydrate the <div id="svelte"> element in src/app.html
|
||||
// target: '#svelte'
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
6
packages/gui/tests/test.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test('index page has expected h1', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
expect(await page.textContent('h1')).toBe('Welcome to SvelteKit');
|
||||
});
|
17
packages/gui/tsconfig.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true
|
||||
}
|
||||
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||
//
|
||||
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
||||
// from the referenced tsconfig.json - TypeScript does not merge them in
|
||||
}
|
8
packages/gui/vite.config.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import type { UserConfig } from 'vite';
|
||||
|
||||
const config: UserConfig = {
|
||||
plugins: [sveltekit()]
|
||||
};
|
||||
|
||||
export default config;
|
1918
pnpm-lock.yaml
Normal file
3
pnpm-workspace.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
packages:
|
||||
- 'packages/*'
|
||||
- '!**/test/**'
|