( localPath: string, projectName: string, selectedProject: ExampleProjectInterface )
| 120 | } |
| 121 | |
| 122 | export async function cloneProjectTemplate( |
| 123 | localPath: string, |
| 124 | projectName: string, |
| 125 | selectedProject: ExampleProjectInterface |
| 126 | ): Promise<string> { |
| 127 | const projectPath = path.join(localPath, projectName); |
| 128 | //make temp directory to store project |
| 129 | const tempPath = await makeTempDir(); |
| 130 | //use sparse-checkout to clone project to temp directory |
| 131 | await git(tempPath).init().addRemote('origin', selectedProject.remote); |
| 132 | await git(tempPath).raw('sparse-checkout', 'set', selectedProject.path); |
| 133 | await git(tempPath).raw('pull', 'origin', 'main'); |
| 134 | // Copy content to project path |
| 135 | await fs.promises.cp(path.join(tempPath, selectedProject.path), projectPath, {recursive: true}); |
| 136 | // Clean temp folder |
| 137 | fs.rmSync(tempPath, {recursive: true, force: true}); |
| 138 | return projectPath; |
| 139 | } |
| 140 | |
| 141 | export async function readDefaults(projectPath: string): Promise<{ |
| 142 | endpoint: ProjectNetworkConfig['endpoint']; |
no test coverage detected