jvcs 1.2.5 → 1.2.7
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/apicall/handleDbForRepo.js +1 -1
- package/config/drive-config.js +2 -0
- package/controllers/clone.js +1 -1
- package/controllers/login.js +1 -1
- package/controllers/revert.js +1 -1
- package/controllers/signup.js +1 -1
- package/controllers/verifyOtp.js +1 -1
- package/package.json +19 -19
- package/.env +0 -4
- package/.history/controllers/add_20251028230103.js +0 -122
- package/.history/controllers/add_20251030112406.js +0 -121
- package/.history/index_20251029172546.js +0 -199
- package/.history/index_20251030111704.js +0 -199
- package/.history/index_20251030112456.js +0 -199
- package/.history/index_20251030112510.js +0 -199
- package/.history/index_20251030112514.js +0 -199
- package/.history/index_20251030112533.js +0 -199
- package/.history/index_20251030112544.js +0 -199
- package/.history/index_20251030112551.js +0 -193
- package/.history/index_20251030112553.js +0 -193
- package/.history/index_20251030112557.js +0 -200
- package/.history/index_20251030112558.js +0 -200
- package/.history/index_20251030150146.js +0 -199
- package/.history/index_20251030150151.js +0 -199
- package/.history/index_20251030150328.js +0 -199
- package/.history/index_20251030150333.js +0 -199
- package/.history/index_20251030150349.js +0 -199
- package/.history/index_20251030150350.js +0 -199
- package/.history/index_20251030150808.js +0 -199
- package/.history/index_20251030150809.js +0 -199
package/config/drive-config.js
CHANGED
|
@@ -13,6 +13,7 @@ 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."));
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -20,6 +21,7 @@ function getDriveClient() {
|
|
|
20
21
|
const { CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, REFRESH_TOKEN } = data;
|
|
21
22
|
|
|
22
23
|
if(!CLIENT_ID || !CLIENT_SECRET || !REFRESH_TOKEN) {
|
|
24
|
+
console.log(chalk.red("Incomplete credentials in ~/.jvcs/config.json"));
|
|
23
25
|
return null;
|
|
24
26
|
}
|
|
25
27
|
|
package/controllers/clone.js
CHANGED
package/controllers/login.js
CHANGED
package/controllers/revert.js
CHANGED
package/controllers/signup.js
CHANGED
package/controllers/verifyOtp.js
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "jvcs",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"bin": {
|
|
5
|
-
"jvcs": "./index.js"
|
|
6
|
-
},
|
|
7
|
-
"keywords": [],
|
|
8
|
-
"author": "",
|
|
9
|
-
"license": "ISC",
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"chalk": "^4.1.2",
|
|
12
|
-
"crypto": "^1.0.1",
|
|
13
|
-
"dotenv": "^17.2.3",
|
|
14
|
-
"googleapis": "^164.1.0",
|
|
15
|
-
"inquirer": "^8.2.7",
|
|
16
|
-
"uuid": "^13.0.0",
|
|
17
|
-
"validator": "^13.15.20",
|
|
18
|
-
"yargs": "^18.0.0"
|
|
19
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "jvcs",
|
|
3
|
+
"version": "1.2.7",
|
|
4
|
+
"bin": {
|
|
5
|
+
"jvcs": "./index.js"
|
|
6
|
+
},
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"chalk": "^4.1.2",
|
|
12
|
+
"crypto": "^1.0.1",
|
|
13
|
+
"dotenv": "^17.2.3",
|
|
14
|
+
"googleapis": "^164.1.0",
|
|
15
|
+
"inquirer": "^8.2.7",
|
|
16
|
+
"uuid": "^13.0.0",
|
|
17
|
+
"validator": "^13.15.20",
|
|
18
|
+
"yargs": "^18.0.0"
|
|
19
|
+
}
|
|
20
20
|
}
|
package/.env
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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//04dWkzGCpoIgACgYIARAAGAQSNwF-L9IrRV-B67zRcIkhs7USx3vLewtE764bZPv7d5d7hAlH7QThZxj2CQUr5flQIG12Ad64dQI
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
const { checkGlobalConfig, getGlobalConfig, checkforjvcs } = require("./utility")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const fssync = require("fs")
|
|
4
|
-
const chalk = require("chalk")
|
|
5
|
-
const fs = require("fs").promises
|
|
6
|
-
const crypto = require("crypto")
|
|
7
|
-
|
|
8
|
-
async function getFileHash(filepath) {
|
|
9
|
-
const buffer = await fs.readFile(filepath)
|
|
10
|
-
return crypto.createHash("sha256").update(buffer).digest("hex")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function hashDirectoryRecursive(dir,hashData) {
|
|
14
|
-
|
|
15
|
-
const entries = await fs.readdir(dir, {withFileTypes: true})
|
|
16
|
-
console.log(entries)
|
|
17
|
-
|
|
18
|
-
for(const entry of entries) {
|
|
19
|
-
|
|
20
|
-
const fullPath = path.join(dir,entry.name)
|
|
21
|
-
const relativePath = path.relative(process.cwd(),fullPath)
|
|
22
|
-
|
|
23
|
-
if(entry.isFile()) {
|
|
24
|
-
const hash = await getFileHash(fullPath)
|
|
25
|
-
hashData[relativePath] = {
|
|
26
|
-
hash,
|
|
27
|
-
time: new Date().toISOString(),
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else if(entry.isDirectory()) {
|
|
31
|
-
await hashDirectoryRecursive(fullPath,hashData)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function addCmd(paths) {
|
|
37
|
-
|
|
38
|
-
if(!paths || paths.length === 0) {
|
|
39
|
-
console.log(chalk.yellow("Please specify files or folders to add."));
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if(!checkGlobalConfig()) {
|
|
44
|
-
console.log(chalk.red("No existing session found. Please login or signup."))
|
|
45
|
-
console.log(chalk.green("jvcs --help for help"))
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let configData = getGlobalConfig()
|
|
50
|
-
|
|
51
|
-
if(!configData) {
|
|
52
|
-
console.log(chalk.red("No existing session found. Please login or signup."))
|
|
53
|
-
console.log(chalk.green("jvcs --help for help"))
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if(!checkforjvcs()) {
|
|
58
|
-
console.log(chalk.red("Repository is not initialized or is deleted. Please create it."))
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const repoPath = path.join(process.cwd(),".jvcs")
|
|
63
|
-
const staging = path.join(repoPath,"staging")
|
|
64
|
-
|
|
65
|
-
if(!fssync.existsSync(staging))
|
|
66
|
-
fssync.mkdirSync(staging, {recursive: true})
|
|
67
|
-
|
|
68
|
-
const hashPath = path.join(staging,"jvcs_hashcode.json")
|
|
69
|
-
let hashData = {}
|
|
70
|
-
|
|
71
|
-
if(fssync.existsSync(hashPath)) {
|
|
72
|
-
hashData = JSON.parse(await fs.readFile(hashPath,"utf-8"))
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let targets = []
|
|
76
|
-
if(paths.length === 1 && paths[0] === ".") {
|
|
77
|
-
targets = await fs.readdir(process.cwd(),{withFileTypes: true})
|
|
78
|
-
targets = targets.filter((target)=> target.name !== ".jvcs" && target.name !== "node_modules").map((item)=> path.resolve(process.cwd(),item.name))
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
targets = paths.map((p)=> path.resolve(process.cwd(),p))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// copying the files and folders to staging area
|
|
85
|
-
for(const target of targets) {
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
|
|
89
|
-
if(!fssync.existsSync(target)) {
|
|
90
|
-
console.log(chalk.red(`Path not found: ${target}`))
|
|
91
|
-
continue
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const destination = path.join(staging,path.relative(process.cwd(),target))
|
|
95
|
-
await fs.mkdir(path.dirname(destination), {recursive: true})
|
|
96
|
-
|
|
97
|
-
const stats = await fs.stat(target)
|
|
98
|
-
|
|
99
|
-
if(stats.isFile()) {
|
|
100
|
-
await fs.copyFile(target,destination)
|
|
101
|
-
const hash = await getFileHash(target)
|
|
102
|
-
hashData[path.relative(process.cwd(),target)] = {
|
|
103
|
-
hash,
|
|
104
|
-
time: new Date().toISOString(),
|
|
105
|
-
}
|
|
106
|
-
console.log(chalk.green(`Added file: ${path.relative(process.cwd(), target)}`));
|
|
107
|
-
}
|
|
108
|
-
else if(stats.isDirectory()) {
|
|
109
|
-
await fs.cp(target,destination,{recursive: true})
|
|
110
|
-
await hashDirectoryRecursive(target,hashData)
|
|
111
|
-
console.log(chalk.cyan(`Added folder: ${path.relative(process.cwd(), target)}`));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch(error) {
|
|
115
|
-
console.log(chalk.red(`Unexpected error: ${error.message}`));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
await fs.writeFile(hashPath, JSON.stringify(hashData, null, 2));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
module.exports = addCmd
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
const { checkGlobalConfig, getGlobalConfig, checkforjvcs } = require("./utility")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const fssync = require("fs")
|
|
4
|
-
const chalk = require("chalk")
|
|
5
|
-
const fs = require("fs").promises
|
|
6
|
-
const crypto = require("crypto")
|
|
7
|
-
|
|
8
|
-
async function getFileHash(filepath) {
|
|
9
|
-
const buffer = await fs.readFile(filepath)
|
|
10
|
-
return crypto.createHash("sha256").update(buffer).digest("hex")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function hashDirectoryRecursive(dir,hashData) {
|
|
14
|
-
|
|
15
|
-
const entries = await fs.readdir(dir, {withFileTypes: true})
|
|
16
|
-
|
|
17
|
-
for(const entry of entries) {
|
|
18
|
-
|
|
19
|
-
const fullPath = path.join(dir,entry.name)
|
|
20
|
-
const relativePath = path.relative(process.cwd(),fullPath)
|
|
21
|
-
|
|
22
|
-
if(entry.isFile()) {
|
|
23
|
-
const hash = await getFileHash(fullPath)
|
|
24
|
-
hashData[relativePath] = {
|
|
25
|
-
hash,
|
|
26
|
-
time: new Date().toISOString(),
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else if(entry.isDirectory()) {
|
|
30
|
-
await hashDirectoryRecursive(fullPath,hashData)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function addCmd(paths) {
|
|
36
|
-
|
|
37
|
-
if(!paths || paths.length === 0) {
|
|
38
|
-
console.log(chalk.yellow("Please specify files or folders to add."));
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if(!checkGlobalConfig()) {
|
|
43
|
-
console.log(chalk.red("No existing session found. Please login or signup."))
|
|
44
|
-
console.log(chalk.green("jvcs --help for help"))
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let configData = getGlobalConfig()
|
|
49
|
-
|
|
50
|
-
if(!configData) {
|
|
51
|
-
console.log(chalk.red("No existing session found. Please login or signup."))
|
|
52
|
-
console.log(chalk.green("jvcs --help for help"))
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if(!checkforjvcs()) {
|
|
57
|
-
console.log(chalk.red("Repository is not initialized or is deleted. Please create it."))
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const repoPath = path.join(process.cwd(),".jvcs")
|
|
62
|
-
const staging = path.join(repoPath,"staging")
|
|
63
|
-
|
|
64
|
-
if(!fssync.existsSync(staging))
|
|
65
|
-
fssync.mkdirSync(staging, {recursive: true})
|
|
66
|
-
|
|
67
|
-
const hashPath = path.join(staging,"jvcs_hashcode.json")
|
|
68
|
-
let hashData = {}
|
|
69
|
-
|
|
70
|
-
if(fssync.existsSync(hashPath)) {
|
|
71
|
-
hashData = JSON.parse(await fs.readFile(hashPath,"utf-8"))
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let targets = []
|
|
75
|
-
if(paths.length === 1 && paths[0] === ".") {
|
|
76
|
-
targets = await fs.readdir(process.cwd(),{withFileTypes: true})
|
|
77
|
-
targets = targets.filter((target)=> target.name !== ".jvcs" && target.name !== "node_modules").map((item)=> path.resolve(process.cwd(),item.name))
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
targets = paths.map((p)=> path.resolve(process.cwd(),p))
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// copying the files and folders to staging area
|
|
84
|
-
for(const target of targets) {
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
|
|
88
|
-
if(!fssync.existsSync(target)) {
|
|
89
|
-
console.log(chalk.red(`Path not found: ${target}`))
|
|
90
|
-
continue
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const destination = path.join(staging,path.relative(process.cwd(),target))
|
|
94
|
-
await fs.mkdir(path.dirname(destination), {recursive: true})
|
|
95
|
-
|
|
96
|
-
const stats = await fs.stat(target)
|
|
97
|
-
|
|
98
|
-
if(stats.isFile()) {
|
|
99
|
-
await fs.copyFile(target,destination)
|
|
100
|
-
const hash = await getFileHash(target)
|
|
101
|
-
hashData[path.relative(process.cwd(),target)] = {
|
|
102
|
-
hash,
|
|
103
|
-
time: new Date().toISOString(),
|
|
104
|
-
}
|
|
105
|
-
console.log(chalk.green(`Added file: ${path.relative(process.cwd(), target)}`));
|
|
106
|
-
}
|
|
107
|
-
else if(stats.isDirectory()) {
|
|
108
|
-
await fs.cp(target,destination,{recursive: true})
|
|
109
|
-
await hashDirectoryRecursive(target,hashData)
|
|
110
|
-
console.log(chalk.cyan(`Added folder: ${path.relative(process.cwd(), target)}`));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch(error) {
|
|
114
|
-
console.log(chalk.red(`Unexpected error: ${error.message}`));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
await fs.writeFile(hashPath, JSON.stringify(hashData, null, 2));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
module.exports = addCmd
|
|
@@ -1,199 +0,0 @@
|
|
|
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();
|