MCPcopy
hub / github.com/subquery/subql / cloneProjectTemplate

Function cloneProjectTemplate

packages/cli/src/controller/init-controller.ts:122–139  ·  view source on GitHub ↗
(
  localPath: string,
  projectName: string,
  selectedProject: ExampleProjectInterface
)

Source from the content-addressed store, hash-verified

120}
121
122export 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
141export async function readDefaults(projectPath: string): Promise<{
142 endpoint: ProjectNetworkConfig['endpoint'];

Callers 5

createTestProjectFunction · 0.90
prepareProjectFunction · 0.90
initAdapterFunction · 0.90

Calls 2

makeTempDirFunction · 0.90
initMethod · 0.65

Tested by

no test coverage detected