( componentName: string, targetPath: string )
| 115 | * Copies a component from source to target location |
| 116 | */ |
| 117 | export async function copyComponent( |
| 118 | componentName: string, |
| 119 | targetPath: string |
| 120 | ): Promise<void> { |
| 121 | const { componentsPath } = await ensureSourcePaths(); |
| 122 | const sourcePath = path.join(componentsPath, componentName); |
| 123 | const destPath = path.join( |
| 124 | targetPath, |
| 125 | "craftrn-ui", |
| 126 | "components", |
| 127 | componentName |
| 128 | ); |
| 129 | |
| 130 | if (!(await fs.pathExists(sourcePath))) { |
| 131 | throw new Error( |
| 132 | `Component ${componentName} source not found at: ${sourcePath}` |
| 133 | ); |
| 134 | } |
| 135 | |
| 136 | await fs.ensureDir(path.dirname(destPath)); |
| 137 | await fs.copy(sourcePath, destPath); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Copies all theme files to target location |
no test coverage detected