Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Migrate to WXT #44

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions .github/workflows/submit.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
.output
dist
artifacts
*.local
coverage
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ dist-*
artifacts
coverage
.wxt
.output
dist
coverage
*.lock
413 changes: 286 additions & 127 deletions bun.lock

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,34 @@
"type": "module",
"scripts": {
"check": "check",
"dev": "wxt",
"dev:firefox": "wxt --browser firefox",
"build": "wxt build",
"build:firefox": "wxt build --browser firefox",
"dev": "vite",
"build": "vite build",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"zip": "wxt zip",
"zip:firefox": "wxt zip -b firefox",
"prepare": "simple-git-hooks",
"postinstall": "wxt prepare"
"prepare": "simple-git-hooks"
},
"dependencies": {
"@aklinker1/check": "^1.4.5",
"@tanstack/vue-query": "^5.59.13",
"@webext-core/messaging": "^2.0.2",
"@webext-core/proxy-service": "^1.2.0",
"@wxt-dev/storage": "^1.1.0",
"async-mutex": "^0.5.0",
"fast-deep-equal": "^3.1.3",
"minimatch": "^10.0.1",
"ofetch": "^1.4.1"
},
"devDependencies": {
"@aklinker1/generate-changelog": "^1.1.2",
"@crxjs/vite-plugin": "^2.0.0-beta.31",
"@iconify/json": "^2.2.261",
"@tailwindcss/vite": "^4.0.6",
"@types/bun": "^1.1.11",
"@types/chrome": "^0.0.278",
"@types/chrome": "^0.0.304",
"@types/jsdom": "^21.1.7",
"@vitejs/plugin-vue": "^5.2.1",
"@vitest/coverage-v8": "^2.1.3",
"@wxt-dev/auto-icons": "^1.0.2",
"@wxt-dev/i18n": "^0.2.1",
"@wxt-dev/module-vue": "^1.0.1",
"daisyui": "^5.0.0-beta.7",
"env-cmd": "^10.1.0",
"fast-glob": "^3.3.2",
Expand All @@ -49,10 +45,10 @@
"tailwindcss": "^4.0.6",
"typescript": "^5.6.3",
"unplugin-icons": "^0.19.3",
"vite": "6.0.8",
"vitest": "^2.1.3",
"vue": "^3.5.12",
"vue-tsc": "^2.1.6",
"wxt": "^0.19.11"
"vue-tsc": "^2.1.6"
},
"simple-git-hooks": {
"pre-commit": "bun lint-staged"
Expand Down
3 changes: 3 additions & 0 deletions src/components/CommitDiff.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { i18n } from "@/utils/i18n";
import { createDiffComponent } from "./createDiffComponent";

export const CommitDiff = createDiffComponent({
getAdditionsElement: () =>
document.querySelector<HTMLElement>("#toc>*>strong:nth-child(2)"),
Expand Down
3 changes: 3 additions & 0 deletions src/components/CompareDiff.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { i18n } from "@/utils/i18n";
import { createDiffComponent } from "./createDiffComponent";

export const CompareDiff = createDiffComponent({
getAdditionsElement: () =>
document.querySelectorAll<HTMLElement>(".toc-diff-stats>strong")[0],
Expand Down
2 changes: 2 additions & 0 deletions src/components/CustomListItem.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts" setup>
import { i18n } from "@/utils/i18n";

defineProps<{
value: string;
}>();
Expand Down
1 change: 1 addition & 0 deletions src/components/CustomListsPref.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { computed } from "vue";
import type { CustomLists } from "@/utils/storage";
import CustomListItem from "./CustomListItem.vue";
import { i18n } from "@/utils/i18n";

const customLists = defineModel<CustomLists>("customLists", { required: true });

Expand Down
3 changes: 3 additions & 0 deletions src/components/OptionsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
githubPatStorage,
customListsStorage,
} from "@/utils/storage";
import { useForm } from "@/composables/useForm";
import { commitHashDiffsCache } from "@/utils/global-cache";
import { i18n } from "@/utils/i18n";

const { state, hasChanges, reset, saveChanges } = useForm<{
hideGeneratedLineCount: boolean;
Expand Down
3 changes: 3 additions & 0 deletions src/components/PrDiff.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { i18n } from "@/utils/i18n";
import { createDiffComponent } from "./createDiffComponent";

export const PrDiff = createDiffComponent({
getAdditionsElement: () =>
document.querySelector<HTMLElement>("#diffstat .color-fg-success"),
Expand Down
2 changes: 2 additions & 0 deletions src/components/ShowGeneratedCountPref.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts" setup>
import { i18n } from "@/utils/i18n";

const hideLineCount = defineModel<boolean>("hideGeneratedLineCount", {
required: true,
});
Expand Down
3 changes: 3 additions & 0 deletions src/components/TokenPref.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script lang="ts" setup>
import IMdiEye from "~icons/mdi/eye";
import IMdiEyeOffOutline from "~icons/mdi/eye-off-outline";
import { ref } from "vue";
import { i18n } from "@/utils/i18n";
import useGithubUserQuery from "@/composables/useGithubUserQuery";

const token = defineModel<string>("githubPat", {
required: true,
Expand Down
5 changes: 5 additions & 0 deletions src/components/createDiffComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { DIFF_COMPONENT_ID, GREY_COLOR } from "@/utils/constants";
import type { RecalculateResult } from "@/utils/github";
import { hideGeneratedLineCountStorage } from "@/utils/storage";
import { Spinner } from "./Spinner";
import { i18n } from "@/utils/i18n";
import { logger } from "@/utils/logger";

export function createDiffComponent(options: {
getAdditionsElement: () => HTMLElement | null | undefined;
Expand Down
1 change: 1 addition & 0 deletions src/composables/useForm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import isDeepEqual from "fast-deep-equal";
import { computed, reactive } from "vue";

export function useForm<T extends Record<string, any>>(
initialState: T,
Expand Down
2 changes: 2 additions & 0 deletions src/composables/useGithubUserQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { getGithubService, Github } from "@/utils/github";
import { QueryKeys } from "@/utils/QueryKeys";
import { useQuery } from "@tanstack/vue-query";

export default function (token: { value: string | undefined }) {
const github = getGithubService();
Expand Down
1 change: 1 addition & 0 deletions src/utils/cache/createKeyValueCache.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { storage } from "@wxt-dev/storage";
import { Mutex } from "async-mutex";

interface CachedValue<TValue> {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/github/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type {
PullRequest,
User,
} from "./types";
import { githubPatStorage } from "../storage";
import { logger } from "../logger";

export function createGithubApi() {
/**
Expand Down
4 changes: 4 additions & 0 deletions src/utils/github/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import type { GithubApi } from "./api";
import type { DiffEntry } from "./types";
import { minimatch } from "minimatch";
import { GitAttributes } from "../gitattributes";
import { logger } from "../logger";
import { customListsStorage } from "../storage";
import { commitHashDiffsCache } from "../global-cache";
import { HOUR } from "../time";

export const [registerGithubService, getGithubService] = defineProxyService(
"GithubService",
Expand Down
2 changes: 2 additions & 0 deletions src/utils/replaceCount.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DIFF_COMPONENT_ID } from "./constants";
import { getGithubService } from "./github";
import type { RecalculateOptions, RecalculateResult } from "./github";
import { logger } from "./logger";

/**
* Calculate and add the generated count to the page.
Expand Down
2 changes: 2 additions & 0 deletions src/utils/storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { storage } from "@wxt-dev/storage";

export interface CustomLists {
all: string;
}
Expand Down
18 changes: 15 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
{
"extends": "./.wxt/tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext", "DOM"],
"isolatedModules": true,
"types": ["bun", "unplugin-icons/types/vue"],
"verbatimModuleSyntax": true
"types": ["bun", "unplugin-icons/types/vue", "@types/chrome"],
"verbatimModuleSyntax": true,
"paths": {
"@/*": ["./src/*"],
"~/*": ["./src/*"]
}
}
}
45 changes: 0 additions & 45 deletions wxt.config.ts

This file was deleted.