autoforce 0.1.9 → 0.1.11
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/CHANGELOG.md +20 -3
- package/README.md +6 -3
- package/commands/modelA/tasks/start.json +2 -2
- package/commands/modelC/new/issue.json +41 -0
- package/commands/modelC/subtasks/checkout-branch.json +60 -0
- package/commands/modelC/subtasks/create-pull.json +20 -0
- package/commands/modelC/subtasks/pack.json +29 -0
- package/commands/modelC/subtasks/publish-branch.json +20 -0
- package/commands/modelC/tasks/cancel.json +6 -0
- package/commands/modelC/tasks/finish.json +41 -0
- package/commands/modelC/tasks/list.json +11 -0
- package/commands/modelC/tasks/publish.json +13 -0
- package/commands/modelC/tasks/start.json +51 -0
- package/commands/modelC/tasks/stop.json +32 -0
- package/commands/modelC/tasks/switch.json +53 -0
- package/commands/modelC/tasks/view.json +13 -0
- package/commands/models.json +18 -0
- package/lib/auto.js +2 -1
- package/lib/helpers/class.js +4 -3
- package/lib/helpers/context.d.ts +4 -1
- package/lib/helpers/context.js +48 -27
- package/lib/helpers/github-graphql.d.ts +1 -1
- package/lib/helpers/github-graphql.js +1 -1
- package/lib/helpers/github-project-graphql.d.ts +9 -1
- package/lib/helpers/github-project-graphql.js +22 -12
- package/lib/helpers/gitlab-graphql.d.ts +2 -1
- package/lib/helpers/gitlab-graphql.js +7 -2
- package/lib/helpers/lwc.js +4 -3
- package/lib/helpers/metadata.js +2 -2
- package/lib/helpers/object.js +4 -3
- package/lib/helpers/openai.js +1 -1
- package/lib/helpers/taskFunctions.js +29 -8
- package/lib/helpers/tasks.js +7 -7
- package/lib/helpers/template.d.ts +3 -3
- package/lib/helpers/template.js +5 -4
- package/lib/helpers/util.d.ts +8 -1
- package/lib/helpers/util.js +86 -20
- package/package.json +1 -1
- package/templates/modelB/changelog.md +4 -0
- package/templates/modelB/openIssues.md +0 -0
- package/templates/models.json +12 -0
- package/templates/story.md +0 -32
- package/templates/usecase.md +0 -52
- /package/templates/{dictionary → modelA/dictionary}/class-all.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/class-diagrama.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/class-inner.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/class-metodos.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/class-public.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/class-referencias.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/class.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/classes.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/object.md +0 -0
- /package/templates/{dictionary → modelA/dictionary}/objects.md +0 -0
- /package/templates/{intro.md → modelA/intro.md} +0 -0
- /package/templates/{process.md → modelA/process.md} +0 -0
package/lib/helpers/util.js
CHANGED
@@ -10,13 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
import fs from "fs";
|
11
11
|
import { fileURLToPath } from 'url';
|
12
12
|
import prompts from "prompts";
|
13
|
-
import { ProjectServices, GitServices } from "./context.js";
|
13
|
+
import context, { ProjectServices, GitServices } from "./context.js";
|
14
14
|
import { logInfo, logWarning } from "./color.js";
|
15
15
|
const COMMAND_FOLDER = searchInFolderHierarchy('commands', fileURLToPath(import.meta.url));
|
16
|
+
export const CONFIG_FILE = process.cwd() + '/.autoforce.json';
|
16
17
|
export const TEMPLATES_FOLDER = searchInFolderHierarchy('templates', fileURLToPath(import.meta.url));
|
17
|
-
export const
|
18
|
+
export const TEMPLATE_MODEL_FOLDER = TEMPLATES_FOLDER + '/' + getConfig('modelTemplates', 'modelA');
|
19
|
+
export const DICTIONARY_FOLDER = TEMPLATE_MODEL_FOLDER + "/diccionarios";
|
18
20
|
export const WORKING_FOLDER = process.env.INIT_CWD || ".";
|
19
|
-
export const CONFIG_FILE = process.cwd() + '/.autoforce.json';
|
20
21
|
export const filterJson = (fullPath) => fullPath.endsWith(".json");
|
21
22
|
export const filterDirectory = (fullPath) => fs.lstatSync(fullPath).isDirectory();
|
22
23
|
export const filterFiles = (fullPath) => !fs.lstatSync(fullPath).isDirectory();
|
@@ -68,23 +69,26 @@ export function getDataFromPackage() {
|
|
68
69
|
}
|
69
70
|
return data;
|
70
71
|
}
|
72
|
+
export function findChoicesPosition(choices, value) {
|
73
|
+
const index = choices.findIndex(choice => choice.value === value);
|
74
|
+
return index === -1 ? 0 : index;
|
75
|
+
}
|
71
76
|
export function createConfigurationFile() {
|
72
77
|
return __awaiter(this, void 0, void 0, function* () {
|
73
78
|
// Todo: Chequear el repoOwner y repo
|
74
|
-
const
|
75
|
-
const
|
76
|
-
if (!data.repositoryOwner || !data.repositoryRepo) {
|
77
|
-
throw new Error('No se encontro repository en el package.json ! Por favor agreguelo y vuelva a intentar');
|
78
|
-
}
|
79
|
-
const initialServices = data.repositoryUrl.includes("github.com") ? 0 : 1;
|
79
|
+
const config = { backlogColumn: context.backlogColumn, model: context.model, modelTemplates: context.modelTemplates, gitServices: context.gitServices, projectServices: context.projectServices, projectId: context.projectId };
|
80
|
+
const gitChoices = [{ title: 'Github', value: GitServices.GitHub }, { title: 'Gitlab', value: GitServices.GitLab }];
|
80
81
|
// Preguntar por GitHub o GitLab
|
81
82
|
const gitServices = yield prompts([{
|
82
83
|
type: "select",
|
83
84
|
name: "git",
|
84
|
-
initial: initialServices,
|
85
85
|
message: "Elija un servicio de Git",
|
86
|
-
|
86
|
+
initial: findChoicesPosition(gitChoices, config.gitServices),
|
87
|
+
choices: gitChoices
|
87
88
|
}]);
|
89
|
+
if (gitServices.git === undefined)
|
90
|
+
return false;
|
91
|
+
config.gitServices = gitServices.git;
|
88
92
|
// Chequear las variables de entorno
|
89
93
|
if (gitServices.git === GitServices.GitHub && !process.env.GITHUB_TOKEN) {
|
90
94
|
logWarning('A fin de que la herramienta funcione debe configurar una variable de entorno GITHUB_TOKEN');
|
@@ -92,13 +96,19 @@ export function createConfigurationFile() {
|
|
92
96
|
if (gitServices.git === GitServices.GitLab && !process.env.GITLAB_TOKEN) {
|
93
97
|
logWarning('A fin de que la herramienta funcione debe configurar una variable de entorno GITLAB_TOKEN');
|
94
98
|
}
|
95
|
-
|
99
|
+
// Selecciona el modelo de automatizacion
|
100
|
+
const models = readJsonSync(`${COMMAND_FOLDER}/models.json`);
|
101
|
+
models.push({ title: 'Personalizado', value: 'custom', description: 'En este caso los comandos son configurados fuera de la herramienta y los lee de la carpeta commands en el root del repo' });
|
96
102
|
const automationModel = yield prompts([{
|
97
103
|
type: "select",
|
98
104
|
name: "model",
|
99
105
|
message: "Elija un modelo de automatizacion",
|
100
|
-
|
106
|
+
initial: findChoicesPosition(models, config.model),
|
107
|
+
choices: models
|
101
108
|
}]);
|
109
|
+
if (automationModel.model === undefined)
|
110
|
+
return false;
|
111
|
+
config.model = automationModel.model;
|
102
112
|
// Si es custom pregunta si quiere tomar de base alguno existente
|
103
113
|
if (automationModel.model === 'custom') {
|
104
114
|
const baseModel = yield prompts([{
|
@@ -112,31 +122,53 @@ export function createConfigurationFile() {
|
|
112
122
|
}
|
113
123
|
}
|
114
124
|
// Gestion del Proyecto
|
125
|
+
const projectChoices = [{ title: 'Github Projects', value: ProjectServices.GitHub }, { title: 'GitLab Projects', value: ProjectServices.GitLab }, { title: 'Jira', value: ProjectServices.Jira }, { title: 'None', value: ProjectServices.None }];
|
115
126
|
const projectServices = yield prompts([{
|
116
127
|
type: "select",
|
117
128
|
name: "project",
|
118
|
-
initial: initialServices,
|
119
129
|
message: "Gestion de proyecto",
|
120
|
-
|
130
|
+
initial: findChoicesPosition(projectChoices, config.projectServices),
|
131
|
+
choices: projectChoices
|
121
132
|
}]);
|
133
|
+
if (projectServices.project === undefined)
|
134
|
+
return false;
|
135
|
+
config.projectServices = projectServices.project;
|
136
|
+
;
|
122
137
|
if (projectServices.project === ProjectServices.GitHub || projectServices.project === ProjectServices.GitLab) {
|
123
138
|
// Gestion del Proyecto
|
124
139
|
const backlogColumn = yield prompts([{
|
125
140
|
type: "text",
|
126
141
|
name: "backlogColumn",
|
127
|
-
initial:
|
142
|
+
initial: config.backlogColumn,
|
128
143
|
message: "Nombre de la columna donde se crean nuevos issues"
|
129
144
|
}]);
|
130
|
-
|
131
|
-
|
145
|
+
if (backlogColumn.backlogColumn === undefined)
|
146
|
+
return false;
|
147
|
+
config.backlogColumn = backlogColumn.backlogColumn;
|
148
|
+
logInfo(`Por omision ser utilizan proyectos dentro de ${context.repositoryOwner} y ${context.repositoryRepo} `);
|
132
149
|
}
|
150
|
+
// Id de Projecto
|
133
151
|
const projectId = yield prompts([{
|
134
152
|
type: "text",
|
135
153
|
name: "projectId",
|
154
|
+
initial: config.projectId,
|
136
155
|
message: "Id del proyecto"
|
137
156
|
}]);
|
138
|
-
|
139
|
-
|
157
|
+
if (projectId.projectId === undefined)
|
158
|
+
return false;
|
159
|
+
config.projectId = projectId.projectId;
|
160
|
+
// Modelo de Dcumentacion
|
161
|
+
const modelsTemplates = readJsonSync(`${TEMPLATES_FOLDER}/models.json`);
|
162
|
+
const modelTemplates = yield prompts([{
|
163
|
+
type: "select",
|
164
|
+
name: "model",
|
165
|
+
message: "Elija un modelo de documentacion",
|
166
|
+
initial: findChoicesPosition(modelsTemplates, config.modelTemplates),
|
167
|
+
choices: modelsTemplates
|
168
|
+
}]);
|
169
|
+
if (modelTemplates.model === undefined)
|
170
|
+
return false;
|
171
|
+
config.modelTemplates = modelTemplates.model;
|
140
172
|
try {
|
141
173
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
142
174
|
}
|
@@ -146,6 +178,35 @@ export function createConfigurationFile() {
|
|
146
178
|
return true;
|
147
179
|
});
|
148
180
|
}
|
181
|
+
export function getConfig(variable, defaultValue) {
|
182
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
183
|
+
const content = fs.readFileSync(CONFIG_FILE, "utf8");
|
184
|
+
try {
|
185
|
+
const config = JSON.parse(content);
|
186
|
+
if (config[variable]) {
|
187
|
+
return config[variable];
|
188
|
+
}
|
189
|
+
}
|
190
|
+
catch (_a) {
|
191
|
+
return defaultValue;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
return defaultValue;
|
195
|
+
}
|
196
|
+
export function storeConfig(variable, value) {
|
197
|
+
let config = {};
|
198
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
199
|
+
const content = fs.readFileSync(CONFIG_FILE, "utf8");
|
200
|
+
try {
|
201
|
+
config = JSON.parse(content);
|
202
|
+
}
|
203
|
+
catch (_a) {
|
204
|
+
throw new Error(`Verifique que el ${CONFIG_FILE} sea json valido`);
|
205
|
+
}
|
206
|
+
}
|
207
|
+
config[variable] = value;
|
208
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
209
|
+
}
|
149
210
|
export function sortByName(objA, objB) {
|
150
211
|
return objA.Name > objB.Name ? 1 : objA.Name < objB.Name ? -1 : 0;
|
151
212
|
}
|
@@ -239,3 +300,8 @@ export function convertKeyToName(key) {
|
|
239
300
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
240
301
|
.join(' ');
|
241
302
|
}
|
303
|
+
export function readJsonSync(filename) {
|
304
|
+
const content = fs.readFileSync(filename, "utf8");
|
305
|
+
const data = JSON.parse(content);
|
306
|
+
return data;
|
307
|
+
}
|
package/package.json
CHANGED
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"title": "Procesos de Negocio en Salesforce",
|
4
|
+
"value": "modelA",
|
5
|
+
"description": "Documenta Clases, Objetos y LWC a traves de procesos de negocios. Se basa en docusaurus"
|
6
|
+
},
|
7
|
+
{
|
8
|
+
"title": "Proyecto simple en Github Docs",
|
9
|
+
"value": "modelB",
|
10
|
+
"description": "Github pages con changelog, readme y carpeta docs de Markdowns"
|
11
|
+
}
|
12
|
+
]
|
package/templates/story.md
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sidebar_position: 1
|
3
|
-
tags: [{ { rol } }]
|
4
|
-
---
|
5
|
-
|
6
|
-
# {{titulo}}
|
7
|
-
|
8
|
-
- Modulo: [{{modulo}}](/{{modulo}})
|
9
|
-
- Roles: [{{rol}}](/tags/{{rol}})
|
10
|
-
|
11
|
-
## Descripcion:
|
12
|
-
|
13
|
-
## Escenarios
|
14
|
-
|
15
|
-
1.
|
16
|
-
|
17
|
-
<!-- START autogenerated-objects -->
|
18
|
-
<!-- END autogenerated-objects -->
|
19
|
-
|
20
|
-
<!-- START autogenerated-classes -->
|
21
|
-
<!-- END autogenerated-classes -->
|
22
|
-
|
23
|
-
<!-- START autogenerated-usecase -->
|
24
|
-
|
25
|
-
:::tip
|
26
|
-
Para refrescar metadata:
|
27
|
-
|
28
|
-
```bash
|
29
|
-
{{command}}
|
30
|
-
```
|
31
|
-
|
32
|
-
<!-- END autogenerated-usecase -->
|
package/templates/usecase.md
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sidebar_position: 1
|
3
|
-
tags: [{ { actor } }]
|
4
|
-
---
|
5
|
-
|
6
|
-
# {{titulo}}
|
7
|
-
|
8
|
-
- Modulo: [{{modulo}}](/{{modulo}})
|
9
|
-
- Roles: [{{actor}}](/tags/{{actor}})
|
10
|
-
- Alcance:
|
11
|
-
- Proposito:
|
12
|
-
|
13
|
-
## Descripcion:
|
14
|
-
|
15
|
-
- Suposiciones:
|
16
|
-
- Cuando:
|
17
|
-
- Precondiciones:
|
18
|
-
- Postcondiciones:
|
19
|
-
|
20
|
-
## Flujo Principal
|
21
|
-
|
22
|
-
_Pasos: _
|
23
|
-
|
24
|
-
1.
|
25
|
-
|
26
|
-
## Flujos Alternativos
|
27
|
-
|
28
|
-
_Pasos: _
|
29
|
-
|
30
|
-
1.
|
31
|
-
|
32
|
-
## Use cases relacionados
|
33
|
-
|
34
|
-
| Nombre | Descripcion |
|
35
|
-
| ------ | ----------- |
|
36
|
-
|
37
|
-
<!-- START autogenerated-objects -->
|
38
|
-
<!-- END autogenerated-objects -->
|
39
|
-
|
40
|
-
<!-- START autogenerated-classes -->
|
41
|
-
<!-- END autogenerated-classes -->
|
42
|
-
|
43
|
-
<!-- START autogenerated-usecase -->
|
44
|
-
|
45
|
-
:::tip
|
46
|
-
Para refrescar metadata:
|
47
|
-
|
48
|
-
```bash
|
49
|
-
{{command}}
|
50
|
-
```
|
51
|
-
|
52
|
-
<!-- END autogenerated-usecase -->
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|