Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/fresh-tools-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"neogrok": patch
---

Migrate to SvelteKit 3 and its TypeScript 6 and Vite 8 toolchain.
4 changes: 3 additions & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import globals from "globals";
import { fileURLToPath } from "node:url";
import ts from "typescript-eslint";
const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));
import svelteConfig from "./svelte.config.js";
import { loadConfig } from "@sveltejs/load-config";

const svelteConfig = (await loadConfig("./", { traverse: false }))?.config;

export default defineConfig(
includeIgnoreFile(gitignorePath),
Expand Down
4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import { createServer } from "node:http";
import { register } from "prom-client";
import { handler } from "./build/handler.js";
import { env } from "./build/env.js";

const env = (name, fallback) =>
name in process.env ? process.env[name] : fallback;

// These are copied straight out of the default SvelteKit entrypoint.
const path = env("SOCKET_PATH", false);
Expand Down
27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,26 @@
"@changesets/cli": "3.0.1",
"@eslint/compat": "2.0.2",
"@eslint/js": "10.0.1",
"@sveltejs/adapter-node": "5.5.4",
"@sveltejs/kit": "2.53.4",
"@sveltejs/vite-plugin-svelte": "6.2.4",
"@tailwindcss/vite": "4.2.1",
"@sveltejs/adapter-node": "6.0.0",
"@sveltejs/kit": "3.0.0",
"@sveltejs/load-config": "0.2.2",
"@sveltejs/vite-plugin-svelte": "7.3.1",
"@tailwindcss/vite": "4.2.2",
"@types/lucene": "2.1.5",
"@types/node": "24.11.0",
"eslint": "10.0.2",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-svelte": "3.15.0",
"prettier": "3.8.1",
"prettier-plugin-svelte": "3.5.1",
"svelte": "5.53.6",
"svelte-check": "4.4.4",
"tailwindcss": "4.2.1",
"svelte": "5.57.1",
"svelte-check": "4.7.5",
"tailwindcss": "4.2.2",
"type-fest": "4.4.0",
"typescript": "5.9.3",
"typescript-eslint": "8.56.1",
"vite": "7.3.1",
"vitest": "4.0.18"
"typescript": "6.0.3",
"typescript-eslint": "8.71.0",
"vite": "8.3.2",
"vitest": "5.0.3"
},
"dependencies": {
"@badrap/valita": "0.4.6",
Expand All @@ -69,5 +70,9 @@
"resolutions": {
"is-core-module": "npm:@nolyfill/is-core-module@^1",
"safer-buffer": "npm:@nolyfill/safer-buffer@^1"
},
"imports": {
"#lib": "./src/lib/index.js",
"#lib/*": "./src/lib/*"
}
}
12 changes: 6 additions & 6 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { building } from "$app/environment";
import { resolveConfiguration } from "$lib/server/configuration";
import type { Handle, HandleServerError } from "@sveltejs/kit/hooks";
import { building } from "$app/env";
import { resolveConfiguration } from "#lib/server/configuration.js";
import {
neogrokRequestCount,
neogrokRequestDuration,
neogrokRequestConcurrency,
} from "$lib/server/metrics";
import type { Handle, HandleServerError } from "@sveltejs/kit";
} from "#lib/server/metrics.js";

