authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-04-07 23:15:28-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-04-07 23:19:38-07:00
logd5c9b6794fc8bbcc39e12ee346004d0c70011db2
tree49406d97cb04e00ed4a7fda2b1368554ae420711
parent03c98693c032d95fe0dbbb05cf485758372d37d5
signature Signed by SSH key SHA256:xbd+BjjhyBfwk7GVoURf9Yx0gzDerHbvYv7SddNWmAs

revert bs stuff in autofmt


2 files changed, 67 insertions(+), 70 deletions(-)

packages/autofmt/autofmt.js+64-70
......@@ -69,13 +69,6 @@ const formatters = {
6969 cmd: ["treefmt", "--", "$files"],
7070 stdin: (file) => ["treefmt", "--stdin", file],
7171 },
72 // -- web ecosystem --
73 deno: {
74 languages: ["javascript", "markdown", "json", "yaml", "html", "css"],
75 files: ["deno.json", "deno.jsonc"],
76 cmd: ["deno", "fmt", "--", "$files"],
77 stdin: (file) => ["deno", "fmt", "--ext", path.extname(file).slice(1), "-"],
78 },
7972 vp: {
8073 languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"],
8174 mustMatchFile: true,
......@@ -88,6 +81,13 @@ const formatters = {
8881 file,
8982 ],
9083 },
84 // -- web ecosystem --
85 deno: {
86 languages: ["javascript", "markdown", "json", "yaml", "html", "css"],
87 files: ["deno.json", "deno.jsonc"],
88 cmd: ["deno", "fmt", "--", "$files"],
89 stdin: (file) => ["deno", "fmt", "--ext", path.extname(file).slice(1), "-"],
90 },
9191 oxfmt: {
9292 languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"],
9393 mustMatchFile: true,
......@@ -168,66 +168,50 @@ const formatters = {
168168};
169169
170170// -- cli --
171function cli() {
172 if (!fs.globSync) {
173 console.error(`error: autofmt must be run with Node.js v22 or newer`);
174 process.exit(1);
175 }
176 const [, bin, ...argv] = process.argv;
177 let inputs = [];
178 let globalExclude = [];
179 let gitignore = true;
180 let dryRun = false;
181 let stdio = null;
182 let excludes = [".git"];
183 while (argv.length > 0) {
184 const arg = argv.shift();
185 if (arg === "-h" || arg === "--help") cliUsage();
186 else if (arg === "--no-gitignore") gitignore = false;
187 else if (arg === "--dry-run") dryRun = true;
188 else if (arg.match(/^--stdio=./)) {
189 if (stdio) {
190 console.error("error: can only pass --stdio once");
191 cliUsage();
192 }
193 stdio = arg.slice("--stdio=".length);
194 } else if (arg === "--stdio") {
195 const value = argv.shift();
196 if (!value) {
197 console.error("error: missing value for --stdio");
198 cliUsage();
199 }
200 if (stdio) {
201 console.error("error: can only pass --stdio once");
202 cliUsage();
203 }
204 stdio = value;
205 } else if (arg.match(/^--exclude=./)) {
206 excludes.push(arg.slice("--exclude=".length));
207 } else if (arg === "--") {
208 inputs.push(...argv);
209 break;
210 } else if (arg.startsWith("-")) {
211 console.error("error: unknown option " + JSON.stringify(arg));
212 cliUsage();
213 } else inputs.push(arg);
214 }
215 if (inputs.length === 0 && !stdio) cliUsage();
216 if (stdio && inputs.length > 0) {
217 console.error("error: stdio mode only operates on one file");
218 process.exit(1);
219 }
220 // -- disable warnings --
221 const { emit: originalEmit } = process;
222 const warnings = ["ExperimentalWarning"];
223 process.emit = function (event, error) {
224 return event === "warning" && warnings.includes(error.name)
225 ? false
226 : originalEmit.apply(process, arguments);
227 };
171if (!fs.globSync) {
172 console.error(`error: autofmt must be run with Node.js v22 or newer`);
173 process.exit(1);
228174}
229
230function cliUsage() {
175const [, bin, ...argv] = process.argv;
176let inputs = [];
177let globalExclude = [];
178let gitignore = true;
179let dryRun = false;
180let stdio = null;
181let excludes = [".git"];
182while (argv.length > 0) {
183 const arg = argv.shift();
184 if (arg === "-h" || arg === "--help") usage();
185 else if (arg === "--no-gitignore") gitignore = false;
186 else if (arg === "--dry-run") dryRun = true;
187 else if (arg.match(/^--stdio=./)) {
188 if (stdio) {
189 console.error("error: can only pass --stdio once");
190 usage();
191 }
192 stdio = arg.slice("--stdio=".length);
193 } else if (arg === "--stdio") {
194 const value = argv.shift();
195 if (!value) {
196 console.error("error: missing value for --stdio");
197 usage();
198 }
199 if (stdio) {
200 console.error("error: can only pass --stdio once");
201 usage();
202 }
203 stdio = value;
204 } else if (arg.match(/^--exclude=./)) {
205 excludes.push(arg.slice("--exclude=".length));
206 } else if (arg === "--") {
207 inputs.push(...argv);
208 break;
209 } else if (arg.startsWith("-")) {
210 console.error("error: unknown option " + JSON.stringify(arg));
211 usage();
212 } else inputs.push(arg);
213}
214function usage() {
231215 const exe = path.basename(bin);
232216 console.error(`usage: ${exe} [...files or directories]`);
233217 console.error(``);
......@@ -244,9 +228,21 @@ function cliUsage() {
244228 console.error(``);
245229 process.exit(1);
246230}
247
248export function autofmt({ files, progress }) {
231if (inputs.length === 0 && !stdio) usage();
232if (stdio && inputs.length > 0) {
233 console.error("error: stdio mode only operates on one file");
234 process.exit(1);
249235}
236const { sep } = path;
237
238// -- disable warnings --
239const { emit: originalEmit } = process;
240const warnings = ["ExperimentalWarning"];
241process.emit = function (event, error) {
242 return event === "warning" && warnings.includes(error.name)
243 ? false
244 : originalEmit.apply(process, arguments);
245};
250246
251247// -- vars --
252248const extToLanguage = Object.fromEntries(
......@@ -355,7 +351,6 @@ const syncEnd = "\u001B[?2026l";
355351let buffer = "";
356352let statusVisible = false;
357353const tty = process.stderr.isTTY;
358
359354function writeStatus() {
360355 if (!tty) return;
361356 clearStatus();
......@@ -655,7 +650,6 @@ function escapeGlob(str) {
655650import * as child_process from "node:child_process";
656651import * as fs from "node:fs";
657652import * as path from "node:path";
658import { sep } from "node:path";
659653import * as readline from "node:readline";
660654import * as events from "node:events";
661655import process from "node:process";
users/clover/home.nix+3
......@@ -10,6 +10,9 @@ in
1010{
1111 home = {
1212 stateVersion = "23.05"; # Please read the comment before changing.
13 sessionPath = [
14 "$HOME/.vite-plus/bin"
15 ];
1316 packages =
1417 with pkgs;
1518 let