web preview and refactor native api integration module (#222)

* #213 web preview and cleanup native api integration
* remove old tauri build implementation
* fix git path 

---------

Co-authored-by: neil <neil@neils-MacBook-Pro.local>
This commit is contained in:
Neil 2023-02-22 15:59:37 +08:00 committed by GitHub
parent e5fd744c3f
commit 7359da0319
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
151 changed files with 182 additions and 7030 deletions

View file

@ -55,19 +55,53 @@ jobs:
run: pnpm -r lint
build_svelte:
needs: changes
if: needs.changes.outputs.svelte == 'true'
runs-on: ubuntu-latest
steps:
- uses: teaxyz/setup@v0
- uses: actions/checkout@v3
- name: cache gui linux
- name: cache node_modules build
# TODO: cache issue in our self-hosted macos runner ESPIPE: invalid seek, read
# but its ok to ignore, its still the fastest builder
# NOTE: enabling cache in the self hosted runner slows down the pipeline by 4m because post-cache builder error ^
if: startsWith(inputs.platform, 'linux') || matrix.platform.name == 'darwin+x86-64'
uses: actions/cache@v3
with:
key: linux+x86-64-20-pnpm-cargo
key: ubuntu-latest-pnpm
path: |
./pnpm
./target
- name: build tauri for Linux
uses: ./devops/linux-builder
./.pnpm-store
./node_modules
./modules/desktop/node_modules
./modules/ui/node_modules
- name: cache electron build
uses: actions/cache@v3
with:
key: ubuntu-latest-electron
path: |
./modules/desktop/.svelte-kit
./modules/desktop/build
- name: get gui version
id: gui-version
run: |
tea +stedolan.github.io/jq
export version=$(echo $(cat modules/desktop/package.json) | jq --raw-output .version)
export postfix=
if GIT_DIR=/path/to/repo/.git git rev-parse $1 >/dev/null 2>&1
then
echo "Found tag"
else
export postfix=-dev
fi
echo "version=$version$postfix" >> $GITHUB_OUTPUT
- name: build
run: |
tea -ES +nodejs.org@18 xc setup
cd modules/desktop && tea -ES pnpm vite build && cp build/app.html build/index.html
env:
PUBLIC_VERSION: ${{ steps.gui-version.outputs.version }}
BUILD_FOR: preview
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
@ -77,13 +111,13 @@ jobs:
env:
prefix: ${{ needs.changes.outputs.preview_folder }}
run: |
aws s3 sync ./modules/gui/build \
aws s3 sync ./modules/desktop/build \
"s3://preview.gui.tea.xyz/$prefix"
- name: Install package
run: sudo apt-get install -y jq coreutils
- name: setup preview
id: preview_setup
run: .github/create-invalidate-preview.sh ${{ needs.changes.outputs.preview_folder }}
run: |
tea +stedolan.github.io/jq .github/create-invalidate-preview.sh ${{ needs.changes.outputs.preview_folder }}
- name: comment preview site
uses: mshick/add-pr-comment@v2
@ -97,7 +131,7 @@ jobs:
```
copy-paste into a browser to view
build_desktop:
needs: changes
needs: [changes, test, build_svelte]
# if: needs.changes.outputs.desktop == 'true'
strategy:
matrix:

View file

@ -84,6 +84,7 @@
"electron-vite": "^1.0.18",
"electron-window-state": "^5.0.3",
"fuse.js": "^6.6.2",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"lorem-ipsum": "^2.0.8",
"mkdirp": "^2.1.3",

View file

@ -1,8 +1,8 @@
<script lang="ts">
import '$appcss';
import Button from '@tea/ui/Button/Button.svelte';
import Button from '@tea/ui/button/button.svelte';
import { openTerminal } from '@native';
const { ipcRenderer } = window.require('electron');
let copyButtonText = 'COPY';
const copyValue = `sh <(curl https://tea.xyz)`;
@ -12,7 +12,7 @@
};
const onInstall = () => {
ipcRenderer.invoke('open-terminal', { cmd: copyValue });
openTerminal(copyValue);
}
</script>

View file

@ -1,7 +1,7 @@
<script lang="ts">
import '$appcss';
import type { AirtablePost } from '@tea/ui/types';
import Posts from '@tea/ui/Posts/Posts.svelte';
import Posts from '@tea/ui/posts/posts.svelte';
import PanelHeader from '@tea/ui/panel-header/panel-header.svelte';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import { postsStore } from '$libs/stores';

View file

@ -3,7 +3,7 @@
import { postsStore } from '$libs/stores';
import type { Course } from '$libs/types';
import Gallery from '@tea/ui/Gallery/Gallery.svelte';
import Gallery from '@tea/ui/gallery/gallery.svelte';
let courses: Course[] = [];

View file

@ -3,7 +3,7 @@
import { onMount } from 'svelte';
import type { Package } from '@tea/ui/types';
import Gallery from '@tea/ui/Gallery/Gallery.svelte';
import Gallery from '@tea/ui/gallery/gallery.svelte';
import {
featuredPackages as featuredPackagesStore,
initializeFeaturedPackages

View file

@ -1,5 +1,5 @@
<script lang="ts">
import Button from '@tea/ui/Button/Button.svelte';
import Button from '@tea/ui/button/button.svelte';
import * as pub from '$env/static/public';
</script>

View file

@ -2,7 +2,7 @@
import '$appcss';
import { postsStore } from '$libs/stores';
import type { AirtablePost } from '@tea/ui/types';
import Posts from '@tea/ui/Posts/Posts.svelte';
import Posts from '@tea/ui/posts/posts.svelte';
import PanelHeader from '@tea/ui/panel-header/panel-header.svelte';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';

View file

@ -2,12 +2,11 @@
import '$appcss';
import '@tea/ui/icons/icons.css';
import type { Package, Bottle } from '@tea/ui/types';
import Button from '@tea/ui/Button/Button.svelte';
import Button from '@tea/ui/button/button.svelte';
import StarRating from '@tea/ui/star-rating/star-rating.svelte';
import { onMount } from 'svelte';
import { getPackageBottles } from '@api';
const { ipcRenderer } = window.require('electron');
import { getPackageBottles } from '@native';
import { openTerminal } from '@native';
export let pkg: Package;
let bottles: Bottle[] = [];
@ -21,7 +20,7 @@
};
const onOpenTerminal = () => {
ipcRenderer.invoke('open-terminal', { cmd: `sh <(curl tea.xyz) +${pkg.full_name}` });
openTerminal(`sh <(curl tea.xyz) +${pkg.full_name}`);
}
onMount(async () => {

View file

@ -6,9 +6,7 @@
import PackageCard from '@tea/ui/package-card/package-card.svelte';
import { packagesStore } from '$libs/stores';
// TODO: replace with getting foundation essentials
import { getTopPackages } from '$libs/api/mock';
import { installPackage } from '@api';
import { installPackage } from '@native';
export let title = 'Packages';
export let category = ''; // filter

View file

@ -1,7 +1,8 @@
<script lang="ts">
import '$appcss';
import { shellOpenExternal } from '@native';
const openGithub = () => {
// open('https://github.com/teaxyz');
shellOpenExternal("https://github.com/teaxyz");
};
</script>

View file

@ -8,7 +8,7 @@
import SearchInput from '@tea/ui/search-input/search-input.svelte';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import { installPackage } from '@api';
import { installPackage } from '@native';
let packages: GUIPackage[] = [];

View file

@ -4,9 +4,9 @@
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import PackageCard from '@tea/ui/package-card/package-card.svelte';
import { PackageStates } from '$libs/types';
import Posts from '@tea/ui/Posts/Posts.svelte';
import Posts from '@tea/ui/posts/posts.svelte';
import { installPackage } from '@api';
import { installPackage } from '@native';
import type { AirtablePost } from '@tea/ui/types';
let term: string;
let packages: GUIPackage[] = [];

View file

@ -6,7 +6,7 @@
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import PackageCard from '@tea/ui/package-card/package-card.svelte';
import { onMount } from 'svelte';
import { installPackage } from '@api';
import { installPackage } from '@native';
import { packagesStore } from '$libs/stores';
export let pkg: Package;

View file

@ -2,14 +2,13 @@
import { authStore } from '$libs/stores';
import type { Developer } from '@tea/ui/types';
import { baseUrl } from '$libs/v1-client';
const { shell } = window.require('electron');
import { shellOpenExternal } from '@native';
let user: Developer | null = null;
const deviceId = authStore.deviceIdStore;
const openGithub = () => {
shell.openExternal(`${baseUrl}/auth/user?device_id=${$deviceId}`)
shellOpenExternal(`${baseUrl}/auth/user?device_id=${$deviceId}`)
try {
authStore.pollSession();
} catch (error) {

View file

@ -1,13 +1,13 @@
import axios from "axios";
import type { Contributor, Package } from "@tea/ui/types";
const yaml = window.require("yaml");
import yaml from "js-yaml";
export async function getPackageYaml(pkgYamlUrl: string) {
const url = pkgYamlUrl.replace("/github.com", "/raw.githubusercontent.com").replace("/blob", "");
const { data: rawYaml } = await axios.get(url);
const data = await yaml.parse(rawYaml);
const data = await yaml.load(rawYaml);
return data;
}

View file

@ -10,22 +10,22 @@
* - connect to remote api(api.tea.xyz) and returns a data
* - connect to a local platform api and returns a data
*/
import axios from "axios";
import type { Package, Review, AirtablePost, Bottle } from "@tea/ui/types";
import type { GUIPackage, Course, Category, DeviceAuth } from "../types";
import type { GUIPackage, Course, Category, DeviceAuth, Session } from "./types";
import * as mock from "./mock";
import { PackageStates } from "../types";
import { getInstalledPackages } from "$libs/tea-dir";
import { installPackageCommand } from "$libs/cli";
import * as mock from "./native-mock";
import { PackageStates } from "./types";
import { installPackageCommand } from "./native/cli";
import { get as apiGet } from "$libs/v1-client";
const { ipcRenderer, shell } = window.require("electron");
export async function getPackages(): Promise<GUIPackage[]> {
const [packages, installedPackages] = await Promise.all([
apiGet<Package[]>("packages", { nocache: "true" }),
getInstalledPackages()
ipcRenderer.invoke("get-installed-packages") as { version: string; full_name: string }[]
]);
return (packages || []).map((pkg) => {
@ -114,3 +114,16 @@ export async function registerDevice(): Promise<string> {
const { deviceId } = await apiGet<{ deviceId: string }>("/auth/registerDevice");
return deviceId;
}
export const getSession = async (): Promise<Session | null> => {
const session = await ipcRenderer.invoke("get-session");
return session;
};
export const updateSession = async (session: Partial<Session>) => {
await ipcRenderer.invoke("update-session", session);
};
export const openTerminal = (cmd: string) => ipcRenderer.invoke("open-terminal", { cmd });
export const shellOpenExternal = (link: string) => shell.openExternal(link);

View file

@ -6,11 +6,11 @@
* * make cors work with api.tea.xyz/v1
*/
import type { Package, Review, AirtablePost, Bottle } from "@tea/ui/types";
import type { GUIPackage, Course, Category } from "../types";
import { PackageStates } from "../types";
import type { GUIPackage, Course, Category, Session } from "./types";
import { PackageStates } from "./types";
import { loremIpsum } from "lorem-ipsum";
import _ from "lodash";
// import { getInstalledPackages } from '$libs/tea-dir';
// import { getSession } from '$libs/stores/auth';
import * as v1Client from "$libs/v1-client";
@ -27,7 +27,8 @@ const packages: Package[] = [
maintainer: "",
desc: "Fast and user friendly build system",
thumb_image_url: "https://tea.xyz/Images/packages/mesonbuild_com.jpg",
installs: 0
installs: 0,
categories: ["foundation_essentials"]
},
{
slug: "pixman_org",
@ -41,7 +42,8 @@ const packages: Package[] = [
thumb_image_name: "pixman_org_option 1.jpg ",
desc: "Pixman is a library that provides low-level pixel manipulation features such as image compositing and trapezoid rasterization.",
thumb_image_url: "https://tea.xyz/Images/packages/pixman_org.jpg",
installs: 0
installs: 0,
categories: ["foundation_essentials"]
},
{
slug: "freedesktop_org_pkg_config",
@ -55,7 +57,8 @@ const packages: Package[] = [
thumb_image_name: "freedecktop_org_pkg_config option 1.jpg ",
desc: "Manage compile and link flags for libraries",
thumb_image_url: "https://tea.xyz/Images/packages/freedesktop_org_pkg_config.jpg",
installs: 0
installs: 0,
categories: ["foundation_essentials"]
},
{
slug: "gnu_org_gettext",
@ -69,7 +72,8 @@ const packages: Package[] = [
thumb_image_name: "gnu_org_gettext_option 1.jpg ",
desc: "GNU internationalization (i18n) and localization (l10n) library",
thumb_image_url: "https://tea.xyz/Images/packages/gnu_org_gettext.jpg",
installs: 0
installs: 0,
categories: ["foundation_essentials"]
},
{
slug: "ipfs_tech",
@ -83,7 +87,8 @@ const packages: Package[] = [
maintainer: "",
desc: "Peer-to-peer hypermedia protocol",
thumb_image_url: "https://tea.xyz/Images/packages/ipfs_tech.jpg",
installs: 0
installs: 0,
categories: ["foundation_essentials"]
},
{
slug: "nixos_org_patchelf",
@ -97,7 +102,8 @@ const packages: Package[] = [
thumb_image_name: "nixos_org_patchelf_option 1.jpg ",
desc: "PatchELF is a simple utility for modifying existing ELF executables and libraries.",
thumb_image_url: "https://tea.xyz/Images/packages/nixos_org_patchelf.jpg",
installs: 0
installs: 0,
categories: ["top_packages", "foundation_essentials"]
},
{
slug: "tea_xyz",
@ -111,7 +117,8 @@ const packages: Package[] = [
thumb_image_name: "tea_xyz_option 2.jpg ",
desc: "Website of tea.xyz",
thumb_image_url: "https://tea.xyz/Images/packages/tea_xyz.jpg",
installs: 0
installs: 0,
categories: ["top_packages", "foundation_essentials"]
},
{
slug: "charm_sh_gum",
@ -125,7 +132,8 @@ const packages: Package[] = [
thumb_image_name: "charm_sh_gum.jpg ",
desc: "",
thumb_image_url: "https://tea.xyz/Images/packages/charm_sh_gum.jpg",
installs: 0
installs: 0,
categories: ["top_packages", "foundation_essentials"]
},
{
slug: "pyyaml_org",
@ -139,7 +147,8 @@ const packages: Package[] = [
maintainer: "",
desc: "YAML framework for Python",
thumb_image_url: "https://tea.xyz/Images/packages/pyyaml_org.jpg",
installs: 0
installs: 0,
categories: ["top_packages", "foundation_essentials"]
},
{
slug: "tea_xyz_gx_cc",
@ -153,7 +162,8 @@ const packages: Package[] = [
thumb_image_name: "tea_xyz_gx.jpg ",
desc: "",
thumb_image_url: "https://tea.xyz/Images/packages/tea_xyz_gx_cc.jpg",
installs: 0
installs: 0,
categories: ["top_packages", "foundation_essentials"]
}
];
@ -332,17 +342,35 @@ export async function getDeviceAuth(deviceId: string): Promise<any> {
export async function getPackageBottles(name: string): Promise<Bottle[]> {
return [
{ name, platform: "darwin", arch: "aarch64", version: "3.39.4" },
{ name, platform: "darwin", arch: "aarch64", version: "3.40.0" },
{ name, platform: "darwin", arch: "x86-64", version: "3.39.4" },
{ name, platform: "darwin", arch: "x86-64", version: "3.40.0" },
{ name, platform: "linux", arch: "aarch64", version: "3.39.4" },
{ name, platform: "linux", arch: "aarch64", version: "3.40.0" },
{ name, platform: "linux", arch: "x86-64", version: "3.39.4" },
{ name, platform: "linux", arch: "x86-64", version: "3.40.0" }
{ name, platform: "darwin", arch: "aarch64", version: "3.39.4", bytes: 123456 },
{ name, platform: "darwin", arch: "aarch64", version: "3.40.0", bytes: 123456 },
{ name, platform: "darwin", arch: "x86-64", version: "3.39.4", bytes: 123456 },
{ name, platform: "darwin", arch: "x86-64", version: "3.40.0", bytes: 123456 },
{ name, platform: "linux", arch: "aarch64", version: "3.39.4", bytes: 123456 },
{ name, platform: "linux", arch: "aarch64", version: "3.40.0", bytes: 123456 },
{ name, platform: "linux", arch: "x86-64", version: "3.39.4", bytes: 123456 },
{ name, platform: "linux", arch: "x86-64", version: "3.40.0", bytes: 123456 }
];
}
export async function getPackage(packageName: string): Promise<Partial<Package>> {
return packages.find((pkg) => pkg.full_name === packageName) || packages[0];
}
export async function registerDevice(): Promise<string> {
return "uuid1234";
}
export const getSession = async (): Promise<Session | null> => {
return null;
};
export const updateSession = async (session: Partial<Session>) => {
console.log(session);
};
export const openTerminal = (cmd: string) => console.log(cmd);
export const shellOpenExternal = (link: string) => {
window.open(link, "_blank");
};

View file

@ -8,12 +8,6 @@ type Dir = {
children?: Dir[];
};
const { ipcRenderer } = window.require("electron");
export async function getInstalledPackages() {
const pkgs = await ipcRenderer.invoke("get-installed-packages");
return pkgs as { version: string; full_name: string }[];
}
const semverTest =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/g;

View file

@ -4,7 +4,7 @@ import Fuse from "fuse.js";
import type { Package, Review, AirtablePost } from "@tea/ui/types";
import type { GUIPackage } from "$libs/types";
import { getFeaturedPackages, getPackageReviews, getAllPosts } from "@api";
import { getFeaturedPackages, getPackageReviews, getAllPosts } from "@native";
import initAuthStore from "./stores/auth";
import initNavStore from "./stores/nav";
import initPackagesStore from "./stores/pkgs";

View file

@ -1,16 +1,15 @@
import { writable } from "svelte/store";
import { getDeviceAuth } from "@api";
import { getDeviceAuth } from "@native";
import type { Developer } from "@tea/ui/types";
import type { Session } from "$libs/types";
const { ipcRenderer } = window.require("electron");
import { getSession as electronGetSession, updateSession as electronUpdateSession } from "@native";
const basePath = ".tea/tea.xyz/gui";
export let session: Session | null = null;
export const getSession = async (): Promise<Session | null> => {
session = await ipcRenderer.invoke("get-session");
session = await electronGetSession();
return session;
};
@ -39,7 +38,7 @@ export default function initAuthStore() {
user: data.user
};
console.log("localSession:", localSession);
await ipcRenderer.invoke("update-session", localSession);
await electronUpdateSession(localSession);
sessionStore.set(localSession);
}

View file

@ -1,8 +1,8 @@
import { writable } from "svelte/store";
import type { GUIPackage } from "../types";
import { getPackages } from "@api";
import { getPackages } from "@native";
import Fuse from "fuse.js";
import { getPackage } from "@api";
import { getPackage } from "@native";
import { getReadme, getContributors, getRepoAsPackage } from "$libs/github";

View file

@ -6,7 +6,7 @@
import Packages from '$components/packages/packages.svelte';
import News from '$components/news/news.svelte';
import HeaderCard from '@tea/ui/HeaderCard/HeaderCard.svelte';
import HeaderCard from '@tea/ui/header-card/header-card.svelte';
import TopPackages from '$components/top-packages/top-packages.svelte';
import TopScripts from '$components/top-scripts/top-scripts.svelte';
</script>

View file

@ -1,15 +1,12 @@
<script lang="ts">
import '$appcss';
import { onMount } from 'svelte';
import PageHeader from '$components/page-header/page-header.svelte';
import { packagesReviewStore } from '$libs/stores';
import PackageBanner from '$components/package-banner/package-banner.svelte';
import type { Review, Bottle } from '@tea/ui/types';
import SuggestedPackages from '$components/suggested-packages/suggested-packages.svelte';
import Tabs from '@tea/ui/Tabs/Tabs.svelte';
import Tabs from '@tea/ui/tabs/tabs.svelte';
import type { Tab } from '@tea/ui/types';
import Bottles from '@tea/ui/Bottles/Bottles.svelte';
import { getPackageBottles } from '@api';
import Bottles from '@tea/ui/bottles/bottles.svelte';
import PackageMetas from '@tea/ui/package-metas/package-metas.svelte';
import Markdown from '@tea/ui/markdown/markdown.svelte';
import PackageSnippets from '@tea/ui/package-snippets/package-snippets.svelte';
@ -17,7 +14,7 @@
/** @type {import('./$types').PageData} */
export let data;
import { packagesStore, featuredPackages } from '$libs/stores';
import { packagesStore } from '$libs/stores';
import type { Package } from '@tea/ui/types';

View file

@ -14,7 +14,7 @@
"paths": {
"$appcss": ["src/app.css"],
"$libs/*": ["src/libs/*"],
"@api": ["src/libs/api/electron.ts"],
"@native": ["src/libs/native-electron.ts"],
"$components/*": ["src/components/*"],
"@tea/ui/*": ["../ui/src/*"]
}

View file

@ -2,7 +2,7 @@ import { sveltekit } from "@sveltejs/kit/vite";
import type { UserConfig } from "vite";
import path from "path";
// const isMock = process.env.BUILD_FOR === 'preview';
const isMock = process.env.BUILD_FOR === "preview";
const config: UserConfig = {
plugins: [sveltekit()],
@ -11,8 +11,9 @@ const config: UserConfig = {
"@tea/ui/*": path.resolve("../ui/src/*"),
// this dynamic-ish static importing is followed by the svelte build
// but for vscode editing intellisense tsconfig.json is being used
// TODO: replace it with correct api
"@api": path.resolve("src/libs/api/electron.ts"),
"@native": isMock
? path.resolve("src/libs/native-mock.ts")
: path.resolve("src/libs/native-electron.ts"),
$components: path.resolve("./src/components"),
$libs: path.resolve("./src/libs"),
$appcss: path.resolve("./src/app.css")

View file

@ -1,15 +0,0 @@
.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
src-tauri/target/*
coverage/*

View file

@ -1,28 +0,0 @@
module.exports = {
root: true,
globals: {
NodeJS: 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
}
};

View file

@ -1,9 +0,0 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
coverage/*

View file

@ -1,2 +0,0 @@
engine-strict=true
auto-install-peers=true

View file

@ -1,23 +0,0 @@
.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
build
/src-tauri/src/*
/src-tauri/icons/*
/src-tauri/target/**/*
/src-tauri/build/*
/src-tauri/Cargo.lock
/src-tauri/Cargo.toml
src-tauri
coverage/*
**/*.plist

View file

@ -1,10 +0,0 @@
{
"tabWidth": 2,
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

View file

@ -1,4 +0,0 @@
*
!src/**/*
!src-tauri/**/*

View file

@ -1,41 +0,0 @@
# @tea/gui
Desktop app of [tea](https://tea.xyz) for installing packages/softwares
More interesting and possibly updated documentations are at this [NOTION](https://www.notion.so/teaxyz/tea-gui-fdd9f50aa980432fa370b2cf6a03cb50) page. It is ideal to review it also, its more updated.
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
# use if you need interaction with the rust handlers
pnpm tauri dev
# or if ui dev only
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.
## Testing
```bash
pnpm playwright install
pnpm test
```
## Intuition Building Links
- [Rust module system is weird?](https://www.sheshbabu.com/posts/rust-module-system/)

View file

@ -1,70 +0,0 @@
{
"name": "@tea/gui",
"version": "0.0.0",
"private": true,
"scripts": {
"tauri": "tauri",
"dev": "vite dev --port 8080",
"build": "vite build && cp build/app.html build/index.html",
"preview": "vite preview",
"unit:test": "vitest",
"coverage": "vitest run --coverage",
"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/experimental-ct-svelte": "^1.29.2",
"@playwright/test": "1.25.0",
"@sveltejs/adapter-auto": "^1.0.0",
"@sveltejs/adapter-static": "^1.0.0",
"@sveltejs/kit": "^1.0.1",
"@tauri-apps/cli": "^1.2.2",
"@tea/ui": "workspace:*",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/svelte": "^3.2.2",
"@types/testing-library__jest-dom": "^5.14.5",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"autoprefixer": "^10.4.13",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^4.0.0",
"jsdom": "^21.0.0",
"postcss": "^8.4.19",
"prettier": "^2.7.1",
"prettier-plugin-svelte": "^2.7.0",
"prettier-plugin-tailwindcss": "^0.2.0",
"svelte": "^3.55.0",
"svelte-check": "^2.8.0",
"svelte-preprocess": "^5.0.0",
"svelte2tsx": "^0.5.20",
"tailwindcss": "^3.2.4",
"tslib": "^2.3.1",
"typescript": "^4.7.4",
"vite": "^4.1.1",
"vitest": "^0.27.1"
},
"type": "module",
"dependencies": {
"@tauri-apps/api": "^1.2.0",
"@types/bcryptjs": "^2.4.2",
"@types/url-join": "^4.0.1",
"@vitest/coverage-c8": "^0.27.1",
"bcryptjs": "^2.4.3",
"buffer": "^6.0.3",
"fuse.js": "^6.6.2",
"lodash": "^4.17.21",
"lorem-ipsum": "^2.0.8",
"svelte-markdown": "^0.2.3",
"svelte-watch-resize": "^1.0.3",
"url-join": "^5.0.0"
},
"pnpm": {
"onlyBuiltDependencies": [
"@tea/ui"
]
}
}

View file

@ -1,10 +0,0 @@
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
}
};
export default config;

View file

@ -1,6 +0,0 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};

View file

@ -1,4 +0,0 @@
import matchers from '@testing-library/jest-dom/matchers';
import { expect } from 'vitest';
expect.extend(matchers);

View file

@ -1,3 +0,0 @@
# Generated by Cargo
# will have compiled files and executables
/target/

File diff suppressed because it is too large Load diff

View file

@ -1,30 +0,0 @@
[package]
name = "app"
version = "0.1.0"
description = "A tea.xyz desktop 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 = ["fs-create-dir", "fs-read-dir", "fs-read-file", "fs-write-file", "http-all", "path-all", "shell-all", "window-all"] }
uuid = "1.2.1"
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" ]

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>tea</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tea</string>
</array>
</dict>
</array>
</dict>
</plist>

View file

@ -1,3 +0,0 @@
fn main() {
tauri_build::build()
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

View file

@ -1 +0,0 @@
pub mod packages;

View file

@ -1,5 +0,0 @@
#[tauri::command]
pub fn install_package(package: String) {
println!("installing: {}", package);
}

View file

@ -1,15 +0,0 @@
#![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");
}

View file

@ -1,144 +0,0 @@
{
"$schema": "../../../node_modules/@tauri-apps/cli/schema.json",
"build": {
"beforeBuildCommand": "pnpm build",
"beforeDevCommand": "pnpm dev",
"devPath": "http://localhost:8080",
"distDir": "../build"
},
"package": {
"productName": "tea",
"version": "0.1.0"
},
"tauri": {
"allowlist": {
"http": {
"all": true,
"request": true,
"scope": ["https://api.tea.xyz/v1/*", "https://github.com/*", "http://localhost:3000/v1/*", "https://app.tea.xyz/*"]
},
"shell": {
"all": true,
"execute": true,
"open": true,
"scope": [
{
"name": "tea-install",
"cmd": "tea",
"args": [{ "validator": "\\S+" }, "true"]
},
{
"name": "node",
"cmd": "node",
"args": ["--version"]
},
{
"name": "list-packages",
"cmd": "ls",
"args": ["-R ~/.tea/tea.xyz/var/www | grep 'xz\\|gz'"]
},
{
"name": "open",
"cmd": "open",
"args": ["-a iterm"]
}
],
"sidecar": false
},
"window": {
"all": true,
"center": true,
"close": true,
"create": true,
"hide": true,
"maximize": true,
"minimize": true,
"print": true,
"requestUserAttention": true,
"setAlwaysOnTop": true,
"setCursorGrab": true,
"setCursorIcon": true,
"setCursorPosition": true,
"setCursorVisible": true,
"setDecorations": true,
"setFocus": true,
"setFullscreen": true,
"setIcon": true,
"setIgnoreCursorEvents": true,
"setMaxSize": true,
"setMinSize": true,
"setPosition": true,
"setResizable": true,
"setSize": true,
"setSkipTaskbar": true,
"setTitle": true,
"show": true,
"startDragging": true,
"unmaximize": true,
"unminimize": true
},
"fs": {
"readDir": true,
"createDir": true,
"writeFile": true,
"readFile": true,
"scope": [
"$HOME/.tea/**",
"$HOME/.tea"
]
},
"path": {
"all": true
}
},
"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": "xyz.tea.gui",
"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": "tea",
"width": 1200,
"decorations": true
}
]
}
}

View file

@ -1,43 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@font-face {
font-family: 'pp-neue-machina';
src: url('/fonts/PPNeueMachina-InktrapLight.woff');
}
@font-face {
font-family: 'sono';
src: url('/fonts/Sono-Light.woff2');
}
html {
background-color: #1a1a1a;
color: #fff;
user-select: none;
cursor: default;
}
@layer base {
html {
font-family: sono, sans-serif;
}
}
.text-primary,
header,
h1,
h2,
h3,
h4,
h5,
h6,
button,
.click-copy {
font-family: 'pp-neue-machina' !important;
}
.pk-version {
font-family: 'sono';
}

View file

@ -1,9 +0,0 @@
// 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 {}
}

View file

@ -1,12 +0,0 @@
<!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>

View file

@ -1,9 +0,0 @@
<script lang="ts">
import '$appcss';
import Placeholder from '$components/Placeholder/Placeholder.svelte';
export let arg1: string;
</script>
<Placeholder label="Badges" />
<h1>{arg1 || 'tes'}</h1>

View file

@ -1,5 +0,0 @@
<script lang="ts">
import '$appcss';
</script>
<section class="border-gray h-56 border bg-black" />

View file

@ -1,24 +0,0 @@
<script lang="ts">
import PanelHeader from '@tea/ui/panel-header/panel-header.svelte';
import MiniPackageCard from '@tea/ui/mini-package-card/mini-package-card.svelte';
import type { Category } from '$libs/types';
import { onMount } from 'svelte';
import { getCategorizedPackages } from '@api';
let categories: Category[] = [];
onMount(async () => {
categories = await getCategorizedPackages();
});
</script>
{#each categories as category}
<PanelHeader ctaLabel={category.cta_label} ctaLink={'#'} title={category.label} />
<ul class="border-gray grid grid-cols-3 border border-r-0 bg-black">
{#each category.packages as pkg}
<div class="border-gray border border-t-0 border-l-0 p-4">
<MiniPackageCard {pkg} ctaLabel="DETAILS" link={`/packages/${pkg.slug}`} />
</div>
{/each}
</ul>
{/each}

View file

@ -1,27 +0,0 @@
<script lang="ts">
import '$appcss';
import Button from '@tea/ui/Button/Button.svelte';
let copyButtonText = 'COPY';
const copyValue = `sh <(curl https://tea.xyz)`;
const onCopy = () => {
copyButtonText = 'COPIED!';
navigator.clipboard.writeText(copyValue);
};
</script>
<section class="border-gray mt-4 border bg-black">
<header class="flex flex-col items-center py-8">
<figure>
<img alt="tea" src="/images/tea-icon.png" class="rounded-md" />
</figure>
<p class="text-primary">tea.cli ver. 0.6.0</p>
</header>
<footer class="border-gray flex h-20 border-t text-white">
<input class="flex-grow bg-black pl-4" disabled value="sh <(curl tea.xyz)>" />
<Button class="w-16 border-0 border-l-2 text-sm" onClick={onCopy}>{copyButtonText}</Button>
<Button class="w-56 border-0 border-l-2 text-sm" onClick={() => console.log('cli')}
>OPEN IN TERMINAL</Button
>
</footer>
</section>

View file

@ -1,24 +0,0 @@
<script lang="ts">
import '$appcss';
import type { AirtablePost } from '@tea/ui/types';
import Posts from '@tea/ui/Posts/Posts.svelte';
import PanelHeader from '@tea/ui/panel-header/panel-header.svelte';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import { postsStore } from '$libs/stores';
export let title = 'Workshops';
export let ctaLabel = 'View all';
let courses: AirtablePost[] = [];
postsStore.subscribeByTag('course', (posts) => (courses = posts));
</script>
<PanelHeader {title} {ctaLabel} ctaLink="/" />
{#if courses.length}
<Posts posts={courses} linkTarget="_blank" />
{:else}
<section class="border-gray h-64 border bg-black p-4">
<Preloader />
</section>
{/if}

View file

@ -1,31 +0,0 @@
<script lang="ts">
import '$appcss';
import { postsStore } from '$libs/stores';
import type { Course } from '$libs/types';
import Gallery from '@tea/ui/Gallery/Gallery.svelte';
let courses: Course[] = [];
postsStore.subscribeByTag('featured_course', (posts) => {
courses = posts.map((post) => {
return {
title: post.title,
sub_title: post.sub_title,
banner_image_url: post.thumb_image_url,
link: post.link
} as Course;
});
});
</script>
<Gallery
title="FEATURED COURSES"
items={courses.map((course) => ({
title: course.title,
subTitle: course.sub_title,
imageUrl: course.banner_image_url,
link: course.link
}))}
linkTarget="_blank"
/>

View file

@ -1,33 +0,0 @@
<script lang="ts">
import '$appcss';
import { onMount } from 'svelte';
import type { Package } from '@tea/ui/types';
import Gallery from '@tea/ui/Gallery/Gallery.svelte';
import {
featuredPackages as featuredPackagesStore,
initializeFeaturedPackages
} from '$libs/stores';
let featuredPackages: Package[] = [];
featuredPackagesStore.subscribe((v) => {
featuredPackages = v;
});
onMount(() => {
if (!featuredPackages.length) {
initializeFeaturedPackages();
}
});
</script>
<Gallery
title="FEATURED PACKAGES"
items={featuredPackages.map((pkg) => ({
title: pkg.full_name,
subTitle: pkg.maintainer || '',
imageUrl: pkg.thumb_image_url,
link: `/packages/${pkg.slug}`
}))}
/>

View file

@ -1,85 +0,0 @@
<script lang="ts">
import Button from '@tea/ui/Button/Button.svelte';
</script>
<footer class="font-machina relative h-auto w-full bg-black">
<section class="p-4 px-16 py-16">
<h3 class="text-primary mb-5 text-2xl">QUICK LINKS</h3>
<menu class="flex gap-4">
<div class="border-gray flex-grow border border-l-0 border-r-0">
<a href="/">
<Button>
<div class="text-primary flex justify-between hover:text-black">
<div class="uppercase">About the tea store</div>
<div>&#8594</div>
</div>
</Button>
</a>
</div>
<div class="border-gray flex-grow border border-l-0 border-r-0">
<a href="/">
<Button>
<div class="text-primary flex justify-between hover:text-black">
<div class="uppercase">REPORT A PROBLEM</div>
<div>&#8594</div>
</div>
</Button>
</a>
</div>
<div class="border-gray flex-grow border border-l-0 border-r-0">
<a href="https://tea.xyz" target="_blank" rel="noreferrer">
<Button>
<div class="text-primary flex justify-between hover:text-black">
<div class="uppercase">VISIT TEA.XYZ</div>
<div>&#8594</div>
</div>
</Button>
</a>
</div>
</menu>
</section>
<section class="border-gray h-16 border border-r-0 p-4 px-16">
<div class="text-gray flex gap-4 text-xs">
<a
href="https://tea.xyz/terms-of-use/"
target="_blank"
rel="noreferrer"
class="hover:text-white"
>
TERMS & SERVICES
</a>
<a
href="https://tea.xyz/privacy-policy/"
target="_blank"
rel="noreferrer"
class="hover:text-white"
>
PRIVACY POLICY
</a>
</div>
</section>
</footer>
<style>
h3 {
font-family: 'pp-neue-machina', sans-serif;
color: #00ffd0;
}
p,
.nav-item {
font-family: 'sono', sans-serif;
color: #ffffff;
}
.list-group-item {
font-family: 'pp-neue-machina', sans-serif;
text-transform: uppercase;
transition: 0.1s ease-in;
}
.list-group-item:hover {
padding-left: 1vw;
}
</style>

View file

@ -1,45 +0,0 @@
<script lang="ts">
import '$appcss';
import ArticleCard from '@tea/ui/article-card/article-card.svelte';
const doStuff = () => {
console.log('do stuff!');
};
</script>
<header class="border-gray text-primary border bg-black p-4">GETTING STARTED WITH TEA</header>
<section class="grid grid-cols-3 bg-black">
<div class="border-gray border p-4">
<ArticleCard
content={{
title: 'installing tea',
copy: "It's time to take your first sip! Click below to visit our tea-cli documentation page.",
img_url: '/images/bored-ape.png',
cta_label: 'Get Started',
link: '/cli'
}}
/>
</div>
<div class="border-gray border p-4">
<ArticleCard
content={{
title: 'authenticating',
copy: 'Using tea without authenticating is like playing a video game without the DLC. Join us today!',
img_url: '/images/bored-ape.png',
cta_label: 'Get Started',
link: ''
}}
onClick={doStuff}
/>
</div>
<div class="border-gray border p-4">
<ArticleCard
content={{
title: 'give us a star',
copy: 'Revolutions are built on the will of the people. Show your support for a more equitable internet.',
img_url: '/images/bored-ape.png',
cta_label: 'Get Started'
}}
/>
</div>
</section>

View file

@ -1,38 +0,0 @@
<script lang="ts">
import '$appcss';
import type { GUIPackage } from '$libs/types';
import { PackageStates } from '$libs/types';
import PanelHeader from '@tea/ui/panel-header/panel-header.svelte';
import { packagesStore } from '$libs/stores';
import MiniPackageCard from '@tea/ui/mini-package-card/mini-package-card.svelte';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
let packages: GUIPackage[] = [];
packagesStore.subscribe((v) => {
packages = v.filter((p) => p.state === PackageStates.INSTALLED);
});
</script>
<PanelHeader title="My installs" ctaLabel="Check for updates >" ctaLink="#" />
<ul class="border-gray grid grid-cols-3 border border-r-0 bg-black">
{#if packages.length > 0}
{#each packages as pkg}
<div class="border-gray border border-t-0 border-l-0 p-4">
<MiniPackageCard
{pkg}
ctaLabel="DETAILS"
onClickCTA={async () => {
console.log('do something with:', pkg.full_name);
}}
/>
</div>
{/each}
{:else}
{#each Array(12) as _}
<section class="h-50 border-gray border p-4">
<Preloader />
</section>
{/each}
{/if}
</ul>

View file

@ -1,21 +0,0 @@
<script lang="ts">
import '$appcss';
import { postsStore } from '$libs/stores';
import type { AirtablePost } from '@tea/ui/types';
import Posts from '@tea/ui/Posts/Posts.svelte';
import PanelHeader from '@tea/ui/panel-header/panel-header.svelte';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
let news: AirtablePost[] = [];
postsStore.subscribeByTag('news', (posts) => (news = posts));
</script>
<PanelHeader title="Open-source News" ctaLabel="Read more articles >" ctaLink="/" />
{#if news.length}
<Posts posts={news} linkTarget="_blank" />
{:else}
<section class="border-gray h-64 border bg-black p-4">
<Preloader />
</section>
{/if}

View file

@ -1,52 +0,0 @@
<script lang="ts">
import '$appcss';
import '@tea/ui/icons/icons.css';
import type { Package, Bottle } from '@tea/ui/types';
import Button from '@tea/ui/Button/Button.svelte';
import StarRating from '@tea/ui/star-rating/star-rating.svelte';
import { onMount } from 'svelte';
import { getPackageBottles } from '@api';
export let pkg: Package;
let bottles: Bottle[] = [];
let packageRating = 0;
let copyButtonText = 'COPY';
const copyValue = `sh <(curl tea.xyz ) +${pkg.full_name}`;
const onCopy = () => {
copyButtonText = 'COPIED!';
navigator.clipboard.writeText(copyValue);
};
onMount(async () => {
try {
bottles = await getPackageBottles(pkg.full_name);
} catch (err) {
console.error(err);
}
});
</script>
<section class="border-gray mt-4 border bg-black">
<header class="flex p-2">
<figure class="grow-1 w-1/3">
<img width={260} src={pkg.thumb_image_url} alt={pkg.full_name} />
</figure>
<article class="w-2/3 p-4 pt-8">
<h3 class="text-primary text-3xl">{pkg.full_name}</h3>
<h3>&#x2022; {pkg.maintainer || ''}{pkg.maintainer ? ' |' : ''} {bottles.length} bottles</h3>
<div class="mt-4">
<StarRating maxRating={5} rating={packageRating} />
</div>
<p class="font-sono mt-4 text-sm">{pkg.desc}</p>
</article>
</header>
<footer class="border-gray flex h-20 border-t text-white">
<input class="click-copy flex-grow bg-black pl-4" disabled value={copyValue} />
<Button class="w-16 border-0 border-l-2 text-sm" onClick={onCopy}>{copyButtonText}</Button>
<Button class="w-56 border-0 border-l-2 text-sm" onClick={() => console.log('cli')}
>OPEN IN TERMINAL</Button
>
</footer>
</section>

View file

@ -1,8 +0,0 @@
<script lang="ts">
import type { Package } from '@tea/ui/types';
export let pkg: Package;
</script>
<section class="h-64 w-full">
<h1>{pkg.full_name}</h1>
</section>

View file

@ -1,56 +0,0 @@
<script lang="ts">
import '$appcss';
import { afterUpdate } from 'svelte';
import ReviewCard from '@tea/ui/review-card/review-card.svelte';
import type { Review } from '@tea/ui/types';
export let reviews: Review[];
export let showLimit = 9;
let showMore = false;
const getColReviews = (n: number) => {
const showReviews = reviews.filter((_item, i) => (i - n) % 3 === 0);
return showMore ? showReviews : showReviews.slice(0, showLimit / 3);
};
let col1: Review[] = [];
let col2: Review[] = [];
let col3: Review[] = [];
afterUpdate(() => {
col1 = getColReviews(0);
col2 = getColReviews(1);
col3 = getColReviews(2);
});
// TODO: problem with reviews with differing heights
// ideally they should work like metro-ui to not have extreme height diff between columns
</script>
<header class="border-gray text-primary border bg-black p-4">REVIEWS ({reviews.length})</header>
<section class="font-machina flex flex-row flex-wrap bg-black">
<div class="border-gray w-1/3 border-0 border-l-2 border-b-2 p-4">
{#each col1 as review}
<ReviewCard {review} />
<div class="mt-4" />
{/each}
</div>
<div class="border-gray w-1/3 border-0 border-l-2 border-b-2 p-4">
{#each col2 as review}
<ReviewCard {review} />
<div class="mt-4" />
{/each}
</div>
<div class="border-gray w-1/3 border-0 border-x-2 border-b-2 p-4">
{#each col3 as review}
<ReviewCard {review} />
<div class="mt-4" />
{/each}
</div>
</section>
{#if showLimit <= reviews.length && showMore === false}
<footer class="border-gray border bg-black p-4">
<button on:click={() => (showMore = true)}>SHOW MORE</button>
</footer>
{/if}

View file

@ -1,64 +0,0 @@
<script lang="ts">
import '$appcss';
import type { GUIPackage } from '$libs/types';
import { PackageStates } from '$libs/types';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import PackageCard from '@tea/ui/package-card/package-card.svelte';
import { onMount } from 'svelte';
// TODO: replace with getting foundation essentials
import { getTopPackages } from '$libs/api/mock';
import { installPackage } from '@api';
export let title = 'Packages';
let packages: GUIPackage[] = [];
const getCTALabel = (state: PackageStates): string => {
return {
[PackageStates.AVAILABLE]: 'INSTALL',
[PackageStates.INSTALLED]: 'INSTALLED',
[PackageStates.INSTALLING]: 'INSTALLING',
[PackageStates.UNINSTALLED]: 'RE-INSTALL'
}[state];
};
onMount(async () => {
if (!packages.length) {
packages = await getTopPackages();
}
});
</script>
<header class="border-gray text-primary flex items-center justify-between border bg-black p-4">
<span>{title}</span>
<a href="/packages" class="font-sono text-sm underline">View all packages</a>
</header>
<ul class="grid grid-cols-3 bg-black">
{#if packages.length > 0}
{#each packages as pkg}
<div class={pkg.state === PackageStates.INSTALLING ? 'animate-pulse' : ''}>
<PackageCard
{pkg}
link={`/packages/${pkg.slug}`}
ctaLabel={getCTALabel(pkg.state)}
onClickCTA={async () => {
try {
pkg.state = PackageStates.INSTALLING;
await installPackage(pkg.full_name);
pkg.state = PackageStates.INSTALLED;
} catch (error) {
console.error(error);
}
}}
/>
</div>
{/each}
{:else}
{#each Array(9) as _}
<section class="h-50 border-gray border p-4">
<Preloader />
</section>
{/each}
{/if}
</ul>

View file

@ -1,14 +0,0 @@
<script lang="ts">
export let coverUrl = '';
let clazz = '';
export { clazz as class };
</script>
<figure class={`font-machina relative mb-8 h-32 w-full uppercase ${clazz}`}>
{#if coverUrl}
<img src={coverUrl} class="absolute z-0 h-32 w-full object-cover" alt="cover" />
{/if}
<div class="text-primary absolute bottom-0 z-10 text-6xl leading-[32px]">
<slot />
</div>
</figure>

View file

@ -1,24 +0,0 @@
<script lang="ts">
export let label = '';
</script>
<section class="bg-gray p-8">
<header>{label}</header>
<slot />
</section>
<style>
section {
position: relative;
min-height: 240px;
height: 100%;
width: 100%;
min-width: 100%;
/* background-color: #ccc; */
display: flex;
}
header {
color: rgb(50, 48, 48);
font-size: 3em;
}
</style>

View file

@ -1,35 +0,0 @@
<script lang="ts">
import '$appcss';
import { open } from '@tauri-apps/api/shell';
const openGithub = () => {
open('https://github.com/teaxyz');
};
</script>
<div class="card social-box" style="width: 100%; float:right;">
<header class="border-gray text-primary border-b pt-7 pb-7 pl-5">PRE-FLIGHT</header>
<div class="listbox-item border-gray border-b p-6">
<a href="/cli">
<p>Install Tea</p>
</a>
</div>
<div class="listbox-item border-gray border-b p-6">
<div>
<p>Authenticate</p>
</div>
</div>
<div class="listbox-item p-6">
<button on:click={openGithub}>Give tea a star</button>
</div>
</div>
<style>
.card {
border: 2px solid #949494;
background-color: #1a1a1a;
}
.listbox-item {
height: 75px;
}
</style>

View file

@ -1,36 +0,0 @@
<script lang="ts">
import '$appcss';
import { authStore } from '$libs/stores';
import type { Developer } from '@tea/ui/types';
let user: Developer | null = null;
const authPage = `http://localhost:3000/v1/auth/user?device_id=${authStore.deviceId}`; // https://api.tea.xyz/v1/auth/user?device_id=device_id
authStore.subscribe((u) => (user = u));
</script>
{#if user}
<section class="border-gray border-2 bg-black p-2">
<div class="profile_banner border-gray container flex border bg-black">
<img class="w-1/5" src={user.avatar_url || '/images/bored-ape.png'} alt="profile" />
<div class="flex w-4/5 items-center p-5">
<div class="w-1/2 pl-5">
<p class="text-gray uppercase">Authenticated with GitHub</p>
<p />
<p class="text-primary text-4xl">@{user.login}</p>
</div>
<div class="border-gray h-full border-l" />
<div class="w-1/2 pl-10">
<p class="text-gray uppercase leading-loose">
Country: <span>{user?.country}</span><br />Wallet:
{#if user.wallet}
<span>{user.wallet}</span>
{:else}
<a class="text-green underline" href="/">Connect Now</a>
{/if}
</p>
</div>
</div>
</div>
</section>
{/if}

View file

@ -1,103 +0,0 @@
<script lang="ts">
import '$appcss';
import { packagesStore } from '$libs/stores';
import SortingButtons from './SortingButtons.svelte';
import type { GUIPackage } from '$libs/types';
import { PackageStates } from '$libs/types';
import PackageCard from '@tea/ui/package-card/package-card.svelte';
import SearchInput from '@tea/ui/search-input/search-input.svelte';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import { installPackage } from '@api';
let packages: GUIPackage[] = [];
let sortBy = 'popularity';
let sortDirection: 'asc' | 'desc' = 'desc';
const searchLimit = 10;
const setPackages = (pkgs: GUIPackage[], isSearch?: boolean) => {
packages = isSearch
? pkgs
: pkgs.sort((a, b) => {
if (sortBy === 'popularity') {
const aPop = +a.dl_count + a.installs;
const bPop = +b.dl_count + b.installs;
return sortDirection === 'asc' ? aPop - bPop : bPop - aPop;
} else {
// most recent
const aDate = new Date(a.last_modified);
const bDate = new Date(b.last_modified);
return sortDirection === 'asc' ? +aDate - +bDate : +bDate - +aDate;
}
});
};
const onSearch = async (term: string) => {
if (term !== '' && term.length > 1) {
const matchingPackages: GUIPackage[] = await packagesStore.search(term, searchLimit);
setPackages(matchingPackages, true);
} else {
setPackages(packagesStore.packages, false);
}
};
const onSort = (opt: string, dir: 'asc' | 'desc') => {
sortBy = opt;
sortDirection = dir;
setPackages(packages);
};
const getCTALabel = (state: PackageStates): string => {
return {
[PackageStates.AVAILABLE]: 'INSTALL',
[PackageStates.INSTALLED]: 'INSTALLED',
[PackageStates.INSTALLING]: 'INSTALLING',
[PackageStates.UNINSTALLED]: 'RE-INSTALL'
}[state];
};
packagesStore.subscribe(setPackages);
</script>
<div class="border-gray border bg-black">
<section class="flex items-center justify-between">
<div>
<SearchInput size="medium" {onSearch} />
</div>
<div class="pr-4">
<section class="border-gray h-12 w-48 border">
<SortingButtons {onSort} />
</section>
</div>
</section>
<ul class="grid grid-cols-3">
{#if packages.length > 0}
{#each packages as pkg}
<div class={pkg.state === PackageStates.INSTALLING ? 'animate-pulse' : ''}>
<PackageCard
{pkg}
link={`/packages/${pkg.slug}`}
ctaLabel={getCTALabel(pkg.state)}
onClickCTA={async () => {
try {
pkg.state = PackageStates.INSTALLING;
await installPackage(pkg.full_name);
pkg.state = PackageStates.INSTALLED;
} catch (error) {
console.error(error);
}
}}
/>
</div>
{/each}
{:else}
{#each Array(12) as _}
<section class="h-50 border-gray border p-4">
<Preloader />
</section>
{/each}
{/if}
</ul>
</div>

View file

@ -1,132 +0,0 @@
<script lang="ts">
import '$appcss';
export let onSort: (opt: string, dir: 'asc' | 'desc') => void;
let sortBy = 'popularity';
let sortDirection: 'asc' | 'desc' = 'desc';
const sortOptions = ['popularity', 'most recent'];
const setSortBy = (opt: string) => {
sortBy = opt;
if (onSort) {
onSort(sortBy, sortDirection);
}
};
const setSortDir = (opt: string, dir: 'asc' | 'desc') => {
sortDirection = dir;
setSortBy(opt);
};
</script>
<section class="sorting-container font-machina bg-black text-white">
<div class="dropdown">
<div class="dropdown-title">SORT ORDER</div>
<ul class="dropdown-content column flex">
{#each sortOptions as option}
<li class="flex items-center">
<button
class={`sort-btn uppercase ${sortBy === option ? 'active' : ''}`}
on:click={() => setSortBy(option)}
>
{option}
</button>
<div class="direction-arrows">
<button
on:click={() => setSortDir(option, 'asc')}
class={sortBy === option && sortDirection === 'asc' ? 'active' : ''}>&uarr;</button
>
<button
on:click={() => setSortDir(option, 'desc')}
class={sortBy === option && sortDirection === 'desc' ? 'active' : ''}>&darr;</button
>
</div>
</li>
{/each}
</ul>
</div>
</section>
<style>
.direction-arrows {
float: right;
}
.direction-arrows button {
opacity: 0.3;
}
.direction-arrows button.active {
opacity: 1;
}
.sorting-container {
display: inline-block;
text-align: center;
text-decoration: none;
text-transform: uppercase;
max-width: 240px;
width: 100%;
height: 100%;
min-height: 34px;
transition: 0.1s linear;
}
.dropdown {
width: 100%;
height: auto;
position: relative;
display: inline-block;
cursor: pointer;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #1a1a1a;
width: 100%;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
color: white;
list-style: none;
padding: 0px;
}
.dropdown-content li {
position: relative;
padding: 0px 10px;
height: 40px;
width: 100%;
line-height: 40px;
}
.dropdown-content li .sort-btn {
height: 100%;
width: calc(100% - 40px);
opacity: 0.6;
}
.dropdown-content li .sort-btn.active {
font-weight: bold;
opacity: 1;
}
.dropdown-content li .direction-arrows {
position: absolute;
right: 10px;
top: 0px;
}
.dropdown-content li:hover {
background: #00ffd0;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown-title {
height: 50px;
line-height: 50px;
padding-left: 10px;
}
</style>

View file

@ -1,163 +0,0 @@
<script lang="ts">
import { searchStore } from '$libs/stores';
import type { GUIPackage } from '$libs/types';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import PackageCard from '@tea/ui/package-card/package-card.svelte';
import { PackageStates } from '$libs/types';
import Posts from '@tea/ui/Posts/Posts.svelte';
import { installPackage } from '@api';
import type { AirtablePost } from '@tea/ui/types';
let term: string;
let packages: GUIPackage[] = [];
let articles: AirtablePost[] = []; // news, blogs, etc
let workshops: AirtablePost[] = []; // workshops, course
let loading = true;
searchStore.subscribe((v) => {
term = v;
});
searchStore.packagesSearch.subscribe((pkgs) => {
packages = pkgs;
});
searchStore.postsSearch.subscribe((posts) => {
let partialArticles: AirtablePost[] = [];
let partialWorkshops: AirtablePost[] = [];
for (let post of posts) {
if (post.tags.includes('news')) {
partialArticles.push(post);
}
if (post.tags.includes('course') || post.tags.includes('featured_course')) {
partialWorkshops.push(post);
}
}
articles = partialArticles;
workshops = partialWorkshops;
});
searchStore.searching.subscribe((v) => (loading = v));
const getCTALabel = (state: PackageStates): string => {
return {
[PackageStates.AVAILABLE]: 'INSTALL',
[PackageStates.INSTALLED]: 'INSTALLED',
[PackageStates.INSTALLING]: 'INSTALLING',
[PackageStates.UNINSTALLED]: 'RE-INSTALL'
}[state];
};
const onClose = () => {
term = '';
};
</script>
<section class={term ? 'show' : ''}>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<figure on:click={onClose} />
<div class="border-gray z-20 border bg-black">
<header class="flex justify-between p-4">
<div class="text-primary text-2xl">Showing search results for `{term}`</div>
<button on:click={onClose}>&#x2715</button>
</header>
<menu class="bg-accent flex h-8 w-full gap-4 px-4 text-xs">
<button>packages ({packages.length})</button>
<button>articles ({articles.length})</button>
<button>workshops ({workshops.length})</button>
</menu>
<header class="text-primary p-4 text-lg">
Top Package Results ({packages.length})
</header>
<ul class="grid grid-cols-3">
{#if packages.length > 0}
{#each packages as pkg}
<div class={pkg.state === PackageStates.INSTALLING ? 'animate-pulse' : ''}>
<PackageCard
{pkg}
link={`/packages/${pkg.slug}`}
ctaLabel={getCTALabel(pkg.state)}
onClickCTA={async () => {
try {
pkg.state = PackageStates.INSTALLING;
await installPackage(pkg.full_name);
pkg.state = PackageStates.INSTALLED;
} catch (error) {
console.error(error);
}
}}
/>
</div>
{/each}
{:else if loading}
{#each Array(12) as _}
<section class="h-50 border-gray border p-4">
<Preloader />
</section>
{/each}
{/if}
</ul>
<header class="text-primary p-4 text-lg">
Top Article Results ({articles.length})
</header>
{#if articles.length}
<Posts posts={articles} linkTarget="_blank" />
{:else if loading}
<section class="border-gray h-64 border bg-black p-4">
<Preloader />
</section>
{/if}
<header class="text-primary p-4 text-lg">
Top Workshop Results ({workshops.length})
</header>
{#if workshops.length}
<Posts posts={workshops} linkTarget="_blank" />
{:else if loading}
<section class="border-gray h-64 border bg-black p-4">
<Preloader />
</section>
{/if}
</div>
</section>
<style>
section {
position: fixed;
top: 80px;
left: 0px;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 0.3s ease-in-out;
opacity: 0%;
overflow: hidden;
height: 0px;
}
section.show {
padding: 36px;
z-index: 10;
}
section > figure {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
section.show {
opacity: 100%;
height: 100%;
}
section > div {
position: relative;
height: 0%;
transition: height 0.6s ease-in-out;
overflow-y: scroll;
}
section.show > div {
height: 90%;
}
</style>

View file

@ -1,63 +0,0 @@
<script lang="ts">
import '$appcss';
import type { GUIPackage } from '$libs/types';
import type { Package } from '@tea/ui/types';
import { PackageStates } from '$libs/types';
import Preloader from '@tea/ui/Preloader/Preloader.svelte';
import PackageCard from '@tea/ui/package-card/package-card.svelte';
import { onMount } from 'svelte';
import { installPackage } from '@api';
import { packagesStore } from '$libs/stores';
export let pkg: Package;
let packages: GUIPackage[] = [];
const getCTALabel = (state: PackageStates): string => {
return {
[PackageStates.AVAILABLE]: 'INSTALL',
[PackageStates.INSTALLED]: 'INSTALLED',
[PackageStates.INSTALLING]: 'INSTALLING',
[PackageStates.UNINSTALLED]: 'RE-INSTALL'
}[state];
};
onMount(async () => {
if (!packages.length) {
const matches = await packagesStore.search(pkg.desc, 4);
packages = matches.filter((mp) => mp.full_name !== pkg.full_name).slice(0, 3);
}
});
</script>
<header class="border-gray text-primary flex items-center justify-between border bg-black p-4">
<span>MORE LIKE THIS</span>
</header>
<ul class="grid grid-cols-3 bg-black">
{#if packages.length > 0}
{#each packages as pkg}
<div class={pkg.state === PackageStates.INSTALLING ? 'animate-pulse' : ''}>
<PackageCard
{pkg}
link={`/packages/${pkg.slug}`}
ctaLabel={getCTALabel(pkg.state)}
onClickCTA={async () => {
try {
pkg.state = PackageStates.INSTALLING;
await installPackage(pkg.full_name);
pkg.state = PackageStates.INSTALLED;
} catch (error) {
console.error(error);
}
}}
/>
</div>
{/each}
{:else}
{#each Array(9) as _}
<section class="h-50 border-gray border p-4">
<Preloader />
</section>
{/each}
{/if}
</ul>

View file

@ -1,37 +0,0 @@
<script lang="ts">
import { open } from '@tauri-apps/api/shell';
import { authStore } from '$libs/stores';
import type { Developer } from '@tea/ui/types';
import { baseUrl } from '$libs/v1-client';
let user: Developer | null = null;
const deviceId = authStore.deviceIdStore;
const openGithub = () => {
open(`${baseUrl}/auth/user?device_id=${$deviceId}`);
try {
authStore.pollSession();
} catch (error) {
console.error(error);
}
};
authStore.subscribe((u) => (user = u));
</script>
{#if user}
<a href="/profile">
<section class="flex">
<img width="40" height="40" src={user.avatar_url || '/images/bored-ape.png'} alt="profile" />
<div class="text-gray p-2">@{user.login}</div>
</section>
</a>
{:else}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<section class="flex" on:click={openGithub}>
<figure class="p-2">
<img width="28" height="28" src="/images/github.png" alt="profile" />
</figure>
<div class="text-gray p-2">Login</div>
</section>
{/if}

View file

@ -1,75 +0,0 @@
<script lang="ts">
import { page } from '$app/stores';
import { beforeUpdate } from 'svelte';
import { searchStore } from '$libs/stores';
import SearchInput from '@tea/ui/search-input/search-input.svelte';
import { navStore } from '$libs/stores';
import ProfileNavButton from './ProfileNavButton.svelte';
let { nextPath, prevPath } = navStore;
const onSearch = (term: string) => {
searchStore.search(term);
};
let currentPath: string;
beforeUpdate(async () => {
currentPath = $page.url.pathname;
});
</script>
<header class="border-gray flex w-full border border-l-0 border-r-0">
<a href="/">
<img width="40" height="40" src="/images/tea-icon.png" alt="tea" />
</a>
<ul class="text-gray flex h-10 gap-4 pl-4 align-middle leading-10">
<button on:click={navStore.back} class={$prevPath ? 'active' : ''}>&#8592</button>
<button on:click={navStore.next} class={$nextPath ? 'active' : ''}>&#8594</button>
</ul>
<SearchInput
class="flex-grow border border-none py-4"
size="small"
placeholder="search the tea store"
{onSearch}
/>
<ul class="text-gray flex gap-4 pr-4 pt-2 align-middle">
<button class="icon-filter hover:text-white" />
<button class="icon-share hover:text-white" />
<button class="icon-star-empty hover:text-white" />
</ul>
<ProfileNavButton />
</header>
<menu
class="border-gray text-gray flex h-10 gap-4 border border-l-0 border-r-0 border-t-0 pl-4 align-middle leading-10"
>
<a href="/cli" class={currentPath === '/cli' ? 'active' : ''}>install teaCli</a>
<a href="/documentation" class={currentPath === '/documentation' ? 'active' : ''}>documentation</a
>
<a href="/packages" class={currentPath === '/packages' ? 'active' : ''}>packages</a>
<a href="https://github.com/teaxyz" target="_blank" rel="noreferrer">
<i class="icon-star-empty" /> Github (5.2k)
</a>
</menu>
<style>
@tailwind base;
@tailwind components;
@tailwind utilities;
menu > a:hover {
color: white;
}
menu a.active {
color: white;
}
ul button {
pointer-events: none;
}
ul button.active {
color: white;
pointer-events: all;
}
</style>

View file

@ -1,49 +0,0 @@
import { getPkgBottles } from '../tea-dir';
describe('tea-dir module', () => {
it('should getPkgBottles from nested Dir object/s', () => {
const results = getPkgBottles({
name: 'kkos',
path: '/Users/x/.tea/github.com/kkos',
children: [
{ name: '.DS_Store', path: '/Users/x/.tea/github.com/kkos/.DS_Store' },
{
name: 'oniguruma',
path: '/Users/x/.tea/github.com/kkos/oniguruma',
children: [
{ name: '.DS_Store', path: '/Users/x/.tea/github.com/kkos/oniguruma/.DS_Store' },
{
path: '/Users/x/.tea/github.com/kkos/oniguruma/v6',
name: 'v6',
children: [
{ name: '.DS_Store', path: '/Users/x/.tea/github.com/kkos/oniguruma/v6/.DS_Store' }
]
},
{
name: 'v*',
path: '/Users/x/.tea/github.com/kkos/oniguruma/v*',
children: []
},
{
name: 'v6.9.8',
path: '/Users/x/.tea/github.com/kkos/oniguruma/v6.9.8',
children: []
},
{
name: 'v6.9',
path: '/Users/x/.tea/github.com/kkos/oniguruma/v6.9',
children: []
}
]
}
]
});
expect(results).toEqual([
'github.com/kkos/oniguruma/v*',
'github.com/kkos/oniguruma/v6',
'github.com/kkos/oniguruma/v6.9',
'github.com/kkos/oniguruma/v6.9.8'
]);
});
});

View file

@ -1,359 +0,0 @@
/**
* primarily used to make this desktop app work in the website preview setting in the CI/CD
* may contain fake/mock data
*
* TODO:
* * make cors work with api.tea.xyz/v1
*/
import type { Package, Review, AirtablePost, Bottle } from '@tea/ui/types';
import type { GUIPackage, Course, Category } from '../types';
import { PackageStates } from '../types';
import { loremIpsum } from 'lorem-ipsum';
import _ from 'lodash';
const packages: Package[] = [
{
slug: 'mesonbuild_com',
homepage: 'https://mesonbuild.com',
name: 'mesonbuild.com',
version: '0.63.3',
last_modified: '2022-10-06T15:45:08.000Z',
full_name: 'mesonbuild.com',
dl_count: 270745,
thumb_image_name: 'mesonbuild_com_option 1.jpg ',
maintainer: '',
desc: 'Fast and user friendly build system',
thumb_image_url: 'https://tea.xyz/Images/packages/mesonbuild_com.jpg',
installs: 0
},
{
slug: 'pixman_org',
homepage: 'http://www.pixman.org/',
maintainer: 'freedesktop',
name: 'pixman.org',
version: '0.40.0',
last_modified: '2022-09-26T19:37:47.000Z',
full_name: 'pixman.org',
dl_count: 0,
thumb_image_name: 'pixman_org_option 1.jpg ',
desc: 'Pixman is a library that provides low-level pixel manipulation features such as image compositing and trapezoid rasterization.',
thumb_image_url: 'https://tea.xyz/Images/packages/pixman_org.jpg',
installs: 0
},
{
slug: 'freedesktop_org_pkg_config',
homepage: 'https://freedesktop.org',
maintainer: 'freedesktop.org',
name: 'pkg-config',
version: '0.29.2',
last_modified: '2022-10-20T01:32:15.000Z',
full_name: 'freedesktop.org/pkg-config',
dl_count: 2661501,
thumb_image_name: 'freedecktop_org_pkg_config option 1.jpg ',
desc: 'Manage compile and link flags for libraries',
thumb_image_url: 'https://tea.xyz/Images/packages/freedesktop_org_pkg_config.jpg',
installs: 0
},
{
slug: 'gnu_org_gettext',
homepage: 'https://gnu.org',
maintainer: 'gnu.org',
name: 'gettext',
version: '0.21.1',
last_modified: '2022-10-20T01:23:46.000Z',
full_name: 'gnu.org/gettext',
dl_count: 3715970,
thumb_image_name: 'gnu_org_gettext_option 1.jpg ',
desc: 'GNU internationalization (i18n) and localization (l10n) library',
thumb_image_url: 'https://tea.xyz/Images/packages/gnu_org_gettext.jpg',
installs: 0
},
{
slug: 'ipfs_tech',
homepage: 'https://ipfs.tech',
name: 'ipfs.tech',
version: '0.16.0',
last_modified: '2022-10-19T21:36:52.000Z',
full_name: 'ipfs.tech',
dl_count: 14457,
thumb_image_name: 'ipfs_tech_option 2.jpg ',
maintainer: '',
desc: 'Peer-to-peer hypermedia protocol',
thumb_image_url: 'https://tea.xyz/Images/packages/ipfs_tech.jpg',
installs: 0
},
{
slug: 'nixos_org_patchelf',
homepage: 'https://nixos.org',
maintainer: 'nixos.org',
name: 'patchelf',
version: '0.15.0',
last_modified: '2022-09-27T04:50:44.000Z',
full_name: 'nixos.org/patchelf',
dl_count: 0,
thumb_image_name: 'nixos_org_patchelf_option 1.jpg ',
desc: 'PatchELF is a simple utility for modifying existing ELF executables and libraries.',
thumb_image_url: 'https://tea.xyz/Images/packages/nixos_org_patchelf.jpg',
installs: 0
},
{
slug: 'tea_xyz',
homepage: 'https://tea.xyz',
maintainer: 'tea.xyz',
name: 'tea.xyz',
version: '0.8.6',
last_modified: '2022-10-19T19:13:51.000Z',
full_name: 'tea.xyz',
dl_count: 0,
thumb_image_name: 'tea_xyz_option 2.jpg ',
desc: 'Website of tea.xyz',
thumb_image_url: 'https://tea.xyz/Images/packages/tea_xyz.jpg',
installs: 0
},
{
slug: 'charm_sh_gum',
homepage: 'https://charm.sh',
maintainer: 'charm.sh',
name: 'gum',
version: '0.8.0',
last_modified: '2022-10-21T02:15:16.000Z',
full_name: 'charm.sh/gum',
dl_count: 0,
thumb_image_name: 'charm_sh_gum.jpg ',
desc: '',
thumb_image_url: 'https://tea.xyz/Images/packages/charm_sh_gum.jpg',
installs: 0
},
{
slug: 'pyyaml_org',
homepage: 'https://pyyaml.org',
name: 'pyyaml.org',
version: '0.2.5',
last_modified: '2022-10-03T15:35:14.000Z',
full_name: 'pyyaml.org',
dl_count: 107505,
thumb_image_name: 'pyyaml_org_option 1.jpg ',
maintainer: '',
desc: 'YAML framework for Python',
thumb_image_url: 'https://tea.xyz/Images/packages/pyyaml_org.jpg',
installs: 0
},
{
slug: 'tea_xyz_gx_cc',
homepage: 'https://tea.xyz',
maintainer: 'tea.xyz',
name: 'cc',
version: '0.1.0',
last_modified: '2022-10-19T16:47:44.000Z',
full_name: 'tea.xyz/gx/cc',
dl_count: 0,
thumb_image_name: 'tea_xyz_gx.jpg ',
desc: '',
thumb_image_url: 'https://tea.xyz/Images/packages/tea_xyz_gx_cc.jpg',
installs: 0
}
];
export async function getPackages(): Promise<GUIPackage[]> {
await delay(2000);
return packages.map((pkg) => {
return {
...pkg,
state: PackageStates.AVAILABLE
};
});
}
export async function getFeaturedPackages(): Promise<Package[]> {
await delay(2000);
return packages.slice(0, 4);
}
export async function getPackageReviews(full_name: string): Promise<Review[]> {
console.log(`generating reviews for ${full_name}`);
const reviewCount = _.random(9, 21);
const reviews: Review[] = [];
for (let i = 0; i < reviewCount; i++) {
const title = loremIpsum({
count: _.random(2, 5),
format: 'plain',
paragraphLowerBound: 3,
paragraphUpperBound: 7,
random: Math.random,
sentenceLowerBound: 5,
sentenceUpperBound: 15,
units: 'words'
});
const comment = loremIpsum({
count: 2,
format: 'plain',
paragraphLowerBound: 3,
paragraphUpperBound: 7,
random: Math.random,
sentenceLowerBound: 5,
sentenceUpperBound: 15,
units: 'sentences'
});
const rating = _.random(0, 5);
reviews.push({
title,
comment,
rating
});
}
await delay(2000);
return reviews;
}
export async function installPackage(full_name: string) {
console.log('installing: ', full_name);
await delay(10000);
}
function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export async function getFeaturedCourses(): Promise<Course[]> {
const mockCourses: Course[] = [
{
title: 'Developing With Tea',
sub_title: 'by Mxcl',
link: '#',
banner_image_url: 'https://tea.xyz/Images/packages/mesonbuild_com.jpg'
},
{
title: 'Brewing Tea',
sub_title: 'by Mxcl',
link: '#',
banner_image_url: 'https://tea.xyz/Images/packages/tea_xyz_gx_cc.jpg'
},
{
title: 'Harvesting Tea',
sub_title: 'by Mxcl',
link: '#',
banner_image_url: 'https://tea.xyz/Images/packages/ipfs_tech.jpg'
}
];
return mockCourses;
}
export async function getTopPackages(): Promise<GUIPackage[]> {
await delay(500);
return packages.slice(0, 9).map((pkg) => {
return {
...pkg,
state: PackageStates.AVAILABLE
};
});
}
export async function getAllPosts(type: string): Promise<AirtablePost[]> {
console.log('filter by type:', type);
const posts: AirtablePost[] = [
{
airtable_record_id: 'a',
link: 'https://google.com',
title: 'Tea Inc releases game changing api!',
sub_title: 'lorem ipsum dolor sit amet',
short_description: 'lorem ipsum dolor sit amet',
thumb_image_url: '/images/bored-ape.png',
thumb_image_name: 'borred-api.png',
created_at: new Date(),
updated_at: new Date(),
published_at: new Date(),
tags: ['news']
},
{
airtable_record_id: 'b',
link: 'https://google.com',
title: 'Bored Ape not bored anymore',
sub_title: 'lorem ipsum dolor sit amet',
short_description: 'lorem ipsum dolor sit amet',
thumb_image_url: '/images/bored-ape.png',
thumb_image_name: 'borred-api.png',
created_at: new Date(),
updated_at: new Date(),
published_at: new Date(),
tags: ['news']
},
{
airtable_record_id: 'c',
link: 'https://google.com',
title: 'Markdown can be executed! hoohah!',
sub_title: 'lorem ipsum dolor sit amet',
short_description: 'lorem ipsum dolor sit amet',
thumb_image_url: '/images/bored-ape.png',
thumb_image_name: 'borred-api.png',
created_at: new Date(),
updated_at: new Date(),
published_at: new Date(),
tags: ['news']
}
];
return posts;
}
export async function getCategorizedPackages(): Promise<Category[]> {
const mockPackages = packages.slice(0, 9).map((pkg) => ({
...pkg,
state: PackageStates.AVAILABLE
}));
return [
{
label: 'framework essentials',
cta_label: 'View all essentials >',
packages: mockPackages
},
{
label: 'star-struck heavyweights',
cta_label: 'View all star-strucks >',
packages: mockPackages
},
{
label: 'simply delightful',
cta_label: 'View all delightful packages >',
packages: mockPackages
}
];
}
export async function getDeviceAuth(deviceId: string): Promise<any> {
// const data = await get<any>(`/auth/device/${deviceId}`);
return {
status: 'SUCCESS',
user: {
developer_id: 'xxx',
name: 'Neil paul Molina',
login: 'getneil',
avatar_url: 'https://avatars.githubusercontent.com/u/7913978?v=4',
created_at: 'xxx',
updated_at: 'xxx',
country: 'germany',
wallet: 'wallet'
},
key: 'xxx'
};
}
export async function getPackageBottles(name: string): Promise<Bottle[]> {
return [
{ name, platform: 'darwin', arch: 'aarch64', version: '3.39.4' },
{ name, platform: 'darwin', arch: 'aarch64', version: '3.40.0' },
{ name, platform: 'darwin', arch: 'x86-64', version: '3.39.4' },
{ name, platform: 'darwin', arch: 'x86-64', version: '3.40.0' },
{ name, platform: 'linux', arch: 'aarch64', version: '3.39.4' },
{ name, platform: 'linux', arch: 'aarch64', version: '3.40.0' },
{ name, platform: 'linux', arch: 'x86-64', version: '3.39.4' },
{ name, platform: 'linux', arch: 'x86-64', version: '3.40.0' }
];
}
export async function registerDevice(): Promise<string> {
return 'uuid1234';
}

View file

@ -1,110 +0,0 @@
/**
* this is the main api integration, anything added here
* should be mock replicated in ./mock.ts
* why? to make it easier to verify features without us always
* going through
* the build->download->install->test loop
* thus saving us so much time
*
* primary concerns here are any method that does the following:
* - connect to remote api(api.tea.xyz) and returns a data
* - connect to a local platform api and returns a data
*/
import { getClient } from '@tauri-apps/api/http';
import urlJoin from 'url-join';
import type { Package, Review, AirtablePost, Developer, Bottle } from '@tea/ui/types';
import type { GUIPackage, Course, Category, AuthStatus, DeviceAuth } from '../types';
import * as mock from './mock';
import { PackageStates } from '../types';
import { getInstalledPackages } from '$libs/tea-dir';
import { installPackageCommand } from '$libs/cli';
import { get as apiGet } from '$libs/v1-client';
export async function getPackages(): Promise<GUIPackage[]> {
const [packages, installedPackages] = await Promise.all([
apiGet<Package[]>('packages'),
getInstalledPackages()
]);
return (packages || []).map((pkg) => {
const found = installedPackages.find((p) => p.full_name === pkg.full_name);
return {
...pkg,
state: found ? PackageStates.INSTALLED : PackageStates.AVAILABLE,
installed_version: found ? found.version : ''
};
});
}
export async function getFeaturedPackages(): Promise<Package[]> {
const packages = await mock.getFeaturedPackages();
return packages;
}
export async function getPackageReviews(full_name: string): Promise<Review[]> {
console.log(`getting reviews for ${full_name}`);
const reviews: Review[] = await apiGet<Review[]>(
`packages/${full_name.replaceAll('/', ':')}/reviews`
);
return reviews;
}
export async function installPackage(full_name: string) {
try {
await installPackageCommand(full_name);
} catch (error) {
console.error(error);
}
}
export async function getFeaturedCourses(): Promise<Course[]> {
const posts = await apiGet<AirtablePost[]>('posts', { tag: 'featured_course' });
return posts.map((post) => {
return {
title: post.title,
sub_title: post.sub_title,
banner_image_url: post.thumb_image_url,
link: post.link
} as Course;
});
}
export async function getTopPackages(): Promise<GUIPackage[]> {
const packages = await mock.getTopPackages();
return packages;
}
export async function getAllPosts(tag?: string): Promise<AirtablePost[]> {
// add filter here someday: tag = news | course
const posts = await apiGet<AirtablePost[]>('posts', tag ? { tag } : {});
return posts;
}
export async function getCategorizedPackages(): Promise<Category[]> {
const categories = await apiGet<Category[]>('/packages/categorized');
return categories;
}
export async function getDeviceAuth(deviceId: string): Promise<DeviceAuth> {
const data = await apiGet<DeviceAuth>(`/auth/device/${deviceId}`);
return data;
}
export async function getPackageBottles(packageName: string): Promise<Bottle[]> {
console.log('getting bottles for ', packageName);
const client = await getClient();
const uri = urlJoin('https://app.tea.xyz/api/bottles/', packageName);
const { data } = await client.get<Bottle[]>(uri.toString());
console.log('got bottles', data);
return data;
}
export async function registerDevice(): Promise<string> {
const { deviceId } = await apiGet<{ deviceId: string }>('/auth/registerDevice');
return deviceId;
}

View file

@ -1,33 +0,0 @@
import { Command } from '@tauri-apps/api/shell';
export async function installPackageCommand(full_name: string) {
return new Promise((resolve, reject) => {
const teaInstallCommand = new Command('tea-install', [`+${full_name}`, 'true']);
teaInstallCommand.on('error', reject);
const handleLineOutput = async (line: string | { code: number }) => {
const c = await child;
if (
(typeof line === 'string' && line.includes('installed:')) ||
(typeof line !== 'string' && line?.code === 0)
) {
c.kill();
resolve(c.pid);
} else if (typeof line !== 'string' && line?.code === 1) {
reject();
}
};
teaInstallCommand.stdout.on('data', handleLineOutput);
teaInstallCommand.stderr.on('data', handleLineOutput);
teaInstallCommand.on('close', (line: string) => {
console.log('command closed!');
handleLineOutput(line || '');
});
teaInstallCommand.on('error', (line: string) => {
console.log('command error!', line);
handleLineOutput(line || '');
});
const child = teaInstallCommand.spawn();
});
}

View file

@ -1,144 +0,0 @@
import { writable } from 'svelte/store';
import Fuse from 'fuse.js';
import type { Package, Review, AirtablePost } from '@tea/ui/types';
import type { GUIPackage } from '$libs/types';
import { getFeaturedPackages, getPackageReviews, getAllPosts } from '@api';
import initAuthStore from './stores/auth';
import initNavStore from './stores/nav';
import initPackagesStore from './stores/pkgs';
export const featuredPackages = writable<Package[]>([]);
export const packagesStore = initPackagesStore();
export const initializeFeaturedPackages = async () => {
console.log('intialize featured packages');
const packages = await getFeaturedPackages();
featuredPackages.set(packages);
};
interface PackagesReview {
[full_name: string]: Review[];
}
function initPackagesReviewStore() {
const { update, subscribe } = writable<PackagesReview>({});
let packagesReviews: PackagesReview = {};
subscribe((v) => (packagesReviews = v));
const getSetPackageReviews = async (full_name: string) => {
if (full_name && !packagesReviews[full_name]) {
packagesReviews[full_name] = [];
const reviews = await getPackageReviews(full_name);
update((v) => {
return {
...v,
[full_name]: reviews
};
});
}
};
return {
subscribe: (full_name: string, reset: (reviews: Review[]) => void) => {
getSetPackageReviews(full_name);
return subscribe((value) => {
if (value[full_name]) {
reset(value[full_name]);
}
});
}
};
}
export const packagesReviewStore = initPackagesReviewStore();
function initPosts() {
let initialized = false;
const { subscribe, set } = writable<AirtablePost[]>([]);
const posts: AirtablePost[] = [];
let postsIndex: Fuse<AirtablePost>;
if (!initialized) {
initialized = true;
getAllPosts().then(set);
}
subscribe((v) => {
posts.push(...v);
postsIndex = new Fuse(posts, {
keys: ['title', 'sub_title', 'short_description', 'tags']
});
});
return {
subscribe,
search: async (term: string, limit = 10) => {
const res = postsIndex.search(term, { limit });
const matchingPosts: AirtablePost[] = res.map((v) => v.item);
return matchingPosts;
},
subscribeByTag: (tag: string, cb: (posts: AirtablePost[]) => void) => {
subscribe((newPosts: AirtablePost[]) => {
const filteredPosts = newPosts.filter((post) => post.tags.includes(tag));
cb(filteredPosts);
});
}
};
}
export const postsStore = initPosts();
function initSearchStore() {
const searching = writable<boolean>(false);
const { subscribe, set } = writable<string>('');
const packagesSearch = writable<GUIPackage[]>([]);
const postsSearch = writable<AirtablePost[]>([]);
// TODO:
// should use algolia if user is somehow online
const packagesFound: GUIPackage[] = [];
let term = '';
subscribe((v) => (term = v));
packagesSearch.subscribe((v) => packagesFound.push(...v));
return {
term,
searching,
packagesSearch,
postsSearch,
packagesFound,
subscribe,
search: async (term: string) => {
searching.set(true);
try {
if (term) {
const [resultPkgs, resultPosts] = await Promise.all([
packagesStore.search(term, 5),
postsStore.search(term, 10)
]);
packagesSearch.set(resultPkgs);
postsSearch.set(resultPosts);
} else {
packagesSearch.set([]);
postsSearch.set([]);
}
set(term);
} finally {
searching.set(false);
}
}
};
}
export const searchStore = initSearchStore();
export const authStore = initAuthStore();
export const navStore = initNavStore();

Some files were not shown because too many files have changed in this diff Show more