autoforce 0.1.11 → 0.1.13
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 +28 -0
- package/README.md +20 -19
- 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 +14 -1
- package/lib/helpers/context.js +70 -16
- package/lib/helpers/github-graphql.d.ts +2 -33
- package/lib/helpers/github-graphql.js +50 -50
- package/lib/helpers/github-project-graphql.d.ts +37 -5
- package/lib/helpers/github-project-graphql.js +81 -15
- package/lib/helpers/gitlab-graphql.d.ts +4 -2
- package/lib/helpers/gitlab-graphql.js +12 -2
- package/lib/helpers/taskFunctions.js +101 -35
- package/lib/helpers/tasks.js +6 -2
- package/lib/helpers/template.d.ts +2 -1
- package/lib/helpers/template.js +20 -3
- package/lib/helpers/util.d.ts +3 -2
- package/lib/helpers/util.js +64 -17
- package/package.json +3 -3
- package/templates/modelB/changelog.md +8 -4
- package/templates/modelB/openIssues.bash +4 -0
- package/templates/modelB/viewIssue.bash +8 -0
- package/templates/modelB/openIssues.md +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,7 +1,34 @@
|
|
1
1
|
# Versiones
|
2
|
+
## Version 0.1.12
|
3
|
+
- Fecha: 8/12/2024
|
4
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.12)
|
5
|
+
- Cambios:
|
6
|
+
* [Publish] ponga en Changelog todos los issues Closed del milestone asociado. Y los mueva al final de todo a la Columna "Published"
|
7
|
+
- https://github.com/sebastianclaros/autoforce/issues/11
|
8
|
+
* [List] Poner Filtros: Abiertos Mios, Por Label, Por Milestone
|
9
|
+
- https://github.com/sebastianclaros/autoforce/issues/17
|
10
|
+
* [List] Guardar en autoforce el list default list template y default list Filter
|
11
|
+
- https://github.com/sebastianclaros/autoforce/issues/18
|
12
|
+
* [new Issue] Agregar Milestone
|
13
|
+
- https://github.com/sebastianclaros/autoforce/issues/19
|
14
|
+
* [config] dividir config general en config por comandos
|
15
|
+
- https://github.com/sebastianclaros/autoforce/issues/27
|
16
|
+
* [list] que tome de los argumentos valores.
|
17
|
+
- https://github.com/sebastianclaros/autoforce/issues/28
|
18
|
+
* [list] que reciba argumentos en taskFunctions y que tome orden de precedencia parametros de funcion, argumentos de comando y por ultimo autoforce.json
|
19
|
+
- https://github.com/sebastianclaros/autoforce/issues/29
|
20
|
+
* [new] que el milestone sea opcional
|
21
|
+
- https://github.com/sebastianclaros/autoforce/issues/30
|
22
|
+
|
23
|
+
## Version 0.1.11
|
24
|
+
- Fecha: 29/11/2024
|
25
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.11)
|
26
|
+
- Cambios:
|
27
|
+
* [comando config lea del autoforce.json](https://github.com/sebastianclaros/autoforce/issues/4)
|
2
28
|
|
3
29
|
## Version 0.1.10
|
4
30
|
- Fecha: 28/11/2024
|
31
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.10)
|
5
32
|
- Cambios:
|
6
33
|
* [publish deberia pedir la version, y asignarla en el autoforce version](https://github.com/sebastianclaros/autoforce/issues/12)
|
7
34
|
* [Models en config que lea un json descriptivo](https://github.com/sebastianclaros/autoforce/issues/9)
|
@@ -16,6 +43,7 @@
|
|
16
43
|
|
17
44
|
## Version 0.1.9
|
18
45
|
|
46
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.9)
|
19
47
|
- Cambios:
|
20
48
|
* Comando de new issue para crear un issue nuevo en el backlog
|
21
49
|
* Comando de list para ver issues en backlog o ver los detalles de uno
|
package/README.md
CHANGED
@@ -1,18 +1,33 @@
|
|
1
1
|
# Autoforce
|
2
2
|
|
3
|
-
El proyecto esta en Beta todavia,
|
3
|
+
El proyecto esta todavia en Beta todavia, pero la idea es que pueda estar productivo para algunos proyectos pronto.
|
4
4
|
|
5
5
|
|
6
6
|
## Objetivo
|
7
7
|
|
8
|
-
|
8
|
+
Hace un tiempo estabamos armando un repo para hacer practicas sobre Salesforce. Y empezamos a crear unos scripts para crear una instancia y subir el codigo. La idea fue evolucionando, y los scripts se fueron complejizando. Tambien surgieron limitaciones, si algo fallaba se quedaba por la mitad, los que tenian windows algunas cosas no funcionaban, y termine moviendo la idea a una herramienta.
|
9
9
|
|
10
|
-
|
10
|
+
El objetivo termino siendo facilitar y automatizar las tareas comunes que realizamos los desarrolladores. Si bien empece con Salesforce, la idea es generalizarla para que soporte distintos modelos, de hecho uno es para este mismo proyecto :)
|
11
11
|
|
12
|
-
|
12
|
+
## Orden en un Repositorio
|
13
13
|
|
14
|
-
|
14
|
+
Soy muy ansioso, y muchas veces queria hacer varios cambios juntos, el famoso ya que estoy aca tocando, o se me ocurrio algo. Pero despues es dificil de seguir, o se hacen mas largas las code reviews, etc.
|
15
15
|
|
16
|
+
Asi que el primer objetivo fue organizar el proyecto, si tengo una idea la guardo enseguida (new). Y si quiero arrancar algo, puedo empezar por ver las proximas stories (list).
|
17
|
+
|
18
|
+
|
19
|
+
## Tareas repetitivas
|
20
|
+
|
21
|
+
El segundo objetivo fue que pueda arrancar el desarrollo y arme el entorno, cree una branch y suba datos de prueba (start). Y por otro lado, cuando termine ese desarrollo,que baje los cambios en la scratch, documente, y valide la calidad del codigo(finish).
|
22
|
+
|
23
|
+
Basicamente las tareas comunes que identificamos fueron:
|
24
|
+
1. start
|
25
|
+
2. finish
|
26
|
+
3. stop
|
27
|
+
4. cancel
|
28
|
+
|
29
|
+
|
30
|
+
En cada una de ellas buscamos automatizar o integrar las siguientes gestiones:
|
16
31
|
- Branching Strategy en Git (Github o Gitlab)
|
17
32
|
- Armado de ambiente de desarrollo (Salesforce)
|
18
33
|
- Gestion de proyecto (Github projects, Gitlab projects o Jira).
|
@@ -20,7 +35,6 @@ En este repo las tareas buscan automatizar o integrar el siguiente tipo gestione
|
|
20
35
|
- Calidad de codigo (PMD)
|
21
36
|
- Uso de IA ( OpenAI, )
|
22
37
|
|
23
|
-
|
24
38
|
## Roadmap Status
|
25
39
|
|
26
40
|
1. Modelos
|
@@ -60,19 +74,6 @@ En este repo las tareas buscan automatizar o integrar el siguiente tipo gestione
|
|
60
74
|
|
61
75
|
|
62
76
|
|
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
77
|
## Usos
|
77
78
|
Una vez instalado se puede crear scripts a medida o bien ejecutar
|
78
79
|
|
@@ -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,7 +56,13 @@ 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;
|
52
61
|
constructor();
|
62
|
+
labels(): Promise<prompts.Choice[]>;
|
63
|
+
listFilters(): prompts.Choice[];
|
64
|
+
milestoneNumbers(): Promise<prompts.Choice[]>;
|
65
|
+
milestones(): Promise<prompts.Choice[]>;
|
53
66
|
loadProjectApi(): void;
|
54
67
|
loadGitApi(): void;
|
55
68
|
loadPackage(): void;
|
@@ -85,7 +98,7 @@ declare class Context implements IObjectRecord {
|
|
85
98
|
get process(): string | undefined;
|
86
99
|
askForprocess(): Promise<any>;
|
87
100
|
askFornewIssueType(): Promise<any>;
|
88
|
-
convertToArrayOfInputs(inputs: TaskArguments): TaskArgument[]
|
101
|
+
convertToArrayOfInputs(inputs: TaskArguments): Promise<TaskArgument[]>;
|
89
102
|
askForExit(): Promise<void>;
|
90
103
|
mergeArgs(args: StepArguments): StepArguments;
|
91
104
|
askForArguments(inputs: TaskArguments): Promise<void>;
|
package/lib/helpers/context.js
CHANGED
@@ -22,6 +22,12 @@ export var GitServices;
|
|
22
22
|
GitServices["GitLab"] = "gitlab";
|
23
23
|
GitServices["None"] = "none";
|
24
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";
|
@@ -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,9 +54,49 @@ 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';
|
50
60
|
this.loadConfig();
|
51
61
|
this.loadPackage();
|
52
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
|
+
});
|
99
|
+
}
|
53
100
|
loadProjectApi() {
|
54
101
|
if (!this.isProjectApi) {
|
55
102
|
if (this.projectServices == ProjectServices.GitHub && process.env.GITHUB_TOKEN) {
|
@@ -369,7 +416,7 @@ class Context {
|
|
369
416
|
askForprocess() {
|
370
417
|
return __awaiter(this, void 0, void 0, function* () {
|
371
418
|
if (this.projectApi && !this.issueTitle && this.issueNumber) {
|
372
|
-
const issue = yield this.projectApi.
|
419
|
+
const issue = yield this.projectApi.getIssue(this.issueNumber);
|
373
420
|
this.issueTitle = issue.title;
|
374
421
|
}
|
375
422
|
if (this.issueTitle) {
|
@@ -405,22 +452,29 @@ class Context {
|
|
405
452
|
});
|
406
453
|
}
|
407
454
|
convertToArrayOfInputs(inputs) {
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
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]));
|
419
474
|
}
|
420
|
-
inputsArray.push(Object.assign({ name: key, type: 'text', initial, message: `Por favor ingrese ${key}?` }, inputs[key]));
|
421
475
|
}
|
422
|
-
|
423
|
-
|
476
|
+
return inputsArray;
|
477
|
+
});
|
424
478
|
}
|
425
479
|
askForExit() {
|
426
480
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -459,7 +513,7 @@ class Context {
|
|
459
513
|
askForArguments(inputs) {
|
460
514
|
return __awaiter(this, void 0, void 0, function* () {
|
461
515
|
// unifica los dos tipos de inputs (array y objeto) en un array de inputs
|
462
|
-
const inputsArray = this.convertToArrayOfInputs(inputs);
|
516
|
+
const inputsArray = yield this.convertToArrayOfInputs(inputs);
|
463
517
|
for (const input of inputsArray) {
|
464
518
|
const hasValue = yield this.get(input.name);
|
465
519
|
if (!hasValue) {
|
@@ -10,6 +10,8 @@ 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?: {
|
@@ -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 = `
|
@@ -97,7 +136,17 @@ export class GitHubApi {
|
|
97
136
|
assignBranchToIssue(issueNumber, branchName, commitSha) {
|
98
137
|
return __awaiter(this, void 0, void 0, function* () {
|
99
138
|
var _a;
|
100
|
-
const
|
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
|
}[]>;
|