@r_masseater/vite-plus-adopt
v0.23.2
Published
Adopt h56m secret scanning, commitlint, textlint, fallow and dependency checks into Vite+ through the settings in vite.config.ts, and ship @arethetypeswrong/core for TypeScript 7.
Downloads
11,804
Maintainers
Readme
@r_masseater/vite-plus-adopt
vpa is a CLI that brings secret scanning with h56m, commitlint, textlint, fallow, agent skill installation and pinned command-line tools into Vite+. Write their settings and your dependency rules in vite.config.ts, and vpa reads them from there.
Running vpa once with no arguments runs every configured check in parallel and prints the results together.
It also bundles @arethetypeswrong/core running on TypeScript 7 alone.
For Feature-Sliced Design and other structure rules, use wism.
Published to
Usage
vp add -D @r_masseater/vite-plus-adopt @r_masseater/h56m/presetsimport { betterleaks } from "@r_masseater/h56m/presets";
import type {} from "@r_masseater/vite-plus-adopt";
import { defineConfig } from "vite-plus";
export default defineConfig({
commitlint: { extends: ["@commitlint/config-conventional"] },
dependencyRules: {
banned: { "Import tests from vite-plus/test": ["vitest", "@vitest/*"] },
peerRanges: "intersect",
},
h56m: {
extend: { path: betterleaks },
filter: 'matchesAny(finding.line, [`\\bCF_BEACON_TOKEN = "[0-9a-f]{32}"`])',
ignoredSecrets: ["<SHA-256 of the secret>"],
},
textlint: {
ignores: ["CHANGELOG.md"],
rules: { "preset-ja-technical-writing": true },
},
fallow: { production: true, rules: { "unused-files": "error" } },
run: { tasks: { vpa: { command: "vpa", cache: false } } },
});import type {} from "@r_masseater/vite-plus-adopt" types the keys vpa reads (commitlint, dependencyRules, fallow, h56m, skills, textlint and tools) on defineConfig.
textlint checks the Markdown files Git tracks. To check other files too, list their globs (files) and the settings for them in textlint.sources. presets work there as well.
filterModules takes textlint filter rules as modules, such as { comments: commentsFilter }, and filters: { comments: true } turns one on, so the repository does not have to install them for textlint to find them. With reportUnusedDirectives: true, a textlint-disable comment that hides no message is an error. The check lints a file with a disable comment a second time without the filters.
Write the Git hooks like this.
# .vite-hooks/pre-commit
vpa --staged
# .vite-hooks/commit-msg
vpa --commit-msg "$1"Agent skills
List GitHub repositories and commits in skills, and vpa --prepare puts their skills in .agents/skills/. Skills are picked by the name in SKILL.md, and "all" picks every skill under root.
export default defineConfig({
skills: {
"masseater/skills": {
commit: "40c8069607f259ab20d7cfee82f7c29b29fc65ad",
root: "plugins/masseater-skills/skills",
skills: "all",
},
"cloudflare/skills": { commit: "…", root: "skills", skills: ["cloudflare"] },
"./docs/skills": { skills: "all" },
},
});vpa --prepare leaves alone the links that pnpm made into .agents/skills/, which .gitignore there lists in its # pnpm block, and fails when a declared skill has the same name as one of them. pnpm links the skills that approved dependencies ship, so list in skills only what no dependency ships.
Fetched skills are stored read-only in ~/.cache/vpa/skills/ (under XDG_CACHE_HOME, or LOCALAPPDATA on Windows), and .agents/skills/ points to them with symbolic links (junctions on Windows). A commit is fetched once per machine and shared by every worktree. Private repositories are fetched with GITHUB_TOKEN.
A key starting with ./ is a folder in this repository. It takes no commit and points directly to the folders under it that contain SKILL.md.
Put vpa --prepare in prepare. To let Renovate update the commits and the tool versions, extend this preset in renovate.json.
{ "extends": ["github>masseater/ecosystems//libs/vite-plus-adopt/renovate"] }Command-line tools
List release assets in tools, and vpa --prepare downloads them, checks their sha256 and links their binaries into node_modules/.bin, where vp run and vp exec find them. This replaces mise for tools that ship as archives.
export default defineConfig({
tools: {
"open-telemetry/weaver": {
version: "0.28.0",
assets: {
"linux-x64": "weaver-x86_64-unknown-linux-gnu.tar.xz",
"darwin-arm64": "weaver-aarch64-apple-darwin.tar.xz",
"win32-x64": "weaver-x86_64-pc-windows-msvc.zip",
},
},
"open-telemetry/opentelemetry-collector-releases": {
version: "0.166.0",
bin: ["otelcol"],
assets: { "linux-x64": "otelcol_{version}_linux_amd64.tar.gz" },
},
dotnet: {
version: "11.0.100",
base: "https://builds.dotnet.microsoft.com/dotnet/Sdk/{version}",
assets: { "linux-x64": "dotnet-sdk-{version}-linux-x64.tar.gz" },
},
},
});- The key is
owner/repoof the GitHub release, which is downloaded fromhttps://github.com/<owner>/<repo>/releases/download/v<version>/<asset>. Any other key needsbase, the URL that holds the assets.{version}inbaseand in an asset name is replaced byversion. assetsmaps a platform (linux-x64,linux-arm64,darwin-x64,darwin-arm64,win32-x64) to an asset name. A tool with no asset for the current platform is skipped.binlists the executables to link. It defaults to the repository name. Windows gets.cmdlaunchers, because linking an.exethere needs the symbolic link privilege. Archives are unpacked withtar, which is bsdtar on Windows and reads.zipand.tar.xztoo.vpa-lock.jsonnext tovite.config.tspins the sha256 of each asset by its URL. A URL without an entry is recorded when it is first downloaded, and a download that no longer matches its entry fails. Commit the file.- Tools are stored in
~/.cache/vpa/tools/, keyed by version, platform and checksum, and shared by every worktree. SetVPA_TOOLS=falseto skip them, for a job that needs none. - A
toolssection in thevite.config.tsof a workspace works withvpa --preparerun in that workspace. It links into that workspace'snode_modules/.bin.
The Renovate preset updates version of each GitHub key and of dotnet. A new version has no entry in vpa-lock.json yet, so vpa --prepare records it.
GitHub Actions caches
vpa ci puts the shared setup action of typescript-template into every job that runs vp, and removes what that action replaces: hand-written actions/cache steps for the pnpm store, the pnpm metadata, the vpa tools and msch, the voidzero-dev/setup-vp step and the vp install --frozen-lockfile step. Comments and formatting around the edited steps stay. It pins every template action and workflow to one commit, and calls maintain-caches.yml from .github/workflows/cache.yml, which saves the pnpm store on the default branch and deletes cache entries that it no longer needs. A local action in .github/actions/ that wraps the shared one keeps its extra steps, and vpa ci forwards the inputs cache, save and session-path that it declares. In a repository that uses the shared setup action, it also writes up-to-date.yml and update-branches.yml as the template has them, with their triggers and jobs such as the wake job that starts the merge queue, and keeps the up-to-date job that the repository owns. Renovate only moves the pinned commits, so without this the rest of those workflows stays at what the template had when they were copied. Run it again after a new vpa version to move the pins. The library entry exports findCiDrift(root), which lists the files vpa ci would change, the queue workflows that differ from the template and the files whose template pins differ.
Replacement for @arethetypeswrong/core
@r_masseater/vite-plus-adopt/attw provides the same API as @arethetypeswrong/core 0.18.5, on tsrs, the Rust port of TypeScript 7.1, alone.
Pass it to pack.attw.module, and the same checks run without installing @arethetypeswrong/core.
import * as attw from "@r_masseater/vite-plus-adopt/attw";
import { defineConfig } from "vite-plus";
export default defineConfig({
pack: {
attw: { module: attw, profile: "esm-only", level: "error" },
},
});License
MIT. The licenses of the original packages bundled in dist/attw.mjs are in THIRD-PARTY-NOTICES.
