jvcs 1.1.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jvcs/HEAD +1 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/add.js +122 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/begin.js +201 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/clone.js +138 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/commit.js +83 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/driveUtility.js +56 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/init.js +60 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/log.js +99 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/login.js +33 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/push.js +165 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/revert.js +208 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/signup.js +28 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/status.js +160 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/unstage.js +104 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/utility.js +29 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/verifyOtp.js +55 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/jvcs_hashcode.json +62 -0
- package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/meta.json +7 -0
- package/.jvcs/config.json +9 -0
- package/.jvcs/staging/controllers/add.js +122 -0
- package/.jvcs/staging/controllers/begin.js +201 -0
- package/.jvcs/staging/controllers/clone.js +138 -0
- package/.jvcs/staging/controllers/commit.js +83 -0
- package/.jvcs/staging/controllers/driveUtility.js +56 -0
- package/.jvcs/staging/controllers/init.js +60 -0
- package/.jvcs/staging/controllers/log.js +99 -0
- package/.jvcs/staging/controllers/login.js +33 -0
- package/.jvcs/staging/controllers/push.js +165 -0
- package/.jvcs/staging/controllers/revert.js +208 -0
- package/.jvcs/staging/controllers/signup.js +28 -0
- package/.jvcs/staging/controllers/status.js +160 -0
- package/.jvcs/staging/controllers/unstage.js +104 -0
- package/.jvcs/staging/controllers/utility.js +29 -0
- package/.jvcs/staging/controllers/verifyOtp.js +55 -0
- package/.jvcs/staging/jvcs_hashcode.json +62 -0
- package/controllers/clone.js +25 -15
- package/package.json +1 -1
package/controllers/clone.js
CHANGED
|
@@ -24,37 +24,47 @@ async function findFolderIdByName(name,parentId=null) {
|
|
|
24
24
|
|
|
25
25
|
async function downloadFolderFromDrive(folderId, destPath) {
|
|
26
26
|
try {
|
|
27
|
+
fs.mkdirSync(destPath, { recursive: true });
|
|
28
|
+
|
|
27
29
|
const res = await drive.files.list({
|
|
28
30
|
q: `'${folderId}' in parents and trashed=false`,
|
|
29
31
|
fields: "files(id, name, mimeType)",
|
|
30
32
|
});
|
|
31
33
|
|
|
32
34
|
const files = res.data.files;
|
|
33
|
-
if
|
|
35
|
+
if(!files.length) return;
|
|
36
|
+
|
|
37
|
+
for(const file of files) {
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
if(file.name === "jvcs_hashcode.json" || file.name === "meta.json")
|
|
40
|
+
continue
|
|
41
|
+
|
|
36
42
|
const filePath = path.join(destPath, file.name);
|
|
37
43
|
|
|
38
|
-
if
|
|
44
|
+
if(file.mimeType === "application/vnd.google-apps.folder") {
|
|
39
45
|
// create folder locally
|
|
40
|
-
if
|
|
46
|
+
if(!fs.existsSync(filePath)) fs.mkdirSync(filePath);
|
|
41
47
|
await downloadFolderFromDrive(file.id, filePath);
|
|
42
|
-
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
43
51
|
const dest = fs.createWriteStream(filePath);
|
|
44
|
-
await drive.files.get(
|
|
52
|
+
const resFile = await drive.files.get(
|
|
45
53
|
{ fileId: file.id, alt: "media" },
|
|
46
54
|
{ responseType: "stream" }
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
await new Promise((resolve,reject)=> {
|
|
58
|
+
resFile.data.on("end", resolve)
|
|
59
|
+
.on("error",reject)
|
|
60
|
+
.pipe(dest)
|
|
61
|
+
})
|
|
55
62
|
}
|
|
63
|
+
|
|
64
|
+
console.log(chalk.gray(`Downloaded: ${filePath}`));
|
|
56
65
|
}
|
|
57
|
-
}
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
58
68
|
console.log(chalk.red("Error downloading folder: " + err.message));
|
|
59
69
|
}
|
|
60
70
|
}
|