jvcs 1.0.1 → 1.0.3

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 (53) hide show
  1. package/.env +4 -4
  2. package/.jvcs/HEAD +1 -1
  3. package/.jvcs/commits/3a1169c8-ec67-4ce5-8024-ab4f08d7b609/index.js +146 -0
  4. package/.jvcs/commits/3a1169c8-ec67-4ce5-8024-ab4f08d7b609/jvcs_hashcode.json +6 -0
  5. package/.jvcs/commits/3a1169c8-ec67-4ce5-8024-ab4f08d7b609/meta.json +7 -0
  6. package/.jvcs/commits/c362f97f-997b-499a-bb45-9e67f298f61e/index.js +146 -0
  7. package/.jvcs/commits/c362f97f-997b-499a-bb45-9e67f298f61e/jvcs_hashcode.json +6 -0
  8. package/.jvcs/commits/c362f97f-997b-499a-bb45-9e67f298f61e/meta.json +7 -0
  9. package/.jvcs/config.json +1 -1
  10. package/.jvcs/staging/index.js +146 -0
  11. package/.jvcs/staging/jvcs_hashcode.json +6 -1
  12. package/controllers/driveUtility.js +56 -0
  13. package/controllers/push.js +121 -111
  14. package/index.js +17 -2
  15. package/package.json +1 -1
  16. package/.jvcs/commits/292abee1-42ea-4ddf-b590-be7c98abaf45/jvcs_hashcode.json +0 -1
  17. package/.jvcs/commits/292abee1-42ea-4ddf-b590-be7c98abaf45/meta.json +0 -7
  18. package/.jvcs/commits/302af5ea-5789-4ee9-98fe-eab9308b2e27/jvcs_hashcode.json +0 -1
  19. package/.jvcs/commits/302af5ea-5789-4ee9-98fe-eab9308b2e27/meta.json +0 -7
  20. package/.jvcs/commits/376d44d4-c595-429e-b711-ae6ec7c9ef74/jvcs_hashcode.json +0 -1
  21. package/.jvcs/commits/376d44d4-c595-429e-b711-ae6ec7c9ef74/meta.json +0 -7
  22. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/add.js +0 -122
  23. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/begin.js +0 -201
  24. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/commit.js +0 -82
  25. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/init.js +0 -60
  26. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/login.js +0 -33
  27. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/pull.js +0 -98
  28. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/push.js +0 -135
  29. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/revert.js +0 -110
  30. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/signup.js +0 -28
  31. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/unstage.js +0 -96
  32. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/utility.js +0 -28
  33. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/controllers/verifyOtp.js +0 -55
  34. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/jvcs_hashcode.json +0 -50
  35. package/.jvcs/commits/484ac37d-c1a9-4ddd-8796-6e3facda1e11/meta.json +0 -7
  36. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/add.js +0 -122
  37. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/begin.js +0 -201
  38. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/commit.js +0 -82
  39. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/init.js +0 -60
  40. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/login.js +0 -33
  41. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/pull.js +0 -98
  42. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/push.js +0 -135
  43. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/revert.js +0 -110
  44. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/signup.js +0 -28
  45. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/unstage.js +0 -96
  46. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/utility.js +0 -28
  47. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/controllers/verifyOtp.js +0 -55
  48. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/jvcs_hashcode.json +0 -50
  49. package/.jvcs/commits/c3f6ff7a-13bd-4697-a80e-041f7dae8a09/meta.json +0 -7
  50. package/.jvcs/commits/c7aa89bd-5016-4f21-8979-02e3c0a2c8ee/jvcs_hashcode.json +0 -1
  51. package/.jvcs/commits/c7aa89bd-5016-4f21-8979-02e3c0a2c8ee/meta.json +0 -7
  52. package/controllers/pull.js +0 -98
  53. package/controllers/revert.js +0 -110
