autoforce 0.1.18 → 0.1.19

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.
@@ -5,5 +5,5 @@ export declare function getTasks(command?: string): Record<string, ITask>;
5
5
  export declare function helpTask(task: ITask): Promise<boolean>;
6
6
  export declare function validateTask(task: ITask): boolean;
7
7
  export declare function runTask(task: ITask, taskContext: CommandOptions, tabs?: string): Promise<boolean>;
8
- export declare function previewTask(task: ITask, tabs?: string): Promise<void>;
8
+ export declare function previewTask(task: ITask, taskContext: CommandOptions, tabs?: string): Promise<boolean>;
9
9
  export declare function createObject(fields: ObjectRecord, values: AnyValue[]): ObjectRecord;
@@ -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 context, { initializeContext } from "./context.js";
11
2
  import { logError, logStep } from "./color.js";
12
3
  import { getModelFolders, getFiles, filterJson, readJsonSync } from "./util.js";
@@ -40,7 +31,7 @@ export function getTasks(command = 'tasks') {
40
31
  }
41
32
  function mergeTask(newTask, oldTask) {
42
33
  const newSteps = newTask.steps ? [...newTask.steps, ...oldTask.steps] : oldTask.steps;
43
- const newArguments = newTask.arguments ? Object.assign(Object.assign({}, newTask.arguments), oldTask.arguments) : oldTask.arguments;
34
+ const newArguments = newTask.arguments ? { ...newTask.arguments, ...oldTask.arguments } : oldTask.arguments;
44
35
  const newGuards = newTask.guards ? [...newTask.guards, ...oldTask.guards] : oldTask.guards;
45
36
  const newVerbose = newTask.verbose || oldTask.verbose;
46
37
  const newDescription = newTask.description ? newTask.description + ' ' + oldTask.description : oldTask.description;
@@ -67,14 +58,12 @@ function isCriteriaMet(criteria) {
67
58
  const result = context[field] == value;
68
59
  return result;
69
60
  }
70
- export function helpTask(task) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- console.log('Nombre:', task.name);
73
- console.log('Descripcion:', task.description);
74
- console.log('Guards:', task.guards);
75
- console.log('Argumentos:', task.arguments);
76
- return true;
77
- });
61
+ export async function helpTask(task) {
62
+ console.log('Nombre:', task.name);
63
+ console.log('Descripcion:', task.description);
64
+ console.log('Guards:', task.guards);
65
+ console.log('Argumentos:', task.arguments);
66
+ return true;
78
67
  }
79
68
  export function validateTask(task) {
80
69
  initializeContext();
@@ -113,46 +102,43 @@ export function validateTask(task) {
113
102
  }
114
103
  return true;
115
104
  }
