Skip to content

Commit 71eb014

Browse files
committed
Update dependencies, small refactor
1 parent fb71fa3 commit 71eb014

13 files changed

Lines changed: 195 additions & 205 deletions

File tree

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.12/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

bun.lock

Lines changed: 85 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,32 @@
77
"packages/*"
88
],
99
"catalog": {
10-
"@astrojs/cloudflare": "beta",
11-
"@astrojs/solid-js": "beta",
12-
"@better-auth/cli": "^1.4.15",
13-
"@better-auth/passkey": "^1.4.15",
10+
"@astrojs/cloudflare": "13.0.0-beta.1",
11+
"@astrojs/solid-js": "6.0.0-beta.2",
12+
"@better-auth/cli": "^1.4.17",
13+
"@better-auth/passkey": "^1.4.17",
1414
"@tailwindcss/vite": "^4.1.18",
15-
"@typescript/native-preview": "7.0.0-dev.20260118.1",
16-
"astro": "beta",
17-
"better-auth": "^1.4.15",
15+
"astro": "6.0.0-beta.3",
16+
"better-auth": "^1.4.17",
1817
"drizzle-orm": "^0.45.1",
1918
"elysia": "^1.4.22",
20-
"rolldown": "1.0.0-beta.59",
21-
"solid-js": "^1.9.10",
19+
"rolldown": "1.0.0-rc.1",
20+
"solid-js": "^1.9.11",
2221
"tailwindcss": "^4.1.18",
23-
"tsdown": "^0.19.0",
22+
"tsdown": "^0.20.1",
2423
"wrangler": "^4.59.2",
25-
"zod": "^4.3.5"
24+
"zod": "^4.3.6"
2625
}
2726
},
2827
"scripts": {
2928
"lint": "biome lint",
3029
"format": "biome check --write --linter-enabled=false",
31-
"build:app": "bun run -F './apps/registry' build",
32-
"build:cli": "bun run -F './packages/usts' build",
33-
"test": "bun run -F './packages/usts' test"
30+
"build:app": "bun run --cwd ./apps/registry build",
31+
"build:cli": "bun run --cwd ./packages/usts build",
32+
"test": "bun run --cwd ./packages/usts test"
3433
},
3534
"devDependencies": {
36-
"@biomejs/biome": "2.3.11",
37-
"@typescript/native-preview": "catalog:"
35+
"@biomejs/biome": "2.3.12"
3836
},
3937
"overrides": {
4038
"esbuild": "^0.27.2"

packages/usts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"LICENSE"
2121
],
2222
"exports": {
23-
".": "./dist/index.mjs",
2423
"./bin/cli": "./dist/bin/cli.mjs",
2524
"./config": "./dist/config.mjs",
25+
"./core": "./dist/core.mjs",
2626
"./package.json": "./package.json"
2727
},
2828
"bin": {

packages/usts/src/bin/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bun
22

3-
async function main() {
3+
async function main(): Promise<void> {
44
const bunVersion = process.versions.bun;
55

66
if (bunVersion) {
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
import build from "~/core/build";
1+
import { resolveConfig } from "~/config/resolve";
2+
import { buildUserscript } from "~/core/build";
3+
4+
async function build(): Promise<void> {
5+
const { userscriptConfig, root } = await resolveConfig();
6+
7+
const outDir = userscriptConfig.outDir;
8+
9+
if (outDir === root || root.includes(outDir)) {
10+
throw new Error(
11+
"The outDir cannot be the root folder. Please build to a different folder.",
12+
);
13+
}
14+
15+
await buildUserscript(userscriptConfig, { write: true });
16+
}
17+
218
export { build };

packages/usts/src/core/build/build.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
1-
import { resolveConfig } from "~/config/resolve";
2-
import { buildUserscript } from "./build";
1+
import * as path from "node:path";
32

4-
export default async function build(): Promise<void> {
5-
const { userscriptConfig, root } = await resolveConfig();
3+
import * as rolldown from "rolldown";
64

7-
const outDir = userscriptConfig.outDir;
5+
import type { ResolvedUserscriptConfig } from "~/config/schema";
86

9-
if (outDir === root || root.includes(outDir)) {
10-
throw new Error(
11-
"The outDir cannot be the root folder. Please build to a different folder.",
12-
);
7+
import { serializeMetaHeader } from "./meta-header";
8+
9+
async function buildUserscript(
10+
config: ResolvedUserscriptConfig,
11+
options?: { write?: boolean },
12+
): Promise<string> {
13+
const header = serializeMetaHeader(config.header);
14+
15+
const USERSCRIPT_OUTPUT_FILE_NAME = "index.user.js";
16+
const outFile = path.join(config.outDir, USERSCRIPT_OUTPUT_FILE_NAME);
17+
18+
const result = await rolldown.build({
19+
input: config.entryPoint,
20+
tsconfig: true,
21+
plugins: [config.plugins],
22+
output: {
23+
format: "iife",
24+
sourcemap: false,
25+
minify: "dce-only",
26+
postBanner: `${header}\n`,
27+
cleanDir: config.clean,
28+
file: outFile,
29+
},
30+
write: options?.write ?? false,
31+
});
32+
33+
if (result.output.length !== 1) {
34+
throw new Error(`❌ Unexpected userscript build output`);
1335
}
1436

15-
await buildUserscript(userscriptConfig, { write: true });
37+
return result.output[0].code;
1638
}
39+
40+
export { buildUserscript };

packages/usts/src/core/build/meta-header.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ export function serializeMetaHeader(
2828
headerConfig: UserscriptMetaHeaderConfig,
2929
): string {
3030
const headerConfigEntries = Object.entries(headerConfig);
31-
const headerLines = headerConfigEntries.flatMap(([kwy, val]) =>
32-
getHeaderLines(kwy, val),
31+
const headerLines = headerConfigEntries.flatMap(([key, val]) =>
32+
getHeaderLines(key, val),
3333
);
3434

3535
const headerStart = "// ==UserScript==";
3636
const headerEnd = "// ==/UserScript==";
3737
const serializedHeaderLines = headerLines.join("\n");
38-
const serializedHeader =
39-
`${headerStart}\n${serializedHeaderLines}\n${headerEnd}` as const;
38+
const serializedHeader = `${headerStart}\n${serializedHeaderLines}\n${headerEnd}`;
4039
return serializedHeader;
4140
}

packages/usts/src/core/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { buildUserscript } from "./build";

0 commit comments

Comments
 (0)