autoforce 0.1.10 → 0.1.12
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 +49 -3
- package/README.md +0 -13
- package/commands/modelA/tasks/list.json +1 -1
- package/commands/modelC/new/issue.json +6 -23
- package/commands/modelC/tasks/list.json +3 -1
- package/commands/modelC/tasks/publish.json +2 -1
- package/lib/auto.js +3 -3
- package/lib/helpers/context.d.ts +16 -2
- package/lib/helpers/context.js +103 -38
- package/lib/helpers/github-graphql.d.ts +3 -34
- package/lib/helpers/github-graphql.js +51 -51
- package/lib/helpers/github-project-graphql.d.ts +37 -5
- package/lib/helpers/github-project-graphql.js +83 -17
- package/lib/helpers/gitlab-graphql.d.ts +4 -2
- package/lib/helpers/gitlab-graphql.js +12 -2
- package/lib/helpers/openai.js +1 -1
- package/lib/helpers/taskFunctions.js +114 -36
- package/lib/helpers/tasks.js +12 -8
- package/lib/helpers/template.d.ts +3 -2
- package/lib/helpers/template.js +23 -3
- package/lib/helpers/util.d.ts +5 -3
- package/lib/helpers/util.js +97 -27
- package/package.json +1 -1
- package/templates/modelB/changelog.md +8 -4
- package/templates/modelB/openIssues.bash +4 -0
- package/templates/modelB/viewIssue.bash +8 -0
- package/templates/models.json +2 -3
- package/templates/modelB/openIssues.md +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,4 +1,50 @@
|
|
1
|
+
# Versiones
|
1
2
|
|
2
|
-
Version 0.1.
|
3
|
-
|
4
|
-
|
3
|
+
## Version 0.1.12
|
4
|
+
- Fecha: 28/11/2024
|
5
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.10)
|
6
|
+
- Cambios:
|
7
|
+
|
8
|
+
* [Publish] ponga en Changelog todos los issues Closed del milestone asociado. Y los mueva al final de todo a la Columna "Published"
|
9
|
+
- https://github.com/sebastianclaros/autoforce/issues/11
|
10
|
+
* [List] Poner Filtros: Abiertos Mios, Por Label, Por Milestone
|
11
|
+
- https://github.com/sebastianclaros/autoforce/issues/17
|
12
|
+
* [List] Guardar en autoforce el list default list template y default list Filter
|
13
|
+
- https://github.com/sebastianclaros/autoforce/issues/18
|
14
|
+
* [new Issue] Agregar Milestone
|
15
|
+
- https://github.com/sebastianclaros/autoforce/issues/19
|
16
|
+
* [config] dividir config general en config por comandos
|
17
|
+
- https://github.com/sebastianclaros/autoforce/issues/27
|
18
|
+
* [list] que tome de los argumentos valores.
|
19
|
+
- https://github.com/sebastianclaros/autoforce/issues/28
|
20
|
+
* [list] que reciba argumentos en taskFunctions y que tome orden de precedencia parametros de funcion, argumentos de comando y por ultimo autoforce.json
|
21
|
+
- https://github.com/sebastianclaros/autoforce/issues/29
|
22
|
+
* [new] que el milestone sea opcional
|
23
|
+
- https://github.com/sebastianclaros/autoforce/issues/30
|
24
|
+
## Version 0.1.11
|
25
|
+
- Fecha: 29/11/2024
|
26
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.11)
|
27
|
+
- Cambios:
|
28
|
+
* [comando config lea del autoforce.json](https://github.com/sebastianclaros/autoforce/issues/4)
|
29
|
+
|
30
|
+
## Version 0.1.10
|
31
|
+
- Fecha: 28/11/2024
|
32
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.10)
|
33
|
+
- Cambios:
|
34
|
+
* [publish deberia pedir la version, y asignarla en el autoforce version](https://github.com/sebastianclaros/autoforce/issues/12)
|
35
|
+
* [Models en config que lea un json descriptivo](https://github.com/sebastianclaros/autoforce/issues/9)
|
36
|
+
* [comando list](https://github.com/sebastianclaros/autoforce/issues/1)
|
37
|
+
* [Guard para verificar existencia de Variables de Entorno por ejemplo NPM_TOKEN con un $NPM_TOKEN ?
|
38
|
+
(https://github.com/sebastianclaros/autoforce/issues/10)
|
39
|
+
]
|
40
|
+
* [New issue con Body optativo](https://github.com/sebastianclaros/autoforce/issues/3)
|
41
|
+
* [Parametros adicionales tipo npx autoforce start XXX](https://github.com/sebastianclaros/autoforce/issues/5)
|
42
|
+
* [Modelos en los Templates](https://github.com/sebastianclaros/autoforce/issues/8)
|
43
|
+
|
44
|
+
|
45
|
+
## Version 0.1.9
|
46
|
+
|
47
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.9)
|
48
|
+
- Cambios:
|
49
|
+
* Comando de new issue para crear un issue nuevo en el backlog
|
50
|
+
* Comando de list para ver issues en backlog o ver los detalles de uno
|
package/README.md
CHANGED
@@ -60,19 +60,6 @@ En este repo las tareas buscan automatizar o integrar el siguiente tipo gestione
|
|
60
60
|
|
61
61
|
|
62
62
|
|
63
|
-
## Instalación
|
64
|
-
|
65
|
-
```
|
66
|
-
yarn add -D autoforce
|
67
|
-
```
|
68
|
-
|
69
|
-
Chequear instalacion
|
70
|
-
|
71
|
-
```
|
72
|
-
npx autoforce version
|
73
|
-
```
|
74
|
-
|
75
|
-
|
76
63
|
## Usos
|
77
64
|
Una vez instalado se puede crear scripts a medida o bien ejecutar
|
78
65
|
|
@@ -5,28 +5,11 @@
|
|
5
5
|
"title": { "required": true },
|
6
6
|
"label": {
|
7
7
|
"type": "select",
|
8
|
-
"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
},
|
14
|
-
{
|
15
|
-
"title": "Bugfix",
|
16
|
-
"value": "bug",
|
17
|
-
"description": "Correxion de codigo, no hay incremento funcional"
|
18
|
-
},
|
19
|
-
{
|
20
|
-
"title": "Documentation",
|
21
|
-
"value": "documentation",
|
22
|
-
"description": "Cambios en la documentacion"
|
23
|
-
},
|
24
|
-
{
|
25
|
-
"title": "Feature",
|
26
|
-
"value": "feature",
|
27
|
-
"description": "Nuevas funcionalidades"
|
28
|
-
}
|
29
|
-
]
|
8
|
+
"values": "labels"
|
9
|
+
},
|
10
|
+
"milestone": {
|
11
|
+
"type": "select",
|
12
|
+
"values": "milestones"
|
30
13
|
},
|
31
14
|
"body": { "required": false }
|
32
15
|
},
|
@@ -35,7 +18,7 @@
|
|
35
18
|
{
|
36
19
|
"name": "Crear un issue nuevo",
|
37
20
|
"function": "createIssue",
|
38
|
-
"arguments": ["${title}", "${label}", "${body}"]
|
21
|
+
"arguments": ["${title}", "${label}", "${body}", "${milestone}"]
|
39
22
|
}
|
40
23
|
]
|
41
24
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "list",
|
3
3
|
"guards": ["isGitApi"],
|
4
|
+
"arguments": ["filter", "template"],
|
4
5
|
"description": "Comando para ver en detalle el requerimiento",
|
5
6
|
"steps": [
|
6
7
|
{
|
7
8
|
"name": "Ver los issues del Backlog",
|
8
|
-
"function": "listIssues"
|
9
|
+
"function": "listIssues",
|
10
|
+
"arguments": ["${filter}", "${template}"]
|
9
11
|
}
|
10
12
|
]
|
11
13
|
}
|
@@ -8,6 +8,7 @@
|
|
8
8
|
"steps": [
|
9
9
|
{ "name": "Paquetiza", "subtask": "pack" },
|
10
10
|
{ "name": "Actualiza la version", "function": "storeConfig", "arguments": ["version", "${newVersion}"] },
|
11
|
-
{ "name": "Publica", "command": "yarn publish ", "arguments": {"--new-version": "${newVersion}"} }
|
11
|
+
{ "name": "Publica", "command": "yarn publish ", "arguments": {"--new-version": "${newVersion}"} },
|
12
|
+
{ "name": "Salida para el Changelog.md", "task": "list", "arguments": {"filter": "milestone", "template": "changelog", "milestone": "${newVersion}"} }
|
12
13
|
]
|
13
14
|
}
|
package/lib/auto.js
CHANGED
@@ -39,10 +39,10 @@ export default function main() {
|
|
39
39
|
const taskName = yield askForTaskName(config.taskName, tasks);
|
40
40
|
if (taskName) {
|
41
41
|
const task = tasks[taskName];
|
42
|
-
|
42
|
+
context.options = config.arguments && task.arguments ? Object.assign(Object.assign({}, config.options), createObject(task.arguments, config.arguments)) : config.options;
|
43
43
|
// Valida los json de task y subtask
|
44
44
|
if (validateTask(task)) {
|
45
|
-
yield taskCommand[config.command](task, options);
|
45
|
+
yield taskCommand[config.command](task, context.options);
|
46
46
|
}
|
47
47
|
else {
|
48
48
|
logError('Verifique que los json de task y subtask esten validos');
|
@@ -50,7 +50,7 @@ export default function main() {
|
|
50
50
|
}
|
51
51
|
}
|
52
52
|
else {
|
53
|
-
yield proxyCommand[config.command]();
|
53
|
+
yield proxyCommand[config.command](config.taskName, config.options);
|
54
54
|
}
|
55
55
|
}
|
56
56
|
catch (error) {
|
package/lib/helpers/context.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import prompts from "prompts";
|
1
2
|
import type { PromptChoices } from "../types/helpers/context.js";
|
2
3
|
import type { IProcessHeader, Processes, AnyValue, IProcessInfo, ObjectRecord, IObjectRecord } from "../types/auto.js";
|
3
4
|
import type { TaskArguments, TaskArgument, StepArguments } from "../types/helpers/tasks.js";
|
@@ -6,6 +7,11 @@ export declare enum GitServices {
|
|
6
7
|
GitLab = "gitlab",
|
7
8
|
None = "none"
|
8
9
|
}
|
10
|
+
export declare enum ListFilters {
|
11
|
+
Mios = "mios",
|
12
|
+
PorMilestone = "milestone",
|
13
|
+
PorLabel = "label"
|
14
|
+
}
|
9
15
|
export declare enum ProjectServices {
|
10
16
|
GitHub = "github",
|
11
17
|
GitLab = "gitlab",
|
@@ -20,6 +26,7 @@ declare class Context implements IObjectRecord {
|
|
20
26
|
isGitApi: boolean;
|
21
27
|
gitApi: IGitApi | undefined;
|
22
28
|
version: string | undefined;
|
29
|
+
options: Record<string, AnyValue>;
|
23
30
|
projectServices: ProjectServices;
|
24
31
|
isProjectApi: boolean;
|
25
32
|
projectApi: IProjectApi | undefined;
|
@@ -49,10 +56,17 @@ declare class Context implements IObjectRecord {
|
|
49
56
|
repositoryRepo: string | undefined;
|
50
57
|
projectId: string | undefined;
|
51
58
|
backlogColumn: string;
|
59
|
+
listFilter: ListFilters;
|
60
|
+
listTemplate: string;
|
61
|
+
constructor();
|
62
|
+
labels(): Promise<prompts.Choice[]>;
|
63
|
+
listFilters(): prompts.Choice[];
|
64
|
+
milestoneNumbers(): Promise<prompts.Choice[]>;
|
65
|
+
milestones(): Promise<prompts.Choice[]>;
|
52
66
|
loadProjectApi(): void;
|
53
67
|
loadGitApi(): void;
|
54
68
|
loadPackage(): void;
|
55
|
-
loadConfig():
|
69
|
+
loadConfig(): Promise<boolean>;
|
56
70
|
init(): void;
|
57
71
|
get targetOrg(): string;
|
58
72
|
get existBranchScratch(): boolean;
|
@@ -84,7 +98,7 @@ declare class Context implements IObjectRecord {
|
|
84
98
|
get process(): string | undefined;
|
85
99
|
askForprocess(): Promise<any>;
|
86
100
|
askFornewIssueType(): Promise<any>;
|
87
|
-
convertToArrayOfInputs(inputs: TaskArguments): TaskArgument[]
|
101
|
+
convertToArrayOfInputs(inputs: TaskArguments): Promise<TaskArgument[]>;
|
88
102
|
askForExit(): Promise<void>;
|
89
103
|
mergeArgs(args: StepArguments): StepArguments;
|
90
104
|
askForArguments(inputs: TaskArguments): Promise<void>;
|
package/lib/helpers/context.js
CHANGED
@@ -21,14 +21,20 @@ export var GitServices;
|
|
21
21
|
GitServices["GitHub"] = "github";
|
22
22
|
GitServices["GitLab"] = "gitlab";
|
23
23
|
GitServices["None"] = "none";
|
24
|
-
})(GitServices
|
24
|
+
})(GitServices || (GitServices = {}));
|
25
|
+
export var ListFilters;
|
26
|
+
(function (ListFilters) {
|
27
|
+
ListFilters["Mios"] = "mios";
|
28
|
+
ListFilters["PorMilestone"] = "milestone";
|
29
|
+
ListFilters["PorLabel"] = "label";
|
30
|
+
})(ListFilters || (ListFilters = {}));
|
25
31
|
export var ProjectServices;
|
26
32
|
(function (ProjectServices) {
|
27
33
|
ProjectServices["GitHub"] = "github";
|
28
34
|
ProjectServices["GitLab"] = "gitlab";
|
29
35
|
ProjectServices["Jira"] = "Jira";
|
30
36
|
ProjectServices["None"] = "none";
|
31
|
-
})(ProjectServices
|
37
|
+
})(ProjectServices || (ProjectServices = {}));
|
32
38
|
const filterProcesses = (fullPath) => fullPath.endsWith(".md"); // && !fullPath.endsWith("intro.md")
|
33
39
|
const ISSUES_TYPES = [{ value: 'feature', title: 'feature' }, { value: 'bug', title: 'bug' }, { value: 'documentation', title: 'documentation' }, { value: 'automation', title: 'automation' }];
|
34
40
|
class Context {
|
@@ -37,6 +43,7 @@ class Context {
|
|
37
43
|
this.modelTemplates = 'modelA'; // Default Model de templates
|
38
44
|
this.gitServices = GitServices.None;
|
39
45
|
this.isGitApi = false;
|
46
|
+
this.options = {};
|
40
47
|
this.projectServices = ProjectServices.None;
|
41
48
|
this.isProjectApi = false;
|
42
49
|
this.sfInstalled = true;
|
@@ -47,6 +54,48 @@ class Context {
|
|
47
54
|
// Ultima salida del shell
|
48
55
|
this.salida = '';
|
49
56
|
this.backlogColumn = 'Todo';
|
57
|
+
//Templates especiales
|
58
|
+
this.listFilter = ListFilters.Mios;
|
59
|
+
this.listTemplate = 'openIssues';
|
60
|
+
this.loadConfig();
|
61
|
+
this.loadPackage();
|
62
|
+
}
|
63
|
+
labels() {
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
65
|
+
var _a;
|
66
|
+
const choices = [{ value: '', title: 'Ninguno' }];
|
67
|
+
const labels = yield ((_a = this.gitApi) === null || _a === void 0 ? void 0 : _a.getLabels());
|
68
|
+
if (labels) {
|
69
|
+
labels.forEach(label => choices.push({ value: label.name, title: label.name }));
|
70
|
+
}
|
71
|
+
return choices;
|
72
|
+
});
|
73
|
+
}
|
74
|
+
listFilters() {
|
75
|
+
const filters = [{ title: 'Solo mios abiertos', value: ListFilters.Mios, description: 'Busca los issues donde este asignado y esten en state Open' }, { title: 'Por Milestone', value: ListFilters.PorMilestone, description: 'Busca los issues de un deterinado milestone' }, { title: 'Por Label', value: ListFilters.PorLabel, description: 'Busca los issues de un deterinado label' }];
|
76
|
+
return filters;
|
77
|
+
}
|
78
|
+
milestoneNumbers() {
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
80
|
+
var _a;
|
81
|
+
const choices = [{ value: '', title: 'Ninguno' }];
|
82
|
+
const milestones = yield ((_a = this.gitApi) === null || _a === void 0 ? void 0 : _a.getMilestones());
|
83
|
+
if (milestones) {
|
84
|
+
milestones.forEach(milestone => choices.push({ value: milestone.number, title: milestone.title }));
|
85
|
+
}
|
86
|
+
return choices;
|
87
|
+
});
|
88
|
+
}
|
89
|
+
milestones() {
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
91
|
+
var _a;
|
92
|
+
const choices = [{ value: '', title: 'Ninguno' }];
|
93
|
+
const milestones = yield ((_a = this.gitApi) === null || _a === void 0 ? void 0 : _a.getMilestones());
|
94
|
+
if (milestones) {
|
95
|
+
milestones.forEach(milestone => choices.push({ value: milestone.id, title: milestone.title }));
|
96
|
+
}
|
97
|
+
return choices;
|
98
|
+
});
|
50
99
|
}
|
51
100
|
loadProjectApi() {
|
52
101
|
if (!this.isProjectApi) {
|
@@ -119,28 +168,38 @@ class Context {
|
|
119
168
|
this.repositoryRepo = data.repositoryRepo;
|
120
169
|
}
|
121
170
|
loadConfig() {
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
172
|
+
if (!fs.existsSync(CONFIG_FILE)) {
|
173
|
+
logWarning('Bienvenido! La herramienta Autoforce necesita un primer paso de configuracion antes de usarla.');
|
174
|
+
logWarning('- Podes usar el asistente ejecutando npx autoforce config');
|
175
|
+
logWarning('- Podes hacerlo manualmente leyendo la documentacion y creando .autoforce.json manualmente en el root del proyecto (https://sebastianclaros.github.io/autoforce/docs/configuracion)');
|
176
|
+
const answer = yield prompts([
|
177
|
+
{
|
178
|
+
type: "confirm",
|
179
|
+
name: "asistente",
|
180
|
+
message: "Queres ejecutar el asistente ahora?"
|
181
|
+
}
|
182
|
+
]);
|
183
|
+
if (answer.asistente) {
|
184
|
+
yield createConfigurationFile();
|
185
|
+
return true;
|
186
|
+
}
|
187
|
+
return false;
|
134
188
|
}
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
189
|
+
const content = fs.readFileSync(CONFIG_FILE, "utf8");
|
190
|
+
try {
|
191
|
+
const config = JSON.parse(content);
|
192
|
+
for (const key in config) {
|
193
|
+
this.set(key, config[key]);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
catch (_a) {
|
197
|
+
throw new Error(`Verifique que el ${CONFIG_FILE} sea json valido`);
|
198
|
+
}
|
199
|
+
return true;
|
200
|
+
});
|
139
201
|
}
|
140
202
|
init() {
|
141
|
-
// Busca variables de entorno
|
142
|
-
this.loadConfig();
|
143
|
-
this.loadPackage();
|
144
203
|
this.loadProjectApi();
|
145
204
|
this.loadGitApi();
|
146
205
|
//
|
@@ -357,7 +416,7 @@ class Context {
|
|
357
416
|
askForprocess() {
|
358
417
|
return __awaiter(this, void 0, void 0, function* () {
|
359
418
|
if (this.projectApi && !this.issueTitle && this.issueNumber) {
|
360
|
-
const issue = yield this.projectApi.
|
419
|
+
const issue = yield this.projectApi.getIssue(this.issueNumber);
|
361
420
|
this.issueTitle = issue.title;
|
362
421
|
}
|
363
422
|
if (this.issueTitle) {
|
@@ -393,22 +452,29 @@ class Context {
|
|
393
452
|
});
|
394
453
|
}
|
395
454
|
convertToArrayOfInputs(inputs) {
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
455
|
+
return __awaiter(this, void 0, void 0, function* () {
|
456
|
+
let inputsArray = [];
|
457
|
+
if (Array.isArray(inputs)) {
|
458
|
+
// Si viene los args como ['name1', 'names] lo convierte a [{name: 'name1'}, {name: 'name2'}]
|
459
|
+
inputsArray = inputs.map(input => { return { name: input, type: 'text', message: `Por favor ingrese ${input}?` }; });
|
460
|
+
}
|
461
|
+
else {
|
462
|
+
// Si viene args como objeto { name1: {...}, name2: {...}} lo convierte a [{name: name1...}, {name: name2...}]
|
463
|
+
for (const key in inputs) {
|
464
|
+
if (typeof inputs[key].default == 'string') {
|
465
|
+
inputs[key].initial = this.merge(inputs[key].default);
|
466
|
+
}
|
467
|
+
if (typeof inputs[key].values == 'string' && typeof this[inputs[key].values] == 'function') {
|
468
|
+
const choices = yield this[inputs[key].values]();
|
469
|
+
if (Array.isArray(choices)) {
|
470
|
+
inputs[key].choices = choices;
|
471
|
+
}
|
472
|
+
}
|
473
|
+
inputsArray.push(Object.assign({ name: key, type: 'text', message: `Por favor ingrese ${key}?` }, inputs[key]));
|
407
474
|
}
|
408
|
-
inputsArray.push(Object.assign({ name: key, type: 'text', initial, message: `Por favor ingrese ${key}?` }, inputs[key]));
|
409
475
|
}
|
410
|
-
|
411
|
-
|
476
|
+
return inputsArray;
|
477
|
+
});
|
412
478
|
}
|
413
479
|
askForExit() {
|
414
480
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -447,7 +513,7 @@ class Context {
|
|
447
513
|
askForArguments(inputs) {
|
448
514
|
return __awaiter(this, void 0, void 0, function* () {
|
449
515
|
// unifica los dos tipos de inputs (array y objeto) en un array de inputs
|
450
|
-
const inputsArray = this.convertToArrayOfInputs(inputs);
|
516
|
+
const inputsArray = yield this.convertToArrayOfInputs(inputs);
|
451
517
|
for (const input of inputsArray) {
|
452
518
|
const hasValue = yield this.get(input.name);
|
453
519
|
if (!hasValue) {
|
@@ -518,7 +584,6 @@ class Context {
|
|
518
584
|
}
|
519
585
|
}
|
520
586
|
const context = new Context();
|
521
|
-
context.loadConfig();
|
522
587
|
let initialized = false;
|
523
588
|
export function initializeContext() {
|
524
589
|
try {
|
@@ -10,11 +10,13 @@ export declare class GitHubApi implements IGitApi {
|
|
10
10
|
login: string;
|
11
11
|
id: number;
|
12
12
|
}>;
|
13
|
+
getLabels(): Promise<ILabel[]>;
|
14
|
+
getMilestones(): Promise<IMilestone[]>;
|
13
15
|
getRepository(label?: string): Promise<{
|
14
16
|
id: string;
|
15
17
|
label?: {
|
16
18
|
id: string;
|
17
|
-
}
|
19
|
+
};
|
18
20
|
projectV2: {
|
19
21
|
id: string;
|
20
22
|
field: {
|
@@ -29,39 +31,6 @@ export declare class GitHubApi implements IGitApi {
|
|
29
31
|
}>;
|
30
32
|
createPullRequest(branchName: string, title: string, body: string): Promise<boolean>;
|
31
33
|
assignBranchToIssue(issueNumber: string, branchName: string, commitSha: string): Promise<boolean>;
|
32
|
-
getIssue(issueNumber: string): Promise<{
|
33
|
-
id: string;
|
34
|
-
title: string;
|
35
|
-
labels: {
|
36
|
-
nodes: {
|
37
|
-
name: string;
|
38
|
-
color: string;
|
39
|
-
}[];
|
40
|
-
};
|
41
|
-
projectItems: {
|
42
|
-
nodes: {
|
43
|
-
id: string;
|
44
|
-
project: {
|
45
|
-
id: string;
|
46
|
-
};
|
47
|
-
fieldValueByName: {
|
48
|
-
name: string;
|
49
|
-
id: string;
|
50
|
-
field: {
|
51
|
-
id: string;
|
52
|
-
};
|
53
|
-
};
|
54
|
-
}[];
|
55
|
-
};
|
56
|
-
linkedBranches: {
|
57
|
-
nodes: {
|
58
|
-
ref: {
|
59
|
-
id: string;
|
60
|
-
name: string;
|
61
|
-
};
|
62
|
-
}[];
|
63
|
-
};
|
64
|
-
}>;
|
65
34
|
getCommit(commitSha: string): Promise<{
|
66
35
|
id: string;
|
67
36
|
oid: string;
|
@@ -31,6 +31,45 @@ export class GitHubApi {
|
|
31
31
|
return viewer;
|
32
32
|
});
|
33
33
|
}
|
34
|
+
getLabels() {
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
36
|
+
const query = `
|
37
|
+
query getRepo($owner:String!, $repo: String! ) {
|
38
|
+
repository(owner: $owner, name: $repo) {
|
39
|
+
labels(last: 10, orderBy: { field: CREATED_AT, direction: DESC}) {
|
40
|
+
nodes{
|
41
|
+
id
|
42
|
+
name
|
43
|
+
color
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
`;
|
49
|
+
const { repository } = yield this.graphqlAuth(query, this.repoVar);
|
50
|
+
return repository.labels.nodes;
|
51
|
+
});
|
52
|
+
}
|
53
|
+
getMilestones() {
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
55
|
+
const query = `
|
56
|
+
query getRepo($owner:String!, $repo: String! ) {
|
57
|
+
repository(owner: $owner, name: $repo) {
|
58
|
+
milestones(last: 10, states: OPEN, orderBy: { field: CREATED_AT, direction: DESC} ) {
|
59
|
+
nodes{
|
60
|
+
id
|
61
|
+
number
|
62
|
+
title
|
63
|
+
dueOn
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
`;
|
69
|
+
const { repository } = yield this.graphqlAuth(query, this.repoVar);
|
70
|
+
return repository.milestones.nodes;
|
71
|
+
});
|
72
|
+
}
|
34
73
|
getRepository(label) {
|
35
74
|
return __awaiter(this, void 0, void 0, function* () {
|
36
75
|
const query = `
|
@@ -95,9 +134,19 @@ export class GitHubApi {
|
|
95
134
|
});
|
96
135
|
}
|
97
136
|
assignBranchToIssue(issueNumber, branchName, commitSha) {
|
98
|
-
var _a;
|
99
137
|
return __awaiter(this, void 0, void 0, function* () {
|
100
|
-
|
138
|
+
var _a;
|
139
|
+
const query = `
|
140
|
+
query getIssue($owner:String!, $repo: String!, $issueNumber: Int!) {
|
141
|
+
repository(owner: $owner, name: $repo) {
|
142
|
+
issue(number: $issueNumber) {
|
143
|
+
id
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
`;
|
148
|
+
const { repository } = yield this.graphqlAuth(query, Object.assign({ issueNumber: Number.parseInt(issueNumber) }, this.repoVar));
|
149
|
+
const issue = repository.issue;
|
101
150
|
const commit = yield this.getCommit(commitSha);
|
102
151
|
const mutation = `
|
103
152
|
mutation createLinkedBranch( $issueId: ID!, $oid: GitObjectID!, $branchName: String!) {
|
@@ -116,55 +165,6 @@ export class GitHubApi {
|
|
116
165
|
return ((_a = createLinkedBranch === null || createLinkedBranch === void 0 ? void 0 : createLinkedBranch.issue) === null || _a === void 0 ? void 0 : _a.id) ? true : false;
|
117
166
|
});
|
118
167
|
}
|
119
|
-
getIssue(issueNumber) {
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
121
|
-
const query = `
|
122
|
-
query getIssue($owner:String!, $repo: String!, $issueNumber: Int!) {
|
123
|
-
repository(owner: $owner, name: $repo) {
|
124
|
-
issue(number: $issueNumber) {
|
125
|
-
title
|
126
|
-
id
|
127
|
-
labels(first:3, orderBy: { field: CREATED_AT, direction: DESC}) {
|
128
|
-
nodes {
|
129
|
-
color
|
130
|
-
name
|
131
|
-
}
|
132
|
-
}
|
133
|
-
projectItems(last: 1) {
|
134
|
-
nodes{
|
135
|
-
id,
|
136
|
-
project {
|
137
|
-
id
|
138
|
-
}
|
139
|
-
fieldValueByName(name: "Status"){
|
140
|
-
... on ProjectV2ItemFieldSingleSelectValue {
|
141
|
-
name
|
142
|
-
id
|
143
|
-
field {
|
144
|
-
... on ProjectV2SingleSelectField {
|
145
|
-
id
|
146
|
-
}
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
linkedBranches(last:1){
|
153
|
-
nodes {
|
154
|
-
ref {
|
155
|
-
id
|
156
|
-
name
|
157
|
-
}
|
158
|
-
}
|
159
|
-
}
|
160
|
-
}
|
161
|
-
}
|
162
|
-
}
|
163
|
-
`;
|
164
|
-
const { repository } = yield this.graphqlAuth(query, Object.assign({ issueNumber: Number.parseInt(issueNumber) }, this.repoVar));
|
165
|
-
return repository.issue;
|
166
|
-
});
|
167
|
-
}
|
168
168
|
getCommit(commitSha) {
|
169
169
|
return __awaiter(this, void 0, void 0, function* () {
|
170
170
|
const query = `
|
@@ -3,15 +3,47 @@ export declare class GitHubProjectApi extends GitHubApi implements IProjectApi {
|
|
3
3
|
projectNumber: number;
|
4
4
|
constructor(token: string, owner: string, repo: string, projectNumber: number);
|
5
5
|
getColumnValueMap(): Promise<Record<string, string>>;
|
6
|
-
createIssue(title: string, state?: string, label?: string, body?: string,
|
6
|
+
createIssue(title: string, state?: string, label?: string, body?: string, milestoneId?: string): Promise<number>;
|
7
7
|
getIssueState(issueNumber: string): Promise<string>;
|
8
8
|
getIssueName(title: string): string;
|
9
|
-
|
10
|
-
|
9
|
+
_getIssue(issueNumber: string): Promise<{
|
10
|
+
number: number;
|
11
11
|
id: string;
|
12
|
+
body: string;
|
13
|
+
url: string;
|
12
14
|
title: string;
|
13
|
-
|
14
|
-
|
15
|
+
labels: {
|
16
|
+
nodes: {
|
17
|
+
name: string;
|
18
|
+
color: string;
|
19
|
+
}[];
|
20
|
+
};
|
21
|
+
projectItems: {
|
22
|
+
nodes: {
|
23
|
+
id: string;
|
24
|
+
project: {
|
25
|
+
id: string;
|
26
|
+
};
|
27
|
+
fieldValueByName: {
|
28
|
+
name: string;
|
29
|
+
id: string;
|
30
|
+
field: {
|
31
|
+
id: string;
|
32
|
+
};
|
33
|
+
};
|
34
|
+
}[];
|
35
|
+
};
|
36
|
+
linkedBranches: {
|
37
|
+
nodes: {
|
38
|
+
ref: {
|
39
|
+
id: string;
|
40
|
+
name: string;
|
41
|
+
};
|
42
|
+
}[];
|
43
|
+
};
|
44
|
+
}>;
|
45
|
+
getIssue(issueNumber: string): Promise<IIssueObject>;
|
46
|
+
getIssues(): Promise<{
|
15
47
|
id: string;
|
16
48
|
title: string;
|
17
49
|
}[]>;
|