autoforce 0.1.14 → 0.1.16
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 +11 -0
- package/CHANGELOG.md +16 -1
- package/commands/modelA/new/issue.json +8 -24
- package/commands/modelC/tasks/publish.json +2 -2
- package/lib/auto.js +6 -2
- package/lib/helpers/context.js +2 -2
- package/lib/helpers/github-graphql.d.ts +21 -17
- package/lib/helpers/github-graphql.js +89 -21
- package/lib/helpers/github-project-graphql.d.ts +2 -1
- package/lib/helpers/github-project-graphql.js +27 -5
- package/lib/helpers/gitlab-graphql.d.ts +14 -1
- package/lib/helpers/gitlab-graphql.js +13 -1
- package/lib/helpers/taskFunctions.js +42 -4
- package/lib/helpers/util.d.ts +1 -0
- package/lib/helpers/util.js +10 -4
- package/package.json +2 -1
- package/templates/modelA/openIssues.bash +4 -0
- package/templates/modelA/viewIssue.bash +8 -0
package/.autoforce.json
ADDED
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Versiones
|
2
|
+
|
3
|
+
## Version 0.1.15
|
4
|
+
- Fecha: 9 Dic 2024
|
5
|
+
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.15)
|
6
|
+
- Cambios:
|
7
|
+
* [new] que muestre la url
|
8
|
+
- https://github.com/sebastianclaros/autoforce/issues/37
|
9
|
+
* [list] falta templates en modelA
|
10
|
+
- https://github.com/sebastianclaros/autoforce/issues/38
|
11
|
+
|
12
|
+
## Version 0.1.13 y 0.1.14
|
13
|
+
- Fecha: 9 Dic 2024
|
14
|
+
- Cambios:
|
15
|
+
* Error en el publish por una dependencia erronea a si mismo
|
16
|
+
|
2
17
|
## Version 0.1.12
|
3
|
-
- Fecha: 8
|
18
|
+
- Fecha: 8 Dic 2024
|
4
19
|
- Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.12)
|
5
20
|
- Cambios:
|
6
21
|
* [Publish] ponga en Changelog todos los issues Closed del milestone asociado. Y los mueva al final de todo a la Columna "Published"
|
@@ -5,36 +5,20 @@
|
|
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
|
-
]
|
30
|
-
}
|
8
|
+
"values": "labels"
|
9
|
+
},
|
10
|
+
"milestone": {
|
11
|
+
"type": "select",
|
12
|
+
"values": "milestones"
|
13
|
+
},
|
14
|
+
"body": { "required": false }
|
31
15
|
},
|
32
16
|
"description": "Comando para crear un requerimiento nuevo",
|
33
17
|
"steps": [
|
34
18
|
{
|
35
19
|
"name": "Crear un issue nuevo",
|
36
20
|
"function": "createIssue",
|
37
|
-
"arguments": ["${title}", "${label}"]
|
21
|
+
"arguments": ["${title}", "${label}", "${body}", "${milestone}"]
|
38
22
|
}
|
39
23
|
]
|
40
24
|
}
|
@@ -6,9 +6,9 @@
|
|
6
6
|
},
|
7
7
|
"description": "Comando para publicar un requerimiento al ambiente",
|
8
8
|
"steps": [
|
9
|
-
{ "name": "Paquetiza", "subtask": "pack" },
|
10
9
|
{ "name": "Actualiza la version", "function": "storeConfig", "arguments": ["version", "${newVersion}"] },
|
11
|
-
{ "name": "
|
10
|
+
{ "name": "Paquetiza", "subtask": "pack" },
|
11
|
+
{ "name": "Publica", "command": "yarn publish ", "arguments": {"--new-version": "${newVersion}"} },
|
12
12
|
{ "name": "Salida para el Changelog.md", "task": "list", "arguments": {"filter": "milestone", "template": "changelog", "milestone": "${newVersion}"} }
|
13
13
|
]
|
14
14
|
}
|
package/lib/auto.js
CHANGED
@@ -11,8 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
11
11
|
import { createObject, validateTask, getTasks, helpTask, runTask, getTaskFolder } from "./helpers/tasks.js";
|
12
12
|
import { logError } from "./helpers/color.js";
|
13
13
|
import prompts from "prompts";
|
14
|
-
import { createConfigurationFile } from "./helpers/util.js";
|
14
|
+
import { createConfigurationFile, getConfigFile } from "./helpers/util.js";
|
15
15
|
import context from "./helpers/context.js";
|
16
|
+
import { fileURLToPath } from "url";
|
17
|
+
import { dirname } from 'path';
|
16
18
|
const proxyCommand = {
|
17
19
|
'version': showVersion,
|
18
20
|
'config': createConfigurationFile
|
@@ -25,7 +27,9 @@ const taskCommand = {
|
|
25
27
|
};
|
26
28
|
function showVersion() {
|
27
29
|
return __awaiter(this, void 0, void 0, function* () {
|
28
|
-
|
30
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
31
|
+
const version = getConfigFile(__dirname + '/../.autoforce.json', 'version', '0.1.14');
|
32
|
+
console.log('AutoForce v' + version);
|
29
33
|
return true;
|
30
34
|
});
|
31
35
|
}
|
package/lib/helpers/context.js
CHANGED
@@ -63,7 +63,7 @@ class Context {
|
|
63
63
|
labels() {
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
65
65
|
var _a;
|
66
|
-
const choices = [{ value: '', title: 'Ninguno' }];
|
66
|
+
const choices = [{ value: '', title: 'Ninguno' }, { value: 'new', title: 'Nuevo' }];
|
67
67
|
const labels = yield ((_a = this.gitApi) === null || _a === void 0 ? void 0 : _a.getLabels());
|
68
68
|
if (labels) {
|
69
69
|
labels.forEach(label => choices.push({ value: label.name, title: label.name }));
|
@@ -89,7 +89,7 @@ class Context {
|
|
89
89
|
milestones() {
|
90
90
|
return __awaiter(this, void 0, void 0, function* () {
|
91
91
|
var _a;
|
92
|
-
const choices = [{ value: '', title: 'Ninguno' }];
|
92
|
+
const choices = [{ value: '', title: 'Ninguno' }, { value: 'new', title: 'Nuevo' }];
|
93
93
|
const milestones = yield ((_a = this.gitApi) === null || _a === void 0 ? void 0 : _a.getMilestones());
|
94
94
|
if (milestones) {
|
95
95
|
milestones.forEach(milestone => choices.push({ value: milestone.id, title: milestone.title }));
|
@@ -5,30 +5,34 @@ export declare class GitHubApi implements IGitApi {
|
|
5
5
|
};
|
6
6
|
projectNumber: number | undefined;
|
7
7
|
graphqlAuth: import("@octokit/graphql/types").graphql;
|
8
|
+
octokit: import("@octokit/core").Octokit & {
|
9
|
+
paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
|
10
|
+
} & import("@octokit/plugin-paginate-graphql").paginateGraphQLInterface & import("@octokit/plugin-rest-endpoint-methods").Api & {
|
11
|
+
retry: {
|
12
|
+
retryRequest: (error: import("octokit").RequestError, retries: number, retryAfter: number) => import("octokit").RequestError;
|
13
|
+
};
|
14
|
+
};
|
15
|
+
_repository: IRepository | undefined;
|
16
|
+
_labels: ILabel[] | undefined;
|
17
|
+
_defaultColors: Record<string, string>;
|
18
|
+
getRepository(): Promise<IRepository>;
|
8
19
|
constructor(token: string, owner: string, repo: string, projectNumber?: number);
|
20
|
+
createLabel(name: string, color?: string): Promise<ILabel | undefined>;
|
21
|
+
getRandomColor(): string;
|
22
|
+
createMilestone(title: string, state?: string, description?: string, dueOn?: string): Promise<{
|
23
|
+
id: any;
|
24
|
+
title: any;
|
25
|
+
description: any;
|
26
|
+
dueOn: any;
|
27
|
+
url: any;
|
28
|
+
}>;
|
9
29
|
getUser(): Promise<{
|
10
30
|
login: string;
|
11
31
|
id: number;
|
12
32
|
}>;
|
13
33
|
getLabels(): Promise<ILabel[]>;
|
14
34
|
getMilestones(): Promise<IMilestone[]>;
|
15
|
-
|
16
|
-
id: string;
|
17
|
-
label?: {
|
18
|
-
id: string;
|
19
|
-
};
|
20
|
-
projectV2: {
|
21
|
-
id: string;
|
22
|
-
field: {
|
23
|
-
id: string;
|
24
|
-
name: string;
|
25
|
-
options: {
|
26
|
-
name: string;
|
27
|
-
id: string;
|
28
|
-
}[];
|
29
|
-
};
|
30
|
-
};
|
31
|
-
}>;
|
35
|
+
getRepositoryObject(): Promise<IRepository>;
|
32
36
|
createPullRequest(branchName: string, title: string, body: string): Promise<boolean>;
|
33
37
|
assignBranchToIssue(issueNumber: string, branchName: string, commitSha: string): Promise<boolean>;
|
34
38
|
getCommit(commitSha: string): Promise<{
|
@@ -8,8 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
});
|
9
9
|
};
|
10
10
|
import { graphql } from "@octokit/graphql";
|
11
|
+
import { Octokit } from "octokit";
|
11
12
|
export class GitHubApi {
|
13
|
+
getRepository() {
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
15
|
+
if (this._repository === undefined) {
|
16
|
+
const repository = yield this.getRepositoryObject();
|
17
|
+
this._repository = repository;
|
18
|
+
}
|
19
|
+
return this._repository;
|
20
|
+
});
|
21
|
+
}
|
12
22
|
constructor(token, owner, repo, projectNumber) {
|
23
|
+
this._defaultColors = { 'red': 'b60205', 'orange': 'd93f0b', 'yellow': 'fbca04', 'green': '0e8a16', 'dupont': '006b75', 'light-blue': '1d76db', 'blue': '0052cc', 'purple': '5319e7', 'pastel-red': 'e99695', 'pastel-orange': 'f9d0c4', 'pastel-yellow': 'fef2c0', 'pastel-green': 'c2e0c6', 'pastel-dupont': 'bfdadc', 'pastel-light': 'c5def5', 'pastel-blue': 'bfd4f2', 'pastel-purple': 'd4c5f9' };
|
13
24
|
this.repoVar = { owner, repo };
|
14
25
|
this.projectNumber = projectNumber;
|
15
26
|
this.graphqlAuth = graphql.defaults({
|
@@ -18,6 +29,65 @@ export class GitHubApi {
|
|
18
29
|
"X-Github-Next-Global-ID": 1
|
19
30
|
},
|
20
31
|
});
|
32
|
+
this.octokit = new Octokit({
|
33
|
+
auth: token
|
34
|
+
});
|
35
|
+
}
|
36
|
+
createLabel(name_1) {
|
37
|
+
return __awaiter(this, arguments, void 0, function* (name, color = 'random') {
|
38
|
+
const repositoryId = (yield this.getRepository()).id;
|
39
|
+
if (color === 'random') {
|
40
|
+
color = this.getRandomColor();
|
41
|
+
}
|
42
|
+
else if (this._defaultColors[color] !== undefined) {
|
43
|
+
color = this._defaultColors[color];
|
44
|
+
}
|
45
|
+
const variables = { name, repositoryId, color };
|
46
|
+
const mutationCreateLabel = `
|
47
|
+
mutation createLabel( $name: String!, $repositoryId: ID!, $color: String! ) {
|
48
|
+
createLabel(
|
49
|
+
input: {
|
50
|
+
repositoryId: $repositoryId,
|
51
|
+
name: $name
|
52
|
+
color: $color
|
53
|
+
}
|
54
|
+
) {
|
55
|
+
label {
|
56
|
+
id
|
57
|
+
name
|
58
|
+
color
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}`;
|
62
|
+
try {
|
63
|
+
const { createLabel } = yield this.graphqlAuth(mutationCreateLabel, variables);
|
64
|
+
return createLabel.label;
|
65
|
+
}
|
66
|
+
catch (error) {
|
67
|
+
console.log(error);
|
68
|
+
}
|
69
|
+
return;
|
70
|
+
});
|
71
|
+
}
|
72
|
+
getRandomColor() {
|
73
|
+
const colors = Object.values(this._defaultColors);
|
74
|
+
const number = Math.floor(Math.random() * colors.length);
|
75
|
+
return colors[number];
|
76
|
+
}
|
77
|
+
createMilestone(title_1) {
|
78
|
+
return __awaiter(this, arguments, void 0, function* (title, state = 'open', description, dueOn) {
|
79
|
+
const result = yield this.octokit.request(`POST /repos/${this.repoVar.owner}/${this.repoVar.repo}/milestones`, {
|
80
|
+
title,
|
81
|
+
state,
|
82
|
+
description,
|
83
|
+
due_on: dueOn,
|
84
|
+
headers: {
|
85
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
86
|
+
}
|
87
|
+
});
|
88
|
+
const milestone = { id: result.data.node_id, title: result.data.title, description: result.data.description, dueOn: result.data.due_on, url: result.data.url };
|
89
|
+
return milestone;
|
90
|
+
});
|
21
91
|
}
|
22
92
|
getUser() {
|
23
93
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -33,21 +103,24 @@ export class GitHubApi {
|
|
33
103
|
}
|
34
104
|
getLabels() {
|
35
105
|
return __awaiter(this, void 0, void 0, function* () {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
106
|
+
if (this._labels === undefined) {
|
107
|
+
const query = `
|
108
|
+
query getRepo($owner:String!, $repo: String! ) {
|
109
|
+
repository(owner: $owner, name: $repo) {
|
110
|
+
labels(last: 10, orderBy: { field: CREATED_AT, direction: DESC}) {
|
111
|
+
nodes{
|
112
|
+
id
|
113
|
+
name
|
114
|
+
color
|
115
|
+
}
|
44
116
|
}
|
45
117
|
}
|
46
118
|
}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
119
|
+
`;
|
120
|
+
const { repository } = yield this.graphqlAuth(query, this.repoVar);
|
121
|
+
this._labels = repository.labels.nodes;
|
122
|
+
}
|
123
|
+
return this._labels;
|
51
124
|
});
|
52
125
|
}
|
53
126
|
getMilestones() {
|
@@ -70,16 +143,12 @@ export class GitHubApi {
|
|
70
143
|
return repository.milestones.nodes;
|
71
144
|
});
|
72
145
|
}
|
73
|
-
|
146
|
+
getRepositoryObject() {
|
74
147
|
return __awaiter(this, void 0, void 0, function* () {
|
75
148
|
const query = `
|
76
|
-
query getRepo($owner:String!, $repo: String!, $projectNumber: Int
|
149
|
+
query getRepo($owner:String!, $repo: String!, $projectNumber: Int! ) {
|
77
150
|
repository(owner: $owner, name: $repo) {
|
78
151
|
id
|
79
|
-
${label ?
|
80
|
-
`label(name: $label) {
|
81
|
-
id
|
82
|
-
}` : ''}
|
83
152
|
projectV2( number: $projectNumber ) {
|
84
153
|
id
|
85
154
|
field(name: "Status") {
|
@@ -96,14 +165,13 @@ export class GitHubApi {
|
|
96
165
|
}
|
97
166
|
}
|
98
167
|
`;
|
99
|
-
const { repository } = yield this.graphqlAuth(query, Object.assign({
|
168
|
+
const { repository } = yield this.graphqlAuth(query, Object.assign({ projectNumber: this.projectNumber }, this.repoVar));
|
100
169
|
return repository;
|
101
170
|
});
|
102
171
|
}
|
103
172
|
createPullRequest(branchName, title, body) {
|
104
173
|
return __awaiter(this, void 0, void 0, function* () {
|
105
|
-
const
|
106
|
-
const repositoryId = repository.id;
|
174
|
+
const repositoryId = (yield this.getRepository()).id;
|
107
175
|
const headRefName = 'main';
|
108
176
|
const baseRefName = branchName;
|
109
177
|
const mutationPullRequest = `
|
@@ -3,7 +3,8 @@ 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
|
-
|
6
|
+
findLabelByName(name: string | undefined): Promise<ILabel | undefined>;
|
7
|
+
createIssue(title: string, state?: string, label?: string, body?: string, milestoneId?: string): Promise<IIssueObject>;
|
7
8
|
getIssueState(issueNumber: string): Promise<string>;
|
8
9
|
getIssueName(title: string): string;
|
9
10
|
_getIssue(issueNumber: string): Promise<{
|
@@ -42,14 +42,30 @@ export class GitHubProjectApi extends GitHubApi {
|
|
42
42
|
return mapValues;
|
43
43
|
});
|
44
44
|
}
|
45
|
+
findLabelByName(name) {
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
47
|
+
if (name) {
|
48
|
+
const labels = yield this.getLabels();
|
49
|
+
if (labels.length > 0) {
|
50
|
+
for (const label of labels) {
|
51
|
+
if (label.name === name) {
|
52
|
+
return label;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
return;
|
58
|
+
});
|
59
|
+
}
|
45
60
|
createIssue(title, state, label, body, milestoneId) {
|
46
61
|
return __awaiter(this, void 0, void 0, function* () {
|
47
62
|
var _a;
|
48
63
|
const user = yield this.getUser();
|
49
|
-
const repository = yield this.getRepository(
|
64
|
+
const repository = yield this.getRepository();
|
50
65
|
const repositoryId = repository.id;
|
51
|
-
const labelId = (_a =
|
66
|
+
const labelId = (label === null || label === void 0 ? void 0 : label.startsWith('LA_')) ? label : (_a = (yield this.findLabelByName(label))) === null || _a === void 0 ? void 0 : _a.id;
|
52
67
|
const projectId = repository.projectV2.id;
|
68
|
+
const variables = { labelId, body, assignId: user.id, projectId, repositoryId, title, milestoneId: milestoneId ? milestoneId : null };
|
53
69
|
const mutationIssue = `
|
54
70
|
mutation createIssue($repositoryId: ID!, $assignId: ID!, $title: String!, $body: String, $milestoneId: ID ${labelId ? ', $labelId: ID!' : ''} ) {
|
55
71
|
createIssue(
|
@@ -65,13 +81,19 @@ export class GitHubProjectApi extends GitHubApi {
|
|
65
81
|
issue {
|
66
82
|
id
|
67
83
|
number
|
84
|
+
url
|
85
|
+
milestone {
|
86
|
+
title
|
87
|
+
dueOn
|
88
|
+
url
|
89
|
+
}
|
68
90
|
}
|
69
91
|
}
|
70
92
|
}`;
|
71
|
-
const { createIssue } = yield this.graphqlAuth(mutationIssue,
|
93
|
+
const { createIssue } = yield this.graphqlAuth(mutationIssue, variables);
|
72
94
|
const issue = createIssue.issue;
|
73
95
|
if (!state || !issue.number) {
|
74
|
-
return issue
|
96
|
+
return issue;
|
75
97
|
}
|
76
98
|
const mutationItem = `
|
77
99
|
mutation addProjectV2ItemById($projectId: ID!, $contentId: ID! ) {
|
@@ -111,7 +133,7 @@ export class GitHubProjectApi extends GitHubApi {
|
|
111
133
|
}`;
|
112
134
|
yield this.graphqlAuth(mutationColumn, { projectId, itemId, fieldId, columnValue });
|
113
135
|
}
|
114
|
-
return issue
|
136
|
+
return issue;
|
115
137
|
});
|
116
138
|
}
|
117
139
|
getIssueState(issueNumber) {
|
@@ -13,7 +13,20 @@ export declare class GitLabApi implements IGitApi, IProjectApi {
|
|
13
13
|
getIssue(issueNumber: string): Promise<{}>;
|
14
14
|
getIssues(): Promise<never[]>;
|
15
15
|
getIssuesWithFilter(filter: string): Promise<never[]>;
|
16
|
-
|
16
|
+
createLabel(name: string, color?: string): Promise<{
|
17
|
+
id: string;
|
18
|
+
name: string;
|
19
|
+
color: string;
|
20
|
+
}>;
|
21
|
+
createMilestone(title: string, state?: string, description?: string, dueOn?: string): Promise<{
|
22
|
+
id: string;
|
23
|
+
title: string;
|
24
|
+
state: string;
|
25
|
+
url: string;
|
26
|
+
}>;
|
27
|
+
createIssue(title: string, state?: string, label?: string, body?: string, milestone?: string): Promise<{
|
28
|
+
number: number;
|
29
|
+
}>;
|
17
30
|
moveIssue(issueNumber: string, state: string): Promise<boolean>;
|
18
31
|
assignIssueToMe(issueNumber: string): Promise<boolean>;
|
19
32
|
getUser(): Promise<{
|
@@ -42,10 +42,22 @@ export class GitLabApi {
|
|
42
42
|
return [];
|
43
43
|
});
|
44
44
|
}
|
45
|
+
createLabel(name_1) {
|
46
|
+
return __awaiter(this, arguments, void 0, function* (name, color = 'random') {
|
47
|
+
console.log(name, color);
|
48
|
+
return { id: '', name, color };
|
49
|
+
});
|
50
|
+
}
|
51
|
+
createMilestone(title_1) {
|
52
|
+
return __awaiter(this, arguments, void 0, function* (title, state = 'open', description, dueOn) {
|
53
|
+
console.log(title, state, description, dueOn);
|
54
|
+
return { id: '', title: '', state: '', url: '' };
|
55
|
+
});
|
56
|
+
}
|
45
57
|
createIssue(title, state, label, body, milestone) {
|
46
58
|
return __awaiter(this, void 0, void 0, function* () {
|
47
59
|
console.log(title, state, label, body, milestone);
|
48
|
-
return 1;
|
60
|
+
return { number: 1 };
|
49
61
|
});
|
50
62
|
}
|
51
63
|
moveIssue(issueNumber, state) {
|
@@ -335,12 +335,50 @@ export const taskFunctions = {
|
|
335
335
|
},
|
336
336
|
createIssue(title, label, body, milestone) {
|
337
337
|
return __awaiter(this, void 0, void 0, function* () {
|
338
|
-
if (context.projectApi === undefined) {
|
338
|
+
if (context.projectApi === undefined || context.gitApi === undefined) {
|
339
339
|
return false;
|
340
340
|
}
|
341
|
-
|
342
|
-
|
343
|
-
|
341
|
+
if (label === 'new') {
|
342
|
+
const answer = yield prompts([
|
343
|
+
{
|
344
|
+
message: 'Nombre del Label',
|
345
|
+
name: 'nombre',
|
346
|
+
type: 'text'
|
347
|
+
}
|
348
|
+
]);
|
349
|
+
if (answer.nombre !== undefined) {
|
350
|
+
const result = yield context.gitApi.createLabel(answer.nombre);
|
351
|
+
if (result === null || result === void 0 ? void 0 : result.id) {
|
352
|
+
label = result.id;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
else {
|
356
|
+
label = '';
|
357
|
+
}
|
358
|
+
}
|
359
|
+
if (milestone === 'new') {
|
360
|
+
const answer = yield prompts([
|
361
|
+
{
|
362
|
+
message: 'Nombre del Milestone',
|
363
|
+
name: 'nombre',
|
364
|
+
type: 'text'
|
365
|
+
}
|
366
|
+
]);
|
367
|
+
if (answer.nombre !== undefined) {
|
368
|
+
const result = yield context.gitApi.createMilestone(answer.nombre);
|
369
|
+
milestone = result === null || result === void 0 ? void 0 : result.id;
|
370
|
+
}
|
371
|
+
else {
|
372
|
+
milestone = '';
|
373
|
+
}
|
374
|
+
}
|
375
|
+
const issue = yield context.projectApi.createIssue(title, context.backlogColumn, label, body, milestone);
|
376
|
+
if (issue) {
|
377
|
+
console.log(`Se creo el issue ${issue.number}`);
|
378
|
+
console.log(`${issue.url}`);
|
379
|
+
// if ( issue.milestone) {
|
380
|
+
// console.log(`Milestone ${issue.milestone.title} expira en ${issue.milestone.dueOn} `);
|
381
|
+
// }
|
344
382
|
return true;
|
345
383
|
}
|
346
384
|
return false;
|
package/lib/helpers/util.d.ts
CHANGED
@@ -23,6 +23,7 @@ export declare function titlesToChoices(list: string[], titleToValue?: (title: s
|
|
23
23
|
export declare function getDataFromPackage(): Record<string, string>;
|
24
24
|
export declare function findChoicesPosition(choices: Choice[], value: string): number;
|
25
25
|
export declare function createConfigurationFile(taskName?: string): Promise<boolean>;
|
26
|
+
export declare function getConfigFile(file: string, variable: string, defaultValue: AnyValue): any;
|
26
27
|
export declare function getConfig(variable: string, defaultValue: AnyValue): any;
|
27
28
|
export declare function storeConfig(record: Record<string, AnyValue>): void;
|
28
29
|
export declare function sortByName(objA: {
|
package/lib/helpers/util.js
CHANGED
@@ -34,7 +34,10 @@ export function titlesToChoices(list, titleToValue = (title) => title) {
|
|
34
34
|
export function getDataFromPackage() {
|
35
35
|
const data = {};
|
36
36
|
try {
|
37
|
-
const filename =
|
37
|
+
const filename = searchInFolderHierarchy("package.json", process.cwd());
|
38
|
+
if (!filename) {
|
39
|
+
throw new Error("No se encontro el package.json en " + process.cwd());
|
40
|
+
}
|
38
41
|
const content = fs.readFileSync(filename, "utf8");
|
39
42
|
const packageJson = JSON.parse(content);
|
40
43
|
if (packageJson.repository) {
|
@@ -218,9 +221,9 @@ export function createConfigurationFile(taskName) {
|
|
218
221
|
return true;
|
219
222
|
});
|
220
223
|
}
|
221
|
-
export function
|
222
|
-
if (fs.existsSync(
|
223
|
-
const content = fs.readFileSync(
|
224
|
+
export function getConfigFile(file, variable, defaultValue) {
|
225
|
+
if (fs.existsSync(file)) {
|
226
|
+
const content = fs.readFileSync(file, "utf8");
|
224
227
|
try {
|
225
228
|
const config = JSON.parse(content);
|
226
229
|
if (config[variable]) {
|
@@ -233,6 +236,9 @@ export function getConfig(variable, defaultValue) {
|
|
233
236
|
}
|
234
237
|
return defaultValue;
|
235
238
|
}
|
239
|
+
export function getConfig(variable, defaultValue) {
|
240
|
+
return getConfigFile(CONFIG_FILE, variable, defaultValue);
|
241
|
+
}
|
236
242
|
export function storeConfig(record) {
|
237
243
|
let config = {};
|
238
244
|
if (fs.existsSync(CONFIG_FILE)) {
|
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.16",
|
6
6
|
"keywords": [
|
7
7
|
"Salesforce",
|
8
8
|
"Automation",
|
@@ -18,6 +18,7 @@
|
|
18
18
|
"commands/**/*",
|
19
19
|
"templates/**/*",
|
20
20
|
"lib/**/*",
|
21
|
+
".autoforce.json",
|
21
22
|
"bin/**/*"
|
22
23
|
],
|
23
24
|
"bin": {
|