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 apps/registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"name": "registry",
"type": "module",
"private": true,
"imports": {
"#styles": "./src/styles/global.css",
"#layout": "./src/layouts/Layout.astro",
"#components/*": "./src/components/*"
},
"scripts": {
"build": "astro build",
"dev": "astro dev",
Expand Down
4 changes: 1 addition & 3 deletions apps/registry/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import "~/styles/global.css";
import "#styles";

interface Props {
title: string;
Expand All @@ -26,12 +26,10 @@ const { title, description } = Astro.props;
<title>{title}</title>
<meta name="description" content={description} />

<!-- Open Graph -->
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={canonical} />

<!-- Twitter -->
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />

Expand Down
2 changes: 1 addition & 1 deletion apps/registry/src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Layout from "~/layouts/Layout.astro";
import Layout from "#layout";

export const prerender = true;

Expand Down
2 changes: 1 addition & 1 deletion apps/registry/src/pages/500.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Layout from "~/layouts/Layout.astro";
import Layout from "#layout";

export const prerender = true;

Expand Down
4 changes: 2 additions & 2 deletions apps/registry/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import TopBar from "~/components/TopBar.astro";
import Layout from "~/layouts/Layout.astro";
import TopBar from "#components/TopBar.astro";
import Layout from "#layout";

export const prerender = true;

Expand Down
1 change: 0 additions & 1 deletion apps/registry/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "astro/tsconfigs/strictest",
"compilerOptions": {
"paths": { "~/*": ["./src/*"] },
"jsxImportSource": "solid-js",
"jsx": "preserve"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/registry/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "u",

"compatibility_date": "2025-12-02",
"compatibility_date": "2026-03-17",

"compatibility_flags": ["nodejs_compat"],

Expand Down
4 changes: 0 additions & 4 deletions biome.json

This file was deleted.

4 changes: 4 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.9/schema.json",
"extends": ["@gameroman/config/biome"]
}
104 changes: 52 additions & 52 deletions bun.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"packages/*"
],
"catalog": {
"@astrojs/cloudflare": "^13.1.3",
"@astrojs/cloudflare": "^13.1.4",
"@astrojs/solid-js": "^6.0.1",
"@tailwindcss/vite": "^4.2.2",
"astro": "^6.0.8",
"rolldown": "^1.0.0-rc.9",
"solid-js": "^1.9.11",
"astro": "^6.1.1",
"rolldown": "^1.0.0-rc.12",
"solid-js": "^1.9.12",
"tailwindcss": "^4.2.2",
"tsdown": "^0.21.4",
"wrangler": "^4.76.0",
"tsdown": "^0.21.7",
"wrangler": "^4.78.0",
"zod": "^4.3.6"
}
},
Expand All @@ -28,8 +28,8 @@
"test": "bun run --cwd ./packages/usts test"
},
"devDependencies": {
"@biomejs/biome": "2.4.8",
"@gameroman/config": "^0.0.2"
"@biomejs/biome": "2.4.9",
"@gameroman/config": "^0.0.5"
},
"overrides": {
"esbuild": "^0.27.3",
Expand Down
32 changes: 18 additions & 14 deletions packages/usts/package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
{
"name": "usts",
"version": "0.1.0",
"type": "module",
"author": "gameroman",
"license": "MIT",
"scripts": {
"build": "bunx --bun tsdown",
"prepublishOnly": "bun run build",
"test": "bun test"
},
"author": "gameroman",
"repository": {
"type": "git",
"url": "https://github.com/us-ts/userscripts.git",
"directory": "packages/usts"
},
"bin": {
"usts": "./dist/cli.mjs"
},
"files": [
"dist"
],
"type": "module",
"imports": {
"#core/*": "./src/core/*.ts",
"#config/*": "./src/config/*.ts"
},
"exports": {
"./bin/cli": "./dist/bin/cli.mjs",
"./cli": "./dist/cli.mjs",
"./config": "./dist/config.mjs",
"./core": "./dist/core.mjs",
"./package.json": "./package.json",
"./types": "./dist/virtual.d.ts"
},
"bin": {
"usts": "./dist/bin/cli.mjs"
},
"engines": {
"node": ">=24.0.0",
"bun": ">=1.3.0"
"scripts": {
"build": "bunx --bun tsdown",
"prepublishOnly": "bun run build",
"test": "bun test"
},
"dependencies": {
"rolldown": "catalog:",
"zod": "catalog:"
},
"devDependencies": {
"tsdown": "catalog:"
},
"engines": {
"bun": ">=1.3.0",
"node": ">=24.0.0"
}
}
35 changes: 0 additions & 35 deletions packages/usts/src/bin/cli.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/usts/src/cli/build/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolveConfig } from "~/config/resolve";
import { buildUserscript } from "~/core/build";
import { watchUserscript } from "~/core/build/watch";
import { resolveConfig } from "#config/resolve";
import { buildUserscript } from "#core/build/index";
import { watchUserscript } from "#core/build/watch";

async function build(options: { watch?: boolean }): Promise<void> {
const { userscriptConfig, root } = await resolveConfig();
Expand Down
62 changes: 62 additions & 0 deletions packages/usts/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { parseArgs } from "node:util";

type CLICommand = "help" | "build";

type Flags = { watch: boolean };

interface Args {
values: Flags;
positionals: string[];
}

async function printHelp() {
console.log(`
usts build - build a userscript
usts build --watch - build userscript in watch mode
`);
}

function isSupportedCommand<T extends CLICommand>(
supportedCommands: T[],
cmd: string,
): cmd is T {
return new Set<string>(supportedCommands).has(cmd);
}

function resolveCommand(parsedArgs: Args): CLICommand {
const cmd = parsedArgs.positionals[2];

if (!cmd) {
return "help";
}

if (isSupportedCommand(["build"], cmd)) {
return cmd;
}

return "help";
}

async function runCommand(cmd: CLICommand, flags: Flags) {
switch (cmd) {
case "help": {
await printHelp();
return;
}
case "build": {
const { build } = await import("./build/index.js");
await build({ watch: flags.watch });
return;
}
}
}

export async function cli(argv: string[]): Promise<void> {
const parsedArgs = parseArgs({
args: argv,
allowPositionals: true,
options: { watch: { type: "boolean", default: false } },
});
const cmd = resolveCommand(parsedArgs);
await runCommand(cmd, parsedArgs.values);
}
87 changes: 30 additions & 57 deletions packages/usts/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,35 @@
import { parseArgs } from "node:util";

type CLICommand = "help" | "build";

type Flags = { watch: boolean };

interface Args {
values: Flags;
positionals: string[];
}

async function printHelp() {
console.log(`
usts build - build a userscript
usts build --watch - build userscript in watch mode
`);
}

function isSupportedCommand<T extends CLICommand>(
supportedCommands: T[],
cmd: string,
): cmd is T {
return new Set<string>(supportedCommands).has(cmd);
}

function resolveCommand(parsedArgs: Args): CLICommand {
const cmd = parsedArgs.positionals[2];

if (!cmd) {
return "help";
}

if (isSupportedCommand(["build"], cmd)) {
return cmd;
}

return "help";
}

async function runCommand(cmd: CLICommand, flags: Flags) {
switch (cmd) {
case "help": {
await printHelp();
return;
#!/usr/bin/env bun

async function main(): Promise<void> {
const bunVersion = process.versions.bun;

if (bunVersion) {
try {
const { semver } = await import("bun");
const supportedBunVersion = ">=1.3.0";
if (!semver.satisfies(bunVersion, supportedBunVersion)) {
throw new Error("Unsupported Bun version. Please upgrade Bun.");
}
} catch {
console.error("Unsupported Bun version. Please upgrade Bun.");
throw new Error("Unsupported Bun version. Please upgrade Bun.");
}
case "build": {
const { build } = await import("./build/index.js");
await build({ watch: flags.watch });
return;
} else {
const version = parseInt(process.versions.node, 10) || 0;
const minSupportedNodeVersion = 24;
if (version < minSupportedNodeVersion) {
throw new Error("Unsupported Node version. Please upgrade Node.\n");
}
}
}

export async function cli(argv: string[]): Promise<void> {
const parsedArgs = parseArgs({
args: argv,
allowPositionals: true,
options: { watch: { type: "boolean", default: false } },
});
const cmd = resolveCommand(parsedArgs);
await runCommand(cmd, parsedArgs.values);
return import("./cli")
.then(({ cli }) => cli(process.argv))
.catch((error: unknown) => {
console.error(error);
process.exit(1);
});
}

main()
.then(() => process.exit(0))
.catch(() => process.exit(1));
2 changes: 1 addition & 1 deletion packages/usts/src/core/build/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as rolldown from "rolldown";

import type { ResolvedUserscriptConfig } from "~/config/schema";
import type { ResolvedUserscriptConfig } from "#config/schema";

import { resolveOptions } from "./options";

Expand Down
2 changes: 1 addition & 1 deletion packages/usts/src/core/build/meta-header.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserscriptMetaHeaderConfig } from "~/config/schema";
import type { UserscriptMetaHeaderConfig } from "#config/schema";

function getHeaderLine(
key: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/usts/src/core/build/options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from "node:path";
import type { InputOptions, OutputOptions } from "rolldown";
import type { ResolvedUserscriptConfig } from "~/config/schema";
import type { ResolvedUserscriptConfig } from "#config/schema";
import { serializeMetaHeader } from "./meta-header";
import { userscriptPlugin } from "./plugin";

Expand Down
Loading