autoforce 0.1.25 → 0.1.27

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/.autoforce.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.23",
2
+ "version": "0.1.27",
3
3
  "backlogColumn": "Todo",
4
4
  "gitServices": "github",
5
5
  "gitModel": "githubflow",
@@ -11,5 +11,6 @@
11
11
  "devModel": "npm",
12
12
  "docModel": "processes",
13
13
  "filter": "{states: OPEN}",
14
- "template": "openIssues"
14
+ "template": "openIssues",
15
+ "dictionaryFolder": "docs/docs"
15
16
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Versiones
2
2
 
3
+ 0.1.26
4
+ ## Version 0.1.26
5
+ - Fecha:
6
+ - Paquete: [Descargar](https://www.npmjs.com/package/autoforce/v/0.1.26)
7
+ - Cambios:
8
+ * Bugfixing de create-scracth para autoforce-test
9
+
3
10
 
4
11
  0.1.25
5
12
  ## Version 0.1.25
@@ -4,7 +4,7 @@ import { DICTIONARY_FOLDER, getModelFolders } from "./util.js";
4
4
  let _templateEngine;
5
5
  function getTemplateEngine() {
6
6
  if (!_templateEngine) {
7
- _templateEngine = templateGenerator(getModelFolders('dictionary'), "md");
7
+ _templateEngine = templateGenerator(getModelFolders('templates/dictionary'), "md");
8
8
  }
9
9
  return _templateEngine;
10
10
  }
@@ -24,12 +24,12 @@ declare class Context implements IObjectRecord {
24
24
  gitModel: string | undefined;
25
25
  docModel: string | undefined;
26
26
  errorMessage: string;
27
+ projectPath: string;
27
28
  projectModel: string | undefined;
28
29
  gitServices: GitServices;
29
30
  isGitApi: boolean;
30
31
  gitApi: IGitApi | undefined;
31
32
  version: string | undefined;
32
- dictionaryFolder: string;
33
33
  options: Record<string, AnyValue>;
34
34
  projectServices: ProjectServices;
35
35
  isProjectApi: boolean;
@@ -39,6 +39,7 @@ declare class Context implements IObjectRecord {
39
39
  branchName: string | undefined;
40
40
  issueNumber: string | undefined;
41
41
  issueType: string | undefined;
42
+ _dictionaryFolder: string | undefined;
42
43
  _process: string | undefined;
43
44
  _processesHeader: Record<string, IProcessHeader> | undefined;
44
45
  _newIssueNumber: string | undefined;
@@ -80,10 +81,12 @@ declare class Context implements IObjectRecord {
80
81
  [key: string]: any;
81
82
  };
82
83
  addProcessMetadata(component: string, items: string[]): void;
84
+ set dictionaryFolder(value: string);
85
+ get dictionaryFolder(): string;
83
86
  get processesHeader(): Record<string, IProcessHeader>;
84
87
  getProcessMetadata(): IProcessInfo[];
85
88
  getModules(): string[];
86
- get modules(): PromptChoices;
89
+ modules(): PromptChoices;
87
90
  get existScratch(): boolean;
88
91
  get scratch(): OrganizationInfo;
89
92
  validate(guards: string[]): Promise<void>;
@@ -43,13 +43,16 @@ function searchInFolderHierarchy(element, parentFolder) {
43
43
  }
44
44
  return '';
45
45
  }
46
+ function getProjectPath() {
47
+ return searchInFolderHierarchy('package.json', process.cwd() || '.');
48
+ }
46
49
  function getDataFromPackage() {
47
50
  const data = {};
48
51
  try {
49
- const PROJECT_FOLDER = searchInFolderHierarchy('package.json', process.cwd() || '.');
50
- const filename = `${PROJECT_FOLDER}/package.json`;
52
+ const projectPath = getProjectPath();
53
+ const filename = `${projectPath}/package.json`;
51
54
  if (!fs.existsSync(filename)) {
52
- throw new Error("No se encontro el package.json en " + PROJECT_FOLDER);
55
+ throw new Error("No se encontro el package.json en " + projectPath);
53
56
  }
54
57
  const content = fs.readFileSync(filename, "utf8");
55
58
  const packageJson = JSON.parse(content);
@@ -91,12 +94,12 @@ class Context {
91
94
  gitModel;
92
95
  docModel;
93
96
  errorMessage = '';
97
+ projectPath = getProjectPath();
94
98
  projectModel;
95
99
  gitServices = GitServices.None;
96
100
  isGitApi = false;
97
101
  gitApi;
98
102
  version;
99
- dictionaryFolder = process.cwd() + "/docs";
100
103
  options = {};
101
104
  projectServices = ProjectServices.None;
102
105
  isProjectApi = false;
@@ -106,6 +109,7 @@ class Context {
106
109
  branchName;
107
110
  issueNumber;
108
111
  issueType;
112
+ _dictionaryFolder;
109
113
  _process;
110
114
  _processesHeader;
111
115
  _newIssueNumber;
@@ -322,6 +326,12 @@ class Context {
322
326
  throw new Error(`No se pudo guardar la metadata`);
323
327
  }
324
328
  }
329
+ set dictionaryFolder(value) {
330
+ this._dictionaryFolder = value;
331
+ }
332
+ get dictionaryFolder() {
333
+ return this._dictionaryFolder ? this._dictionaryFolder : getProjectPath() + '/docs';
334
+ }
325
335
  get processesHeader() {
326
336
  if (!this._processesHeader) {
327
337
  this._processesHeader = {};
@@ -361,9 +371,9 @@ class Context {
361
371
  return retArray;
362
372
  }
363
373
  getModules() {
364
- return getFiles(this.dictionaryFolder, filterDirectory, false, ['diccionarios']);
374
+ return getFiles(this.dictionaryFolder, filterDirectory, false, ['diccionarios', 'src', '.docusaurus', 'node_modules']);
365
375
  }
366
- get modules() {
376
+ modules() {
367
377
  return this.getModules().map(module => { return { value: module, title: module }; });
368
378
  }
369
379
  get existScratch() {
@@ -549,7 +559,7 @@ class Context {
549
559
  }
550
560
  return inputsArray;
551
561
  }
552
- async askForExit() {
562
+ async askForExit( /* prompt: PromptObject */) {
553
563
  const answer = await prompts([
554
564
  {
555
565
  type: "confirm",
@@ -583,14 +593,19 @@ class Context {
583
593
  }
584
594
  async askForArguments(inputs) {
585
595
  // unifica los dos tipos de inputs (array y objeto) en un array de inputs
586
- const inputsArray = await this.convertToArrayOfInputs(inputs);
587
- for (const input of inputsArray) {
588
- const hasValue = await this.get(input.name);
589
- if (!hasValue) {
590
- const answer = await prompts([input], { onCancel: this.askForExit });
591
- this[input.name] = answer[input.name];
596
+ try {
597
+ const inputsArray = await this.convertToArrayOfInputs(inputs);
598
+ for (const input of inputsArray) {
599
+ const hasValue = await this.get(input.name);
600
+ if (!hasValue) {
601
+ const answer = await prompts([input], { onCancel: this.askForExit });
602
+ this[input.name] = answer[input.name];
603
+ }
592
604
  }
593
605
  }
606
+ catch {
607
+ throw new Error(`No se pudo obtener los argumentos para ${inputs}`);
608
+ }
594
609
  }
595
610
  setObject(obj) {
596
611
  for (const field in obj) {
@@ -4,7 +4,7 @@ import { DICTIONARY_FOLDER, getModelFolders } from "./util.js";
4
4
  let _templateEngine;
5
5
  function getTemplateEngine() {
6
6
  if (!_templateEngine) {
7
- _templateEngine = templateGenerator(getModelFolders('dictionary'), "md");
7
+ _templateEngine = templateGenerator(getModelFolders('templates/dictionary'), "md");
8
8
  }
9
9
  return _templateEngine;
10
10
  }
@@ -4,7 +4,7 @@ import { DICTIONARY_FOLDER, getModelFolders } from "./util.js";
4
4
  let _templateEngine;
5
5
  function getTemplateEngine() {
6
6
  if (!_templateEngine) {
7
- _templateEngine = templateGenerator(getModelFolders('dictionary'), "md");
7
+ _templateEngine = templateGenerator(getModelFolders('templates/dictionary'), "md");
8
8
  }
9
9
  return _templateEngine;
10
10
  }
@@ -18,11 +18,11 @@ function generateTemplate(templateFolder, templateExtension, template, context)
18
18
  templateEngine.render(view);
19
19
  return templateEngine.rendered;
20
20
  }
21
- function createTemplate(templateFolder, templateExtension, template, filename, folder, context) {
22
- if (!template || !filename || !templateFolder || !templateExtension) {
21
+ function createTemplate(templateFolders, templateExtension, template, filename, folder, context) {
22
+ if (!template || !filename || !templateFolders || !templateExtension) {
23
23
  return;
24
24
  }
25
- const templateEngine = templateGenerator([templateFolder], templateExtension);
25
+ const templateEngine = templateGenerator(templateFolders, templateExtension);
26
26
  const formulas = {
27
27
  today: Date.now(),
28
28
  filename
@@ -57,7 +57,8 @@ export async function executeCommand(step) {
57
57
  execSync(step.command + ' ' + convertArgsToString(step.arguments), { stdio: 'inherit' });
58
58
  return true;
59
59
  }
60
- catch {
60
+ catch (e) {
61
+ context.errorMessage = `Se produjo un error al ejecutar el comando: ${e}`;
61
62
  return false;
62
63
  }
63
64
  }
@@ -246,15 +247,15 @@ export const taskFunctions = {
246
247
  if (!tryToRetrieve) {
247
248
  return false;
248
249
  }
249
- executeShell(`sf project retrieve start`);
250
+ executeShell("sf project retrieve start");
250
251
  return await this.validateScratch();
251
252
  },
252
253
  async validateScratch() {
253
254
  const salida = executeShell("sf project retrieve preview");
254
255
  context.salida = salida;
255
- const noHayCambios = salida.indexOf('No files will be deleted') !== -1 && salida.indexOf('No files will be retrieved') !== -1 && salida.indexOf('No conflicts found') !== -1;
256
+ context.noHayCambios = salida.indexOf('No files will be deleted') !== -1 && salida.indexOf('No files will be retrieved') !== -1 && salida.indexOf('No conflicts found') !== -1;
256
257
  // Probar de bajarlos // sf project retrieve start
257
- return noHayCambios;
258
+ return context.noHayCambios;
258
259
  },
259
260
  async commitChanges() {
260
261
  const tryToCommit = await askForContinue("Desea commitear los cambios?");
@@ -370,7 +371,7 @@ export const taskFunctions = {
370
371
  },
371
372
  async createTemplate(template, folder, name, identifier) {
372
373
  const filename = name.toLocaleLowerCase().replaceAll(' ', '-') + '.md';
373
- createTemplate('.', 'md', template, filename, folder, { name, identifier });
374
+ createTemplate(getModelFolders('templates'), 'md', template, filename, folder, { name, identifier });
374
375
  return true;
375
376
  },
376
377
  async validateIssue(issueNumber, states) {
@@ -58,7 +58,7 @@ export class TemplateEngine {
58
58
  // Busca en las carpetas el archivo
59
59
  for (const currentFolder of this._sourceFolders) {
60
60
  folder = currentFolder;
61
- const filterWithExtension = (fileName) => fileName === `${name}.${extension}`;
61
+ const filterWithExtension = (fileName) => fileName.endsWith(`/${name}.${extension}`);
62
62
  const filterWithoutExtension = (fileName) => fileName.split(".")[0].endsWith(name);
63
63
  const filter = (extension === '*' || extension === '') ? filterWithoutExtension : filterWithExtension;
64
64
  const fileNames = getFiles(folder, filter);
@@ -141,6 +141,16 @@ async function getBaseConfig(config) {
141
141
  config.backlogColumn = backlogColumn.backlogColumn;
142
142
  logInfo(`Por omision ser utilizan proyectos dentro de ${context.repositoryOwner} y ${context.repositoryRepo} `);
143
143
  }
144
+ // dictionaryFolder
145
+ const dictionaryFolder = await prompts([{
146
+ type: "text",
147
+ name: "dictionaryFolder",
148
+ initial: config.dictionaryFolder,
149
+ message: "Ruta a los modulos de la documentacion (desde el root del proyecto)"
150
+ }]);
151
+ if (dictionaryFolder.dictionaryFolder === undefined)
152
+ return;
153
+ config.dictionaryFolder = dictionaryFolder.dictionaryFolder;
144
154
  // Id de Projecto
145
155
  const projectId = await prompts([{
146
156
  type: "text",
@@ -8,7 +8,6 @@
8
8
  "steps": [
9
9
  { "name": "Actualiza la version", "function": "storeConfig", "arguments": ["version", "${newVersion}"] },
10
10
  { "name": "Paquetiza", "subtask": "pack" },
11
- { "name": "Salida para el Changelog.md", "task": "list", "arguments": {"filter": "milestone", "template": "changelog", "milestone": "v${newVersion}"} },
12
11
  { "name": "Publica", "command": "yarn publish ", "arguments": {"--new-version": "${newVersion}"} },
13
12
  { "name": "Actualiza el milestone", "function": "updateMilestone", "arguments": ["v${newVersion}", "closed"] }
14
13
  ]
@@ -20,7 +20,7 @@
20
20
  "--name": "${scratchName}",
21
21
  "--duration-days": "${dias}"
22
22
  },
23
- "errorMessage": "No se pudo crear la scracth org, verifique que no se haya pasado del limite scratchs (3 activas)* sf org list --clean\n* o bien si quedo en la mitad del proceso\n* sf org resume"
23
+ "errorMessage": "No se pudo crear la scracth org, verifique que no se haya pasado del limite scratchs (3 activas)* sf org list --clean\n* o bien si quedo en la mitad del proceso\n* sf org resume. Pruebe manualmente: ${command}"
24
24
  },
25
25
  {
26
26
  "criteria": { "field": "existBranchScratch", "value": true },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "process",
3
3
  "arguments": {
4
- "folder": { "type": "select", "choices": "${modules}" },
4
+ "folder": { "type": "select", "values": "modules" },
5
5
  "name": { "required": true },
6
6
  "identifier": { "required": true }
7
7
  },
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.25",
5
+ "version": "0.1.27",
6
6
  "keywords": [
7
7
  "Salesforce",
8
8
  "Automation",
@@ -69,5 +69,6 @@
69
69
  "prompts": "^2.4.2"
70
70
  },
71
71
  "author": "Sebastian Claros <sclaros@gmail.com>",
72
- "license": "MIT"
72
+ "license": "MIT",
73
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
73
74
  }