package/.env CHANGED
@@ -1,4 +1,4 @@
1
- CLIENT_ID='835069827989-3spob55ioa2ocudi3mo8u2ni2ecqohh7.apps.googleusercontent.com';
2
- CLIENT_SECRET='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';
3
- REDIRECT_URI='https://developers.google.com/oauthplayground';
4
- REFRESH_TOKEN='1//046r33XEFgQbICgYIARAAGAQSNwF-L9Ir_HV79cxAU_xla01zIvHyko6dBz0xoJ9Xhb0UQTbEqdf2czDvhkFFZUszyUQWzYw-5WQ';
1
+ CLIENT_ID=835069827989-3spob55ioa2ocudi3mo8u2ni2ecqohh7.apps.googleusercontent.com
2
+ CLIENT_SECRET=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
3
+ REDIRECT_URI=https://developers.google.com/oauthplayground
4
+ REFRESH_TOKEN=1//04wJgrjHWoDOZCgYIARAAGAQSNwF-L9Iryvz_RHMDkqyYlK2wv9TiVMsvq1eghHFnbS868U-zraLb44f8dEPvpNjJEmex_IcMxUE
package/.jvcs/HEAD CHANGED
@@ -1 +1 @@
1
- c7aa89bd-5016-4f21-8979-02e3c0a2c8ee
1
+ 3a1169c8-ec67-4ce5-8024-ab4f08d7b609
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env node
2
+
3
+ const yargs = require("yargs");
4
+ const { hideBin } = require("yargs/helpers");
5
+ const chalk = require("chalk");
6
+ const dotenv = require("dotenv")
7
+ dotenv.config()
8
+
9
+ const beginCmd = require("./controllers/begin")
10
+ const initCmd = require("./controllers/init")
11
+ const addCmd = require("./controllers/add")
12
+ const commitCmd = require("./controllers/commit")
13
+ const unstageCmd = require("./controllers/unstage")
14
+ const logCmd = require("./controllers/log");
15
+ const pushCmd = require("./controllers/push");
16
+
17
+
18
+ yargs(hideBin(process.argv))
19
+ .scriptName("jvcs")
20
+ .command(
21
+ "begin",
22
+ chalk.blue("Initialize the Version Control System (login/signup).\n"),
23
+ {},
24
+ async () => {
25
+ try {
26
+ await beginCmd()
27
+ }
28
+ catch(error) {
29
+ console.log(chalk.red(error))
30
+ }
31
+ }
32
+ )
33
+ .command(
34
+ "init",
35
+ chalk.blue("Create an empty repository.\n"),
36
+ {},
37
+ async () => {
38
+ try {
39
+ await initCmd()
40
+ }
41
+ catch(error) {
42
+ console.log(chalk.red(error))
43
+ }
44
+ }
45
+ )
46
+ .command(
47
+ "add <paths...>",
48
+ chalk.blue(
49
+ `Add files or folders to the staging area.
50
+
51
+ Command | Description
52
+ ---------------------------------|-------------------
53
+ jvcs add . | all files/folders
54
+ jvcs add <file1> <file2> | multiple files
55
+ jvcs add <folder1> <folder2> | multiple folders
56
+ jvcs add <file> <folder> | files and folders\n`
57
+ ),
58
+ (yargs)=> {
59
+ return yargs.positional("paths", {
60
+ type: 'string',
61
+ describe: 'Files and folders to stage'
62
+ })
63
+ },
64
+ async (argv) => {
65
+ try {
66
+ await addCmd(argv.paths)
67
+ }
68
+ catch(error) {
69
+ console.log(chalk.red(error))
70
+ }
71
+ }
72
+ )
73
+ .command(
74
+ "commit <message>",
75
+ chalk.blue("Commit all the files/folders inside staging area\n"),
76
+ (yargs)=> {
77
+ return yargs.positional("message", {
78
+ type: 'string',
79
+ describe: 'Some message with your commit'
80
+ })
81
+ },
82
+ async (argv)=> {
83
+ try {
84
+ await commitCmd(argv.message)
85
+ }
86
+ catch(error) {
87
+ console.log(chalk.red(error))
88
+ }
89
+ }
90
+ )
91
+ .command(
92
+ "unstage <paths...>",
93
+ chalk.blue(`
94
+ Remove files and folders from staging area
95
+
96
+ Command | Description
97
+ ---------------------------------|-------------------
98
+ jvcs unstage . | all files/folders
99
+ jvcs unstage <file1> <file2> | multiple files
100
+ jvcs unstage <folder1> <folder2> | multiple folders
101
+ jvcs unstage <file> <folder> | files and folders\n
102
+ `),
103
+ (yargs)=> {
104
+ return yargs.positional("paths", {
105
+ type: 'string',
106
+ describe: 'Files and folders to unstage'
107
+ })
108
+ },
109
+ async (argv)=> {
110
+ try {
111
+ await unstageCmd(argv.paths)
112
+ }
113
+ catch(error) {
114
+ console.log(chalk.red(error))
115
+ }
116
+ }
117
+ )
118
+ .command(
119
+ "log",
120
+ "show details of all commits",
121
+ {},
122
+ async ()=> {
123
+ try {
124
+ await logCmd()
125
+ }
126
+ catch(error) {
127
+ console.log(chalk.red(error))
128
+ }
129
+ }
130
+ )
131
+ .command(
132
+ "push",
133
+ "Push all the commits to remote",
134
+ {},
135
+ async ()=> {
136
+ try {
137
+ await pushCmd()
138
+ }
139
+ catch(error) {
140
+ console.log(chalk.red(error))
141
+ }
142
+ }
143
+ )
144
+ .demandCommand(1, chalk.yellow("You need at least one command"))
145
+ .help()
146
+ .parse();
@@ -0,0 +1,6 @@
1
+ {
2
+ "index.js": {
3
+ "hash": "ba4b020c3a1b7cd4e9bb5d8ea1979236ced22891fff322dc38c567917a04eb03",
4
+ "time": "2025-10-27T17:03:25.838Z"
5
+ }
6
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "author": "jagdish",
3
+ "id": "3a1169c8-ec67-4ce5-8024-ab4f08d7b609",
4
+ "message": "m2",
5
+ "timeStamp": "2025-10-27T17:04:27.217Z",
6
+ "parentId": "c362f97f-997b-499a-bb45-9e67f298f61e"
7
+ }
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env node
2
+
3
+ const yargs = require("yargs");
4
+ const { hideBin } = require("yargs/helpers");
5
+ const chalk = require("chalk");
6
+ const dotenv = require("dotenv")
7
+ dotenv.config()
8
+
9
+ const beginCmd = require("./controllers/begin")
10
+ const initCmd = require("./controllers/init")
11
+ const addCmd = require("./controllers/add")
12
+ const commitCmd = require("./controllers/commit")
13
+ const unstageCmd = require("./controllers/unstage")
14
+ const logCmd = require("./controllers/log");
15
+ const pushCmd = require("./controllers/push");
16
+
17
+
18
+ yargs(hideBin(process.argv))
19
+ .scriptName("jvcs")
20
+ .command(
21
+ "begin",
22
+ chalk.blue("Initialize the Version Control System (login/signup).\n"),
23
+ {},
24
+ async () => {
25
+ try {
26
+ await beginCmd()
27
+ }
28
+ catch(error) {
29
+ console.log(chalk.red(error))
30
+ }
31
+ }
32
+ )
33
+ .command(
34
+ "init",
35
+ chalk.blue("Create an empty repository.\n"),
36
+ {},
37
+ async () => {
38
+ try {
39
+ await initCmd()
40
+ }
41
+ catch(error) {
42
+ console.log(chalk.red(error))
43
+ }
44
+ }
45
+ )
46
+ .command(
47
+ "add <paths...>",
48
+ chalk.blue(
49
+ `Add files or folders to the staging area.
50
+
51
+ Command | Description
52
+ ---------------------------------|-------------------
53
+ jvcs add . | all files/folders
54
+ jvcs add <file1> <file2> | multiple files
55
+ jvcs add <folder1> <folder2> | multiple folders
56
+ jvcs add <file> <folder> | files and folders\n`
57
+ ),
58
+ (yargs)=> {
59
+ return yargs.positional("paths", {
60
+ type: 'string',
61
+ describe: 'Files and folders to stage'
62
+ })
63
+ },
64
+ async (argv) => {
65
+ try {
66
+ await addCmd(argv.paths)
67
+ }
68
+ catch(error) {
69
+ console.log(chalk.red(error))
70
+ }
71
+ }
72
+ )
73
+ .command(
74
+ "commit <message>",
75
+ chalk.blue("Commit all the files/folders inside staging area\n"),
76
+ (yargs)=> {
77
+ return yargs.positional("message", {
78
+ type: 'string',
79
+ describe: 'Some message with your commit'
80
+ })
81
+ },
82
+ async (argv)=> {
83
+ try {
84
+ await commitCmd(argv.message)
85
+ }
86
+ catch(error) {
87
+ console.log(chalk.red(error))
88
+ }
89
+ }
90
+ )
91
+ .command(
92
+ "unstage <paths...>",
93
+ chalk.blue(`
94
+ Remove files and folders from staging area
95
+
96
+ Command | Description
97
+ ---------------------------------|-------------------
98
+ jvcs unstage . | all files/folders
99
+ jvcs unstage <file1> <file2> | multiple files
100
+ jvcs unstage <folder1> <folder2> | multiple folders
101
+ jvcs unstage <file> <folder> | files and folders\n
102
+ `),
103
+ (yargs)=> {
104
+ return yargs.positional("paths", {
105
+ type: 'string',
106
+ describe: 'Files and folders to unstage'
107
+ })
108
+ },
109
+ async (argv)=> {
110
+ try {
111
+ await unstageCmd(argv.paths)
112
+ }
113
+ catch(error) {
114
+ console.log(chalk.red(error))
115
+ }
116
+ }
117
+ )
118
+ .command(
119
+ "log",
120
+ "show details of all commits",
121
+ {},
122
+ async ()=> {
123
+ try {
124
+ await logCmd()
125
+ }
126
+ catch(error) {
127
+ console.log(chalk.red(error))
128
+ }
129
+ }
130
+ )
131
+ .command(
132
+ "push",
133
+ "Push all the commits to remote",
134
+ {},
135
+ async ()=> {
136
+ try {
137
+ await pushCmd()
138
+ }
139
+ catch(error) {
140
+ console.log(chalk.red(error))
141
+ }
142
+ }
143
+ )
144
+ .demandCommand(1, chalk.yellow("You need at least one command"))
145
+ .help()
146
+ .parse();
@@ -0,0 +1,6 @@
1
+ {
2
+ "index.js": {
3
+ "hash": "ba4b020c3a1b7cd4e9bb5d8ea1979236ced22891fff322dc38c567917a04eb03",
4
+ "time": "2025-10-27T17:03:25.838Z"
5
+ }
6
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "author": "jagdish",
3
+ "id": "c362f97f-997b-499a-bb45-9e67f298f61e",
4
+ "message": "m1",
5
+ "timeStamp": "2025-10-27T17:03:35.670Z",
6
+ "parentId": null
7
+ }
package/.jvcs/config.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "repoName": "backend2",
3
- "createdAt": "2025-10-27T14:28:52.288Z",
3
+ "createdAt": "2025-10-27T17:03:18.444Z",
4
4
  "remote": null,
