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.
Files changed (37) hide show
  1. package/.jvcs/HEAD +1 -0
  2. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/add.js +122 -0
  3. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/begin.js +201 -0
  4. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/clone.js +138 -0
  5. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/commit.js +83 -0
  6. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/driveUtility.js +56 -0
  7. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/init.js +60 -0
  8. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/log.js +99 -0
  9. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/login.js +33 -0
  10. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/push.js +165 -0
  11. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/revert.js +208 -0
  12. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/signup.js +28 -0
  13. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/status.js +160 -0
  14. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/unstage.js +104 -0
  15. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/utility.js +29 -0
  16. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/controllers/verifyOtp.js +55 -0
  17. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/jvcs_hashcode.json +62 -0
  18. package/.jvcs/commits/cd2a0ec7-04b8-4ac9-b539-617bb5fea1f3/meta.json +7 -0
  19. package/.jvcs/config.json +9 -0
  20. package/.jvcs/staging/controllers/add.js +122 -0
  21. package/.jvcs/staging/controllers/begin.js +201 -0
  22. package/.jvcs/staging/controllers/clone.js +138 -0
  23. package/.jvcs/staging/controllers/commit.js +83 -0
  24. package/.jvcs/staging/controllers/driveUtility.js +56 -0
  25. package/.jvcs/staging/controllers/init.js +60 -0
  26. package/.jvcs/staging/controllers/log.js +99 -0
  27. package/.jvcs/staging/controllers/login.js +33 -0
  28. package/.jvcs/staging/controllers/push.js +165 -0
  29. package/.jvcs/staging/controllers/revert.js +208 -0
  30. package/.jvcs/staging/controllers/signup.js +28 -0
  31. package/.jvcs/staging/controllers/status.js +160 -0
  32. package/.jvcs/staging/controllers/unstage.js +104 -0
  33. package/.jvcs/staging/controllers/utility.js +29 -0
  34. package/.jvcs/staging/controllers/verifyOtp.js +55 -0
  35. package/.jvcs/staging/jvcs_hashcode.json +62 -0
  36. package/controllers/clone.js +25 -15
  37. package/package.json +1 -1
@@ -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 (!files.length) return;
35
+ if(!files.length) return;
36
+
37
+ for(const file of files) {
34
38
 
35
- for (const file of files) {
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 (file.mimeType === "application/vnd.google-apps.folder") {
44
+ if(file.mimeType === "application/vnd.google-apps.folder") {
39
45
  // create folder locally
40
- if (!fs.existsSync(filePath)) fs.mkdirSync(filePath);
46
+ if(!fs.existsSync(filePath)) fs.mkdirSync(filePath);
41
47
  await downloadFolderFromDrive(file.id, filePath);
42
- } else {
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
- ).then(res => {
48
- return new Promise((resolve, reject) => {
49
- res.data
50
- .on("end", resolve)
51
- .on("error", reject)
52
- .pipe(dest);
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
- } catch (err) {
66
+ }
67
+ catch (err) {
58
68
  console.log(chalk.red("Error downloading folder: " + err.message));
59
69
  }
60
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jvcs",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "bin": {
5
5
  "jvcs": "./index.js"
6
6
  },