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.
Files changed (55) hide show
  1. package/CHANGELOG.md +20 -3
  2. package/README.md +6 -3
  3. package/commands/modelA/tasks/start.json +2 -2
  4. package/commands/modelC/new/issue.json +41 -0
  5. package/commands/modelC/subtasks/checkout-branch.json +60 -0
  6. package/commands/modelC/subtasks/create-pull.json +20 -0
  7. package/commands/modelC/subtasks/pack.json +29 -0
  8. package/commands/modelC/subtasks/publish-branch.json +20 -0
  9. package/commands/modelC/tasks/cancel.json +6 -0
  10. package/commands/modelC/tasks/finish.json +41 -0
  11. package/commands/modelC/tasks/list.json +11 -0
  12. package/commands/modelC/tasks/publish.json +13 -0
  13. package/commands/modelC/tasks/start.json +51 -0
  14. package/commands/modelC/tasks/stop.json +32 -0
  15. package/commands/modelC/tasks/switch.json +53 -0
  16. package/commands/modelC/tasks/view.json +13 -0
  17. package/commands/models.json +18 -0
  18. package/lib/auto.js +2 -1
  19. package/lib/helpers/class.js +4 -3
  20. package/lib/helpers/context.d.ts +4 -1
  21. package/lib/helpers/context.js +48 -27
  22. package/lib/helpers/github-graphql.d.ts +1 -1
  23. package/lib/helpers/github-graphql.js +1 -1
  24. package/lib/helpers/github-project-graphql.d.ts +9 -1
  25. package/lib/helpers/github-project-graphql.js +22 -12
  26. package/lib/helpers/gitlab-graphql.d.ts +2 -1
  27. package/lib/helpers/gitlab-graphql.js +7 -2
  28. package/lib/helpers/lwc.js +4 -3
  29. package/lib/helpers/metadata.js +2 -2
  30. package/lib/helpers/object.js +4 -3
  31. package/lib/helpers/openai.js +1 -1
  32. package/lib/helpers/taskFunctions.js +29 -8
  33. package/lib/helpers/tasks.js +7 -7
  34. package/lib/helpers/template.d.ts +3 -3
  35. package/lib/helpers/template.js +5 -4
  36. package/lib/helpers/util.d.ts +8 -1
  37. package/lib/helpers/util.js +86 -20
  38. package/package.json +1 -1
  39. package/templates/modelB/changelog.md +4 -0
  40. package/templates/modelB/openIssues.md +0 -0
  41. package/templates/models.json +12 -0
  42. package/templates/story.md +0 -32
  43. package/templates/usecase.md +0 -52
  44. /package/templates/{dictionary → modelA/dictionary}/class-all.md +0 -0
  45. /package/templates/{dictionary → modelA/dictionary}/class-diagrama.md +0 -0
  46. /package/templates/{dictionary → modelA/dictionary}/class-inner.md +0 -0
  47. /package/templates/{dictionary → modelA/dictionary}/class-metodos.md +0 -0
  48. /package/templates/{dictionary → modelA/dictionary}/class-public.md +0 -0
  49. /package/templates/{dictionary → modelA/dictionary}/class-referencias.md +0 -0
  50. /package/templates/{dictionary → modelA/dictionary}/class.md +0 -0
  51. /package/templates/{dictionary → modelA/dictionary}/classes.md +0 -0
  52. /package/templates/{dictionary → modelA/dictionary}/object.md +0 -0
  53. /package/templates/{dictionary → modelA/dictionary}/objects.md +0 -0
  54. /package/templates/{intro.md → modelA/intro.md} +0 -0
  55. /package/templates/{process.md → modelA/process.md} +0 -0
@@ -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 DICTIONARY_FOLDER = TEMPLATES_FOLDER + "/diccionarios";
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 data = getDataFromPackage();
75
- const optionals = {};
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
- choices: [{ title: 'Github', value: GitServices.GitHub }, { title: 'Gitlab', value: GitServices.GitLab }]
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
- const models = valuesToChoices(getFiles(COMMAND_FOLDER, filterDirectory));
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
- choices: models.concat([{ 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' }])
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
- choices: [{ title: 'Github Projects', value: ProjectServices.GitHub }, { title: 'GitLab Projects', value: ProjectServices.GitLab }, { title: 'Jira', value: ProjectServices.Jira }, { title: 'None', value: ProjectServices.None }]
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: 'Backlog',
142
+ initial: config.backlogColumn,
128
143
  message: "Nombre de la columna donde se crean nuevos issues"
129
144
  }]);
130
- optionals['backlogColumn'] = backlogColumn.backlogColumn;
131
- logInfo(`Por omision ser utilizan proyectos dentro de ${data.repositoryOwner} y ${data.repositoryRepo} `);
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
- // console.log('Genera documentacion');
139
- const config = Object.assign({ model: automationModel.model, gitServices: gitServices.git, projectServices: projectServices.project, projectId: projectId.projectId }, optionals);
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
@@ -2,7 +2,7 @@
2
2
  "name": "autoforce",
3
3
  "homepage": "https://sebastianclaros.github.io/autoforce",
4
4
  "private": false,
5
- "version": "0.1.9",
5
+ "version": "0.1.11",
6
6
  "keywords": [
7
7
  "Salesforce",
8
8
  "Automation",
@@ -0,0 +1,4 @@
1
+
2
+ {{#each issues}}
3
+ * {{title}}
4
+ {{/each}}
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
+ ]
@@ -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 -->
@@ -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