116
- export function runTask(task_1, taskContext_1) {
117
- return __awaiter(this, arguments, void 0, function* (task, taskContext, tabs = '') {
118
- initializeContext();
119
- // Valida que este ya esten las variables de enotorno y configuracion
120
- if (task.guards) {
121
- yield context.validate(task.guards);
122
- }
123
- // Pide datos de entrada y los deja en context
124
- if (task.arguments) {
125
- if (taskContext) {
126
- context.setObject(taskContext);
127
- }
128
- yield context.askForArguments(task.arguments);
129
- }
130
- if (task.verbose) {
131
- logStep(`[INICIO] ${task.name}`, tabs);
105
+ export async function runTask(task, taskContext, tabs = '') {
106
+ initializeContext();
107
+ // Valida que este ya esten las variables de enotorno y configuracion
108
+ if (task.guards) {
109
+ await context.validate(task.guards);
110
+ }
111
+ // Pide datos de entrada y los deja en context
112
+ if (task.arguments) {
113
+ if (taskContext) {
114
+ context.setObject(taskContext);
132
115
  }
133
- for (const step of task.steps) {
134
- if (isCriteriaMet(step.criteria)) {
135
- if (!(yield executeStep(step, tabs + '\t', task.verbose))) {
136
- return false;
137
- }
116
+ await context.askForArguments(task.arguments);
117
+ }
118
+ if (task.verbose) {
119
+ logStep(`[INICIO] ${task.name}`, tabs);
120
+ }
121
+ for (const step of task.steps) {
122
+ if (isCriteriaMet(step.criteria)) {
123
+ if (!await executeStep(step, tabs + '\t', task.verbose)) {
124
+ return false;
138
125
  }
139
126
  }
140
- if (task.verbose) {
141
- logStep(`[FIN] ${task.name}`, tabs);
142
- }
143
- return true;
144
- });
127
+ }
128
+ if (task.verbose) {
129
+ logStep(`[FIN] ${task.name}`, tabs);
130
+ }
131
+ return true;
145
132
  }
146
- export function previewTask(task_1) {
147
- return __awaiter(this, arguments, void 0, function* (task, tabs = '') {
148
- initializeContext();
149
- logStep(`${task.name}: ${task.description}`, tabs);
150
- for (const step of task.steps) {
151
- previewStep(step, tabs);
152
- }
153
- });
133
+ export async function previewTask(task, taskContext, tabs = '') {
134
+ initializeContext();
135
+ logStep(`${task.name}: ${task.description}`, tabs);
136
+ for (const step of task.steps) {
137
+ previewStep(step, taskContext, tabs);
138
+ }
139
+ return true;
154
140
  }
155
- function previewStep(step, tabs = '') {
141
+ function previewStep(step, taskContext, tabs = '') {
156
142
  if (step.criteria) {
157
143
  logStep(`Si ${step.criteria.field} ${step.criteria.operator || '=='} ${step.criteria.value}`, tabs);
158
144
  tabs += '\t';
@@ -160,7 +146,7 @@ function previewStep(step, tabs = '') {
160
146
  if (step.subtask) {
161
147
  tabs += '\t';
162
148
  const subtask = getTask(step.subtask, 'subtasks');
163
- previewTask(subtask, tabs);
149
+ previewTask(subtask, taskContext, tabs);
164
150
  }
165
151
  else {
166
152
  logStep(`${step.name}`, tabs);
@@ -177,83 +163,77 @@ export function createObject(fields, values) {
177
163
  }
178
164
  return argsObject;
179
165
  }
180
- function runStep(step, tabs) {
181
- return __awaiter(this, void 0, void 0, function* () {
182
- if (typeof step.command === 'string') {
183
- return executeCommand(step);
184
- }
185
- else if (typeof step.function === 'string') {
186
- return yield executeFunction(step);
187
- }
188
- else if (typeof step.subtask === 'string' || typeof step.task === 'string') {
189
- const subtask = typeof step.subtask === 'string' ? getTask(step.subtask, 'subtask') : getTask(step.task, 'tasks');
190
- let stepContext = step.arguments ? context.mergeArgs(step.arguments) : {};
191
- if (Array.isArray(stepContext)) {
192
- stepContext = createObject(subtask.arguments, stepContext);
193
- }
194
- return yield runTask(subtask, stepContext, tabs);
166
+ async function runStep(step, tabs) {
167
+ if (typeof step.command === 'string') {
168
+ return executeCommand(step);
169
+ }
170
+ else if (typeof step.function === 'string') {
171
+ return await executeFunction(step);
172
+ }
173
+ else if (typeof step.subtask === 'string' || typeof step.task === 'string') {
174
+ const subtask = typeof step.subtask === 'string' ? getTask(step.subtask, 'subtask') : getTask(step.task, 'tasks');
175
+ let stepContext = step.arguments ? context.mergeArgs(step.arguments) : {};
176
+ if (Array.isArray(stepContext)) {
177
+ stepContext = createObject(subtask.arguments, stepContext);
195
178
  }
196
- throw new Error(`No se pudo ejecutar el step ${step.name} porque no tiene command, function o subtasks`);
197
- });
179
+ return await runTask(subtask, stepContext, tabs);
180
+ }
181
+ throw new Error(`No se pudo ejecutar el step ${step.name} porque no tiene command, function o subtasks`);
198
182
  }
199
- function askForContinueOrRetry() {
200
- return __awaiter(this, void 0, void 0, function* () {
201
- if (!context.isVerbose) {
202
- return 'quit';
183
+ async function askForContinueOrRetry() {
184
+ if (!context.isVerbose) {
185
+ return 'quit';
186
+ }
187
+ const answer = await prompts([
188
+ {
189
+ type: "select",
190
+ name: "continue",
191
+ message: "No se pudo ejecutar el step, ¿que quiere hacer? ",
192
+ choices: [{ title: 'Salir', value: 'quit' }, { title: 'Continuar', value: 'continue' }, { title: 'Reintentar', value: 'retry' }],
203
193
  }
204
- const answer = yield prompts([
205
- {
206
- type: "select",
207
- name: "continue",
208
- message: "No se pudo ejecutar el step, ¿que quiere hacer? ",
209
- choices: [{ title: 'Salir', value: 'quit' }, { title: 'Continuar', value: 'continue' }, { title: 'Reintentar', value: 'retry' }],
210
- }
211
- ]);
212
- return answer.continue;
213
- });
194
+ ]);
195
+ return answer.continue;
214
196
  }
215
197
  function getStepError(step, stepName) {
216
198
  return step.errorMessage ? context.merge(step.errorMessage) : stepName ? `Fallo el step ${stepName}` : '';
217
199
  }
218
- function executeStep(step_1, tabs_1) {
219
- return __awaiter(this, arguments, void 0, function* (step, tabs, verbose = false) {
220
- const stepName = step.name ? context.merge(step.name) : undefined;
221
- if (verbose && stepName) {
222
- logStep(`[INICIO] ${stepName}`, tabs);
223
- }
224
- let retry = false;
225
- let success = false;
226
- do {
227
- try {
228
- success = yield runStep(step, tabs);
229
- if (!success) {
230
- logError(getStepError(step, stepName), tabs);
231
- // Si tiene un custom handler cuando hay un error
232
- if (step.onError) {
233
- const errorHandler = taskFunctions[step.onError];
234
- if (typeof errorHandler === 'function') {
235
- success = yield errorHandler();
236
- }
200
+ async function executeStep(step, tabs, verbose = false) {
201
+ const stepName = step.name ? context.merge(step.name) : undefined;
202
+ if (verbose && stepName) {
203
+ logStep(`[INICIO] ${stepName}`, tabs);
204
+ }
205
+ let retry = false;
206
+ let success = false;
207
+ do {
208
+ try {
209
+ success = await runStep(step, tabs);
210
+ if (!success) {
211
+ logError(getStepError(step, stepName), tabs);
212
+ // Si tiene un custom handler cuando hay un error
213
+ if (step.onError) {
214
+ const errorHandler = taskFunctions[step.onError];
215
+ if (typeof errorHandler === 'function') {
216
+ success = await errorHandler();
237
217
  }
238
218
  }
239
219
  }
240
- catch (error) {
241
- if (error instanceof Error) {
242
- logError(error.message, tabs);
243
- }
244
- }
245
- if (!success) {
246
- const result = yield askForContinueOrRetry();
247
- retry = result == 'retry';
248
- success = result == 'continue';
220
+ }
221
+ catch (error) {
222
+ if (error instanceof Error) {
223
+ logError(error.message, tabs);
249
224
  }
250
- } while (!success && retry);
251
- if (verbose && stepName) {
252
- logStep(`[FIN] ${stepName}`, tabs);
253
225
  }
254
226
  if (!success) {
255
- process.exit(!context.isVerbose ? -1 : 0);
227
+ const result = await askForContinueOrRetry();
228
+ retry = result == 'retry';
229
+ success = result == 'continue';
256
230
  }
257
- return success;
258
- });
231
+ } while (!success && retry);
232
+ if (verbose && stepName) {
233
+ logStep(`[FIN] ${stepName}`, tabs);
234
+ }
235
+ if (!success) {
236
+ process.exit(!context.isVerbose ? -1 : 0);
237
+ }
238
+ return success;
259
239
  }
@@ -23,6 +23,10 @@ function openTemplate(sourceFolder, templateName, extension) {
23
23
  return content;
24
24
  }
25
25
  export class TemplateEngine {
26
+ _template;
27
+ _rendered;
28
+ _extension;
29
+ _sourceFolders;
26
30
  constructor(sources, extension = '*') {
27
31
  this._sourceFolders = sources;
28
32
  this._extension = extension;
@@ -18,7 +18,6 @@ export declare function titlesToChoices(list: string[], titleToValue?: (title: s
18
18
  title: string;
19
19
  value: string;
20
20
  }[];
21
- export declare function getDataFromPackage(): Record<string, string>;
22
21
  export declare function findChoicesPosition(choices: Choice[], value: string): number;
23
22
  export declare function getFilesInFolders(folders: string[], filter: (fullPath: string) => boolean, recursive?: boolean, ignoreList?: string[]): string[];
24
23
  export declare function getModelFolders(subfolder: string): string[];
@@ -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 fs from "fs";
11
2
  import { fileURLToPath } from 'url';
12
3
  import prompts from "prompts";
@@ -29,48 +20,6 @@ export function valuesToChoices(list, valueToTitle = (value) => value) {
29
20
  export function titlesToChoices(list, titleToValue = (title) => title) {
30
21
  return list.map(title => { return { title, value: titleToValue(title) }; });
31
22
  }
32
- export function getDataFromPackage() {
33
- const data = {};
34
- try {
35
- const filename = searchInFolderHierarchy("package.json", process.cwd());
36
- if (!filename) {
37
- throw new Error("No se encontro el package.json en " + process.cwd());
38
- }
39
- const content = fs.readFileSync(filename, "utf8");
40
- const packageJson = JSON.parse(content);
41
- if (packageJson.repository) {
42
- if (packageJson.repository.url) {
43
- data.repositoryUrl = packageJson.repository.url;
44
- data.repositoryType = packageJson.repository.type;
45
- // Ver de sacar repo y owner
46
- if (data.repositoryUrl) {
47
- if (data.repositoryUrl.includes("github.com")) {
48
- const repositoryArray = data.repositoryUrl.split('github.com/');
49
- [data.repositoryOwner, data.repositoryRepo] = repositoryArray[1].split('/');
50
- }
51
- if (data.repositoryUrl.includes("gitlab.com")) {
52
- const repositoryArray = data.repositoryUrl.split('gitlab.com/');
53
- [data.repositoryOwner, data.repositoryRepo] = repositoryArray[1].split('/');
54
- }
55
- }
56
- }
57
- else if (typeof packageJson.repository === 'string') {
58
- data.repositoryUrl = packageJson.repository;
59
- const repositoryArray = data.repositoryUrl.split(':');
60
- data.repositoryType = repositoryArray[0];
61
- [data.repositoryOwner, data.repositoryRepo] = repositoryArray[1].split('/');
62
- }
63
- if (data.repositoryRepo && data.repositoryRepo.endsWith('.git')) {
64
- data.repositoryRepo = data.repositoryRepo.replace('.git', '');
65
- }
66
- }
67
- }
68
- catch (error) {
69
- console.log(error);
70
- throw new Error(`Verifique que exista y sea valido el package.json`);
71
- }
72
- return data;
73
- }
74
23
  export function findChoicesPosition(choices, value) {
75
24
  const index = choices.findIndex(choice => choice.value === value);
76
25
  return index === -1 ? 0 : index;
@@ -96,127 +45,121 @@ export function getModelFolders(subfolder) {
96
45
  function getTemplates(filter) {
97
46
  return getFilesInFolders(getModelFolders('templates'), filter);
98
47
  }
99
- function getTaskConfig(config) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- // TODO: Ver si esto se mueve a un config list
102
- // List Command settings
103
- const filters = context.listFilters();
104
- const listFilter = yield prompts([
48
+ async function getTaskConfig(config) {
49
+ // TODO: Ver si esto se mueve a un config list
50
+ // List Command settings
51
+ const filters = context.listFilters();
52
+ const listFilter = await prompts([
53
+ {
54
+ message: 'Elija un filtro, o bien lo puede dejar fijo en autoforce como listFilter',
55
+ name: 'filter',
56
+ type: 'select',
57
+ initial: findChoicesPosition(filters, config.listFilter),
58
+ choices: filters
59
+ }
60
+ ]);
61
+ if (listFilter.filter === undefined)
62
+ return;
63
+ config.listFilter = listFilter.filter;
64
+ const files = getTemplates(filterBash).map(filename => filename.split(".")[0]);
65
+ if (files.length > 0) {
66
+ const templates = valuesToChoices(files);
67
+ const template = await prompts([
105
68
  {
106
- message: 'Elija un filtro, o bien lo puede dejar fijo en autoforce como listFilter',
107
- name: 'filter',
69
+ message: 'Elija un template, o bien lo puede dejar en autoforce como listTemplate',
70
+ name: 'template',
108
71
  type: 'select',
109
- initial: findChoicesPosition(filters, config.listFilter),
110
- choices: filters
72
+ initial: findChoicesPosition(templates, config.listTemplate),
73
+ choices: templates
111
74
  }
112
75
  ]);
113
- if (listFilter.filter === undefined)
76
+ if (template.template === undefined)
114
77
  return;
115
- config.listFilter = listFilter.filter;
116
- const files = getTemplates(filterBash).map(filename => filename.split(".")[0]);
117
- if (files.length > 0) {
118
- const templates = valuesToChoices(files);
119
- const template = yield prompts([
120
- {
121
- message: 'Elija un template, o bien lo puede dejar en autoforce como listTemplate',
122
- name: 'template',
123
- type: 'select',
124
- initial: findChoicesPosition(templates, config.listTemplate),
125
- choices: templates
126
- }
127
- ]);
128
- if (template.template === undefined)
129
- return;
130
- config.listTemplate = template.template;
131
- }
132
- return config;
133
- });
78
+ config.listTemplate = template.template;
79
+ }
80
+ return config;
134
81
  }
135
- function getBaseConfig(config) {
136
- return __awaiter(this, void 0, void 0, function* () {
137
- // Todo: Chequear el repoOwner y repo
138
- const gitChoices = [{ title: 'Github', value: GitServices.GitHub }, { title: 'Gitlab', value: GitServices.GitLab }];
139
- // Preguntar por GitHub o GitLab
140
- const gitServices = yield prompts([{
141
- type: "select",
142
- name: "git",
143
- message: "Elija un servicio de Git",
144
- initial: findChoicesPosition(gitChoices, config.gitServices),
145
- choices: gitChoices
146
- }]);
147
- if (gitServices.git === undefined)
148
- process.exit(0);
149
- config.gitServices = gitServices.git;
150
- // Chequear las variables de entorno
151
- if (gitServices.git === GitServices.GitHub && !process.env.GITHUB_TOKEN) {
152
- logWarning('A fin de que la herramienta funcione debe configurar una variable de entorno GITHUB_TOKEN');
153
- }
154
- if (gitServices.git === GitServices.GitLab && !process.env.GITLAB_TOKEN) {
155
- logWarning('A fin de que la herramienta funcione debe configurar una variable de entorno GITLAB_TOKEN');
156
- }
157
- // Selecciona los modelos de automatizacion
158
- for (const prefix of ['dev', 'git', 'doc', 'project']) {
159
- const contextProperty = prefix + 'Model';
160
- const models = readJsonSync(`${MODELS_FOLDER}/${prefix}/models.json`);
161
- const automationModel = yield prompts([{
162
- type: "select",
163
- name: "model",
164
- message: `Elija un modelo de automatizacion para ${prefix}`,
165
- initial: findChoicesPosition(models, config[contextProperty]),
166
- choices: models
167
- }]);
168
- if (automationModel.model === undefined)
169
- return;
170
- config[contextProperty] = automationModel.model;
171
- }
172
- // Gestion del Proyecto
173
- const projectChoices = [{ title: 'Github Projects', value: ProjectServices.GitHub }, { title: 'GitLab Projects', value: ProjectServices.GitLab }, { title: 'Jira', value: ProjectServices.Jira }, { title: 'None', value: ProjectServices.None }];
174
- const projectServices = yield prompts([{
82
+ async function getBaseConfig(config) {
83
+ // Todo: Chequear el repoOwner y repo
84
+ const gitChoices = [{ title: 'Github', value: GitServices.GitHub }, { title: 'Gitlab', value: GitServices.GitLab }];
85
+ // Preguntar por GitHub o GitLab
86
+ const gitServices = await prompts([{
87
+ type: "select",
88
+ name: "git",
89
+ message: "Elija un servicio de Git",
90
+ initial: findChoicesPosition(gitChoices, config.gitServices),
91
+ choices: gitChoices
92
+ }]);
93
+ if (gitServices.git === undefined)
94
+ process.exit(0);
95
+ config.gitServices = gitServices.git;
96
+ // Chequear las variables de entorno
97
+ if (gitServices.git === GitServices.GitHub && !process.env.GITHUB_TOKEN) {
98
+ logWarning('A fin de que la herramienta funcione debe configurar una variable de entorno GITHUB_TOKEN');
99
+ }
100
+ if (gitServices.git === GitServices.GitLab && !process.env.GITLAB_TOKEN) {
101
+ logWarning('A fin de que la herramienta funcione debe configurar una variable de entorno GITLAB_TOKEN');
102
+ }
103
+ // Selecciona los modelos de automatizacion
104
+ for (const prefix of ['dev', 'git', 'doc', 'project']) {
105
+ const contextProperty = prefix + 'Model';
106
+ const models = readJsonSync(`${MODELS_FOLDER}/${prefix}/models.json`);
107
+ const automationModel = await prompts([{
175
108
  type: "select",
176
- name: "project",
177
- message: "Gestion de proyecto",
178
- initial: findChoicesPosition(projectChoices, config.projectServices),
179
- choices: projectChoices
109
+ name: "model",
110
+ message: `Elija un modelo de automatizacion para ${prefix}`,
111
+ initial: findChoicesPosition(models, config[contextProperty]),
112
+ choices: models
180
113
  }]);
181
- if (projectServices.project === undefined)
114
+ if (automationModel.model === undefined)
182
115
  return;
183
- config.projectServices = projectServices.project;
184
- ;
185
- if (projectServices.project === ProjectServices.GitHub || projectServices.project === ProjectServices.GitLab) {
186
- // Gestion del Proyecto
187
- const backlogColumn = yield prompts([{
188
- type: "text",
189
- name: "backlogColumn",
190
- initial: config.backlogColumn,
191
- message: "Nombre de la columna donde se crean nuevos issues"
192
- }]);
193
- if (backlogColumn.backlogColumn === undefined)
194
- return;
195
- config.backlogColumn = backlogColumn.backlogColumn;
196
- logInfo(`Por omision ser utilizan proyectos dentro de ${context.repositoryOwner} y ${context.repositoryRepo} `);
197
- }
198
- // Id de Projecto
199
- const projectId = yield prompts([{
116
+ config[contextProperty] = automationModel.model;
117
+ }
118
+ // Gestion del Proyecto
119
+ const projectChoices = [{ title: 'Github Projects', value: ProjectServices.GitHub }, { title: 'GitLab Projects', value: ProjectServices.GitLab }, { title: 'Jira', value: ProjectServices.Jira }, { title: 'None', value: ProjectServices.None }];
120
+ const projectServices = await prompts([{
121
+ type: "select",
122
+ name: "project",
123
+ message: "Gestion de proyecto",
124
+ initial: findChoicesPosition(projectChoices, config.projectServices),
125
+ choices: projectChoices
126
+ }]);
127
+ if (projectServices.project === undefined)
128
+ return;
129
+ config.projectServices = projectServices.project;
130
+ ;
131
+ if (projectServices.project === ProjectServices.GitHub || projectServices.project === ProjectServices.GitLab) {
132
+ // Gestion del Proyecto
133
+ const backlogColumn = await prompts([{
200
134
  type: "text",
201
- name: "projectId",
202
- initial: config.projectId,
203
- message: "Id del proyecto"
135
+ name: "backlogColumn",
136
+ initial: config.backlogColumn,
137
+ message: "Nombre de la columna donde se crean nuevos issues"
204
138
  }]);
205
- if (projectId.projectId === undefined)
139
+ if (backlogColumn.backlogColumn === undefined)
206
140
  return;
207
- config.projectId = projectId.projectId;
208
- return config;
209
- });
141
+ config.backlogColumn = backlogColumn.backlogColumn;
142
+ logInfo(`Por omision ser utilizan proyectos dentro de ${context.repositoryOwner} y ${context.repositoryRepo} `);
143
+ }
144
+ // Id de Projecto
145
+ const projectId = await prompts([{
146
+ type: "text",
147
+ name: "projectId",
148
+ initial: config.projectId,
149
+ message: "Id del proyecto"
150
+ }]);
151
+ if (projectId.projectId === undefined)
152
+ return;
153
+ config.projectId = projectId.projectId;
154
+ return config;
210
155
  }
211
- export function createConfigurationFile(taskName) {
212
- return __awaiter(this, void 0, void 0, function* () {
213
- const baseConfig = { backlogColumn: context.backlogColumn, devModel: context.devModel, docModel: context.docModel, projectModel: context.projectModel, gitModel: context.gitModel, gitServices: context.gitServices, projectServices: context.projectServices, projectId: context.projectId, listFilter: context.listFilter, listTemplate: context.listTemplate };
214
- let config = taskName ? yield getTaskConfig(baseConfig) : yield getBaseConfig(baseConfig);
215
- if (!config)
216
- return false;
217
- storeConfig(config);
218
- return true;
219
- });
156
+ export async function createConfigurationFile(taskName) {
157
+ const baseConfig = { backlogColumn: context.backlogColumn, devModel: context.devModel, docModel: context.docModel, projectModel: context.projectModel, gitModel: context.gitModel, gitServices: context.gitServices, projectServices: context.projectServices, projectId: context.projectId, listFilter: context.listFilter, listTemplate: context.listTemplate };
158
+ let config = taskName ? await getTaskConfig(baseConfig) : await getBaseConfig(baseConfig);
159
+ if (!config)
160
+ return false;
161
+ storeConfig(config);
162
+ return true;
220
163
  }
221
164
  export function getConfigFile(file, variable, defaultValue) {
222
165
  if (fs.existsSync(file)) {
@@ -227,7 +170,7 @@ export function getConfigFile(file, variable, defaultValue) {
227
170
  return config[variable];
228
171
  }
229
172
  }
230
- catch (_a) {
173
+ catch {
231
174
  return defaultValue;
232
175
  }
233
176
  }
@@ -243,7 +186,7 @@ export function storeConfig(record) {
243
186
  try {
244
187
  config = JSON.parse(content);
245
188
  }
246
- catch (_a) {
189
+ catch {
247
190
  throw new Error(`Verifique que el ${CONFIG_FILE} sea json valido`);
248
191
  }
249
192
  }
@@ -253,7 +196,7 @@ export function storeConfig(record) {
253
196
  try {
254
197
  fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
255
198
  }
256
- catch (_b) {
199
+ catch {
257
200
  throw new Error(`No se pudo guardar la configuracion en ${CONFIG_FILE}`);
258
201
  }
259
202
  }
@@ -355,7 +298,7 @@ export function readJsonSync(filename) {
355
298
  try {
356
299
  return JSON.parse(content);
357
300
  }
358
- catch (_a) {
301
+ catch {
359
302
  throw new Error(`Verifique que el ${filename} sea json valido`);
360
303
  }
361
304
  }