autoforce 0.1.18 → 0.1.20

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.
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { execSync } from "child_process";
11
2
  import context, { ListFilters } from "./context.js";
12
3
  import { logError, logInfo } from "./color.js";
@@ -22,7 +13,7 @@ function generateTemplate(templateFolder, templateExtension, template, context)
22
13
  const formulas = {
23
14
  today: Date.now(),
24
15
  };
25
- const view = Object.assign(Object.assign({}, formulas), context);
16
+ const view = { ...formulas, ...context };
26
17
  templateEngine.read(template);
27
18
  templateEngine.render(view);
28
19
  return templateEngine.rendered;
@@ -36,7 +27,7 @@ function createTemplate(templateFolder, templateExtension, template, filename, f
36
27
  today: Date.now(),
37
28
  filename
38
29
  };
39
- const view = Object.assign(Object.assign({}, formulas), context);
30
+ const view = { ...formulas, ...context };
40
31
  templateEngine.read(template);
41
32
  templateEngine.render(view);
42
33
  templateEngine.save(filename, folder);
@@ -60,17 +51,15 @@ function convertArgsToString(args) {
60
51
  }
61
52
  return argsString;
62
53
  }
63
- export function executeCommand(step) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- try {
66
- context.set('command', step.command + ' ' + convertArgsToString(step.arguments));
67
- execSync(step.command + ' ' + convertArgsToString(step.arguments), { stdio: 'inherit' });
68
- return true;
69
- }
70
- catch (_a) {
71
- return false;
72
- }
73
- });
54
+ export async function executeCommand(step) {
55
+ try {
56
+ context.set('command', step.command + ' ' + convertArgsToString(step.arguments));
57
+ execSync(step.command + ' ' + convertArgsToString(step.arguments), { stdio: 'inherit' });
58
+ return true;
59
+ }
60
+ catch {
61
+ return false;
62
+ }
74
63
  }
75
64
  export function validateCommand(step) {
76
65
  if (step.command && typeof step.command == 'string') {
@@ -121,32 +110,28 @@ function createArray(fields, record) {
121
110
  }
122
111
  return fieldArray;
123
112
  }
124
- function askForContinue(message) {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- const answer = yield prompts([
127
- {
128
- type: "confirm",
129
- name: "continue",
130
- initial: true,
131
- message
132
- }
133
- ]);
134
- return answer.continue;
135
- });
113
+ async function askForContinue(message) {
114
+ const answer = await prompts([
115
+ {
116
+ type: "confirm",
117
+ name: "continue",
118
+ initial: true,
119
+ message
120
+ }
121
+ ]);
122
+ return answer.continue;
136
123
  }
137
- function askForCommitMessage() {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- const answer = yield prompts([
140
- {
141
- type: "text",
142
- name: "message",
143
- initial: "fix",
144
- validate: value => value.length > 0 ? true : "El mensaje es requerido",
145
- message: "Mensaje del commit"
146
- }
147
- ]);
148
- return answer.message;
149
- });
124
+ async function askForCommitMessage() {
125
+ const answer = await prompts([
126
+ {
127
+ type: "text",
128
+ name: "message",
129
+ initial: "fix",
130
+ validate: value => value.length > 0 ? true : "El mensaje es requerido",
131
+ message: "Mensaje del commit"
132
+ }
133
+ ]);
134
+ return answer.message;
150
135
  }
