style: auto-format codebase with Prettier

Applied formatting to 1487+ files using pnpm format:write
  - TypeScript/JavaScript files
  - Svelte components
  - Astro pages
  - JSON configs
  - Markdown docs

  13 files still need manual review (Astro JSX comments)
This commit is contained in:
Wuesteon 2025-11-27 18:33:16 +01:00
parent 0241f5554c
commit d36b321d9d
3952 changed files with 661498 additions and 739751 deletions

View file

@ -7,67 +7,67 @@ import { getComponentsPath, ensureDir } from './paths';
* Copy a component's files to the destination
*/
export async function copyComponent(
component: ComponentInfo,
category: string,
destinationBase: string
component: ComponentInfo,
category: string,
destinationBase: string
): Promise<string[]> {
const sourcePath = path.join(getComponentsPath(), category, component.name);
const destPath = path.join(destinationBase, category, component.name);
const sourcePath = path.join(getComponentsPath(), category, component.name);
const destPath = path.join(destinationBase, category, component.name);
// Ensure destination directory exists
await ensureDir(destPath);
// Ensure destination directory exists
await ensureDir(destPath);
const copiedFiles: string[] = [];
const copiedFiles: string[] = [];
// Copy each file
for (const file of component.files) {
const sourceFile = path.join(sourcePath, file);
const destFile = path.join(destPath, file);
// Copy each file
for (const file of component.files) {
const sourceFile = path.join(sourcePath, file);
const destFile = path.join(destPath, file);
if (!await fs.pathExists(sourceFile)) {
throw new Error(`Source file not found: ${sourceFile}`);
}
if (!(await fs.pathExists(sourceFile))) {
throw new Error(`Source file not found: ${sourceFile}`);
}
await fs.copy(sourceFile, destFile, { overwrite: true });
copiedFiles.push(destFile);
}
await fs.copy(sourceFile, destFile, { overwrite: true });
copiedFiles.push(destFile);
}
// Also copy index.ts if it exists
const indexFile = path.join(sourcePath, 'index.ts');
if (await fs.pathExists(indexFile)) {
const destIndex = path.join(destPath, 'index.ts');
await fs.copy(indexFile, destIndex, { overwrite: true });
copiedFiles.push(destIndex);
}
// Also copy index.ts if it exists
const indexFile = path.join(sourcePath, 'index.ts');
if (await fs.pathExists(indexFile)) {
const destIndex = path.join(destPath, 'index.ts');
await fs.copy(indexFile, destIndex, { overwrite: true });
copiedFiles.push(destIndex);
}
return copiedFiles;
return copiedFiles;
}
/**
* Check if a component already exists at the destination
*/
export async function componentExists(
component: ComponentInfo,
category: string,
destinationBase: string
component: ComponentInfo,
category: string,
destinationBase: string
): Promise<boolean> {
const destPath = path.join(destinationBase, category, component.name);
return await fs.pathExists(destPath);
const destPath = path.join(destinationBase, category, component.name);
return await fs.pathExists(destPath);
}
/**
* Get the list of files that would be copied
*/
export function getComponentFiles(
component: ComponentInfo,
category: string,
destinationBase: string
component: ComponentInfo,
category: string,
destinationBase: string
): string[] {
const destPath = path.join(destinationBase, category, component.name);
const files = component.files.map(file => path.join(destPath, file));
const destPath = path.join(destinationBase, category, component.name);
const files = component.files.map((file) => path.join(destPath, file));
// Add index.ts
files.push(path.join(destPath, 'index.ts'));
// Add index.ts
files.push(path.join(destPath, 'index.ts'));
return files;
return files;
}

View file

