npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@boze46/dirate

v0.1.0

Published

CLI tool to manage Linux user-dirs based on a KDL layout.

Downloads

6

Readme

Dirate

Dirate = dir + curate:Bun 驱动的交互式 CLI,可根据 dirs.kdl(兼容旧版 folder.kdl)描述同步与整理 Linux XDG user-dirs 及自定义目录结构。

使用 Bun/TypeScript 编写的交互式工具,可根据 dirs.kdl 描述同步 Linux XDG user-dirs 及自定义目录结构。

安装

Dirate 依赖 Bun >= 1.3.3,可直接通过 bunx 试用,或全局安装:

bunx @boze46/dirate --help
# 或全局安装后直接使用
npm install -g @boze46/dirate
dirate --help

即便通过 npm 安装,CLI 仍通过 #!/usr/bin/env bun 启动,需确保本地已安装 Bun(参考 https://bun.sh/ 安装指南)。

运行方式

bun install
bun run src/index.ts help             # 默认输出帮助
bun run src/index.ts init             # 在 ~/.config/dirate 生成模板 dirs.kdl
bun run src/index.ts sync \
  --dirs ~/.config/dirate/dirs.kdl \
  --config ~/.config/user-dirs.dirs
bun run src/index.ts version

参数说明:

  • --dirs: KDL 布局文件路径,默认按顺序查找 $XDG_CONFIG_HOME/dirate/dirs.kdl./dirs.kdl./folder.kdl
  • --config: user-dirs.dirs 文件路径,默认 $XDG_CONFIG_HOME/user-dirs.dirs(或 ~/.config/user-dirs.dirs)。
  • --dry-run: 仅输出计划与提示,不执行任何写操作。
  • --backup-dir: 自定义备份根目录(默认 $HOME/.bak)。
  • --yes/-y--no/-n: 无交互模式,分别全选同意/拒绝(不可同时指定)。
  • 子命令:help(默认)、initsyncversion
  • 环境变量等价项:DIRATE_DIRS_PATHDIRATE_CONFIG_PATHDIRATE_BACKUP_DIRDIRATE_DRY_RUNDIRATE_YESDIRATE_NO
  • init: 生成一份带注释的 dirs.kdl 模板,便于开始使用。

功能特性

  1. KDL 布局解析home { ... } 树定义目录层级;user-dirs(desktop/download/...)可使用 "新名称" 重命名并支持嵌套。
  2. 迁移与备份:对 8 个固定 XDG 目录生成迁移计划,逐步确认;目标存在且非空时提供 备份后替换合并删除跳过 选项。备份统一存储于 $HOME/.bak/<timestamp>/...
  3. 配置同步:迁移后写回 user-dirs.dirs,写入前自动备份;流程结束可选择执行 xdg-user-dirs-update
  4. 自定义目录创建:对非 user-dirs 节点统一 mkdir -p,已存在则跳过。
  5. 安全模式:所有写操作均需确认;--dry-run 用于审阅计划。

开发/测试

项目依赖 Bun 1.3+,使用 Bun 作为唯一包管理与运行时。可参考 user-dirs.dirs.sample 与示例 folder.kdl 做 dry-run:

bun run src/index.ts --dry-run \
  --config ./user-dirs.dirs.sample \
  --kdl ./folder.kdl

类型检查:

bun run typecheck

KDL 约定

  • 根节点必须为 home
  • 8 个 XDG 目录以英文小写键名:desktop, download, templates, publicshare, documents, music, pictures, videos
  • 需要重命名时使用字符串值:music "audio";普通目录仅保留名称(可继续嵌套子节点)。