151
136
  export function getCurrentOrganization() {
152
137
  const salidaConfig = executeShell('sf config get target-org --json');
@@ -157,7 +142,7 @@ export function getCurrentOrganization() {
157
142
  for (const orgType in salidaOrgListJson.result) {
158
143
  for (const orgObject of salidaOrgListJson.result[orgType]) {
159
144
  if (orgObject.alias === targetOrg.value) {
160
- if ((orgObject === null || orgObject === void 0 ? void 0 : orgObject.isExpired) === true) {
145
+ if (orgObject?.isExpired === true) {
161
146
  throw new Error(`La scratch ${orgObject.alias} ha expirado!`);
162
147
  }
163
148
  return orgObject;
@@ -171,7 +156,7 @@ export function getOrganizationObject(alias, type = 'scratchOrgs') {
171
156
  const salida = executeShell('sf org list --json');
172
157
  const salidaJson = JSON.parse(salida);
173
158
  const orgObject = salidaJson.result[type].filter(scratch => scratch.alias === alias)[0];
174
- if ((orgObject === null || orgObject === void 0 ? void 0 : orgObject.isExpired) === true) {
159
+ if (orgObject?.isExpired === true) {
175
160
  throw new Error(`La scratch ${orgObject.alias} ha expirado!`);
176
161
  }
177
162
  return orgObject;
@@ -190,28 +175,26 @@ export function getBranchName() {
190
175
  }
191
176
  return '';
192
177
  }
193
- export function executeFunction(step) {
194
- return __awaiter(this, void 0, void 0, function* () {
195
- let returnValue = false;
196
- const functionName = step.function;
197
- if (typeof taskFunctions[functionName] === 'function') {
198
- if (step.arguments && typeof step.arguments === 'object') {
199
- let mergedArgs = context.mergeArgs(step.arguments);
200
- if (!Array.isArray(mergedArgs)) {
201
- const paramNames = getParams(taskFunctions[functionName]);
202
- mergedArgs = createArray(paramNames, mergedArgs);
203
- }
204
- returnValue = yield taskFunctions[functionName](...mergedArgs);
205
- }
206
- else {
207
- returnValue = yield taskFunctions[functionName]();
208
- }
178
+ export async function executeFunction(step) {
179
+ let returnValue = false;
180
+ const functionName = step.function;
181
+ if (typeof taskFunctions[functionName] === 'function') {
182
+ if (step.arguments && typeof step.arguments === 'object') {
183
+ let mergedArgs = context.mergeArgs(step.arguments);
184
+ if (!Array.isArray(mergedArgs)) {
185
+ const paramNames = getParams(taskFunctions[functionName]);
186
+ mergedArgs = createArray(paramNames, mergedArgs);
187
+ }
188
+ returnValue = await taskFunctions[functionName](...mergedArgs);
209
189
  }
210
190
  else {
211
- throw new Error(`No se encontro la funcion ${functionName}`);
191
+ returnValue = await taskFunctions[functionName]();
212
192
  }
213
- return returnValue;
214
- });
193
+ }
194
+ else {
195
+ throw new Error(`No se encontro la funcion ${functionName}`);
196
+ }
197
+ return returnValue;
215
198
  }
216
199
  export function executeShell(command) {
217
200
  try {
@@ -219,7 +202,7 @@ export function executeShell(command) {
219
202
  const salida = buffer.toString().trim();
220
203
  return (salida.endsWith("\n") ? salida.slice(0, -1) : salida);
221
204
  }
222
- catch (_a) {
205
+ catch {
223
206
  return '';
224
207
  }
225
208
  }
@@ -240,86 +223,74 @@ export const taskFunctions = {
240
223
  storeConfig({ [variable]: value });
241
224
  return true;
242
225
  },
243
- docProcess() {
244
- return __awaiter(this, void 0, void 0, function* () {
245
- if (!context.process) {
246
- return false;
247
- }
248
- const files = getFilesChanged();
249
- if (files.length > 0) {
250
- for (const component in metadata) {
251
- const helper = metadata[component];
252
- const items = helper.getItems(files);
253
- if (items.length > 0) {
254
- context.addProcessMetadata(component, items);
255
- helper.execute(items, context.process, context.module);
256
- }
226
+ async docProcess() {
227
+ if (!context.process) {
228
+ return false;
229
+ }
230
+ const files = getFilesChanged();
231
+ if (files.length > 0) {
232
+ for (const component in metadata) {
233
+ const helper = metadata[component];
234
+ const items = helper.getItems(files);
235
+ if (items.length > 0) {
236
+ context.addProcessMetadata(component, items);
237
+ helper.execute(items, context.process, context.module);
257
238
  }
258
239
  }
259
- return true;
260
- });
261
- },
262
- retrieveCode() {
263
- return __awaiter(this, void 0, void 0, function* () {
264
- const tryToRetrieve = yield askForContinue("Desea bajar los cambios?");
265
- if (!tryToRetrieve) {
266
- return false;
267
- }
268
- executeShell(`sf project retrieve start`);
269
- return yield this.validateScratch();
270
- });
240
+ }
241
+ return true;
271
242
  },
272
- validateScratch() {
273
- return __awaiter(this, void 0, void 0, function* () {
274
- const salida = executeShell("sf project retrieve preview");
275
- context.salida = salida;
276
- const noHayCambios = salida.indexOf('No files will be deleted') !== -1 && salida.indexOf('No files will be retrieved') !== -1 && salida.indexOf('No conflicts found') !== -1;
277
- // Probar de bajarlos // sf project retrieve start
278
- return noHayCambios;
279
- });
243
+ async retrieveCode() {
244
+ const tryToRetrieve = await askForContinue("Desea bajar los cambios?");
245
+ if (!tryToRetrieve) {
246
+ return false;
247
+ }
248
+ executeShell(`sf project retrieve start`);
249
+ return await this.validateScratch();
280
250
  },
281
- commitChanges() {
282
- return __awaiter(this, void 0, void 0, function* () {
283
- const tryToCommit = yield askForContinue("Desea commitear los cambios?");
284
- if (!tryToCommit) {
285
- return false;
286
- }
287
- const message = yield askForCommitMessage();
288
- executeShell(`git add --all`);
289
- executeShell(`git commit -m ${message}`);
290
- return yield this.checkCommitPending();
291
- });
251
+ async validateScratch() {
252
+ const salida = executeShell("sf project retrieve preview");
253
+ context.salida = salida;
254
+ const noHayCambios = salida.indexOf('No files will be deleted') !== -1 && salida.indexOf('No files will be retrieved') !== -1 && salida.indexOf('No conflicts found') !== -1;
255
+ // Probar de bajarlos // sf project retrieve start
256
+ return noHayCambios;
292
257
  },
293
- publishBranch() {
294
- return __awaiter(this, void 0, void 0, function* () {
295
- try {
296
- const branchName = context.branchName;
297
- const salida = executeShell(`git push origin ${branchName}`);
298
- return salida ? false : true;
299
- }
300
- catch (error) {
301
- console.log(error);
302
- }
303
- // mergeBranch
258
+ async commitChanges() {
259
+ const tryToCommit = await askForContinue("Desea commitear los cambios?");
260
+ if (!tryToCommit) {
304
261
  return false;
305
- });
262
+ }
263
+ const message = await askForCommitMessage();
264
+ executeShell(`git add --all`);
265
+ executeShell(`git commit -m ${message}`);
266
+ return await this.checkCommitPending();
306
267
  },
307
- createPullRequest() {
308
- return __awaiter(this, void 0, void 0, function* () {
309
- if (context.gitApi === undefined || context.branchName === undefined || context.issueNumber === undefined) {
310
- return false;
311
- }
312
- try {
313
- context.issueFromBranch(context.branchName);
314
- const result = yield context.gitApi.createPullRequest(context.branchName, `resolves #${context.issueNumber} `, 'AI not implemented yet');
315
- return result;
316
- }
317
- catch (error) {
318
- console.log(error);
319
- }
320
- // mergeBranch
268
+ async publishBranch() {
269
+ try {
270
+ const branchName = context.branchName;
271
+ const salida = executeShell(`git push origin ${branchName}`);
272
+ return salida ? false : true;
273
+ }
274
+ catch (error) {
275
+ console.log(error);
276
+ }
277
+ // mergeBranch
278
+ return false;
279
+ },
280
+ async createPullRequest() {
281
+ if (context.gitApi === undefined || context.branchName === undefined || context.issueNumber === undefined) {
321
282
  return false;
322
- });
283
+ }
284
+ try {
285
+ context.issueFromBranch(context.branchName);
286
+ const result = await context.gitApi.createPullRequest(context.branchName, `resolves #${context.issueNumber} `, 'AI not implemented yet');
287
+ return result;
288
+ }
289
+ catch (error) {
290
+ console.log(error);
291
+ }
292
+ // mergeBranch
293
+ return false;
323
294
  },
324
295
  cancelIssue() {
325
296
  console.log('Not implemented');
@@ -333,284 +304,257 @@ export const taskFunctions = {
333
304
  console.log('Not implemented');
334
305
  return false;
335
306
  },
336
- createIssue(title, label, body, milestone) {
337
- return __awaiter(this, void 0, void 0, function* () {
338
- if (context.projectApi === undefined || context.gitApi === undefined) {
339
- return false;
340
- }
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
- }
307
+ async createIssue(title, label, body, milestone) {
308
+ if (context.projectApi === undefined || context.gitApi === undefined) {
309
+ return false;
310
+ }
311
+ if (label === 'new') {
312
+ const answer = await prompts([
313
+ {
314
+ message: 'Nombre del Label',
315
+ name: 'nombre',
316
+ type: 'text'
354
317
  }
355
- else {
356
- label = '';
318
+ ]);
319
+ if (answer.nombre !== undefined) {
320
+ const result = await context.gitApi.createLabel(answer.nombre);
321
+ if (result?.id) {
322
+ label = result.id;
357
323
  }
358
324
  }
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 = '';
325
+ else {
326
+ label = '';
327
+ }
328
+ }
329
+ if (milestone === 'new') {
330
+ const answer = await prompts([
331
+ {
332
+ message: 'Nombre del Milestone',
333
+ name: 'nombre',
334
+ type: 'text'
373
335
  }
336
+ ]);
337
+ if (answer.nombre !== undefined) {
338
+ const result = await context.gitApi.createMilestone(answer.nombre);
339
+ milestone = result?.id;
374
340
  }
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
- // }
382
- return true;
341
+ else {
342
+ milestone = '';
383
343
  }
344
+ }
345
+ const issue = await context.projectApi.createIssue(title, context.backlogColumn, label, body, milestone);
346
+ if (issue) {
347
+ console.log(`Se creo el issue ${issue.number}`);
348
+ console.log(`${issue.url}`);
349
+ // if ( issue.milestone) {
350
+ // console.log(`Milestone ${issue.milestone.title} expira en ${issue.milestone.dueOn} `);
351
+ // }
352
+ return true;
353
+ }
354
+ return false;
355
+ },
356
+ async createTemplate(template, folder, name, identifier) {
357
+ const filename = name.toLocaleLowerCase().replaceAll(' ', '-') + '.md';
358
+ createTemplate('.', 'md', template, filename, folder, { name, identifier });
359
+ return true;
360
+ },
361
+ async validateIssue(issueNumber, states) {
362
+ if (context.projectApi === undefined) {
384
363
  return false;
385
- });
364
+ }
365
+ const issue = await context.projectApi.getIssue(issueNumber);
366
+ if (!issue.state) {
367
+ return false;
368
+ }
369
+ const arrayStates = states.toLocaleLowerCase().replace(' ', '').split(',');
370
+ return arrayStates.includes(issue.state.toLocaleLowerCase().replace(' ', ''));
386
371
  },
387
- createTemplate(template, folder, name, identifier) {
388
- return __awaiter(this, void 0, void 0, function* () {
389
- const filename = name.toLocaleLowerCase().replaceAll(' ', '-') + '.md';
390
- createTemplate('.', 'md', template, filename, folder, { name, identifier });
391
- return true;
392
- });
372
+ async validaNoseaBranchActual(newBranchName) {
373
+ return getBranchName() !== newBranchName;
393
374
  },
394
- validateIssue(issueNumber, states) {
395
- return __awaiter(this, void 0, void 0, function* () {
396
- if (context.projectApi === undefined) {
397
- return false;
398
- }
399
- const issue = yield context.projectApi.getIssue(issueNumber);
400
- if (!issue.state) {
401
- return false;
402
- }
403
- const arrayStates = states.toLocaleLowerCase().replace(' ', '').split(',');
404
- return arrayStates.includes(issue.state.toLocaleLowerCase().replace(' ', ''));
405
- });
375
+ async checkCommitPending() {
376
+ try {
377
+ const cambios = executeShell("git status --porcelain=v1");
378
+ context.salida = cambios;
379
+ return cambios == '';
380
+ }
381
+ catch (error) {
382
+ console.log(error);
383
+ }
384
+ return false;
406
385
  },
407
- validaNoseaBranchActual(newBranchName) {
408
- return __awaiter(this, void 0, void 0, function* () {
409
- return getBranchName() !== newBranchName;
410
- });
386
+ async createBranch() {
387
+ try {
388
+ const newBranchName = context.newBranchName;
389
+ executeShell(`git checkout -b ${newBranchName} origin/main`);
390
+ context.set('branchName', getBranchName());
391
+ return true;
392
+ }
393
+ catch (error) {
394
+ console.log(error);
395
+ }
396
+ // mergeBranch
397
+ return false;
411
398
  },
412
- checkCommitPending() {
413
- return __awaiter(this, void 0, void 0, function* () {
414
- try {
415
- const cambios = executeShell("git status --porcelain=v1");
416
- context.salida = cambios;
417
- return cambios == '';
418
- }
419
- catch (error) {
420
- console.log(error);
421
- }
422
- return false;
423
- });
399
+ async mergeBranch() {
400
+ try {
401
+ executeShell(`git fetch`);
402
+ executeShell(`git merge origin/main`);
403
+ return true;
404
+ }
405
+ catch (error) {
406
+ console.log(error);
407
+ }
408
+ return false;
424
409
  },
425
- createBranch() {
426
- return __awaiter(this, void 0, void 0, function* () {
427
- try {
428
- const newBranchName = context.newBranchName;
429
- executeShell(`git checkout -b ${newBranchName} origin/main`);
430
- context.set('branchName', getBranchName());
431
- return true;
432
- }
433
- catch (error) {
434
- console.log(error);
435
- }
436
- // mergeBranch
410
+ async moveIssue(issueNumber, state) {
411
+ if (context.projectApi === undefined) {
437
412
  return false;
438
- });
413
+ }
414
+ const result = await context.projectApi.moveIssue(issueNumber, state);
415
+ return result;
439
416
  },
440
- mergeBranch() {
441
- return __awaiter(this, void 0, void 0, function* () {
442
- try {
443
- executeShell(`git fetch`);
444
- executeShell(`git merge origin/main`);
445
- return true;
446
- }
447
- catch (error) {
448
- console.log(error);
449
- }
417
+ async assignBranchToIssue(issueNumber, newBranchName) {
418
+ if (context.gitApi === undefined) {
450
419
  return false;
451
- });
452
- },
453
- moveIssue(issueNumber, state) {
454
- return __awaiter(this, void 0, void 0, function* () {
455
- if (context.projectApi === undefined) {
456
- return false;
457
- }
458
- const result = yield context.projectApi.moveIssue(issueNumber, state);
459
- return result;
460
- });
461
- },
462
- assignBranchToIssue(issueNumber, newBranchName) {
463
- return __awaiter(this, void 0, void 0, function* () {
464
- if (context.gitApi === undefined) {
465
- return false;
466
- }
467
- const commitSha = executeShell(`git rev-parse --verify main`);
468
- const result = yield context.gitApi.assignBranchToIssue(issueNumber, newBranchName, commitSha);
469
- return result;
470
- });
420
+ }
421
+ const commitSha = executeShell(`git rev-parse --verify main`);
422
+ const result = await context.gitApi.assignBranchToIssue(issueNumber, newBranchName, commitSha);
423
+ return result;
471
424
  },
472
- assignIssueToMe(issueNumber) {
473
- return __awaiter(this, void 0, void 0, function* () {
474
- if (!context.projectApi) {
475
- return false;
476
- }
477
- const result = yield context.projectApi.assignIssueToMe(issueNumber);
478
- return result;
479
- });
425
+ async assignIssueToMe(issueNumber) {
426
+ if (!context.projectApi) {
427
+ return false;
428
+ }
429
+ const result = await context.projectApi.assignIssueToMe(issueNumber);
430
+ return result;
480
431
  },
481
- viewIssue(issueNumber_1) {
482
- return __awaiter(this, arguments, void 0, function* (issueNumber, template = 'viewIssue') {
483
- if (!context.projectApi) {
484
- return false;
485
- }
486
- const result = yield context.projectApi.getIssue(issueNumber);
487
- const rendered = generateTemplate(getModelFolders('templates'), 'bash', template, Object.assign({ issue: result }, context));
488
- console.log(rendered);
489
- return true;
490
- });
432
+ async viewIssue(issueNumber, template = 'viewIssue') {
433
+ if (!context.projectApi) {
434
+ return false;
435
+ }
436
+ const result = await context.projectApi.getIssue(issueNumber);
437
+ const rendered = generateTemplate(getModelFolders('templates'), 'bash', template, { issue: result, ...context });
438
+ console.log(rendered);
439
+ return true;
491
440
  },
492
- listIssues(listFilter, listTemplate) {
493
- return __awaiter(this, void 0, void 0, function* () {
494
- let filter = '{states: OPEN}';
495
- const extension = '*';
496
- if (!listFilter) {
497
- listFilter = context.options.filter || context.listFilter;
498
- }
499
- if (!listTemplate) {
500
- listTemplate = context.options.template || context.listTemplate;
501
- }
502
- if (!context.projectApi || !context.gitApi) {
503
- return false;
441
+ async listIssues(listFilter, listTemplate) {
442
+ let filter = '{states: OPEN}';
443
+ const extension = '*';
444
+ if (!listFilter) {
445
+ listFilter = context.options.filter || context.listFilter;
446
+ }
447
+ if (!listTemplate) {
448
+ listTemplate = context.options.template || context.listTemplate;
449
+ }
450
+ if (!context.projectApi || !context.gitApi) {
451
+ return false;
452
+ }
453
+ if (!listFilter) {
454
+ const answer = await prompts([
455
+ {
456
+ message: 'Elija un filtro, o bien lo puede dejar fijo en autoforce como listFilter',
457
+ name: 'filter',
458
+ type: 'select',
459
+ initial: 0,
460
+ choices: context.listFilters
461
+ }
462
+ ]);
463
+ listFilter = answer.filter;
464
+ }
465
+ if (listFilter === ListFilters.PorMilestone) {
466
+ if (context.options.milestone) {
467
+ const milestoneFilter = (await context.gitApi.getMilestones()).filter(milestone => milestone.title == context.options.milestone);
468
+ if (milestoneFilter.length === 0) {
469
+ return false;
470
+ }
471
+ filter = `{ milestoneNumber: "${milestoneFilter[0].number}"}`;
504
472
  }
505
- if (!listFilter) {
506
- const answer = yield prompts([
473
+ else {
474
+ const choices = (await context.gitApi.getMilestones()).map(milestone => { return { value: milestone.number, title: milestone.title }; });
475
+ choices.push({ value: '', title: 'Issues sin Milestone' });
476
+ choices.push({ value: '*', title: 'Issues con Milestone' });
477
+ const answer = await prompts([
507
478
  {
508
- message: 'Elija un filtro, o bien lo puede dejar fijo en autoforce como listFilter',
509
- name: 'filter',
479
+ message: 'Elija un milestone',
480
+ name: 'filterValue',
510
481
  type: 'select',
511
482
  initial: 0,
512
- choices: context.listFilters
483
+ choices
513
484
  }
514
485
  ]);
515
- listFilter = answer.filter;
516
- }
517
- if (listFilter === ListFilters.PorMilestone) {
518
- if (context.options.milestone) {
519
- const milestoneFilter = (yield context.gitApi.getMilestones()).filter(milestone => milestone.title == context.options.milestone);
520
- if (milestoneFilter.length === 0) {
521
- return false;
522
- }
523
- filter = `{ milestoneNumber: "${milestoneFilter[0].number}"}`;
524
- }
525
- else {
526
- const choices = (yield context.gitApi.getMilestones()).map(milestone => { return { value: milestone.number, title: milestone.title }; });
527
- choices.push({ value: '', title: 'Issues sin Milestone' });
528
- choices.push({ value: '*', title: 'Issues con Milestone' });
529
- const answer = yield prompts([
530
- {
531
- message: 'Elija un milestone',
532
- name: 'filterValue',
533
- type: 'select',
534
- initial: 0,
535
- choices
536
- }
537
- ]);
538
- filter = `{ milestoneNumber: "${answer.filterValue}"}`;
539
- if (answer.filterValue === undefined)
540
- return false;
541
- }
486
+ filter = `{ milestoneNumber: "${answer.filterValue}"}`;
487
+ if (answer.filterValue === undefined)
488
+ return false;
542
489
  }
543
- if (listFilter === ListFilters.PorLabel) {
544
- if (context.options.label) {
545
- filter = `{labels: "${context.options.label}"}`;
546
- }
547
- else {
548
- const labels = (yield context.gitApi.getLabels()).map(label => label.name);
549
- const choices = valuesToChoices(labels);
550
- const answer = yield prompts([
551
- {
552
- message: 'Elija un label',
553
- name: 'filterValue',
554
- type: 'select',
555
- initial: 0,
556
- choices
557
- }
558
- ]);
559
- if (answer.filterValue === undefined)
560
- return false;
561
- filter = `{labels: "${answer.filterValue}"}`;
562
- }
490
+ }
491
+ if (listFilter === ListFilters.PorLabel) {
492
+ if (context.options.label) {
493
+ filter = `{labels: "${context.options.label}"}`;
563
494
  }
564
- if (!listTemplate) {
565
- const files = getFilesInFolders(getModelFolders('templates'), filterBash).map(filename => filename.split(".")[0]);
566
- const templates = valuesToChoices(files);
567
- const answer = yield prompts([
495
+ else {
496
+ const labels = (await context.gitApi.getLabels()).map(label => label.name);
497
+ const choices = valuesToChoices(labels);
498
+ const answer = await prompts([
568
499
  {
569
- message: 'Elija un template, o bien lo puede dejar en autoforce como listTemplate',
570
- name: 'template',
500
+ message: 'Elija un label',
501
+ name: 'filterValue',
571
502
  type: 'select',
572
503
  initial: 0,
573
- choices: templates
504
+ choices
574
505
  }
575
506
  ]);
576
- listTemplate = answer.template;
577
- if (listTemplate === undefined)
507
+ if (answer.filterValue === undefined)
578
508
  return false;
509
+ filter = `{labels: "${answer.filterValue}"}`;
579
510
  }
580
- const result = yield context.projectApi.getIssuesWithFilter(filter);
581
- console.log(context.version);
582
- const rendered = generateTemplate(getModelFolders('templates'), extension, listTemplate, { issues: result, context });
583
- console.log(rendered);
584
- return true;
585
- });
586
- },
587
- checkIssueType(issueNumber) {
588
- return __awaiter(this, void 0, void 0, function* () {
589
- var _a;
590
- if (!context.projectApi) {
511
+ }
512
+ if (!listTemplate) {
513
+ const files = getFilesInFolders(getModelFolders('templates'), filterBash).map(filename => filename.split(".")[0]);
514
+ const templates = valuesToChoices(files);
515
+ const answer = await prompts([
516
+ {
517
+ message: 'Elija un template, o bien lo puede dejar en autoforce como listTemplate',
518
+ name: 'template',
519
+ type: 'select',
520
+ initial: 0,
521
+ choices: templates
522
+ }
523
+ ]);
524
+ listTemplate = answer.template;
525
+ if (listTemplate === undefined)
591
526
  return false;
592
- }
593
- const issue = yield context.projectApi.getIssue(issueNumber);
594
- // Setea el issueType segun el issue
595
- try {
596
- let newIssueType = 'feature';
597
- if (issue.labels && ((_a = issue.labels) === null || _a === void 0 ? void 0 : _a.length) > 0) {
598
- if (issue.labels.includes('documentation')) {
599
- newIssueType = 'doc';
600
- }
601
- else if (issue.labels.includes('automation')) {
602
- newIssueType = 'automation';
603
- }
604
- else if (issue.labels.includes('bug')) {
605
- newIssueType = 'fix';
606
- }
527
+ }
528
+ const result = await context.projectApi.getIssuesWithFilter(filter);
529
+ console.log(context.version);
530
+ const rendered = generateTemplate(getModelFolders('templates'), extension, listTemplate, { issues: result, context });
531
+ console.log(rendered);
532
+ return true;
533
+ },
534
+ async checkIssueType(issueNumber) {
535
+ if (!context.projectApi) {
536
+ return false;
537
+ }
538
+ const issue = await context.projectApi.getIssue(issueNumber);
539
+ // Setea el issueType segun el issue
540
+ try {
541
+ let newIssueType = 'feature';
542
+ if (issue.labels && issue.labels?.length > 0) {
543
+ if (issue.labels.includes('documentation')) {
544
+ newIssueType = 'doc';
545
+ }
546
+ else if (issue.labels.includes('automation')) {
547
+ newIssueType = 'automation';
548
+ }
549
+ else if (issue.labels.includes('bug')) {
550
+ newIssueType = 'fix';
607
551
  }
608
- context.newIssueType = newIssueType;
609
- }
610
- catch (error) {
611
- console.log(error);
612
552
  }
613
- return true;
614
- });
553
+ context.newIssueType = newIssueType;
554
+ }
555
+ catch (error) {
556
+ console.log(error);
557
+ }
558
+ return true;
615
559
  }
616
560
  };