mytools-tasks 0.13.0 → 0.15.0
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/dist/index.js +63 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22598,15 +22598,30 @@ const getQuery = (ownership) => {
|
|
|
22598
22598
|
return inProgress;
|
|
22599
22599
|
};
|
|
22600
22600
|
const searchInProgressTasks = async (ownership) => {
|
|
22601
|
-
const url = `${process.env.JIRA_DOMAIN}/rest/api/3/search`;
|
|
22601
|
+
const url = `${process.env.JIRA_DOMAIN}/rest/api/3/search/jql`;
|
|
22602
22602
|
const body = {
|
|
22603
|
-
expand:
|
|
22603
|
+
expand: 'names',
|
|
22604
22604
|
maxResults: 50,
|
|
22605
22605
|
fieldsByKeys: false,
|
|
22606
22606
|
fields: ['summary', 'issuetype', 'status'],
|
|
22607
|
-
startAt: 0,
|
|
22608
22607
|
jql: getQuery(ownership)
|
|
22609
22608
|
};
|
|
22609
|
+
// const bodyData = `{
|
|
22610
|
+
// "expand": "<string>",
|
|
22611
|
+
// "fields": [
|
|
22612
|
+
// "<string>"
|
|
22613
|
+
// ],
|
|
22614
|
+
// "fieldsByKeys": true,
|
|
22615
|
+
// "jql": "<string>",
|
|
22616
|
+
// "maxResults": 273,
|
|
22617
|
+
// "nextPageToken": "<string>",
|
|
22618
|
+
// "properties": [
|
|
22619
|
+
// "<string>"
|
|
22620
|
+
// ],
|
|
22621
|
+
// "reconcileIssues": [
|
|
22622
|
+
// 2154
|
|
22623
|
+
// ]
|
|
22624
|
+
// }`;
|
|
22610
22625
|
const response = await src_fetch(url, {
|
|
22611
22626
|
method: 'post',
|
|
22612
22627
|
body: JSON.stringify(body),
|
|
@@ -22635,6 +22650,7 @@ const findTask = async (taskId) => {
|
|
|
22635
22650
|
Authorization: `Basic ${process.env.JIRA_AUTHORIZATION}`
|
|
22636
22651
|
}
|
|
22637
22652
|
});
|
|
22653
|
+
console.log(JSON.stringify(response, null, 2));
|
|
22638
22654
|
if (!response.ok)
|
|
22639
22655
|
return null;
|
|
22640
22656
|
const issue = (await response.json());
|
|
@@ -22651,68 +22667,68 @@ const findTask = async (taskId) => {
|
|
|
22651
22667
|
|
|
22652
22668
|
|
|
22653
22669
|
async function gitFetch() {
|
|
22654
|
-
console.log(`🐷 ${(0,picocolors.cyan)(
|
|
22670
|
+
console.log(`🐷 ${(0,picocolors.cyan)('info')} making a git fetch...`);
|
|
22655
22671
|
await simpleGit().fetch();
|
|
22656
|
-
console.log(`🐷 ${(0,picocolors.green)(
|
|
22672
|
+
console.log(`🐷 ${(0,picocolors.green)('success')} git fetch completed`);
|
|
22657
22673
|
}
|
|
22658
22674
|
async function gitPull() {
|
|
22659
|
-
console.log(`🐷 ${(0,picocolors.cyan)(
|
|
22675
|
+
console.log(`🐷 ${(0,picocolors.cyan)('info')} pulling branches...`);
|
|
22660
22676
|
await simpleGit().pull();
|
|
22661
|
-
console.log(`🐷 ${(0,picocolors.green)(
|
|
22677
|
+
console.log(`🐷 ${(0,picocolors.green)('success')} pull branches completed`);
|
|
22662
22678
|
}
|
|
22663
22679
|
async function searchTasks(ownership) {
|
|
22664
|
-
console.log(`🐷 ${(0,picocolors.cyan)(
|
|
22680
|
+
console.log(`🐷 ${(0,picocolors.cyan)('info')} requesting task in progress...`);
|
|
22665
22681
|
return await searchInProgressTasks(ownership);
|
|
22666
22682
|
}
|
|
22667
22683
|
async function askUserByTaskOwnership() {
|
|
22668
22684
|
const { ownership } = await prompts_default()({
|
|
22669
|
-
type:
|
|
22670
|
-
name:
|
|
22671
|
-
message:
|
|
22685
|
+
type: 'select',
|
|
22686
|
+
name: 'ownership',
|
|
22687
|
+
message: 'What kind of task do you want to search?',
|
|
22672
22688
|
choices: [
|
|
22673
|
-
{ title:
|
|
22674
|
-
{ title:
|
|
22689
|
+
{ title: 'My tasks', value: TaskOwnership.MY_TASKS },
|
|
22690
|
+
{ title: 'All tasks', value: TaskOwnership.ALL }
|
|
22675
22691
|
],
|
|
22676
|
-
initial: 0
|
|
22692
|
+
initial: 0
|
|
22677
22693
|
});
|
|
22678
22694
|
return ownership;
|
|
22679
22695
|
}
|
|
22680
22696
|
async function askUserByTask(issues) {
|
|
22681
22697
|
const { task } = await prompts_default()({
|
|
22682
|
-
type:
|
|
22683
|
-
name:
|
|
22684
|
-
message:
|
|
22698
|
+
type: 'select',
|
|
22699
|
+
name: 'task',
|
|
22700
|
+
message: 'What task do you want to start?',
|
|
22685
22701
|
choices: issues.map((issue) => {
|
|
22686
22702
|
const title = `${(0,picocolors.cyan)(issue.id)} => ${issue.name} => ${(0,picocolors.yellow)(issue.type)}`;
|
|
22687
22703
|
const value = issue;
|
|
22688
22704
|
return { title, value };
|
|
22689
|
-
})
|
|
22705
|
+
})
|
|
22690
22706
|
});
|
|
22691
22707
|
return task;
|
|
22692
22708
|
}
|
|
22693
22709
|
async function askUserByFormatBranch(formatBranch) {
|
|
22694
22710
|
const { branchName } = await prompts_default()({
|
|
22695
|
-
type:
|
|
22696
|
-
name:
|
|
22697
|
-
message:
|
|
22698
|
-
choices: formatBranch.map((format) => ({ title: format, value: format }))
|
|
22711
|
+
type: 'select',
|
|
22712
|
+
name: 'branchName',
|
|
22713
|
+
message: 'What name of brunch do you like?',
|
|
22714
|
+
choices: formatBranch.map((format) => ({ title: format, value: format }))
|
|
22699
22715
|
});
|
|
22700
22716
|
return branchName;
|
|
22701
22717
|
}
|
|
22702
22718
|
async function checkoutBranch(branchName) {
|
|
22703
|
-
console.log(`🐷 ${(0,picocolors.cyan)(
|
|
22719
|
+
console.log(`🐷 ${(0,picocolors.cyan)('info')} creating new branch ${(0,picocolors.yellow)(branchName)}`);
|
|
22704
22720
|
await simpleGit().checkoutLocalBranch(branchName);
|
|
22705
22721
|
}
|
|
22706
22722
|
const ensureEnvs = async () => {
|
|
22707
22723
|
if (!(await isJiraConfigured())) {
|
|
22708
|
-
return Promise.reject(
|
|
22724
|
+
return Promise.reject('The envs JIRA_DOMAIN or JIRA_AUTHORIZATION not exist. More info in doc');
|
|
22709
22725
|
}
|
|
22710
22726
|
};
|
|
22711
22727
|
const addTaskToFileConfig = async (task) => {
|
|
22712
22728
|
await addTask(task);
|
|
22713
22729
|
};
|
|
22714
22730
|
const cleanFileConfig = async () => {
|
|
22715
|
-
console.log(`🐷 ${(0,picocolors.cyan)(
|
|
22731
|
+
console.log(`🐷 ${(0,picocolors.cyan)('info')} auto clean tasks`);
|
|
22716
22732
|
const tasks = await getInProgressTasks();
|
|
22717
22733
|
await Promise.all(tasks.map(async (task) => {
|
|
22718
22734
|
const taskFound = await findTask(task.jiraId);
|
|
@@ -22731,7 +22747,7 @@ const run = async () => {
|
|
|
22731
22747
|
const ownership = await askUserByTaskOwnership();
|
|
22732
22748
|
const issues = await searchTasks(ownership);
|
|
22733
22749
|
if (!issues.length)
|
|
22734
|
-
return Promise.reject(
|
|
22750
|
+
return Promise.reject('There are not in progress tasks');
|
|
22735
22751
|
const task = await askUserByTask(issues);
|
|
22736
22752
|
const formatBranch = formatBranchName(task);
|
|
22737
22753
|
const branchName = await askUserByFormatBranch(formatBranch);
|
|
@@ -40081,24 +40097,34 @@ var openai = createOpenAI({
|
|
|
40081
40097
|
|
|
40082
40098
|
|
|
40083
40099
|
const generateDiff = async () => {
|
|
40084
|
-
|
|
40100
|
+
const diff = await simpleGit().diff();
|
|
40101
|
+
return diff
|
|
40102
|
+
.split('\n')
|
|
40103
|
+
.filter((line) => line.startsWith('+') && line.includes('it('))
|
|
40104
|
+
.map((line) => {
|
|
40105
|
+
const match = line.match(/it\(\s*'([^']+)'\s*,/);
|
|
40106
|
+
return match ? match[1] : null;
|
|
40107
|
+
})
|
|
40108
|
+
.filter(Boolean);
|
|
40085
40109
|
};
|
|
40086
40110
|
const callAI = async (diff) => {
|
|
40087
40111
|
const { text } = await generateText({
|
|
40088
40112
|
model: openai('gpt-4o-mini'),
|
|
40089
|
-
system:
|
|
40113
|
+
system: `Eres un experto en gramática y redacción en inglés. Tu tarea es revisar los nombres de tests unitarios de un
|
|
40114
|
+
proyecto y corregirlos si tienen errores gramaticales o de estilo. Siempre debes responder con una lista numerada en
|
|
40115
|
+
el siguiente formato:
|
|
40116
|
+
1. **Nombre original:** \`<nombre_original>\`
|
|
40117
|
+
**Nombre corregido:** \`<nombre_corregido>\`
|
|
40118
|
+
**Razón del cambio:** \`<explicación en español de por qué el cambio es necesario>\`
|
|
40119
|
+
Si el nombre del test es correcto, responde con el mismo nombre en "Nombre corregido" y una explicación indicando que
|
|
40120
|
+
no requiere cambios. Mantén la estructura de los nombres de test y evita modificar la semántica de la prueba.`,
|
|
40090
40121
|
messages: [
|
|
40091
40122
|
{
|
|
40092
40123
|
role: 'user',
|
|
40093
|
-
content:
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
|
|
40097
|
-
content: 'Dame siempre el nombre de todos los test que encuentres y siempre con las keys actual, nuevo y una explicación de porque esta mal.'
|
|
40098
|
-
},
|
|
40099
|
-
{
|
|
40100
|
-
role: 'user',
|
|
40101
|
-
content: `'''\n${diff}\n'''`
|
|
40124
|
+
content: `Aquí tienes una lista de nombres de tests unitarios extraídos de un proyecto. Revisa su gramática y
|
|
40125
|
+
corrige cualquier error si es necesario, siguiendo el formato indicado:
|
|
40126
|
+
${diff.join('\n')}
|
|
40127
|
+
Por favor, proporciona la lista con las correcciones y explicaciones en español.`
|
|
40102
40128
|
}
|
|
40103
40129
|
],
|
|
40104
40130
|
temperature: 0.8,
|