vtasks-automate-cli 0.5.0 → 0.6.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/README.md +0 -0
- package/content/index.js +56 -21
- package/package.json +1 -1
package/README.md
ADDED
|
File without changes
|
package/content/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const { exec } = require("child_process");
|
|
2
|
-
const config = require("./config");
|
|
1
|
+
// const { exec } = require("child_process");
|
|
2
|
+
// const config = require("./config");
|
|
3
|
+
|
|
4
|
+
import { exec } from "child_process";
|
|
3
5
|
|
|
4
6
|
const LOG_COLORS = {
|
|
5
7
|
RED: "\x1b[31m",
|
|
@@ -8,6 +10,9 @@ const LOG_COLORS = {
|
|
|
8
10
|
BLUE: "\x1b[34m",
|
|
9
11
|
};
|
|
10
12
|
|
|
13
|
+
const VTASKS_URL =
|
|
14
|
+
"https://vtasks.venturing.com.ar/vTasks/api/project/action/track";
|
|
15
|
+
|
|
11
16
|
class GitService {
|
|
12
17
|
static async getCurrentBranch() {
|
|
13
18
|
return new Promise((resolve, reject) => {
|
|
@@ -44,21 +49,50 @@ class GitService {
|
|
|
44
49
|
});
|
|
45
50
|
});
|
|
46
51
|
}
|
|
52
|
+
|
|
53
|
+
static async getCurrentProject() {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
exec("git remote -v", (error, stdout, stderr) => {
|
|
56
|
+
if (error) {
|
|
57
|
+
console.log(
|
|
58
|
+
LOG_COLORS.RED,
|
|
59
|
+
"Error getting project name: Error executing git cmd"
|
|
60
|
+
);
|
|
61
|
+
reject("Error getting user email: Error executing git cmd");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const list = stdout.split("\n");
|
|
65
|
+
const item = list.find((t) => t.startsWith("origin"));
|
|
66
|
+
if (!item) {
|
|
67
|
+
reject("Error getting project name: origin not found");
|
|
68
|
+
reject("Error getting prject name: origin not found");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const split = item.split(" ");
|
|
72
|
+
const url = split.find((t) => t.includes("http"));
|
|
73
|
+
|
|
74
|
+
const urlSplit = url.split("/");
|
|
75
|
+
const gitfile = urlSplit[urlSplit.length - 1];
|
|
76
|
+
const projectName = gitfile.replace(".git", "");
|
|
77
|
+
resolve(projectName);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
47
81
|
}
|
|
48
82
|
|
|
49
83
|
async function main() {
|
|
50
84
|
console.log(LOG_COLORS.BLUE, "Checking vTasks config:");
|
|
51
|
-
if (!config) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
85
|
+
// if (!config) {
|
|
86
|
+
// console.log(LOG_COLORS.RED, "Git user email not found");
|
|
87
|
+
// throw new Error("Missing config.js file");
|
|
88
|
+
// }
|
|
55
89
|
const userEmail = await GitService.getCurrentUser();
|
|
56
90
|
if (!userEmail) {
|
|
57
91
|
console.log(LOG_COLORS.RED, "Git user email not found");
|
|
58
92
|
throw new Error("Git user email not found");
|
|
59
93
|
}
|
|
60
94
|
console.log(LOG_COLORS.GREEN, `User email: ${userEmail}`);
|
|
61
|
-
const projectName =
|
|
95
|
+
const projectName = await GitService.getCurrentProject();
|
|
62
96
|
if (!projectName) {
|
|
63
97
|
console.log(LOG_COLORS.RED, "Missing project name configuration");
|
|
64
98
|
throw new Error("Missing Project name");
|
|
@@ -66,22 +100,22 @@ async function main() {
|
|
|
66
100
|
console.log(LOG_COLORS.GREEN, `Project: ${projectName}`);
|
|
67
101
|
let issueNumber;
|
|
68
102
|
const branch = await GitService.getCurrentBranch();
|
|
69
|
-
if (branch != "qa" && branch != "dev") {
|
|
103
|
+
if (branch != "qa" && branch != "dev" && branch != "master") {
|
|
70
104
|
issueNumber = Number(branch.split("_")[0]);
|
|
71
105
|
console.log(LOG_COLORS.GREEN, `Currently working on issue: ${issueNumber}`);
|
|
72
|
-
const response = await fetch(`${config.vTasksUrl}`, {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
const parsed = await response.json();
|
|
106
|
+
// const response = await fetch(`${config.vTasksUrl}`, {
|
|
107
|
+
// method: "POST",
|
|
108
|
+
// body: JSON.stringify({
|
|
109
|
+
// projectName,
|
|
110
|
+
// branch,
|
|
111
|
+
// userEmail,
|
|
112
|
+
// issueNumber,
|
|
113
|
+
// }),
|
|
114
|
+
// headers: {
|
|
115
|
+
// "Content-Type": "application/json",
|
|
116
|
+
// },
|
|
117
|
+
// });
|
|
118
|
+
// const parsed = await response.json();
|
|
85
119
|
console.log(LOG_COLORS.GREEN, "vTasks status changed successfully!");
|
|
86
120
|
} else {
|
|
87
121
|
console.log(
|
|
@@ -89,6 +123,7 @@ async function main() {
|
|
|
89
123
|
"Warning: you are working in a not issue branch"
|
|
90
124
|
);
|
|
91
125
|
}
|
|
126
|
+
console.log(userEmail, VTASKS_URL, branch, projectName);
|
|
92
127
|
}
|
|
93
128
|
|
|
94
129
|
main();
|