if (!building) {
// This seems to be the magic way to do truly one-time setup in both dev and
Expand Down Expand Up @@ -40,8 +40,8 @@ export const handle: Handle = async ({ event, resolve }) => {

// SvelteKit logs an error every time anything requests a URL that does not map
// to a route. Bonkers. Override the default behavior to exclude such cases.
export const handleError: HandleServerError = ({ error, event }) => {
if (event.route.id !== null) {
export const handleError: HandleServerError = ({ error, event, kind }) => {
if (event.route.id !== null && kind === "unknown") {
console.error(error);
}
};
2 changes: 1 addition & 1 deletion src/lib/integer-input.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { computeInputColor } from "$lib/input-colors";
import { computeInputColor } from "#lib/input-colors.js";

type Props = {
value: number;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dev } from "$app/environment";
import { dev } from "$app/env";
import {
Counter,
Gauge,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/search-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
parseFileNameMatch,
} from "./content-parser";
import { makeZoektRequest } from "./zoekt-client";
import { evaluateFileUrlTemplate } from "$lib/url-templates";
import { evaluateFileUrlTemplate } from "#lib/url-templates.js";

export const searchQuerySchema = v.object({
query: v.string(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { browser } from "$app/environment";
import { browser } from "$app/env";
import { createSubscriber } from "svelte/reactivity";

class CatchUpMediaQuery {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/toggle-match-sort-order.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { usePreferences } from "$lib/preferences.svelte";
import { usePreferences } from "#lib/preferences.svelte.js";
import ListOrdered from "lucide-svelte/icons/list-ordered";

const prefs = usePreferences();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/toggle-search-type.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { usePreferences } from "$lib/preferences.svelte";
import { usePreferences } from "#lib/preferences.svelte.js";
import Zap from "lucide-svelte/icons/zap";

const prefs = usePreferences();
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(opengrok-compat)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Link from "$lib/link.svelte";
import { usePreferences } from "$lib/preferences.svelte";
import Link from "#lib/link.svelte";
import { usePreferences } from "#lib/preferences.svelte.js";
type Props = {
children: import("svelte").Snippet;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { escapeRegExp } from "$lib/regexp";
import { configuration } from "$lib/server/configuration";
import { listRepositories } from "$lib/server/zoekt-list-repositories";
import { evaluateFileUrlTemplate } from "$lib/url-templates";
import { escapeRegExp } from "#lib/regexp.js";
import { configuration } from "#lib/server/configuration.js";
import { listRepositories } from "#lib/server/zoekt-list-repositories.js";
import { evaluateFileUrlTemplate } from "#lib/url-templates.js";
import { error, redirect } from "@sveltejs/kit";

export const load: import("./$types").PageServerLoad = async ({
Expand Down Expand Up @@ -41,7 +41,7 @@ export const load: import("./$types").PageServerLoad = async ({
});

if (fileUrl && (await parent()).preferences.openGrokInstantRedirect) {
redirect(301, fileUrl);
redirect(301, fileUrl, { external: true });
}

return { file, fileUrl };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import ExampleQuery from "$lib/example-query.svelte";
import Link from "$lib/link.svelte";
import { escapeRegExp } from "$lib/regexp";
import ExampleQuery from "#lib/example-query.svelte";
import Link from "#lib/link.svelte";
import { escapeRegExp } from "#lib/regexp.js";

type Props = {
data: import("./$types").PageData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { escapeRegExp } from "$lib/regexp";
import { configuration } from "$lib/server/configuration";
import { listRepositories } from "$lib/server/zoekt-list-repositories";
import { evaluateFileUrlTemplate } from "$lib/url-templates";
import { escapeRegExp } from "#lib/regexp.js";
import { configuration } from "#lib/server/configuration.js";
import { listRepositories } from "#lib/server/zoekt-list-repositories.js";
import { evaluateFileUrlTemplate } from "#lib/url-templates.js";
import { error, redirect } from "@sveltejs/kit";

export const load: import("./$types").PageServerLoad = async ({
Expand Down Expand Up @@ -41,7 +41,7 @@ export const load: import("./$types").PageServerLoad = async ({
});

if (fileUrl && (await parent()).preferences.openGrokInstantRedirect) {
redirect(301, fileUrl);
redirect(301, fileUrl, { external: true });
}

return { file, fileUrl };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import ExampleQuery from "$lib/example-query.svelte";
import Link from "$lib/link.svelte";
import { escapeRegExp } from "$lib/regexp";
import ExampleQuery from "#lib/example-query.svelte";
import Link from "#lib/link.svelte";
import { escapeRegExp } from "#lib/regexp.js";

type Props = {
data: import("./$types").PageData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { escapeRegExp } from "$lib/regexp";
import { configuration } from "$lib/server/configuration";
import { listRepositories } from "$lib/server/zoekt-list-repositories";
import { evaluateFileUrlTemplate } from "$lib/url-templates";
import { escapeRegExp } from "#lib/regexp.js";
import { configuration } from "#lib/server/configuration.js";
import { listRepositories } from "#lib/server/zoekt-list-repositories.js";
import { evaluateFileUrlTemplate } from "#lib/url-templates.js";
import { redirect } from "@sveltejs/kit";

export const load: import("./$types").PageServerLoad = async ({
Expand Down Expand Up @@ -41,7 +41,7 @@ export const load: import("./$types").PageServerLoad = async ({
});

if (destinationUrl && (await parent()).preferences.openGrokInstantRedirect) {
redirect(301, destinationUrl);
redirect(301, destinationUrl, { external: true });
}

return { file, destinationUrl };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import ExampleQuery from "$lib/example-query.svelte";
import Link from "$lib/link.svelte";
import { escapeRegExp } from "$lib/regexp";
import ExampleQuery from "#lib/example-query.svelte";
import Link from "#lib/link.svelte";
import { escapeRegExp } from "#lib/regexp.js";

type Props = {
data: import("./$types").PageData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { escapeRegExp } from "$lib/regexp";
import { configuration } from "$lib/server/configuration";
import { listRepositories } from "$lib/server/zoekt-list-repositories";
import { evaluateFileUrlTemplate } from "$lib/url-templates";
import { escapeRegExp } from "#lib/regexp.js";
import { configuration } from "#lib/server/configuration.js";
import { listRepositories } from "#lib/server/zoekt-list-repositories.js";
import { evaluateFileUrlTemplate } from "#lib/url-templates.js";
import { error, redirect } from "@sveltejs/kit";

export const load: import("./$types").PageServerLoad = async ({
Expand Down Expand Up @@ -41,7 +41,7 @@ export const load: import("./$types").PageServerLoad = async ({
});

if (fileUrl && (await parent()).preferences.openGrokInstantRedirect) {
redirect(301, fileUrl);
redirect(301, fileUrl, { external: true });
}

return { file, fileUrl };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import ExampleQuery from "$lib/example-query.svelte";
import Link from "$lib/link.svelte";
import { escapeRegExp } from "$lib/regexp";
import ExampleQuery from "#lib/example-query.svelte";
import Link from "#lib/link.svelte";
import { escapeRegExp } from "#lib/regexp.js";

type Props = {
data: import("./$types").PageData;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(opengrok-compat)/search/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
renderRepoQuery,
} from "./opengrok-lucene.server";
import { redirect } from "@sveltejs/kit";
import { listRepositories } from "$lib/server/zoekt-list-repositories";
import { configuration } from "$lib/server/configuration";
import { listRepositories } from "#lib/server/zoekt-list-repositories.js";
import { configuration } from "#lib/server/configuration.js";

export const load: import("./$types").PageServerLoad = async ({
url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
QueryLocation,
ZoektConversionWarning,
} from "./conversion-warnings";
import { escapeRegExp } from "$lib/regexp";
import { escapeRegExp } from "#lib/regexp.js";

const locationSchema = v.object({
column: v.number(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import ExampleQuery from "$lib/example-query.svelte";
import Expression from "$lib/expression.svelte";
import Link from "$lib/link.svelte";
import ExampleQuery from "#lib/example-query.svelte";
import Expression from "#lib/expression.svelte";
import Link from "#lib/link.svelte";
import {
renderWarning,
type QueryLocation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { escapeRegExp } from "$lib/regexp";
import { configuration } from "$lib/server/configuration";
import { listRepositories } from "$lib/server/zoekt-list-repositories";
import { evaluateFileUrlTemplate } from "$lib/url-templates";
import { escapeRegExp } from "#lib/regexp.js";
import { configuration } from "#lib/server/configuration.js";
import { listRepositories } from "#lib/server/zoekt-list-repositories.js";
import { evaluateFileUrlTemplate } from "#lib/url-templates.js";
import { redirect } from "@sveltejs/kit";

export const load: import("./$types").PageServerLoad = async ({
Expand Down Expand Up @@ -41,7 +41,7 @@ export const load: import("./$types").PageServerLoad = async ({
});

if (destinationUrl && (await parent()).preferences.openGrokInstantRedirect) {
redirect(301, destinationUrl);
redirect(301, destinationUrl, { external: true });
}

return { file, destinationUrl };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import ExampleQuery from "$lib/example-query.svelte";
import Link from "$lib/link.svelte";
import { escapeRegExp } from "$lib/regexp";
import ExampleQuery from "#lib/example-query.svelte";
import Link from "#lib/link.svelte";
import { escapeRegExp } from "#lib/regexp.js";

type Props = {
data: import("./$types").PageData;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(search-page)/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { page } from "$app/state";
import type { SearchResults as ApiSearchResults } from "$lib/server/search-api";
import type { SearchResults as ApiSearchResults } from "#lib/server/search-api.js";
import SearchForm from "./search-form.svelte";
import Lander from "./lander.svelte";
import SearchResults from "./search-results.svelte";
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(search-page)/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
SearchQuery,
SearchResponse,
SearchResults,
} from "$lib/server/search-api";
} from "#lib/server/search-api.js";
import { parseSearchParams } from "./route-search-query";

export type SearchOutcome =
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(search-page)/chunk-renderer.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
import { renderChunksToLineGroups } from "./chunk-renderer";
import type { Chunk } from "$lib/server/search-api";
import type { Chunk } from "#lib/server/search-api.js";

// This is real data from a search result against the zoekt repo:
// r:zoekt f:api test
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(search-page)/chunk-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ContentLine } from "$lib/server/content-parser";
import type { Chunk, ResultFile } from "$lib/server/search-api";
import type { ContentLine } from "#lib/server/content-parser.js";
import type { Chunk, ResultFile } from "#lib/server/search-api.js";

export type LineGroup = Array<{
readonly lineNumber: number;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(search-page)/lander.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Link from "$lib/link.svelte";
import ExampleQuery from "$lib/example-query.svelte";
import Link from "#lib/link.svelte";
import ExampleQuery from "#lib/example-query.svelte";
</script>

<h1 class="text-4xl text-center pt-8 tracking-wide">ɴᴇᴏɢʀᴏᴋ</h1>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(search-page)/line-group.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import type { ResultFile } from "$lib/server/search-api";
import type { ResultFile } from "#lib/server/search-api.js";
import { onMount } from "svelte";
import type { ThemedToken, BundledLanguage } from "shiki";
import { prefersDark } from "$lib/theme";
import { prefersDark } from "#lib/theme.js";
import type { LineGroup } from "./chunk-renderer";
import RenderedContent from "./rendered-content.svelte";

Expand Down
Loading
Loading