jvcs 1.2.2 → 1.2.4

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.
@@ -0,0 +1,199 @@
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
+ const statusCmd = require("./controllers/status")
17
+ const revertCmd = require("./controllers/revert")
18
+ const cloneCmd = require("./controllers/clone")
19
+
20
+
21
+ yargs(hideBin(process.argv))
22
+ .scriptName("jvcs")
23
+ .command(
24
+ "begin",
25
+ chalk.blue("Initialize the Version Control System (login/signup).\n"),
26
+ {},
27
+ async () => {
28
+ try {
29
+ await beginCmd()
30
+ }
31
+ catch(error) {
32
+ console.log(chalk.red(error))
33
+ }
34
+ }
35
+ )
36
+ .command(
37
+ "init",
38
+ chalk.blue("Create an empty repository.\n"),
39
+ {},
40
+ async () => {
41
+ try {
42
+ await initCmd()
43
+ }
44
+ catch(error) {
45
+ console.log(chalk.red(error))
46
+ }
47
+ }
48
+ )
49
+ .command(
50
+ "add <paths...>",
51
+ chalk.blue(
52
+ `Add files or folders to the staging area.
53
+
54
+ Command | Description
55
+ ---------------------------------|-------------------
56
+ jvcs add . | all files/folders
57
+ jvcs add <file1> <file2> | multiple files
58
+ jvcs add <folder1> <folder2> | multiple folders
59
+ jvcs add <file> <folder> | files and folders\n`
60
+ ),
61
+ (yargs)=> {
62
+ return yargs.positional("paths", {
63
+ type: 'string',
64
+ describe: 'Files and folders to stage'
65
+ })
66
+ },
67
+ async (argv) => {
68
+ try {
69
+ await addCmd(argv.paths)
70
+ }
71
+ catch(error) {
72
+ console.log(chalk.red(error))
73
+ }
74
+ }
75
+ )
76
+ .command(
77
+ "commit <message>",
78
+ chalk.blue("Commit all the files/folders inside staging area\n"),
79
+ (yargs)=> {
80
+ return yargs.positional("message", {
81
+ type: 'string',
82
+ describe: 'Some message with your commit'
83
+ })
84
+ },
85
+ async (argv)=> {
86
+ try {
87
+ await commitCmd(argv.message)
88
+ }
89
+ catch(error) {
90
+ console.log(chalk.red(error))
91
+ }
92
+ }
93
+ )
94
+ .command(
95
+ "unstage <paths...>",
96
+ chalk.blue(`
97
+ Remove files and folders from staging area
98
+
99
+ Command | Description
100
+ ---------------------------------|-------------------
101
+ jvcs unstage . | all files/folders
102
+ jvcs unstage <file1> <file2> | multiple files
103
+ jvcs unstage <folder1> <folder2> | multiple folders
104
+ jvcs unstage <file> <folder> | files and folders\n
105
+ `),
106
+ (yargs)=> {
107
+ return yargs.positional("paths", {
108
+ type: 'string',
109
+ describe: 'Files and folders to unstage'
110
+ })
111
+ },
112
+ async (argv)=> {
113
+ try {
114
+ await unstageCmd(argv.paths)
115
+ }
116
+ catch(error) {
117
+ console.log(chalk.red(error))
118
+ }
119
+ }
120
+ )
121
+ .command(
122
+ "log",
123
+ chalk.blue("show details of all commits"),
124
+ {},
125
+ async ()=> {
126
+ try {
127
+ await logCmd()
128
+ }
129
+ catch(error) {
130
+ console.log(chalk.red(error))
131
+ }
132
+ }
133
+ )
134
+ .command(
135
+ "push",
136
+ chalk.blue("Push all the commits to remote"),
137
+ {},
138
+ async ()=> {
139
+ try {
140
+ await pushCmd()
141
+ }
142
+ catch(error) {
143
+ console.log(chalk.red(error))
144
+ }
145
+ }
146
+ )
147
+ .command(
148
+ "status",
149
+ chalk.blue("Check status of each file/folder"),
150
+ {},
151
+ async ()=> {
152
+ try {
153
+ await statusCmd()
154
+ }
155
+ catch(error) {
156
+ console.log(chalk.red(error))
157
+ }
158
+ }
159
+ )
160
+ .command(
161
+ "revert <commitId>",
162
+ chalk.blue("Replace your working directory with specific commit you made previously"),
163
+ (yargs)=> {
164
+ return yargs.positional("commitId", {
165
+ type: 'string',
166
+ describe: 'commitId to move your head'
167
+ })
168
+ },
169
+ async (argv)=> {
170
+ try {
171
+ await revertCmd(argv.commitId)
172
+ }
173
+ catch(error) {
174
+ console.log(chalk.red(error))
175
+ }
176
+ }
177
+ )
178
+ .command(
179
+ "clone <path>",
180
+ chalk.blue("Clone a remote repository to local"),
181
+ (yargs)=> {
182
+ return yargs.positional("path", {
183
+ type:"string",
184
+ describe:"path must be of the form username/reponame"
185
+ })
186
+ },
187
+ async (argv)=> {
188
+ try {
189
+ const [username, reponame] = argv.path.split("/");
190
+ await cloneCmd(username,reponame)
191
+ }
192
+ catch(error) {
193
+ console.log(chalk.red(error || error.message))
194
+ }
195
+ }
196
+ )
197
+ .demandCommand(1, chalk.yellow("You need at least one command"))
198
+ .help()
199
+ .parse();
@@ -0,0 +1,199 @@
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
+ const statusCmd = require("./controllers/status")
17
+ const revertCmd = require("./controllers/revert")
18
+ const cloneCmd = require("./controllers/clone")
19
+
20
+
21
+ yargs(hideBin(process.argv))
22
+ .scriptName("jvcs")
23
+ .command(
24
+ "begin",
25
+ chalk.blue("Initialize the Version Control System (login/signup).\n"),
26
+ {},
27
+ async () => {
28
+ try {
29
+ await beginCmd()
30
+ }
31
+ catch(error) {
32
+ console.log(chalk.red(error))
33
+ }
34
+ }
35
+ )
36
+ .command(
37
+ "init",
38
+ chalk.blue("Create an empty repository.\n"),
39
+ {},
40
+ async () => {
41
+ try {
42
+ await initCmd()
43
+ }
44
+ catch(error) {
45
+ console.log(chalk.red(error))
46
+ }
47
+ }
48
+ )
49
+ .command(
50
+ "add <paths...>",
51
+ chalk.blue(
52
+ `Add files or folders to the staging area.
53
+
54
+ Command | Description
55
+ ---------------------------------|-------------------
56
+ jvcs add . | all files/folders
57
+ jvcs add <file1> <file2> | multiple files
58
+ jvcs add <folder1> <folder2> | multiple folders
59
+ jvcs add <file> <folder> | files and folders\n`
60
+ ),
61
+ (yargs)=> {
62
+ return yargs.positional("paths", {
63
+ type: 'string',
64
+ describe: 'Files and folders to stage'
65
+ })
66
+ },
67
+ async (argv) => {
68
+ try {
69
+ await addCmd(argv.paths)
70
+ }
71
+ catch(error) {
72
+ console.log(chalk.red(error))
73
+ }
74
+ }
75
+ )
76
+ .command(
77
+ "commit <message>",
78
+ chalk.blue("Commit all the files/folders inside staging area\n"),
79
+ (yargs)=> {
80
+ return yargs.positional("message", {
81
+ type: 'string',
82
+ describe: 'Some message with your commit'
83
+ })
84
+ },
85
+ async (argv)=> {
86
+ try {
87
+ await commitCmd(argv.message)
88
+ }
89
+ catch(error) {
90
+ console.log(chalk.red(error))
91
+ }
92
+ }
93
+ )
94
+ .command(
95
+ "unstage <paths...>",
96
+ chalk.blue(`
97
+ Remove files and folders from staging area
98
+
99
+ Command | Description
100
+ ---------------------------------|-------------------
101
+ jvcs unstage . | all files/folders
102
+ jvcs unstage <file1> <file2> | multiple files
103
+ jvcs unstage <folder1> <folder2> | multiple folders
104
+ jvcs unstage <file> <folder> | files and folders\n
105
+ `),
106
+ (yargs)=> {
107
+ return yargs.positional("paths", {
108
+ type: 'string',
109
+ describe: 'Files and folders to unstage'
110
+ })
111
+ },
112
+ async (argv)=> {
113
+ try {
114
+ await unstageCmd(argv.paths)
115
+ }
116
+ catch(error) {
117
+ console.log(chalk.red(error))
118
+ }
119
+ }
120
+ )
121
+ .command(
122
+ "log",
123
+ chalk.blue("show details of all commits"),
124
+ {},
125
+ async ()=> {
126
+ try {
127
+ await logCmd()
128
+ }
129
+ catch(error) {
130
+ console.log(chalk.red(error))
131
+ }
132
+ }
133
+ )
134
+ .command(
135
+ "push",
136
+ chalk.blue("Push all the commits to remote"),
137
+ {},
138
+ async ()=> {
139
+ try {
140
+ await pushCmd()
141
+ }
142
+ catch(error) {
143
+ console.log(chalk.red(error))
144
+ }
145
+ }
146
+ )
147
+ .command(
148
+ "status",
149
+ chalk.blue("Check status of each file/folder"),
150
+ {},
151
+ async ()=> {
152
+ try {
153
+ await statusCmd()
154
+ }
155
+ catch(error) {
156
+ console.log(chalk.red(error))
157
+ }
158
+ }
159
+ )
160
+ .command(
161
+ "revert <commitId>",
162
+ chalk.blue("Replace your working directory with specific commit you made previously"),
163
+ (yargs)=> {
164
+ return yargs.positional("commitId", {
165
+ type: 'string',
166
+ describe: 'commitId to move your head'
167
+ })
168
+ },
169
+ async (argv)=> {
170
+ try {
171
+ await revertCmd(argv.commitId)
172
+ }
173
+ catch(error) {
174
+ console.log(chalk.red(error))
175
+ }
176
+ }
177
+ )
178
+ .command(
179
+ "clone <path>",
180
+ chalk.blue("Clone a remote repository to local"),
181
+ (yargs)=> {
182
+ return yargs.positional("path", {
183
+ type:"string",
184
+ describe:"path must be of the form username/reponame"
185
+ })
186
+ },
187
+ async (argv)=> {
188
+ try {
189
+ const [username, reponame] = argv.path.split("/");
190
+ await cloneCmd(username,reponame)
191
+ }
192
+ catch(error) {
193
+ console.log(chalk.red(error || error.message))
194
+ }
195
+ }
196
+ )
197
+ .demandCommand(1, chalk.yellow("You need at least one command"))
198
+ .help()
199
+ .parse();
@@ -13,7 +13,6 @@ const credFile = path.join(credDir, "config.json");
13
13
  function getDriveClient() {
14
14
 
15
15
  if(!fs.existsSync(credFile)) {
16
- console.log(chalk.red("No credentials found. Please login/signup."));
17
16
  return null;
18
17
  }
19
18
 
@@ -21,7 +20,6 @@ function getDriveClient() {
21
20
  const { CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, REFRESH_TOKEN } = data;
22
21
 
23
22
  if(!CLIENT_ID || !CLIENT_SECRET || !REFRESH_TOKEN) {
24
- console.log(chalk.red("Incomplete credentials in ~/.jvcs/config.json"));
25
23
  return null;
26
24
  }
27
25
 
@@ -13,7 +13,6 @@ async function getFileHash(filepath) {
13
13
  async function hashDirectoryRecursive(dir,hashData) {
14
14
 
15
15
  const entries = await fs.readdir(dir, {withFileTypes: true})
16
- console.log(entries)
17
16
 
18
17
  for(const entry of entries) {
19
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jvcs",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "bin": {
5
5
  "jvcs": "./index.js"
6
6
  },
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jvcs — A Lightweight Git & GitHub Clone
2
2
 
3
- > **jvcs** (Jag’s Version Control System) — a simple, beginner-friendly version control system built to make Git-like workflows easier to understand and use.
3
+ > **jvcs** — a simple, beginner-friendly version control system built to make Git-like workflows easier to understand and use.
4
4
  > Designed to simplify core version control operations like committing, reverting, pushing, and cloning — all without the complexity of branches or merges.
5
5
 
6
6
  ---