autoforce 0.1.8 → 0.1.9
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/CHANGELOG.md +4 -0
- package/commands/modelA/tasks/list.json +11 -0
- package/commands/modelA/tasks/view.json +1 -0
- package/lib/helpers/context.d.ts +5 -5
- package/lib/helpers/context.js +2 -2
- package/lib/helpers/github-graphql.d.ts +2 -5
- package/lib/helpers/github-graphql.js +1 -31
- package/lib/helpers/github-project-graphql.d.ts +9 -2
- package/lib/helpers/github-project-graphql.js +49 -5
- package/lib/helpers/gitlab-graphql.d.ts +5 -4
- package/lib/helpers/gitlab-graphql.js +6 -1
- package/lib/helpers/taskFunctions.js +12 -0
- package/lib/helpers/tasks.js +10 -6
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
package/lib/helpers/context.d.ts
CHANGED
@@ -24,11 +24,11 @@ declare class Context implements IObjectRecord {
|
|
24
24
|
sfInstalled: boolean;
|
25
25
|
sfToken: boolean;
|
26
26
|
branchName: string | undefined;
|
27
|
-
issueNumber:
|
27
|
+
issueNumber: string | undefined;
|
28
28
|
issueType: string | undefined;
|
29
29
|
_process: string | undefined;
|
30
30
|
_processesHeader: Record<string, IProcessHeader> | undefined;
|
31
|
-
_newIssueNumber:
|
31
|
+
_newIssueNumber: string | undefined;
|
32
32
|
_newIssueType: string | undefined;
|
33
33
|
newBranchName: string | undefined;
|
34
34
|
defaultDias: number;
|
@@ -67,11 +67,11 @@ declare class Context implements IObjectRecord {
|
|
67
67
|
get scratch(): OrganizationInfo;
|
68
68
|
validate(guards: string[]): Promise<void>;
|
69
69
|
issueFromBranch(branchName: string): void;
|
70
|
-
branchNameFromIssue(issueType: string, issueNumber:
|
70
|
+
branchNameFromIssue(issueType: string, issueNumber: string, title?: string): string;
|
71
71
|
get isDevelopment(): boolean;
|
72
72
|
get isNewDevelopment(): boolean;
|
73
|
-
get newIssueNumber():
|
74
|
-
set newIssueNumber(value:
|
73
|
+
get newIssueNumber(): string | undefined;
|
74
|
+
set newIssueNumber(value: string | undefined);
|
75
75
|
get newIssueType(): string | undefined;
|
76
76
|
set newIssueType(value: string | undefined);
|
77
77
|
setNewBranchName(): void;
|
package/lib/helpers/context.js
CHANGED
@@ -45,7 +45,7 @@ class Context {
|
|
45
45
|
this.existNewBranch = false;
|
46
46
|
// Ultima salida del shell
|
47
47
|
this.salida = '';
|
48
|
-
this.backlogColumn = '
|
48
|
+
this.backlogColumn = 'Todo';
|
49
49
|
}
|
50
50
|
loadProjectApi() {
|
51
51
|
if (!this.isProjectApi) {
|
@@ -254,7 +254,7 @@ class Context {
|
|
254
254
|
if (branchSplit.length > 1) {
|
255
255
|
this.issueType = branchSplit[0];
|
256
256
|
if (!Number.isNaN(Number(branchSplit[1]))) {
|
257
|
-
this.issueNumber =
|
257
|
+
this.issueNumber = branchSplit[1];
|
258
258
|
}
|
259
259
|
else {
|
260
260
|
// [this.issueNumber, this.issueTitle] = branchSplit[1].split() // /^([^ -]+)[ -](.*)$/.exec( branchSplit[1]).slice(1);
|
@@ -28,11 +28,8 @@ export declare class GitHubApi implements IGitApi {
|
|
28
28
|
};
|
29
29
|
}>;
|
30
30
|
createPullRequest(branchName: string, title: string, body: string): Promise<boolean>;
|
31
|
-
assignBranchToIssue(issueNumber:
|
32
|
-
|
33
|
-
getIssueName(title: string): string;
|
34
|
-
getIssueObject(issueNumber: number): Promise<IIssueObject>;
|
35
|
-
getIssue(issueNumber: number): Promise<{
|
31
|
+
assignBranchToIssue(issueNumber: string, branchName: string, commitSha: string): Promise<boolean>;
|
32
|
+
getIssue(issueNumber: string): Promise<{
|
36
33
|
id: string;
|
37
34
|
title: string;
|
38
35
|
labels: {
|
@@ -116,36 +116,6 @@ export class GitHubApi {
|
|
116
116
|
return ((_a = createLinkedBranch === null || createLinkedBranch === void 0 ? void 0 : createLinkedBranch.issue) === null || _a === void 0 ? void 0 : _a.id) ? true : false;
|
117
117
|
});
|
118
118
|
}
|
119
|
-
getIssueState(issueNumber) {
|
120
|
-
var _a, _b, _c;
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
122
|
-
const issue = yield this.getIssue(issueNumber);
|
123
|
-
return (_c = (_b = (_a = issue.projectItems) === null || _a === void 0 ? void 0 : _a.nodes[0]) === null || _b === void 0 ? void 0 : _b.fieldValueByName) === null || _c === void 0 ? void 0 : _c.name;
|
124
|
-
});
|
125
|
-
}
|
126
|
-
getIssueName(title) {
|
127
|
-
return title.toLowerCase().replaceAll(' ', '-');
|
128
|
-
}
|
129
|
-
getIssueObject(issueNumber) {
|
130
|
-
return __awaiter(this, void 0, void 0, function* () {
|
131
|
-
const issue = yield this.getIssue(issueNumber);
|
132
|
-
const issueObject = { title: issue.title };
|
133
|
-
issueObject.name = this.getIssueName(issue.title);
|
134
|
-
if (issue.linkedBranches.nodes.length > 0) {
|
135
|
-
issueObject.branch = issue.linkedBranches.nodes[0].ref.name;
|
136
|
-
}
|
137
|
-
if (issue.projectItems.nodes.length > 0) {
|
138
|
-
issueObject.state = issue.projectItems.nodes[0].fieldValueByName.name;
|
139
|
-
}
|
140
|
-
if (issue.labels.nodes.length > 0) {
|
141
|
-
issueObject.labels = [];
|
142
|
-
for (const node of issue.labels.nodes) {
|
143
|
-
issueObject.labels.push(node.name);
|
144
|
-
}
|
145
|
-
}
|
146
|
-
return issueObject;
|
147
|
-
});
|
148
|
-
}
|
149
119
|
getIssue(issueNumber) {
|
150
120
|
return __awaiter(this, void 0, void 0, function* () {
|
151
121
|
const query = `
|
@@ -191,7 +161,7 @@ export class GitHubApi {
|
|
191
161
|
}
|
192
162
|
}
|
193
163
|
`;
|
194
|
-
const { repository } = yield this.graphqlAuth(query, Object.assign({ issueNumber }, this.repoVar));
|
164
|
+
const { repository } = yield this.graphqlAuth(query, Object.assign({ issueNumber: Number.parseInt(issueNumber) }, this.repoVar));
|
195
165
|
return repository.issue;
|
196
166
|
});
|
197
167
|
}
|
@@ -4,6 +4,13 @@ export declare class GitHubProjectApi extends GitHubApi implements IProjectApi {
|
|
4
4
|
constructor(token: string, owner: string, repo: string, projectNumber: number);
|
5
5
|
getColumnValueMap(): Promise<Record<string, string>>;
|
6
6
|
createIssue(title: string, state?: string, label?: string, milestone?: string, body?: string): Promise<number>;
|
7
|
-
|
8
|
-
|
7
|
+
getIssueState(issueNumber: string): Promise<string>;
|
8
|
+
getIssueName(title: string): string;
|
9
|
+
getIssueObject(issueNumber: string): Promise<IIssueObject>;
|
10
|
+
getIssues(): Promise<{
|
11
|
+
id: string;
|
12
|
+
title: string;
|
13
|
+
}[]>;
|
14
|
+
moveIssue(issueNumber: string, state: string): Promise<boolean>;
|
15
|
+
assignIssueToMe(issueNumber: string): Promise<boolean>;
|
9
16
|
}
|
@@ -109,15 +109,59 @@ export class GitHubProjectApi extends GitHubApi {
|
|
109
109
|
clientMutationId
|
110
110
|
}
|
111
111
|
}`;
|
112
|
-
|
113
|
-
const { updateProjectV2ItemFieldValue } = yield this.graphqlAuth(mutationColumn, { projectId, itemId, fieldId, columnValue });
|
114
|
-
if (!updateProjectV2ItemFieldValue.clientMutationId) {
|
115
|
-
return 0;
|
116
|
-
}
|
112
|
+
yield this.graphqlAuth(mutationColumn, { projectId, itemId, fieldId, columnValue });
|
117
113
|
}
|
118
114
|
return issue.number;
|
119
115
|
});
|
120
116
|
}
|
117
|
+
getIssueState(issueNumber) {
|
118
|
+
var _a, _b, _c;
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
120
|
+
const issue = yield this.getIssue(issueNumber);
|
121
|
+
return (_c = (_b = (_a = issue.projectItems) === null || _a === void 0 ? void 0 : _a.nodes[0]) === null || _b === void 0 ? void 0 : _b.fieldValueByName) === null || _c === void 0 ? void 0 : _c.name;
|
122
|
+
});
|
123
|
+
}
|
124
|
+
getIssueName(title) {
|
125
|
+
return title.toLowerCase().replaceAll(' ', '-');
|
126
|
+
}
|
127
|
+
getIssueObject(issueNumber) {
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
129
|
+
const issue = yield this.getIssue(issueNumber);
|
130
|
+
const issueObject = { title: issue.title };
|
131
|
+
issueObject.name = this.getIssueName(issue.title);
|
132
|
+
if (issue.linkedBranches.nodes.length > 0) {
|
133
|
+
issueObject.branch = issue.linkedBranches.nodes[0].ref.name;
|
134
|
+
}
|
135
|
+
if (issue.projectItems.nodes.length > 0) {
|
136
|
+
issueObject.state = issue.projectItems.nodes[0].fieldValueByName.name;
|
137
|
+
}
|
138
|
+
if (issue.labels.nodes.length > 0) {
|
139
|
+
issueObject.labels = [];
|
140
|
+
for (const node of issue.labels.nodes) {
|
141
|
+
issueObject.labels.push(node.name);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
return issueObject;
|
145
|
+
});
|
146
|
+
}
|
147
|
+
getIssues() {
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
149
|
+
const query = `
|
150
|
+
query getIssue($owner:String!, $repo: String!) {
|
151
|
+
repository(owner: $owner, name: $repo) {
|
152
|
+
issues(last: 10) {
|
153
|
+
nodes {
|
154
|
+
title
|
155
|
+
id
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
`;
|
161
|
+
const { repository } = yield this.graphqlAuth(query, this.repoVar);
|
162
|
+
return repository.issues.nodes;
|
163
|
+
});
|
164
|
+
}
|
121
165
|
moveIssue(issueNumber, state) {
|
122
166
|
return __awaiter(this, void 0, void 0, function* () {
|
123
167
|
const issue = yield this.getIssue(issueNumber);
|
@@ -8,10 +8,11 @@ export declare class GitLabApi implements IGitApi, IProjectApi {
|
|
8
8
|
projectNumber: number | undefined;
|
9
9
|
graphqlAuth: GraphQLClient;
|
10
10
|
constructor(token: string, owner: string, repo: string, projectNumber?: number);
|
11
|
-
getIssueObject(issueNumber:
|
11
|
+
getIssueObject(issueNumber: string): Promise<{}>;
|
12
|
+
getIssues(): Promise<never[]>;
|
12
13
|
createIssue(title: string, state?: string, label?: string, milestone?: string, body?: string): Promise<number>;
|
13
|
-
moveIssue(issueNumber:
|
14
|
-
assignIssueToMe(issueNumber:
|
14
|
+
moveIssue(issueNumber: string, state: string): Promise<boolean>;
|
15
|
+
assignIssueToMe(issueNumber: string): Promise<boolean>;
|
15
16
|
getUser(): Promise<{
|
16
17
|
login: string;
|
17
18
|
id: number;
|
@@ -19,5 +20,5 @@ export declare class GitLabApi implements IGitApi, IProjectApi {
|
|
19
20
|
graphqlQuery(query: string, vars: Record<string, AnyValue>): Promise<unknown>;
|
20
21
|
getRepository(): Promise<void>;
|
21
22
|
createPullRequest(branchName: string, title: string, body: string): Promise<boolean>;
|
22
|
-
assignBranchToIssue(issueNumber:
|
23
|
+
assignBranchToIssue(issueNumber: string, branchName: string, commitSha: string): Promise<boolean>;
|
23
24
|
}
|
@@ -22,6 +22,11 @@ export class GitLabApi {
|
|
22
22
|
return {};
|
23
23
|
});
|
24
24
|
}
|
25
|
+
getIssues() {
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
27
|
+
return [];
|
28
|
+
});
|
29
|
+
}
|
25
30
|
createIssue(title, state, label, milestone, body) {
|
26
31
|
return __awaiter(this, void 0, void 0, function* () {
|
27
32
|
console.log(title, label, milestone, body);
|
@@ -95,7 +100,7 @@ export class GitLabApi {
|
|
95
100
|
const query = `mutation($branchName: ID!, $issueNumber: Int!, $commitSha: String!) {
|
96
101
|
|
97
102
|
}`;
|
98
|
-
yield this.graphqlQuery(query, { branchName, issueNumber, commitSha });
|
103
|
+
yield this.graphqlQuery(query, { branchName, issueNumber: Number.parseInt(issueNumber), commitSha });
|
99
104
|
return true;
|
100
105
|
});
|
101
106
|
}
|
@@ -447,6 +447,18 @@ export const taskFunctions = {
|
|
447
447
|
return true;
|
448
448
|
});
|
449
449
|
},
|
450
|
+
listIssues() {
|
451
|
+
return __awaiter(this, void 0, void 0, function* () {
|
452
|
+
if (!context.projectApi) {
|
453
|
+
return false;
|
454
|
+
}
|
455
|
+
const result = yield context.projectApi.getIssues();
|
456
|
+
for (const issue of result) {
|
457
|
+
console.log(issue.title);
|
458
|
+
}
|
459
|
+
return true;
|
460
|
+
});
|
461
|
+
},
|
450
462
|
checkIssueType(issueNumber) {
|
451
463
|
var _a;
|
452
464
|
return __awaiter(this, void 0, void 0, function* () {
|
package/lib/helpers/tasks.js
CHANGED
@@ -118,15 +118,19 @@ export function runTask(task, taskContext, tabs = '') {
|
|
118
118
|
}
|
119
119
|
yield context.askForArguments(task.arguments);
|
120
120
|
}
|
121
|
-
|
121
|
+
if (task.verbose) {
|
122
|
+
logStep(`[INICIO] ${task.name}`, tabs);
|
123
|
+
}
|
122
124
|
for (const step of task.steps) {
|
123
125
|
if (isCriteriaMet(step.criteria)) {
|
124
|
-
if (!(yield executeStep(step, tabs + '\t'))) {
|
126
|
+
if (!(yield executeStep(step, tabs + '\t', task.verbose))) {
|
125
127
|
return false;
|
126
128
|
}
|
127
129
|
}
|
128
130
|
}
|
129
|
-
|
131
|
+
if (task.verbose) {
|
132
|
+
logStep(`[FIN] ${task.name}`, tabs);
|
133
|
+
}
|
130
134
|
return true;
|
131
135
|
});
|
132
136
|
}
|
@@ -202,10 +206,10 @@ function askForContinueOrRetry() {
|
|
202
206
|
function getStepError(step, stepName) {
|
203
207
|
return step.errorMessage ? context.merge(step.errorMessage) : stepName ? `Fallo el step ${stepName}` : '';
|
204
208
|
}
|
205
|
-
function executeStep(step, tabs) {
|
209
|
+
function executeStep(step, tabs, verbose = false) {
|
206
210
|
return __awaiter(this, void 0, void 0, function* () {
|
207
211
|
const stepName = step.name ? context.merge(step.name) : undefined;
|
208
|
-
if (stepName) {
|
212
|
+
if (verbose && stepName) {
|
209
213
|
logStep(`[INICIO] ${stepName}`, tabs);
|
210
214
|
}
|
211
215
|
let retry = false;
|
@@ -235,7 +239,7 @@ function executeStep(step, tabs) {
|
|
235
239
|
success = result == 'continue';
|
236
240
|
}
|
237
241
|
} while (!success && retry);
|
238
|
-
if (stepName) {
|
242
|
+
if (verbose && stepName) {
|
239
243
|
logStep(`[FIN] ${stepName}`, tabs);
|
240
244
|
}
|
241
245
|
if (!success) {
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "autoforce",
|
3
3
|
"homepage": "https://sebastianclaros.github.io/autoforce",
|
4
4
|
"private": false,
|
5
|
-
"version": "0.1.
|
5
|
+
"version": "0.1.9",
|
6
6
|
"keywords": [
|
7
7
|
"Salesforce",
|
8
8
|
"Automation",
|
@@ -54,6 +54,7 @@
|
|
54
54
|
"@types/graphql": "^14.5.0",
|
55
55
|
"@types/jsforce": "^1.11.5",
|
56
56
|
"@types/prompts": "^2.4.9",
|
57
|
+
"autoforce": "file:./autoforce.tgz",
|
57
58
|
"graphql": "^16.9.0",
|
58
59
|
"graphql-request": "^7.1.0",
|
59
60
|
"gray-matter": "^4.0.3",
|