mirror of
https://github.com/oliverschwendener/ueli.git
synced 2024-10-04 10:07:19 +03:00
Added typechecks
This commit is contained in:
parent
4558edc18e
commit
e3e6ab323e
32
.github/workflows/build.yml
vendored
32
.github/workflows/build.yml
vendored
@ -1,12 +1,12 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -24,22 +24,26 @@ jobs:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 18
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
env:
|
||||
NODE_ENV: development
|
||||
NODE_ENV: development
|
||||
|
||||
- name: Lint TypeScript files
|
||||
- name: Run typecheck
|
||||
run: |
|
||||
pnpm typecheck:electron
|
||||
pnpm typecheck:renderer
|
||||
|
||||
- name: Run linter
|
||||
run: pnpm lint
|
||||
|
||||
- name: Prettier check src folder
|
||||
run: pnpm exec prettier --check src/**/*
|
||||
|
||||
- name: Prettier check electron folder
|
||||
run: pnpm exec prettier --check electron/**/*
|
||||
- name: Run prettier
|
||||
run: |
|
||||
pnpm exec prettier --check src/**/*
|
||||
pnpm exec prettier --check electron/**/*
|
||||
|
||||
- name: Run tests
|
||||
run: pnpm test
|
||||
|
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 18
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
@ -32,6 +32,22 @@ jobs:
|
||||
env:
|
||||
NODE_ENV: development
|
||||
|
||||
- name: Run typecheck
|
||||
run: |
|
||||
pnpm typecheck:electron
|
||||
pnpm typecheck:renderer
|
||||
|
||||
- name: Run linter
|
||||
run: pnpm lint
|
||||
|
||||
- name: Run prettier
|
||||
run: |
|
||||
pnpm exec prettier --check src/**/*
|
||||
pnpm exec prettier --check electron/**/*
|
||||
|
||||
- name: Run tests
|
||||
run: pnpm test
|
||||
|
||||
- name: Bundle files
|
||||
run: pnpm bundle
|
||||
env:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
dist-electron/
|
||||
dist/
|
||||
release/
|
||||
tsconfig.node.tsbuildinfo
|
||||
|
||||
.DS_Store
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { UeliPlugin } from "@common/UeliPlugin";
|
||||
import type { PluginDependencies } from "./PluginDependencies";
|
||||
import type { PluginDependencies } from "../PluginDependencies";
|
||||
|
||||
export const setPluginDependencies = (plugins: UeliPlugin[], pluginDependencies: PluginDependencies) => {
|
||||
for (const plugin of plugins) {
|
||||
|
@ -3,9 +3,15 @@ import type { IpcMain } from "electron";
|
||||
import { serializePluginToIpcEventReturnValue } from "./serializePluginToIpcEventReturnValue";
|
||||
|
||||
export const subscribeToIpcMainEvents = (ipcMain: IpcMain, plugins: UeliPlugin[]) => {
|
||||
ipcMain.on("pluginEnabled", (_, { pluginId }: { pluginId: string }) =>
|
||||
plugins.find(({ id }) => id === pluginId).addSearchResultItemsToSearchIndex(),
|
||||
);
|
||||
ipcMain.on("pluginEnabled", (_, { pluginId }: { pluginId: string }) => {
|
||||
const plugin = plugins.find(({ id }) => id === pluginId);
|
||||
|
||||
if (!plugin) {
|
||||
throw new Error(`Unable to find plugin with id ${pluginId}`);
|
||||
}
|
||||
|
||||
plugin.addSearchResultItemsToSearchIndex();
|
||||
});
|
||||
|
||||
ipcMain.on("getSupportedPlugins", (event) => {
|
||||
event.returnValue = plugins.map((plugin) => serializePluginToIpcEventReturnValue(plugin));
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { join } from "path";
|
||||
import type { PluginDependencies } from "../PluginDependencies";
|
||||
import type { PluginDependencies } from "../../PluginDependencies";
|
||||
|
||||
export class MacOsApplicationIconGenerator {
|
||||
public constructor(private readonly pluginDependencies: PluginDependencies) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { join, normalize, parse } from "path";
|
||||
import type { PluginDependencies } from "../PluginDependencies";
|
||||
import type { PluginDependencies } from "../../PluginDependencies";
|
||||
import { Application } from "./Application";
|
||||
import type { ApplicationRepository } from "./ApplicationRepository";
|
||||
import type { MacOsApplicationIconGenerator } from "./MacOsApplicationIconGenerator";
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { join } from "path";
|
||||
import type { PluginDependencies } from "../PluginDependencies";
|
||||
import type { PluginDependencies } from "../../PluginDependencies";
|
||||
import { Application } from "./Application";
|
||||
import type { ApplicationRepository } from "./ApplicationRepository";
|
||||
import type { WindowsApplicationRetrieverResult } from "./WindowsApplicationRetrieverResult";
|
||||
|
@ -16,12 +16,12 @@ export class SettingsManager {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public getPluginSettingByKey<T>(pluginId: string, key: string, defaultValue?: T): T {
|
||||
public getPluginSettingByKey<T>(pluginId: string, key: string, defaultValue: T): T {
|
||||
return this.getSettingByKey<T>(`plugin[${pluginId}].${key}`, defaultValue);
|
||||
}
|
||||
|
||||
public getSettingByKey<T>(key: string, defaultValue?: T): T {
|
||||
return (this.settings[key] as T) ?? defaultValue;
|
||||
public getSettingByKey<T>(key: string, defaultValue: T): T {
|
||||
return (this.settings[key] as T | undefined) ?? defaultValue;
|
||||
}
|
||||
|
||||
public async saveSetting<T>(key: string, value: T): Promise<void> {
|
||||
|
@ -18,7 +18,8 @@
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:watch": "vitest",
|
||||
"test": "vitest run",
|
||||
"typecheck": "tsc --noEmit"
|
||||
"typecheck:electron": "tsc -p tsconfig.node.json --noEmit",
|
||||
"typecheck:renderer": "tsc -p tsconfig.json --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.6",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { SearchResultItem } from "@common/SearchResultItem";
|
||||
import type { SearchResultItem } from "@common/SearchResultItem";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { filterSearchResultItemsBySearchTerm } from "./filterSearchResultItemsBySearchTerm";
|
||||
|
||||
@ -25,7 +25,7 @@ describe(filterSearchResultItemsBySearchTerm, () => {
|
||||
|
||||
it("should return an empty list if search term does not match any of the search result items", () =>
|
||||
testFilterSearchResultItemsBySearchTerm({
|
||||
searchResultItems: [{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchResultItems: [<SearchResultItem>{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchTerm: "search term",
|
||||
fuzzyness: 0.6,
|
||||
expected: [],
|
||||
@ -34,33 +34,33 @@ describe(filterSearchResultItemsBySearchTerm, () => {
|
||||
it("should return list of one item if search term matches one search result item", () =>
|
||||
testFilterSearchResultItemsBySearchTerm({
|
||||
searchResultItems: [
|
||||
{ id: "item1", name: "Old Man's War", description: "An old book" },
|
||||
{ id: "item2", name: "The Lock Artist", description: "A very old book" },
|
||||
<SearchResultItem>{ id: "item1", name: "Old Man's War", description: "An old book" },
|
||||
<SearchResultItem>{ id: "item2", name: "The Lock Artist", description: "A very old book" },
|
||||
],
|
||||
searchTerm: "Old",
|
||||
fuzzyness: 0.6,
|
||||
expected: [{ id: "item1", name: "Old Man's War", description: "An old book" }],
|
||||
expected: [<SearchResultItem>{ id: "item1", name: "Old Man's War", description: "An old book" }],
|
||||
}));
|
||||
|
||||
it("should be case insensitive", () =>
|
||||
testFilterSearchResultItemsBySearchTerm({
|
||||
searchResultItems: [{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchResultItems: [<SearchResultItem>{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchTerm: "item",
|
||||
fuzzyness: 0.6,
|
||||
expected: [{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
expected: [<SearchResultItem>{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
}));
|
||||
|
||||
it("should include items that partially match the search term if fuzzyness is high", () =>
|
||||
testFilterSearchResultItemsBySearchTerm({
|
||||
searchResultItems: [{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchResultItems: [<SearchResultItem>{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchTerm: "itm",
|
||||
fuzzyness: 0.6,
|
||||
expected: [{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
expected: [<SearchResultItem>{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
}));
|
||||
|
||||
it("should exclude items that partially match the search term if fuzzyness is low", () =>
|
||||
testFilterSearchResultItemsBySearchTerm({
|
||||
searchResultItems: [{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchResultItems: [<SearchResultItem>{ id: "item1", name: "Item 1", description: "Item 1" }],
|
||||
searchTerm: "itm",
|
||||
fuzzyness: 0.2,
|
||||
expected: [],
|
||||
|
@ -20,6 +20,5 @@
|
||||
"@common/*": ["./common/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src", "common"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
"include": ["src", "common"]
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { rmSync } from "fs";
|
||||
import { join } from "path";
|
||||
import { defineConfig, type ConfigEnv, type ServerOptions, type UserConfig } from "vite";
|
||||
import { AliasOptions, defineConfig, type ConfigEnv, type ServerOptions, type UserConfig } from "vite";
|
||||
import electron from "vite-plugin-electron";
|
||||
import renderer from "vite-plugin-electron-renderer";
|
||||
import pkg from "./package.json";
|
||||
@ -13,12 +13,14 @@ export default defineConfig(({ command }: ConfigEnv): UserConfig => {
|
||||
const isBuild = command === "build";
|
||||
const sourcemap = isServe;
|
||||
|
||||
return {
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": join(__dirname, "src"),
|
||||
},
|
||||
const resolve: { alias: AliasOptions } = {
|
||||
alias: {
|
||||
"@common": join(__dirname, "common"),
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
resolve,
|
||||
build: {
|
||||
chunkSizeWarningLimit: 1000,
|
||||
},
|
||||
@ -31,6 +33,7 @@ export default defineConfig(({ command }: ConfigEnv): UserConfig => {
|
||||
options.startup();
|
||||
},
|
||||
vite: {
|
||||
resolve,
|
||||
build: {
|
||||
sourcemap,
|
||||
minify: isBuild,
|
||||
@ -49,6 +52,7 @@ export default defineConfig(({ command }: ConfigEnv): UserConfig => {
|
||||
options.reload();
|
||||
},
|
||||
vite: {
|
||||
resolve,
|
||||
build: {
|
||||
sourcemap: sourcemap ? "inline" : undefined,
|
||||
minify: isBuild,
|
||||
|
Loading…
Reference in New Issue
Block a user