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 = {...@@ -69,13 +69,6 @@ const formatters = {
69 cmd: ["treefmt", "--", "$files"],69 cmd: ["treefmt", "--", "$files"],
70 stdin: (file) => ["treefmt", "--stdin", file],70 stdin: (file) => ["treefmt", "--stdin", file],
71 },71 },
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 },
79 vp: {72 vp: {
80 languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"],73 languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"],
81 mustMatchFile: true,74 mustMatchFile: true,
...@@ -88,6 +81,13 @@ const formatters = {...@@ -88,6 +81,13 @@ const formatters = {
88 file,81 file,
89 ],82 ],
90 },83 },
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 },
91 oxfmt: {91 oxfmt: {
92 languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"],92 languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"],
93 mustMatchFile: true,93 mustMatchFile: true,
...@@ -168,66 +168,50 @@ const formatters = {...@@ -168,66 +168,50 @@ const formatters = {
168};168};
169169
170// -- cli --170// -- cli --
171function cli() {171if (!fs.globSync) {
172 if (!fs.globSync) {172 console.error(`error: autofmt must be run with Node.js v22 or newer`);
173 console.error(`error: autofmt must be run with Node.js v22 or newer`);173 process.exit(1);
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 };
228}174}
229175const [, bin, ...argv] = process.argv;
230function cliUsage() {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() {
231 const exe = path.basename(bin);215 const exe = path.basename(bin);
232 console.error(`usage: ${exe} [...files or directories]`);216 console.error(`usage: ${exe} [...files or directories]`);
233 console.error(``);217 console.error(``);
...@@ -244,9 +228,21 @@ function cliUsage() {...@@ -244,9 +228,21 @@ function cliUsage() {
244 console.error(``);228 console.error(``);
245 process.exit(1);229 process.exit(1);
246}230}
247231if (inputs.length === 0 && !stdio) usage();
248export function autofmt({ files, progress }) {232if (stdio && inputs.length > 0) {
233 console.error("error: stdio mode only operates on one file");
234 process.exit(1);
249}235}
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
251// -- vars --247// -- vars --
252const extToLanguage = Object.fromEntries(248const extToLanguage = Object.fromEntries(
...@@ -355,7 +351,6 @@ const syncEnd = "\u001B[?2026l";...@@ -355,7 +351,6 @@ const syncEnd = "\u001B[?2026l";
355let buffer = "";351let buffer = "";
356let statusVisible = false;352let statusVisible = false;
357const tty = process.stderr.isTTY;353const tty = process.stderr.isTTY;
358
359function writeStatus() {354function writeStatus() {
360 if (!tty) return;355 if (!tty) return;
361 clearStatus();356 clearStatus();
...@@ -655,7 +650,6 @@ function escapeGlob(str) {...@@ -655,7 +650,6 @@ function escapeGlob(str) {
655import * as child_process from "node:child_process";650import * as child_process from "node:child_process";
656import * as fs from "node:fs";651import * as fs from "node:fs";
657import * as path from "node:path";652import * as path from "node:path";
658import { sep } from "node:path";
659import * as readline from "node:readline";653import * as readline from "node:readline";
660import * as events from "node:events";654import * as events from "node:events";
661import process from "node:process";655import process from "node:process";
users/clover/home.nix+3
...@@ -10,6 +10,9 @@ in...@@ -10,6 +10,9 @@ in
10{10{
11 home = {11 home = {
12 stateVersion = "23.05"; # Please read the comment before changing.12 stateVersion = "23.05"; # Please read the comment before changing.
13 sessionPath = [
14 "$HOME/.vite-plus/bin"
15 ];
13 packages =16 packages =
14 with pkgs;17 with pkgs;
15 let18 let