autoforce 0.1.19 → 0.1.21
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/.autoforce.json +1 -1
- package/CHANGELOG.md +9 -0
- package/lib/helpers/github-graphql.d.ts +7 -0
- package/lib/helpers/github-graphql.js +25 -8
- package/lib/helpers/gitlab-graphql.d.ts +6 -0
- package/lib/helpers/gitlab-graphql.js +5 -0
- package/lib/helpers/taskFunctions.js +15 -0
- package/lib/helpers/util.d.ts +2 -2
- package/lib/helpers/util.js +8 -4
- package/models/dev/npm/tasks/publish.json +2 -1
- package/models/project/github-releases/new/milestone.json +21 -0
- package/package.json +1 -1
package/.autoforce.json
CHANGED
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Versiones
|
2
2
|
|
3
|
+
## Version 0.1.20
|
4
|
+
- Fecha:
|
5
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.20)
|
6
|
+
- Cambios:
|
7
|
+
* Test con instalacion de paquete
|
8
|
+
- https://github.com/sebastianclaros/autoforce/issues/49
|
9
|
+
* Que config tome argumentos
|
10
|
+
- https://github.com/sebastianclaros/autoforce/issues/51
|
11
|
+
|
3
12
|
## Version 0.1.18
|
4
13
|
- Fecha:
|
5
14
|
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.18ra la placa
|
@@ -20,6 +20,13 @@ export declare class GitHubApi implements IGitApi {
|
|
20
20
|
constructor(token: string, owner: string, repo: string, projectNumber?: number);
|
21
21
|
createLabel(name: string, color?: string): Promise<ILabel | undefined>;
|
22
22
|
getRandomColor(): string;
|
23
|
+
updateMilestone(title: string, state?: string, description?: string, dueOn?: string): Promise<{
|
24
|
+
id: any;
|
25
|
+
title: any;
|
26
|
+
description: any;
|
27
|
+
dueOn: any;
|
28
|
+
url: any;
|
29
|
+
}>;
|
23
30
|
createMilestone(title: string, state?: string, description?: string, dueOn?: string): Promise<{
|
24
31
|
id: any;
|
25
32
|
title: any;
|
@@ -68,18 +68,35 @@ export class GitHubApi {
|
|
68
68
|
const number = Math.floor(Math.random() * colors.length);
|
69
69
|
return colors[number];
|
70
70
|
}
|
71
|
+
async updateMilestone(title, state = 'open', description, dueOn) {
|
72
|
+
const allMilestones = await this.getMilestones();
|
73
|
+
const toUpdate = allMilestones.filter(milestone => milestone.title === title)[0];
|
74
|
+
if (!toUpdate) {
|
75
|
+
throw new Error(`No se encontro el milestone ${title}`);
|
76
|
+
}
|
77
|
+
const milestone = {
|
78
|
+
title,
|
79
|
+
state,
|
80
|
+
description,
|
81
|
+
};
|
82
|
+
if (dueOn) {
|
83
|
+
milestone.due_on = dueOn;
|
84
|
+
}
|
85
|
+
const result = await this.octokit.request(`PATCH /repos/${this.repoVar.owner}/${this.repoVar.repo}/milestones/{$toUpdate.number}`, { ...milestone, ...{ headers: { 'X-GitHub-Api-Version': '2022-11-28' } } });
|
86
|
+
return { id: result.data.node_id, title: result.data.title, description: result.data.description, dueOn: result.data.due_on, url: result.data.url };
|
87
|
+
}
|
71
88
|
async createMilestone(title, state = 'open', description, dueOn) {
|
72
|
-
const
|
89
|
+
const milestone = {
|
73
90
|
title,
|
74
91
|
state,
|
75
92
|
description,
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
});
|
81
|
-
|
82
|
-
return
|
93
|
+
};
|
94
|
+
if (dueOn) {
|
95
|
+
milestone.due_on = dueOn;
|
96
|
+
}
|
97
|
+
const result = await this.octokit.request(`POST /repos/${this.repoVar.owner}/${this.repoVar.repo}/milestones`, { ...milestone, ...{ headers: { 'X-GitHub-Api-Version': '2022-11-28' } } });
|
98
|
+
console.log(result.data.url);
|
99
|
+
return { id: result.data.node_id, title: result.data.title, description: result.data.description, dueOn: result.data.due_on, url: result.data.url };
|
83
100
|
}
|
84
101
|
async getUser() {
|
85
102
|
const query = `{
|
@@ -24,6 +24,12 @@ export declare class GitLabApi implements IGitApi, IProjectApi {
|
|
24
24
|
state: string;
|
25
25
|
url: string;
|
26
26
|
}>;
|
27
|
+
updateMilestone(title: string, state?: string, description?: string, dueOn?: string): Promise<{
|
28
|
+
id: string;
|
29
|
+
title: string;
|
30
|
+
state: string;
|
31
|
+
url: string;
|
32
|
+
}>;
|
27
33
|
createIssue(title: string, state?: string, label?: string, body?: string, milestone?: string): Promise<{
|
28
34
|
number: number;
|
29
35
|
}>;
|
@@ -24,6 +24,7 @@ export class GitLabApi {
|
|
24
24
|
return [];
|
25
25
|
}
|
26
26
|
async getIssuesWithFilter(filter) {
|
27
|
+
console.log(filter);
|
27
28
|
return [];
|
28
29
|
}
|
29
30
|
async createLabel(name, color = 'random') {
|
@@ -34,6 +35,10 @@ export class GitLabApi {
|
|
34
35
|
console.log(title, state, description, dueOn);
|
35
36
|
return { id: '', title: '', state: '', url: '' };
|
36
37
|
}
|
38
|
+
async updateMilestone(title, state = 'open', description, dueOn) {
|
39
|
+
console.log(title, state, description, dueOn);
|
40
|
+
return { id: '', title: '', state: '', url: '' };
|
41
|
+
}
|
37
42
|
async createIssue(title, state, label, body, milestone) {
|
38
43
|
console.log(title, state, label, body, milestone);
|
39
44
|
return { number: 1 };
|
@@ -221,6 +221,7 @@ export const taskFunctions = {
|
|
221
221
|
},
|
222
222
|
storeConfig(variable, value) {
|
223
223
|
storeConfig({ [variable]: value });
|
224
|
+
context.loadConfig();
|
224
225
|
return true;
|
225
226
|
},
|
226
227
|
async docProcess() {
|
@@ -304,6 +305,20 @@ export const taskFunctions = {
|
|
304
305
|
console.log('Not implemented');
|
305
306
|
return false;
|
306
307
|
},
|
308
|
+
async createMilestone(title, state = 'open', description, dueOn) {
|
309
|
+
if (context.projectApi === undefined || context.gitApi === undefined) {
|
310
|
+
return false;
|
311
|
+
}
|
312
|
+
const result = await context.gitApi.createMilestone(title, state, description, dueOn);
|
313
|
+
return result?.id ? true : false;
|
314
|
+
},
|
315
|
+
async updateMilestone(title, state = 'open', description, dueOn) {
|
316
|
+
if (context.projectApi === undefined || context.gitApi === undefined) {
|
317
|
+
return false;
|
318
|
+
}
|
319
|
+
const result = await context.gitApi.updateMilestone(title, state, description, dueOn);
|
320
|
+
return result?.id ? true : false;
|
321
|
+
},
|
307
322
|
async createIssue(title, label, body, milestone) {
|
308
323
|
if (context.projectApi === undefined || context.gitApi === undefined) {
|
309
324
|
return false;
|
package/lib/helpers/util.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Choice } from "prompts";
|
2
|
-
import { AnyValue } from "../types/auto.js";
|
2
|
+
import { AnyValue, CommandOptions } from "../types/auto.js";
|
3
3
|
export declare const WORKING_FOLDER: string;
|
4
4
|
export declare const CONFIG_FILE: string;
|
5
5
|
export declare const DICTIONARY_FOLDER: string;
|
@@ -21,7 +21,7 @@ export declare function titlesToChoices(list: string[], titleToValue?: (title: s
|
|
21
21
|
export declare function findChoicesPosition(choices: Choice[], value: string): number;
|
22
22
|
export declare function getFilesInFolders(folders: string[], filter: (fullPath: string) => boolean, recursive?: boolean, ignoreList?: string[]): string[];
|
23
23
|
export declare function getModelFolders(subfolder: string): string[];
|
24
|
-
export declare function createConfigurationFile(taskName?: string): Promise<boolean>;
|
24
|
+
export declare function createConfigurationFile(taskName?: string, options?: CommandOptions): Promise<boolean>;
|
25
25
|
export declare function getConfigFile(file: string, variable: string, defaultValue: AnyValue): any;
|
26
26
|
export declare function getConfig(variable: string, defaultValue: AnyValue): any;
|
27
27
|
export declare function storeConfig(record: Record<string, AnyValue>): void;
|
package/lib/helpers/util.js
CHANGED
@@ -127,7 +127,6 @@ async function getBaseConfig(config) {
|
|
127
127
|
if (projectServices.project === undefined)
|
128
128
|
return;
|
129
129
|
config.projectServices = projectServices.project;
|
130
|
-
;
|
131
130
|
if (projectServices.project === ProjectServices.GitHub || projectServices.project === ProjectServices.GitLab) {
|
132
131
|
// Gestion del Proyecto
|
133
132
|
const backlogColumn = await prompts([{
|
@@ -153,9 +152,14 @@ async function getBaseConfig(config) {
|
|
153
152
|
config.projectId = projectId.projectId;
|
154
153
|
return config;
|
155
154
|
}
|
156
|
-
export async function createConfigurationFile(taskName) {
|
157
|
-
|
158
|
-
|
155
|
+
export async function createConfigurationFile(taskName, options) {
|
156
|
+
if (options?.noprompt) {
|
157
|
+
delete options.noprompt;
|
158
|
+
storeConfig(options);
|
159
|
+
return true;
|
160
|
+
}
|
161
|
+
const baseConfig = { backlogColumn: options?.backlogColumn || context.backlogColumn, devModel: options?.devModel || context.devModel, docModel: options?.docModel || context.docModel, projectModel: options?.projectModel || context.projectModel, gitModel: options?.gitModel || context.gitModel, gitServices: options?.gitServices || context.gitServices, projectServices: options?.projectServices || context.projectServices, projectId: options?.projectId || context.projectId, listFilter: options?.listFilter || context.listFilter, listTemplate: options?.listTemplate || context.listTemplate };
|
162
|
+
const config = taskName ? await getTaskConfig(baseConfig) : await getBaseConfig(baseConfig);
|
159
163
|
if (!config)
|
160
164
|
return false;
|
161
165
|
storeConfig(config);
|
@@ -9,6 +9,7 @@
|
|
9
9
|
{ "name": "Actualiza la version", "function": "storeConfig", "arguments": ["version", "${newVersion}"] },
|
10
10
|
{ "name": "Paquetiza", "subtask": "pack" },
|
11
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
|
+
{ "name": "Salida para el Changelog.md", "task": "list", "arguments": {"filter": "milestone", "template": "changelog", "milestone": "${newVersion}"} },
|
13
|
+
{ "name": "Actualiza el milestone", "function": "updateMilestone", "arguments": ["${newVersion}", "closed"] }
|
13
14
|
]
|
14
15
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"name": "milestone",
|
3
|
+
"guards": ["isGitApi"],
|
4
|
+
"arguments": {
|
5
|
+
"title": { "required": true },
|
6
|
+
"state": {
|
7
|
+
"type": "select",
|
8
|
+
"choices": [ { "value": "open", "label": "open"}, { "value": "closed", "label": "closed"} ]
|
9
|
+
},
|
10
|
+
"description": { "required": false },
|
11
|
+
"dueOn": { "required": false }
|
12
|
+
},
|
13
|
+
"description": "Comando para crear un milestone nuevo",
|
14
|
+
"steps": [
|
15
|
+
{
|
16
|
+
"name": "Crear un milestone nuevo",
|
17
|
+
"function": "createMilestone",
|
18
|
+
"arguments": ["${title}", "${state}", "${description}", "${dueOn}"]
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|