Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d07936e
fix(build): remove stale dist output before building
ugcodrr Oct 6, 2026
6c2cd3f
fix(turbo): point globalDependencies at files that exist
ugcodrr Oct 6, 2026
8cce0ee
fix(skin-renderer): cache native binary in turbo build outputs
ugcodrr Oct 6, 2026
50a80b1
fix(pnpm): exclude generated wasm package from the workspace
ugcodrr Oct 6, 2026
df1e2a9
feat(scripts): add setup-worktree script for new checkouts
ugcodrr Oct 6, 2026
27d6ed5
fix(build): only clean dist for the packages being built
ugcodrr Oct 6, 2026
988097f
fix(scripts): keep submodules on the pinned commit in setup-worktree
ugcodrr Oct 6, 2026
c0a651a
fix(turbo): track root tool configs in task hashes
ugcodrr Oct 6, 2026
31ed029
fix(scripts): normalize repo root path in setup-worktree
ugcodrr Oct 6, 2026
f5f0a3c
chore(t3): add t3.json for parallel worktree threads
ugcodrr Oct 10, 2026
527bb49
fix(build): only remove orphaned dist files in the clean task
ugcodrr Oct 10, 2026
ae1c554
fix(scripts): make setup-worktree safe to run in many worktrees at once
ugcodrr Oct 10, 2026
3037a7c
fix(scripts): evict blur cache temp folders left by crashed setups
ugcodrr Oct 10, 2026
7bd98bb
docs: add AGENTS.md and CLAUDE.md for parallel agent threads
ugcodrr Oct 10, 2026
9e25395
refactor(scripts): convert setup-worktree to TypeScript
ugcodrr Oct 10, 2026
c130b71
refactor(scripts): convert clean-dist to TypeScript
ugcodrr Oct 10, 2026
743f0dc
fix(scripts): replace incomplete blur cache entries
ugcodrr Oct 10, 2026
e63de94
fix(scripts): keep setup running when a submodule can't be checked out
ugcodrr Oct 10, 2026
17af310
fix(scripts): link config files as file symlinks on Windows
ugcodrr Oct 10, 2026
dd170d0
fix(scripts): find submodule repos by name in setup-worktree
ugcodrr Oct 10, 2026
de3c897
refactor(scripts): return early for .d.js outputs in clean-dist
ugcodrr Oct 10, 2026
b97873b
refactor(scripts): drop test-only exports from setup-worktree
ugcodrr Oct 10, 2026
d42ff79
fix(scripts): include blur dependency versions in the blur cache key
ugcodrr Oct 10, 2026
e89ae7c
fix(scripts): keep setup running when a submodule update or cache wri…
ugcodrr Oct 10, 2026
15f863a
fix(scripts): only link config.js into worktrees
ugcodrr Oct 10, 2026
2abd505
docs: clarify which apps/scripts scripts agents may run
ugcodrr Oct 10, 2026
e9ea6dd
fix(scripts): don't clone submodules the main checkout lacks in workt…
ugcodrr Oct 10, 2026
38108ed
fix(scripts): read pinned submodule commits from the index
ugcodrr Oct 10, 2026
73b3c01
fix(scripts): keep setup running when blurring backgrounds fails
ugcodrr Oct 10, 2026
b5a8921
fix(scripts): fetch pinned submodule commits by sha as a fallback
ugcodrr Oct 10, 2026
7a6c41e
fix(scripts): read background names from git with -z
ugcodrr Oct 10, 2026
6cea920
build(turbo): scope .swcrc and tsconfig.base.json to the tasks that u…
ugcodrr Oct 10, 2026
7c55304
fix(scripts): never let git prompt for credentials during setup fetches
ugcodrr Oct 10, 2026
36ff624
fix(scripts): use import attributes in validate-commands
ugcodrr Oct 10, 2026
664176a
build(scripts): typecheck the TypeScript scripts in CI
ugcodrr Oct 10, 2026
fe75f21
fix(scripts): harden setup-worktree edge cases
ugcodrr Oct 10, 2026
dbc9789
fix(scripts): match swc's output extensions in clean-dist
ugcodrr Oct 10, 2026
11d3cd3
docs(agents): tighten AGENTS.md for parallel threads
ugcodrr Oct 10, 2026
c59eeb8
build(t3): run affected typecheck and lint in Verify
ugcodrr Oct 10, 2026
679015f
feat(scripts): link local agent instruction files into worktrees
ugcodrr Oct 10, 2026
bb4296d
chore: stop tracking AGENTS.md and CLAUDE.md
ugcodrr Oct 10, 2026
b250880
chore: stop tracking t3.json
ugcodrr Oct 10, 2026
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
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"start": "node --enable-source-maps .",
"build": "swc src --config-file ../../.swcrc --out-dir dist --strip-leading-paths",
"clean": "node ../../apps/scripts/src/clean-dist.ts",
"typecheck": "tsc --noEmit",
"lint": "oxlint",
"lint:ci": "oxlint --format=github"
Expand Down
1 change: 1 addition & 0 deletions apps/discord-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"start": "node --enable-source-maps .",
"build": "swc src --out-dir dist --strip-leading-paths",
"clean": "node ../../apps/scripts/src/clean-dist.ts",
"typecheck": "tsc --noEmit",
"lint": "oxlint",
"lint:ci": "oxlint --format=github"
Expand Down
2 changes: 2 additions & 0 deletions apps/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"type": "module",
"scripts": {
"lint": "oxlint",
"typecheck": "tsc --noEmit",
"lint:ci": "oxlint --format=github",
"api-key": "node src/api-key.js",
"delete-sessions": "node src/delete-sessions.js",
"limit-redis": "node src/limit-redis.js",
"purge": "node src/purge.js",
"setup-worktree": "node src/setup-worktree.ts",
"rank-emojis": "node src/rank-emojis.js",
"timestamp": "node --no-warnings src/timestamp.js",
"validate-commands": "node --no-warnings src/validate-commands.js"
Expand Down
83 changes: 83 additions & 0 deletions apps/scripts/src/clean-dist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Copyright (c) Statsify
*
* This source code is licensed under the GNU GPL v3 license found in the
* LICENSE file in the root directory of this source tree.
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

/**
* Removes files from `dist` whose source file in `src` no longer exists.
*
* Runs in a package directory as its turbo `clean` task, which `build` depends on, so it
* runs before both a real build and a cache restore. A cache restore writes outputs on
* top of `dist` without deleting anything, so this is what keeps deleted or renamed
* sources from leaving orphaned files behind.
*
* Only orphans are removed, so `dist` is never empty while `pnpm build:watch` rebuilds
* and running apps keep their files.
*
* Usage: node ../../apps/scripts/src/clean-dist.ts
*/

import { existsSync, readdirSync, rmSync, rmdirSync } from "node:fs";
import { join } from "node:path";

const DIST = "dist";
const SRC = "src";

// The source extensions swc compiles to each output extension, with the same base name.
// .cjs isn't compiled, so --copy-files copies it as is
const SOURCE_EXTENSIONS: Record<string, string[]> = {
".js": [".ts", ".tsx", ".js", ".jsx", ".mjs", ".es6", ".es"],
".mjs": [".mts"],
".cjs": [".cts", ".cjs"],
};

/**
* @param file path relative to dist
*/
function hasSource(file: string): boolean {
const match = /^(.+?)(\.[cm]?js)(\.map)?$/.exec(file);

// Files that swc copies as is with --copy-files
if (!match) return existsSync(join(SRC, file));

const [, base, outputExtension] = match;

// swc doesn't compile declaration files, so a .d.js output is always an orphan
if (base.endsWith(".d")) return false;

return SOURCE_EXTENSIONS[outputExtension].some((extension) =>
existsSync(join(SRC, `${base}${extension}`)),
);
}

/**
* @param dir path relative to dist
* @returns the number of orphaned files removed
*/
function prune(dir: string): number {
let removed = 0;

for (const entry of readdirSync(join(DIST, dir), { withFileTypes: true })) {
const path = join(dir, entry.name);

if (entry.isDirectory()) {
removed += prune(path);
} else if (!hasSource(path)) {
rmSync(join(DIST, path), { force: true });
removed++;
}
}

if (dir && readdirSync(join(DIST, dir)).length === 0)
rmdirSync(join(DIST, dir));

return removed;
}

if (existsSync(DIST)) {
const removed = prune("");
if (removed > 0) console.log(`Removed ${removed} orphaned files from dist`);
}
Loading
Loading