Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onMessage?: (message: string) => void
depth?: number
singleBranch?: boolean
} = {}
): Promise {
const emitter = new EventEmitter()
if (options.onProgress) {
emitter.on("progress", options.onProgress)
}
if (options.onMessage) {
emitter.on("message", options.onMessage)
}
// not async for test
const clonePromise = git.clone({
dir: projectRoot,
url: cloneDest,
ref: "master",
emitter,
...options
})
while (true) {
await delay(1000)
try {
const list = await git.listFiles({ dir: projectRoot })
const e = await git.status({ dir: projectRoot, filepath: list[0] })
console.log("status correct with", e)
break
} catch (e) {
console.log("wait...", e.message)
remoteSdkUrl: string,
options,
) {
// TODO: Rather than taking a logger, just provide callbacks
const { logger } = options;
const repoDir = await makeTempDir('repo');
try {
/*
TODO: This isn't great. We clone the repo everytime we generate an SDK.
Preferably, we'd only do it once or have some kind of cache for repos we've already cloned.
Would have to probably git reset --hard HEAD~ or something before adding the SDK to the cloned repo
just to make sure there aren't any stray files lying around in the cached repo.
*/
// TODO: Should also be able to configure which branch to checkout, maybe?
logger.verbose(`Cloning ${remoteSdkUrl} into ${repoDir}`);
await clone({
ref: gitInfo.branch,
dir: repoDir,
// Could use mz/fs but I don't trust it guarentees compatibility with isomorphic git
fs: oldFs,
url: gitInfo.repoUrl,
singleBranch: true,
depth: 1,
...gitInfo.auth,
});
await migrateSdkIntoLocalRepo(repoDir, remoteSdkUrl, options);
const addedPaths = await getAllStageableFilepathsInRepo(repoDir);
logger.verbose(`Staging ${addedPaths.length} paths`);
for (const addedPath of addedPaths) {
const relativeFilePath = relative(repoDir, addedPath);
// TODO: Got a lot of "oldFs: fs", maybe make some sort of wrapper to avoid this?
const downloadOas = () => {
return git.clone({
fs: fs,
dir: FOLDER_PATH,
url: REPO_URL,
singleBranch: true,
depth: 1
})
}
async clone() {
await mkdir(this.clonePath);
await git.clone({
gitdir: this.clonePath,
url: this.cloneUrl,
noCheckout: true
});
}
async cloneProject(): Promise {
await clone({
dir: this.projectDir,
url: this._config.default_project_url,
ref: 'master'
});
}