@ -5,49 +5,49 @@ import fs from 'fs-extra';
* Get the root directory of the memoro-ui package
*/
export function getPackageRoot(): string {
// CLI is in packages/memoro-ui/cli/
// Package root is packages/memoro-ui/
return path.resolve(__dirname, '../../../');
// CLI is in packages/memoro-ui/cli/
// Package root is packages/memoro-ui/
return path.resolve(__dirname, '../../../');
}
/**
* Get the path to the registry.json file
*/
export function getRegistryPath(): string {
return path.join(getPackageRoot(), 'registry.json');
return path.join(getPackageRoot(), 'registry.json');
}
/**
* Get the path to the components directory
*/
export function getComponentsPath(): string {
return path.join(getPackageRoot(), 'components');
return path.join(getPackageRoot(), 'components');
}
/**
* Get the destination path for components in the target app
*/
export function getDestinationPath(cwd: string = process.cwd()): string {
// Check if we're in an app directory with a components folder
const possiblePaths = [
path.join(cwd, 'components'),
path.join(cwd, 'app', 'components'),
path.join(cwd, 'src', 'components'),
];
// Check if we're in an app directory with a components folder
const possiblePaths = [
path.join(cwd, 'components'),
path.join(cwd, 'app', 'components'),
path.join(cwd, 'src', 'components'),
];
for (const p of possiblePaths) {
if (fs.existsSync(p)) {
return p;
}
}
for (const p of possiblePaths) {
if (fs.existsSync(p)) {
return p;
}
}
// Default to components/ in current directory
return path.join(cwd, 'components');
// Default to components/ in current directory
return path.join(cwd, 'components');
}
/**
* Ensure a directory exists, create if not
*/
export async function ensureDir(dirPath: string): Promise<void> {
await fs.ensureDir(dirPath);
await fs.ensureDir(dirPath);
}

View file

@ -6,80 +6,80 @@ import { getRegistryPath } from './paths';
* Load the component registry
*/
export async function loadRegistry(): Promise<ComponentRegistry> {
const registryPath = getRegistryPath();
const registryPath = getRegistryPath();
if (!await fs.pathExists(registryPath)) {
throw new Error(`Registry not found at ${registryPath}`);
}
if (!(await fs.pathExists(registryPath))) {
throw new Error(`Registry not found at ${registryPath}`);
}
const content = await fs.readFile(registryPath, 'utf-8');
return JSON.parse(content);
const content = await fs.readFile(registryPath, 'utf-8');
return JSON.parse(content);
}
/**
* Get a specific component from the registry
*/
export async function getComponent(
componentKey: string
componentKey: string
): Promise<{ key: string; component: ComponentInfo; category: string } | null> {
const registry = await loadRegistry();
const registry = await loadRegistry();
for (const [category, components] of Object.entries(registry.components)) {
if (componentKey in components) {
return {
key: componentKey,
component: components[componentKey],
category,
};
}
}
for (const [category, components] of Object.entries(registry.components)) {
if (componentKey in components) {
return {
key: componentKey,
component: components[componentKey],
category,
};
}
}
return null;
return null;
}
/**
* Get all components from the registry
*/
export async function getAllComponents(): Promise<
Array<{ key: string; component: ComponentInfo; category: string }>
Array<{ key: string; component: ComponentInfo; category: string }>
> {
const registry = await loadRegistry();
const components: Array<{ key: string; component: ComponentInfo; category: string }> = [];
const registry = await loadRegistry();
const components: Array<{ key: string; component: ComponentInfo; category: string }> = [];
for (const [category, categoryComponents] of Object.entries(registry.components)) {
for (const [key, component] of Object.entries(categoryComponents)) {
components.push({ key, component, category });
}
}
for (const [category, categoryComponents] of Object.entries(registry.components)) {
for (const [key, component] of Object.entries(categoryComponents)) {
components.push({ key, component, category });
}
}
return components;
return components;
}
/**
* Resolve dependencies for a component recursively
*/
export async function resolveDependencies(
componentKey: string,
visited = new Set<string>()
componentKey: string,
visited = new Set<string>()
): Promise<string[]> {
if (visited.has(componentKey)) {
return [];
}
if (visited.has(componentKey)) {
return [];
}
visited.add(componentKey);
visited.add(componentKey);
const item = await getComponent(componentKey);
if (!item) {
return [];
}
const item = await getComponent(componentKey);
if (!item) {
return [];
}
const deps = item.component.dependencies || [];
const allDeps = [...deps];
const deps = item.component.dependencies || [];
const allDeps = [...deps];
for (const dep of deps) {
const subDeps = await resolveDependencies(dep, visited);
allDeps.push(...subDeps);
}
for (const dep of deps) {
const subDeps = await resolveDependencies(dep, visited);
allDeps.push(...subDeps);
}
return [...new Set(allDeps)];
return [...new Set(allDeps)];
}