run typescript check as part of ci (#503)

* run typescript check as part of ci

* fix compilation
This commit is contained in:
ABevier 2023-04-25 18:41:06 -04:00 committed by GitHub
parent c1c626cc80
commit 7c9aabd013
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 74 additions and 71 deletions

View file

@ -45,6 +45,8 @@ jobs:
with: with:
version: 0.26.2 version: 0.26.2
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: env file
run: cp modules/desktop/.env.example modules/desktop/.env
- name: install app dependencies - name: install app dependencies
run: tea -E xc setup run: tea -E xc setup
# TODO: fix # TODO: fix
@ -52,6 +54,8 @@ jobs:
# run: pnpm --filter desktop run coverage # run: pnpm --filter desktop run coverage
- name: lint - name: lint
run: tea -E pnpm -r lint run: tea -E pnpm -r lint
- name: chec
run: tea -E pnpm -r check
build_svelte: build_svelte:
needs: changes needs: changes
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -54,11 +54,16 @@ contribute to them:
The following can be run with [`xc`], eg. `xc build` The following can be run with [`xc`], eg. `xc build`
## Setup ## Setup
Setup ensures that required configuration placeholder files are present and installs dependencies.
```sh ```sh
if [ ! -e modules/desktop/electron/config.json ]; then if [ ! -e modules/desktop/electron/config.json ]; then
echo '{}' > modules/desktop/electron/config.json echo '{}' > modules/desktop/electron/config.json
fi fi
if [ ! -e modules/desktop/.env ]; then
cp modules/desktop/.env.example modules/desktop/.env
fi
pnpm install pnpm install
``` ```
@ -90,6 +95,14 @@ pnpm --filter tea exec pnpm predist
pnpm --filter tea exec pnpm dist pnpm --filter tea exec pnpm dist
``` ```
## Check
Runs the typescript compiler and linter.
```sh
pnpm run -r check
pnpm run -r lint
```
# Dependencies # Dependencies
| Project | Version | | Project | Version |
@ -103,4 +116,4 @@ pnpm --filter tea exec pnpm dist
[`xc`]: https://xcfile.dev [`xc`]: https://xcfile.dev
[semver]: https://semver.org [semver]: https://semver.org
[notion]: https://www.notion.so/teaxyz/tea-gui-fdd9f50aa980432fa370b2cf6a03cb50 [notion]: https://www.notion.so/teaxyz/tea-gui-fdd9f50aa980432fa370b2cf6a03cb50
[discussion]: https://github.com/orgs/teaxyz/discussions [discussion]: https://github.com/orgs/teaxyz/discussions

View file

@ -0,0 +1,2 @@
PUBLIC_VERSION: dev
PUBLIC_MIXPANEL_TOKEN: <token>

View file

@ -135,7 +135,7 @@ export async function openPackageEntrypointInTerminal(pkg: string) {
}); });
child.on("exit", (code) => { child.on("exit", (code) => {
console.info("exit:", code, `\`${stdout}\``); log.info("exit:", code, `\`${stdout}\``);
if (code == 0) { if (code == 0) {
resolve(stdout); resolve(stdout);
} else { } else {

View file

@ -25,8 +25,8 @@
"unit:test": "vitest", "unit:test": "vitest",
"coverage": "vitest run --coverage", "coverage": "vitest run --coverage",
"test": "playwright test", "test": "playwright test",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --compiler-warnings \"css-unused-selector:ignore\"",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --compiler-warnings \"css-unused-selector:ignore\" --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .", "lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ." "format": "prettier --plugin-search-dir . --write ."
}, },

View file

@ -1,33 +0,0 @@
<script lang="ts">
import '$appcss';
import Button from '@tea/ui/button/button.svelte';
import { openTerminal } from '@native';
let copyButtonText = 'COPY';
const copyValue = `sh <(curl https://tea.xyz)`;
const onCopy = () => {
copyButtonText = 'COPIED!';
navigator.clipboard.writeText(copyValue);
};
const onInstall = () => {
openTerminal(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={onInstall}
>OPEN IN TERMINAL</Button
>
</footer>
</section>

View file

@ -9,8 +9,6 @@
const bugFormUrl = `https://airtable.com/shravDxWeNwwpPkFV?prefill_log_id=${logId}&hide_log_id=true`; const bugFormUrl = `https://airtable.com/shravDxWeNwwpPkFV?prefill_log_id=${logId}&hide_log_id=true`;
shellOpenExternal(bugFormUrl); shellOpenExternal(bugFormUrl);
}; };
const preventDoubleClick = (evt: MouseEvent) => evt.stopPropagation();
</script> </script>
<div class="mr-1 flex h-full items-center justify-end gap-2 p-2"> <div class="mr-1 flex h-full items-center justify-end gap-2 p-2">

View file

@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import { page } from "$app/stores";
import { beforeUpdate } from "svelte";
import { searchStore } from "$libs/stores"; import { searchStore } from "$libs/stores";
import SearchInput from "@tea/ui/search-input/search-input.svelte"; import SearchInput from "@tea/ui/search-input/search-input.svelte";
import { navStore } from "$libs/stores"; import { navStore } from "$libs/stores";
@ -10,11 +8,6 @@
import { topbarDoubleClick } from "$libs/native-electron"; import { topbarDoubleClick } from "$libs/native-electron";
let { nextPath, prevPath } = navStore; let { nextPath, prevPath } = navStore;
let currentPath: string;
beforeUpdate(async () => {
currentPath = $page.url.pathname;
});
</script> </script>
<header <header

View file

@ -202,7 +202,12 @@ export const openPackageEntrypointInTerminal = (pkg: string) => {
} }
}; };
export const shellOpenExternal = (link: string) => shell.openExternal(link); export const shellOpenExternal = (link?: string) => {
if (!link) {
return;
}
shell.openExternal(link);
};
export const listenToChannel = (channel: string, callback: (data: any) => void) => { export const listenToChannel = (channel: string, callback: (data: any) => void) => {
ipcRenderer.on(channel, (_: any, data: any) => callback(data)); ipcRenderer.on(channel, (_: any, data: any) => callback(data));

View file

@ -6,7 +6,7 @@
* * make cors work with api.tea.xyz/v1 * * make cors work with api.tea.xyz/v1
*/ */
import type { Package, Review, AirtablePost, Bottle } from "@tea/ui/types"; import type { Package, Review, AirtablePost, Bottle } from "@tea/ui/types";
import type { GUIPackage, Course, Category, Session, Packages, AutoUpdateStatus } from "./types"; import type { GUIPackage, Session, Packages, AutoUpdateStatus } from "./types";
import { PackageStates } from "./types"; import { PackageStates } from "./types";
import { loremIpsum } from "lorem-ipsum"; import { loremIpsum } from "lorem-ipsum";
import _ from "lodash"; import _ from "lodash";
@ -29,7 +29,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/mesonbuild_com.jpg", thumb_image_url: "https://tea.xyz/Images/packages/mesonbuild_com.jpg",
installs: 0, installs: 0,
categories: ["foundation_essentials"], categories: ["foundation_essentials"],
created: "2022-10-06T15:45:08.000Z" created: "2022-10-06T15:45:08.000Z",
manual_sorting: 0,
card_layout: "bottom"
}, },
{ {
slug: "pixman_org", slug: "pixman_org",
@ -45,7 +47,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/pixman_org.jpg", thumb_image_url: "https://tea.xyz/Images/packages/pixman_org.jpg",
installs: 0, installs: 0,
categories: ["foundation_essentials"], categories: ["foundation_essentials"],
created: "2022-09-26T19:37:47.000Z" created: "2022-09-26T19:37:47.000Z",
manual_sorting: 1,
card_layout: "bottom"
}, },
{ {
slug: "freedesktop_org_pkg_config", slug: "freedesktop_org_pkg_config",
@ -61,7 +65,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/freedesktop_org_pkg_config.jpg", thumb_image_url: "https://tea.xyz/Images/packages/freedesktop_org_pkg_config.jpg",
installs: 0, installs: 0,
categories: ["foundation_essentials"], categories: ["foundation_essentials"],
created: "2022-10-20T01:32:15.000Z" created: "2022-10-20T01:32:15.000Z",
manual_sorting: 2,
card_layout: "bottom"
}, },
{ {
slug: "gnu_org_gettext", slug: "gnu_org_gettext",
@ -77,7 +83,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/gnu_org_gettext.jpg", thumb_image_url: "https://tea.xyz/Images/packages/gnu_org_gettext.jpg",
installs: 0, installs: 0,
categories: ["foundation_essentials"], categories: ["foundation_essentials"],
created: "2022-10-20T01:23:46.000Z" created: "2022-10-20T01:23:46.000Z",
manual_sorting: 3,
card_layout: "bottom"
}, },
{ {
slug: "ipfs_tech", slug: "ipfs_tech",
@ -93,7 +101,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/ipfs_tech.jpg", thumb_image_url: "https://tea.xyz/Images/packages/ipfs_tech.jpg",
installs: 0, installs: 0,
categories: ["foundation_essentials"], categories: ["foundation_essentials"],
created: "2022-10-19T21:36:52.000Z" created: "2022-10-19T21:36:52.000Z",
manual_sorting: 4,
card_layout: "bottom"
}, },
{ {
slug: "nixos_org_patchelf", slug: "nixos_org_patchelf",
@ -109,7 +119,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/nixos_org_patchelf.jpg", thumb_image_url: "https://tea.xyz/Images/packages/nixos_org_patchelf.jpg",
installs: 0, installs: 0,
categories: ["top_packages", "foundation_essentials"], categories: ["top_packages", "foundation_essentials"],
created: "2022-09-27T04:50:44.000Z" created: "2022-09-27T04:50:44.000Z",
manual_sorting: 5,
card_layout: "bottom"
}, },
{ {
slug: "tea_xyz", slug: "tea_xyz",
@ -125,7 +137,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/tea_xyz.jpg", thumb_image_url: "https://tea.xyz/Images/packages/tea_xyz.jpg",
installs: 0, installs: 0,
categories: ["top_packages", "foundation_essentials"], categories: ["top_packages", "foundation_essentials"],
created: "2022-10-19T19:13:51.000Z" created: "2022-10-19T19:13:51.000Z",
manual_sorting: 6,
card_layout: "bottom"
}, },
{ {
slug: "charm_sh_gum", slug: "charm_sh_gum",
@ -141,7 +155,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/charm_sh_gum.jpg", thumb_image_url: "https://tea.xyz/Images/packages/charm_sh_gum.jpg",
installs: 0, installs: 0,
categories: ["top_packages", "foundation_essentials"], categories: ["top_packages", "foundation_essentials"],
created: "2022-10-21T02:15:16.000Z" created: "2022-10-21T02:15:16.000Z",
manual_sorting: 7,
card_layout: "bottom"
}, },
{ {
slug: "pyyaml_org", slug: "pyyaml_org",
@ -157,7 +173,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/pyyaml_org.jpg", thumb_image_url: "https://tea.xyz/Images/packages/pyyaml_org.jpg",
installs: 0, installs: 0,
categories: ["top_packages", "foundation_essentials"], categories: ["top_packages", "foundation_essentials"],
created: "2022-10-03T15:35:14.000Z" created: "2022-10-03T15:35:14.000Z",
manual_sorting: 8,
card_layout: "bottom"
}, },
{ {
slug: "tea_xyz_gx_cc", slug: "tea_xyz_gx_cc",
@ -173,7 +191,9 @@ const packages: Package[] = [
thumb_image_url: "https://tea.xyz/Images/packages/tea_xyz_gx_cc.jpg", thumb_image_url: "https://tea.xyz/Images/packages/tea_xyz_gx_cc.jpg",
installs: 0, installs: 0,
categories: ["top_packages", "foundation_essentials"], categories: ["top_packages", "foundation_essentials"],
created: "2022-10-19T16:47:44.000Z" created: "2022-10-19T16:47:44.000Z",
manual_sorting: 9,
card_layout: "bottom"
} }
]; ];
@ -236,7 +256,7 @@ export async function getPackageReviews(full_name: string): Promise<Review[]> {
} }
export async function installPackage(pkg: GUIPackage, version?: string) { export async function installPackage(pkg: GUIPackage, version?: string) {
console.log("installing: ", pkg.full_name); console.log("installing: ", pkg.full_name, version);
await delay(10000); await delay(10000);
} }
@ -338,12 +358,12 @@ export const updateSession = async (session: Partial<Session>) => {
export const openTerminal = (cmd: string) => console.log(cmd); export const openTerminal = (cmd: string) => console.log(cmd);
export const shellOpenExternal = (link: string) => { export const shellOpenExternal = (link?: string) => {
window.open(link, "_blank"); window.open(link, "_blank");
}; };
export const listenToChannel = (channel: string, callback: (msg: string, ...args: any) => void) => { export const listenToChannel = (channel: string, callback: (msg: string, ...args: any) => void) => {
console.log("listen to channel", callback); console.log("listen to channel", channel, callback);
}; };
export const relaunch = () => { export const relaunch = () => {
@ -380,7 +400,7 @@ export const topbarDoubleClick = async () => {
console.log("topbar double click"); console.log("topbar double click");
}; };
export const cacheImageURL = async (url: string): Promise<string | undefined> => { export const cacheImageURL = async (_url: string): Promise<string | undefined> => {
return undefined; return undefined;
}; };

View file

@ -1,5 +1,4 @@
import type { GUIPackage } from "$libs/types"; import type { GUIPackage } from "$libs/types";
import type { Package } from "@tea/ui/types";
import { clean } from "semver"; import { clean } from "semver";
import semverCompare from "semver/functions/compare"; import semverCompare from "semver/functions/compare";

View file

@ -4,7 +4,7 @@ import Fuse from "fuse.js";
import type { Package, Review, AirtablePost } from "@tea/ui/types"; import type { Package, Review, AirtablePost } from "@tea/ui/types";
import type { GUIPackage } from "$libs/types"; import type { GUIPackage } from "$libs/types";
import { getFeaturedPackages, getPackageReviews, getAllPosts } from "@native"; import { getFeaturedPackages, getPackageReviews } from "@native";
import initAuthStore from "./stores/auth"; import initAuthStore from "./stores/auth";
import initNavStore from "./stores/nav"; import initNavStore from "./stores/nav";
import initPackagesStore from "./stores/pkgs"; import initPackagesStore from "./stores/pkgs";
@ -61,7 +61,7 @@ export const packagesReviewStore = initPackagesReviewStore();
function initPosts() { function initPosts() {
let initialized = false; let initialized = false;
const { subscribe, set } = writable<AirtablePost[]>([]); const { subscribe } = writable<AirtablePost[]>([]);
const posts: AirtablePost[] = []; const posts: AirtablePost[] = [];
let postsIndex: Fuse<AirtablePost>; let postsIndex: Fuse<AirtablePost>;

View file

@ -5,8 +5,6 @@ import type { Developer } from "@tea/ui/types";
import type { Session } from "$libs/types"; import type { Session } from "$libs/types";
import { getSession as electronGetSession, updateSession as electronUpdateSession } from "@native"; import { getSession as electronGetSession, updateSession as electronUpdateSession } from "@native";
import { navStore } from "$libs/stores";
export let session: Session | null = null; export let session: Session | null = null;
export const getSession = async (): Promise<Session | null> => { export const getSession = async (): Promise<Session | null> => {
session = await electronGetSession(); session = await electronGetSession();

View file

@ -38,7 +38,7 @@ export default function initNavStore() {
if (currentIndex === 0) prevPathStore.set(""); if (currentIndex === 0) prevPathStore.set("");
} }
}, },
setNewPath: (newNextPath: string, newPrevPath: string) => { setNewPath: (newNextPath: string, _newPrevPath: string) => {
const oldCurrentPath = history[currentIndex]; const oldCurrentPath = history[currentIndex];
const isNavArrows = isMovingBack || isMovingNext; const isNavArrows = isMovingBack || isMovingNext;
if (!isNavArrows && newNextPath !== oldCurrentPath) { if (!isNavArrows && newNextPath !== oldCurrentPath) {

View file

@ -18,7 +18,7 @@ import {
} from "@native"; } from "@native";
import { getReadme, getContributors, getRepoAsPackage } from "$libs/github"; import { getReadme, getContributors, getRepoAsPackage } from "$libs/github";
import { NotificationType, type Package } from "@tea/ui/types"; import { NotificationType } from "@tea/ui/types";
import { trackInstall, trackInstallFailed } from "$libs/analytics"; import { trackInstall, trackInstallFailed } from "$libs/analytics";
import { addInstalledVersion } from "$libs/packages/pkg-utils"; import { addInstalledVersion } from "$libs/packages/pkg-utils";
import withDebounce from "$libs/utils/debounce"; import withDebounce from "$libs/utils/debounce";

View file

@ -48,7 +48,7 @@
$: needsUpdateCount = pkgsToUpdate.length; $: needsUpdateCount = pkgsToUpdate.length;
afterNavigate(({ from, to }) => { afterNavigate(({ to }) => {
if (to?.url?.pathname === "/") { if (to?.url?.pathname === "/") {
const tab = to.url.searchParams.get("tab"); const tab = to.url.searchParams.get("tab");
sideMenuOption = !tab ? SideMenuOptions.discover : (tab as SideMenuOptions); sideMenuOption = !tab ? SideMenuOptions.discover : (tab as SideMenuOptions);

View file

@ -1,7 +1,11 @@
{ {
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": "..", "baseUrl": "..",
"paths": {}, "paths": {
"$lib": ["src/lib"],
"$lib/*": ["src/lib/*"]
},
"rootDirs": ["..", "./types"], "rootDirs": ["..", "./types"],
"importsNotUsedAsValues": "error", "importsNotUsedAsValues": "error",
"isolatedModules": true, "isolatedModules": true,