5
5
  "owner": {
6
6
  "username": "jagdish",
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env node
2
+
3
+ const yargs = require("yargs");
4
+ const { hideBin } = require("yargs/helpers");
5
+ const chalk = require("chalk");
6
+ const dotenv = require("dotenv")
7
+ dotenv.config()
8
+
9
+ const beginCmd = require("./controllers/begin")
10
+ const initCmd = require("./controllers/init")
11
+ const addCmd = require("./controllers/add")
12
+ const commitCmd = require("./controllers/commit")
13
+ const unstageCmd = require("./controllers/unstage")
14
+ const logCmd = require("./controllers/log");
15
+ const pushCmd = require("./controllers/push");
16
+
17
+
18
+ yargs(hideBin(process.argv))
19
+ .scriptName("jvcs")
20
+ .command(
21
+ "begin",
22
+ chalk.blue("Initialize the Version Control System (login/signup).\n"),
23
+ {},
24
+ async () => {
25
+ try {
26
+ await beginCmd()
27
+ }
28
+ catch(error) {
29
+ console.log(chalk.red(error))
30
+ }
31
+ }
32
+ )
33
+ .command(
34
+ "init",
35
+ chalk.blue("Create an empty repository.\n"),
36
+ {},
37
+ async () => {
38
+ try {
39
+ await initCmd()
40
+ }
41
+ catch(error) {
42
+ console.log(chalk.red(error))
43
+ }
44
+ }
45
+ )
46
+ .command(
47
+ "add <paths...>",
48
+ chalk.blue(
49
+ `Add files or folders to the staging area.
50
+
51
+ Command | Description
52
+ ---------------------------------|-------------------
53
+ jvcs add . | all files/folders
54
+ jvcs add <file1> <file2> | multiple files
55
+ jvcs add <folder1> <folder2> | multiple folders
56
+ jvcs add <file> <folder> | files and folders\n`
57
+ ),
58
+ (yargs)=> {
59
+ return yargs.positional("paths", {
60
+ type: 'string',
61
+ describe: 'Files and folders to stage'
62
+ })
63
+ },
64
+ async (argv) => {
65
+ try {
66
+ await addCmd(argv.paths)
67
+ }
68
+ catch(error) {
69
+ console.log(chalk.red(error))
70
+ }
71
+ }
72
+ )
73
+ .command(
74
+ "commit <message>",
75
+ chalk.blue("Commit all the files/folders inside staging area\n"),
76
+ (yargs)=> {
77
+ return yargs.positional("message", {
78
+ type: 'string',
79
+ describe: 'Some message with your commit'
80
+ })
81
+ },
82
+ async (argv)=> {
83
+ try {
84
+ await commitCmd(argv.message)
85
+ }
86
+ catch(error) {
87
+ console.log(chalk.red(error))
88
+ }
89
+ }
90
+ )
91
+ .command(
92
+ "unstage <paths...>",
93
+ chalk.blue(`
94
+ Remove files and folders from staging area
95
+
96
+ Command | Description
97
+ ---------------------------------|-------------------
98
+ jvcs unstage . | all files/folders
99
+ jvcs unstage <file1> <file2> | multiple files
100
+ jvcs unstage <folder1> <folder2> | multiple folders
101
+ jvcs unstage <file> <folder> | files and folders\n
102
+ `),
103
+ (yargs)=> {
104
+ return yargs.positional("paths", {
105
+ type: 'string',
106
+ describe: 'Files and folders to unstage'
107
+ })
108
+ },
109
+ async (argv)=> {
110
+ try {
111
+ await unstageCmd(argv.paths)
112
+ }
113
+ catch(error) {
114
+ console.log(chalk.red(error))
115
+ }
116
+ }
117
+ )
118
+ .command(
119
+ "log",
120
+ "show details of all commits",
121
+ {},
122
+ async ()=> {
123
+ try {
124
+ await logCmd()
125
+ }
126
+ catch(error) {
127
+ console.log(chalk.red(error))
128
+ }
129
+ }
130
+ )
131
+ .command(
132
+ "push",
133
+ "Push all the commits to remote",
134
+ {},
135
+ async ()=> {
136
+ try {
137
+ await pushCmd()
138
+ }
139
+ catch(error) {
140
+ console.log(chalk.red(error))
141
+ }
142
+ }
143
+ )
144
+ .demandCommand(1, chalk.yellow("You need at least one command"))
145
+ .help()
146
+ .parse();
@@ -1 +1,6 @@
1
- {}
1
+ {
2
+ "index.js": {
3
+ "hash": "ba4b020c3a1b7cd4e9bb5d8ea1979236ced22891fff322dc38c567917a04eb03",
4
+ "time": "2025-10-27T17:03:25.838Z"
5
+ }
6
+ }
@@ -0,0 +1,56 @@
1
+ const { drive } = require("../config/drive-config");
2
+
3
+ async function getDirectoryStructure(username,reponame,commitId) {
4
+
5
+
6
+ async function findOrCreateFolder(name,parentId=null) {
7
+
8
+ const query = [
9
+ `name='${name}'`,
10
+ "mimeType='application/vnd.google-apps.folder'",
11
+ "trashed=false"
12
+ ]
13
+
14
+ if(parentId) {
15
+ query.push(`'${parentId}' in parents`)
16
+ }
17
+
18
+ const res = await drive.files.list({
19
+ q: query.join(" and "),
20
+ fields: "files(id,name)"
21
+ })
22
+
23
+ if (res.data.files.length > 0)
24
+ return { id: res.data.files[0].id, alreadyExists: true };
25
+
26
+ const folderMetaData = {
27
+ name,
28
+ mimeType: "application/vnd.google-apps.folder",
29
+ }
30
+ if(parentId) folderMetaData.parents = [parentId];
31
+
32
+ const folder = await drive.files.create({
33
+ resource: folderMetaData,
34
+ fields: "id"
35
+ })
36
+
37
+ return { id: folder.data.id, alreadyExists: false };
38
+ }
39
+
40
+ // Build folder hierarchy in drive
41
+ const githubClone = await findOrCreateFolder("GithubClone");
42
+ const userFolder = await findOrCreateFolder(username,githubClone.id)
43
+ const repoFolder = await findOrCreateFolder(reponame,userFolder.id)
44
+ const commitFolderName = `commit_${commitId}`
45
+ const commitFolder = await findOrCreateFolder(commitFolderName,repoFolder.id)
46
+
47
+ return {
48
+ githubClone: githubClone.id,
49
+ userFolder: userFolder.id,
50
+ repoFolder: repoFolder.id,
51
+ commitFolder: commitFolder.id,
52
+ commitAlreadyExists: commitFolder.alreadyExists
53
+ }
54
+ }
55
+
56
+ module.exports = getDirectoryStructure