Add project files

This commit is contained in:
Kunthawat Greethong
2025-12-05 09:26:53 +07:00
parent 3b43cb52ef
commit 11986a0196
814 changed files with 141076 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
/*
* From: https://github.com/microsoft/playwright/issues/5181#issuecomment-2769098576
*
* Usage:
* cd e2e-tests/helpers && node codegen.js
*/
const { _electron: electron } = require("playwright");
(async () => {
const browser = await electron.launch({
args: [
"../../out/dyad-darwin-arm64/dyad.app/Contents/Resources/app.asar/.vite/build/main.js",
"--enable-logging",
"--user-data-dir=/tmp/dyad-e2e-tests",
],
executablePath: "../../out/dyad-darwin-arm64/dyad.app/Contents/MacOS/dyad",
});
const context = await browser.context();
await context.route("**/*", (route) => route.continue());
await require("node:timers/promises").setTimeout(3000); // wait for the window to load
await browser.windows()[0].pause(); // .pause() opens the Playwright-Inspector for manual recording
})();

View File

@@ -0,0 +1,135 @@
import fs from "fs";
import path from "path";
import crypto from "crypto";
export interface FileSnapshotData {
relativePath: string;
content: string;
}
const binaryExtensions = new Set([
".png",
".jpg",
".jpeg",
".gif",
".webp",
".tiff",
".psd",
".raw",
".bmp",
".heif",
".ico",
".pdf",
".eot",
".otf",
".ttf",
".woff",
".woff2",
".zip",
".tar",
".gz",
".7z",
".rar",
".mov",
".mp4",
".m4v",
".mkv",
".webm",
".flv",
".avi",
".wmv",
".mp3",
".wav",
".ogg",
".flac",
".exe",
".dll",
".so",
".a",
".lib",
".o",
".db",
".sqlite3",
".wasm",
]);
function isBinaryFile(filePath: string): boolean {
return binaryExtensions.has(path.extname(filePath).toLowerCase());
}
export function generateAppFilesSnapshotData(
currentPath: string,
basePath: string,
): FileSnapshotData[] {
const ignorePatterns = [
".DS_Store",
".git",
"node_modules",
// Avoid snapshotting lock files because they are getting generated
// automatically and cause noise, and not super important anyways.
"package-lock.json",
"pnpm-lock.yaml",
];
const entries = fs.readdirSync(currentPath, { withFileTypes: true });
let files: FileSnapshotData[] = [];
// Sort entries for deterministic order
entries.sort((a, b) => a.name.localeCompare(b.name));
for (const entry of entries) {
const entryPath = path.join(currentPath, entry.name);
if (ignorePatterns.includes(entry.name)) {
continue;
}
if (entry.isDirectory()) {
files = files.concat(generateAppFilesSnapshotData(entryPath, basePath));
} else if (entry.isFile()) {
const relativePath = path
.relative(basePath, entryPath)
// Normalize path separators to always use /
// to prevent diffs on Windows.
.replace(/\\/g, "/");
try {
if (isBinaryFile(entryPath)) {
const fileBuffer = fs.readFileSync(entryPath);
const hash = crypto
.createHash("sha256")
.update(fileBuffer)
.digest("hex");
files.push({
relativePath,
content: `[binary hash="${hash}"]`,
});
continue;
}
let content = fs
.readFileSync(entryPath, "utf-8")
// Normalize line endings to always use \n
.replace(/\r\n/g, "\n");
if (entry.name === "package.json") {
const packageJson = JSON.parse(content);
packageJson.packageManager = "<scrubbed>";
for (const key in packageJson.dependencies) {
if (key.startsWith("@capacitor/")) {
packageJson.dependencies[key] = "<scrubbed>";
}
}
content = JSON.stringify(packageJson, null, 2);
}
files.push({ relativePath, content });
} catch (error) {
// Could be a binary file or permission issue, log and add a placeholder
const e = error as Error;
console.warn(`Could not read file ${entryPath}: ${e.message}`);
files.push({
relativePath,
content: `[Error reading file: ${e.message}]`,
});
}
}
}
return files;
}

File diff suppressed because it is too large Load Diff