Run oxfmt across repo, add format script and docs

Add .oxfmtignore to skip generated bindings and wasm-pack output.
Add npm format script, update DEVELOPMENT.md for Vite+ toolchain,
and format all non-generated files with oxfmt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-03-13 10:15:49 -07:00
parent 45262edfbd
commit b4a1c418bb
664 changed files with 13638 additions and 13492 deletions

View File

@@ -1,9 +1,9 @@
{
"name": "@yaak/template-function-fs",
"displayName": "File System Template Functions",
"description": "Template functions for working with the file system",
"private": true,
"version": "0.1.0",
"private": true,
"description": "Template functions for working with the file system",
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev"

View File

@@ -1,45 +1,45 @@
import fs from 'node:fs';
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
import fs from "node:fs";
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from "@yaakapp/api";
const UTF8 = 'utf8';
const UTF8 = "utf8";
const options = [
{ label: 'ASCII', value: 'ascii' },
{ label: 'UTF-8', value: UTF8 },
{ label: 'UTF-16 LE', value: 'utf16le' },
{ label: 'Base64', value: 'base64' },
{ label: 'Base64 URL-safe', value: 'base64url' },
{ label: 'Latin-1', value: 'latin1' },
{ label: 'Hexadecimal', value: 'hex' },
{ label: "ASCII", value: "ascii" },
{ label: "UTF-8", value: UTF8 },
{ label: "UTF-16 LE", value: "utf16le" },
{ label: "Base64", value: "base64" },
{ label: "Base64 URL-safe", value: "base64url" },
{ label: "Latin-1", value: "latin1" },
{ label: "Hexadecimal", value: "hex" },
];
export const plugin: PluginDefinition = {
templateFunctions: [
{
name: 'fs.readFile',
description: 'Read the contents of a file as utf-8',
previewArgs: ['encoding'],
name: "fs.readFile",
description: "Read the contents of a file as utf-8",
previewArgs: ["encoding"],
args: [
{ title: 'Select File', type: 'file', name: 'path', label: 'File' },
{ title: "Select File", type: "file", name: "path", label: "File" },
{
type: 'select',
name: 'encoding',
label: 'Encoding',
type: "select",
name: "encoding",
label: "Encoding",
defaultValue: UTF8,
description: "Specifies how the file's bytes are decoded into text when read",
options,
},
{
type: 'checkbox',
name: 'trim',
label: 'Trim Whitespace',
description: 'Remove leading and trailing whitespace from the file contents',
type: "checkbox",
name: "trim",
label: "Trim Whitespace",
description: "Remove leading and trailing whitespace from the file contents",
},
],
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (!args.values.path || !args.values.encoding) return null;
try {
const v = await fs.promises.readFile(String(args.values.path ?? ''), {
encoding: String(args.values.encoding ?? 'utf-8') as BufferEncoding,
const v = await fs.promises.readFile(String(args.values.path ?? ""), {
encoding: String(args.values.encoding ?? "utf-8") as BufferEncoding,
});
return args.values.trim ? v.trim() : v;
} catch {