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,20 +1,20 @@
const path = require('node:path');
const crypto = require('node:crypto');
const fs = require('node:fs');
const decompress = require('decompress');
const Downloader = require('nodejs-file-downloader');
const { rmSync, cpSync, mkdirSync, existsSync } = require('node:fs');
const { execSync } = require('node:child_process');
const path = require("node:path");
const crypto = require("node:crypto");
const fs = require("node:fs");
const decompress = require("decompress");
const Downloader = require("nodejs-file-downloader");
const { rmSync, cpSync, mkdirSync, existsSync } = require("node:fs");
const { execSync } = require("node:child_process");
const NODE_VERSION = 'v24.11.1';
const NODE_VERSION = "v24.11.1";
// `${process.platform}_${process.arch}`
const MAC_ARM = 'darwin_arm64';
const MAC_X64 = 'darwin_x64';
const LNX_ARM = 'linux_arm64';
const LNX_X64 = 'linux_x64';
const WIN_X64 = 'win32_x64';
const WIN_ARM = 'win32_arm64';
const MAC_ARM = "darwin_arm64";
const MAC_X64 = "darwin_x64";
const LNX_ARM = "linux_arm64";
const LNX_X64 = "linux_x64";
const WIN_X64 = "win32_x64";
const WIN_ARM = "win32_arm64";
const URL_MAP = {
[MAC_ARM]: `https://nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-darwin-arm64.tar.gz`,
@@ -35,31 +35,31 @@ const SRC_BIN_MAP = {
};
const DST_BIN_MAP = {
[MAC_ARM]: 'yaaknode',
[MAC_X64]: 'yaaknode',
[LNX_ARM]: 'yaaknode',
[LNX_X64]: 'yaaknode',
[WIN_X64]: 'yaaknode.exe',
[WIN_ARM]: 'yaaknode.exe',
[MAC_ARM]: "yaaknode",
[MAC_X64]: "yaaknode",
[LNX_ARM]: "yaaknode",
[LNX_X64]: "yaaknode",
[WIN_X64]: "yaaknode.exe",
[WIN_ARM]: "yaaknode.exe",
};
const SHA256_MAP = {
[MAC_ARM]: 'b05aa3a66efe680023f930bd5af3fdbbd542794da5644ca2ad711d68cbd4dc35',
[MAC_X64]: '096081b6d6fcdd3f5ba0f5f1d44a47e83037ad2e78eada26671c252fe64dd111',
[LNX_ARM]: '0dc93ec5c798b0d347f068db6d205d03dea9a71765e6a53922b682b91265d71f',
[LNX_X64]: '58a5ff5cc8f2200e458bea22e329d5c1994aa1b111d499ca46ec2411d58239ca',
[WIN_X64]: '5355ae6d7c49eddcfde7d34ac3486820600a831bf81dc3bdca5c8db6a9bb0e76',
[WIN_ARM]: 'ce9ee4e547ebdff355beb48e309b166c24df6be0291c9eaf103ce15f3de9e5b4',
[MAC_ARM]: "b05aa3a66efe680023f930bd5af3fdbbd542794da5644ca2ad711d68cbd4dc35",
[MAC_X64]: "096081b6d6fcdd3f5ba0f5f1d44a47e83037ad2e78eada26671c252fe64dd111",
[LNX_ARM]: "0dc93ec5c798b0d347f068db6d205d03dea9a71765e6a53922b682b91265d71f",
[LNX_X64]: "58a5ff5cc8f2200e458bea22e329d5c1994aa1b111d499ca46ec2411d58239ca",
[WIN_X64]: "5355ae6d7c49eddcfde7d34ac3486820600a831bf81dc3bdca5c8db6a9bb0e76",
[WIN_ARM]: "ce9ee4e547ebdff355beb48e309b166c24df6be0291c9eaf103ce15f3de9e5b4",
};
const key = `${process.platform}_${process.env.YAAK_TARGET_ARCH ?? process.arch}`;
const destDir = path.join(__dirname, `..`, 'crates-tauri', 'yaak-app', 'vendored', 'node');
const destDir = path.join(__dirname, `..`, "crates-tauri", "yaak-app", "vendored", "node");
const binDest = path.join(destDir, DST_BIN_MAP[key]);
console.log(`Vendoring NodeJS ${NODE_VERSION} for ${key}`);
if (existsSync(binDest) && tryExecSync(`${binDest} --version`).trim() === NODE_VERSION) {
console.log('NodeJS already vendored');
console.log("NodeJS already vendored");
return;
}
@@ -67,12 +67,12 @@ rmSync(destDir, { recursive: true, force: true });
mkdirSync(destDir, { recursive: true });
const url = URL_MAP[key];
const tmpDir = path.join(__dirname, 'tmp-node');
const tmpDir = path.join(__dirname, "tmp-node");
rmSync(tmpDir, { recursive: true, force: true });
(async function () {
// Download GitHub release artifact
console.log('Downloading NodeJS at', url);
console.log("Downloading NodeJS at", url);
const { filePath } = await new Downloader({
url,
directory: tmpDir,
@@ -82,11 +82,13 @@ rmSync(tmpDir, { recursive: true, force: true });
// Verify SHA256
const expectedHash = SHA256_MAP[key];
const fileBuffer = fs.readFileSync(filePath);
const actualHash = crypto.createHash('sha256').update(fileBuffer).digest('hex');
const actualHash = crypto.createHash("sha256").update(fileBuffer).digest("hex");
if (actualHash !== expectedHash) {
throw new Error(`SHA256 mismatch for ${path.basename(filePath)}\n expected: ${expectedHash}\n actual: ${actualHash}`);
throw new Error(
`SHA256 mismatch for ${path.basename(filePath)}\n expected: ${expectedHash}\n actual: ${actualHash}`,
);
}
console.log('SHA256 verified:', actualHash);
console.log("SHA256 verified:", actualHash);
// Decompress to the same directory
await decompress(filePath, tmpDir, {});
@@ -96,16 +98,16 @@ rmSync(tmpDir, { recursive: true, force: true });
cpSync(binSrc, binDest);
rmSync(tmpDir, { recursive: true, force: true });
console.log('Downloaded NodeJS to', binDest);
console.log("Downloaded NodeJS to", binDest);
})().catch((err) => {
console.log('Script failed:', err);
console.log("Script failed:", err);
process.exit(1);
});
function tryExecSync(cmd) {
try {
return execSync(cmd, { stdio: 'pipe' }).toString('utf-8');
return execSync(cmd, { stdio: "pipe" }).toString("utf-8");
} catch {
return '';
return "";
}
}