autoforce 0.1.2 → 0.1.4

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 (49) hide show
  1. package/README.md +44 -6
  2. package/bin/index.js +6 -0
  3. package/commands/new/issue.json +40 -0
  4. package/commands/new/process.json +21 -0
  5. package/commands/subtasks/checkout-branch.json +60 -0
  6. package/commands/subtasks/create-pull.json +20 -0
  7. package/commands/subtasks/create-scratch.json +84 -0
  8. package/commands/subtasks/deploy-code.json +17 -0
  9. package/commands/subtasks/drop-scratch.json +17 -0
  10. package/commands/subtasks/package-code.json +3 -0
  11. package/commands/subtasks/publish-branch.json +20 -0
  12. package/commands/subtasks/update-documentation.json +8 -0
  13. package/commands/subtasks/validate-code.json +29 -0
  14. package/commands/subtasks/validate-scratch.json +14 -0
  15. package/commands/tasks/cancel.json +6 -0
  16. package/commands/tasks/deploy.json +6 -0
  17. package/commands/tasks/finish.json +41 -0
  18. package/commands/tasks/rollback.json +6 -0
  19. package/commands/tasks/start.json +60 -0
  20. package/commands/tasks/stop.json +32 -0
  21. package/commands/tasks/switch.json +53 -0
  22. package/commands/tasks/view.json +12 -0
  23. package/lib/auto.js +30 -15
  24. package/lib/helpers/class.js +2 -2
  25. package/lib/helpers/context.d.ts +1 -1
  26. package/lib/helpers/context.js +24 -28
  27. package/lib/helpers/github-graphql.d.ts +1 -76
  28. package/lib/helpers/github-graphql.js +331 -363
  29. package/lib/helpers/lwc.js +2 -2
  30. package/lib/helpers/metadata.js +2 -2
  31. package/lib/helpers/object.js +2 -2
  32. package/lib/helpers/tasks.js +10 -5
  33. package/lib/helpers/util.d.ts +4 -1
  34. package/lib/helpers/util.js +45 -2
  35. package/package.json +11 -5
  36. package/templates/dictionary/class-all.md +9 -0
  37. package/templates/dictionary/class-diagrama.md +13 -0
  38. package/templates/dictionary/class-inner.md +19 -0
  39. package/templates/dictionary/class-metodos.md +15 -0
  40. package/templates/dictionary/class-public.md +13 -0
  41. package/templates/dictionary/class-referencias.md +5 -0
  42. package/templates/dictionary/class.md +29 -0
  43. package/templates/dictionary/classes.md +52 -0
  44. package/templates/dictionary/object.md +35 -0
  45. package/templates/dictionary/objects.md +63 -0
  46. package/templates/intro.md +20 -0
  47. package/templates/process.md +23 -0
  48. package/templates/story.md +32 -0
  49. package/templates/usecase.md +52 -0
package/lib/auto.js CHANGED
@@ -10,32 +10,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  // Comandos validos
11
11
  import { createObject, validateTask, getTasks, helpTask, runTask, getTaskFolder } from "./helpers/tasks.js";
12
12
  import { logError } from "./helpers/color.js";
13
- import { createConfigurationFile } from "./helpers/context.js";
14
13
  import prompts from "prompts";
15
- const proxyCommnad = {
14
+ import { createConfigurationFile } from "./helpers/util.js";
15
+ const proxyCommand = {
16
+ 'version': showVersion,
17
+ 'config': createConfigurationFile
18
+ };
19
+ const taskCommand = {
16
20
  'help': helpTask,
17
21
  'task': runTask,
18
22
  'new': runTask,
19
- 'config': createConfigurationFile,
20
23
  'subtask': runTask
21
24
  };
25
+ function showVersion() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ console.log('AutoForce v0.1.3');
28
+ return true;
29
+ });
30
+ }
22
31
  export default function main() {
23
32
  return __awaiter(this, void 0, void 0, function* () {
24
33
  try {
25
34
  const config = getConfigFromArgs(process.argv.slice(2));
26
- const tasks = getTasks(config.taskFolder);
27
- const taskName = yield askForTaskName(config.taskName, tasks);
28
- if (taskName) {
29
- const task = tasks[taskName];
30
- const options = config.arguments && task.arguments ? Object.assign(Object.assign({}, config.options), createObject(task.arguments, config.arguments)) : config.options;
31
- // Valida los json de task y subtask
32
- if (validateTask(task)) {
33
- yield proxyCommnad[config.command](task, options);
34
- }
35
- else {
36
- logError('Verifique que los json de task y subtask esten validos');
35
+ const taskCommandKeys = Object.keys(taskCommand);
36
+ if (taskCommandKeys.includes(config.command)) {
37
+ const tasks = getTasks(config.taskFolder);
38
+ const taskName = yield askForTaskName(config.taskName, tasks);
39
+ if (taskName) {
40
+ const task = tasks[taskName];
41
+ const options = config.arguments && task.arguments ? Object.assign(Object.assign({}, config.options), createObject(task.arguments, config.arguments)) : config.options;
42
+ // Valida los json de task y subtask
43
+ if (validateTask(task)) {
44
+ yield taskCommand[config.command](task, options);
45
+ }
46
+ else {
47
+ logError('Verifique que los json de task y subtask esten validos');
48
+ }
37
49
  }
38
50
  }
51
+ else {
52
+ yield proxyCommand[config.command]();
53
+ }
39
54
  }
40
55
  catch (error) {
41
56
  if (error instanceof Error) {
@@ -59,7 +74,7 @@ export function getConfigFromArgs(processArgs) {
59
74
  }
60
75
  // De acuerdo a args separa comando[help, preview, task o subtask] de taskName
61
76
  let currentArgument = args.shift();
62
- const comandosValidos = Object.keys(proxyCommnad);
77
+ const comandosValidos = [...Object.keys(proxyCommand), ...Object.keys(taskCommand)];
63
78
  if (currentArgument && comandosValidos.includes(currentArgument)) {
64
79
  config.command = currentArgument;
65
80
  currentArgument = args.shift();
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import sf from "./connect.js";
11
11
  import templateGenerator from "./template.js";
12
12
  const templateEngine = templateGenerator("dictionary", "md");
13
- import { sortByName, getNamesByExtension, verFecha, splitFilename, DICTIONARY_FOLDER, DOCS_FOLDER } from "./util.js";
13
+ import { sortByName, getNamesByExtension, verFecha, splitFilename, DICTIONARY_FOLDER, TEMPLATES_FOLDER } from "./util.js";
14
14
  function getMetadata(clases) {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
16
  try {
@@ -189,7 +189,7 @@ function executeClasses(items, filename, folder) {
189
189
  classLink
190
190
  }
191
191
  });
192
- templateEngine.save(filename, DOCS_FOLDER + "/" + folder);
192
+ templateEngine.save(filename, TEMPLATES_FOLDER + "/" + folder);
193
193
  });
194
194
  }
195
195
  const classModule = {
@@ -1,7 +1,6 @@
1
1
  import type { PromptChoices } from "../types/helpers/context.js";
2
2
  import type { IProcessHeader, Processes, AnyValue, IProcessInfo, ObjectRecord, IObjectRecord } from "../types/auto.js";
3
3
  import type { TaskArguments, TaskArgument, StepArguments } from "../types/helpers/tasks.js";
4
- export declare function createConfigurationFile(): Promise<boolean>;
5
4
  declare class Context implements IObjectRecord {
6
5
  [s: string]: AnyValue | undefined;
7
6
  isGitApi: boolean;
@@ -77,4 +76,5 @@ declare class Context implements IObjectRecord {
77
76
  merge(text: string): string;
78
77
  }
79
78
  declare const context: Context;
79
+ export declare function initializeContext(): void;
80
80
  export default context;
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { executeShell, getOrganizationObject, getCurrentOrganization, getBranchName, getTargetOrg } from "./taskFunctions.js";
11
- import { convertNameToKey, convertKeyToName, getFiles, filterDirectory, addNewItems } from "./util.js";
12
- import { GitHubApi } from "./github-graphql.js";
11
+ import { convertNameToKey, convertKeyToName, getFiles, filterDirectory, addNewItems, CONFIG_FILE, createConfigurationFile } from "./util.js";
12
+ //import {GitHubApi} from "./github-graphql.js";
13
13
  import { GitLabApi } from "./gitlab-graphql.js";
14
14
  import prompts from "prompts";
15
15
  import matter from 'gray-matter';
@@ -17,24 +17,6 @@ import fs from "fs";
17
17
  import { logError } from "./color.js";
18
18
  const filterProcesses = (fullPath) => fullPath.endsWith(".md"); // && !fullPath.endsWith("intro.md")
19
19
  const ISSUES_TYPES = [{ value: 'feature', title: 'feature' }, { value: 'bug', title: 'bug' }, { value: 'documentation', title: 'documentation' }, { value: 'automation', title: 'automation' }];
20
- const CONFIG_FILE = process.cwd() + '/.autoforce.json';
21
- export function createConfigurationFile() {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- console.log('Preguntar por GitHub o GitLab');
24
- console.log('Chequear las variables de entorno');
25
- console.log('Tema proyecto guardar la referencia');
26
- console.log('Genera documentacion');
27
- console.log('Direccion de las carpetas');
28
- const config = { projectNumber: 1 };
29
- try {
30
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
31
- }
32
- catch (_a) {
33
- throw new Error(`No se pudo guardar la configuracion en ${CONFIG_FILE}`);
34
- }
35
- return true;
36
- });
37
- }
38
20
  class Context {
39
21
  constructor() {
40
22
  this.isGitApi = false;
@@ -51,13 +33,13 @@ class Context {
51
33
  if (!this.repositoryOwner || !this.repositoryRepo || !this.repositoryUrl) {
52
34
  throw new Error("Falta agregue repository en el package.json para obtener el Owner or Repo");
53
35
  }
54
- const isGithub = this.repositoryUrl.indexOf('github') > 0;
36
+ //const isGithub = this.repositoryUrl.indexOf('github') > 0 ;
55
37
  const isGitlab = this.repositoryUrl.indexOf('gitlab') > 0;
56
- if (isGithub && process.env.GITHUB_TOKEN) {
57
- const token = process.env.GITHUB_TOKEN;
58
- this.gitApi = new GitHubApi(token, this.repositoryOwner, this.repositoryRepo, this.projectNumber);
59
- this.isGitApi = true;
60
- }
38
+ //if ( isGithub && process.env.GITHUB_TOKEN ) {
39
+ // const token = process.env.GITHUB_TOKEN ;
40
+ // this.gitApi = new GitHubApi(token, this.repositoryOwner, this.repositoryRepo, this.projectNumber);
41
+ // this.isGitApi = true;
42
+ //}
61
43
  if (isGitlab && process.env.GITLAB_TOKEN) {
62
44
  const token = process.env.GITLAB_TOKEN;
63
45
  this.gitApi = new GitLabApi(token, this.repositoryOwner, this.repositoryRepo, this.projectNumber);
@@ -114,8 +96,8 @@ class Context {
114
96
  }
115
97
  init() {
116
98
  // Busca variables de entorno
117
- this.loadPackage();
118
99
  this.loadConfig();
100
+ this.loadPackage();
119
101
  this.loadGitApi();
120
102
  //
121
103
  this.branchName = getBranchName();
@@ -484,5 +466,19 @@ class Context {
484
466
  }
485
467
  }
486
468
  const context = new Context();
487
- context.init();
469
+ let initialized = false;
470
+ export function initializeContext() {
471
+ try {
472
+ if (!initialized) {
473
+ context.init();
474
+ initialized = true;
475
+ }
476
+ }
477
+ catch (error) {
478
+ if (error instanceof Error) {
479
+ logError(error.message);
480
+ }
481
+ process.exit(1);
482
+ }
483
+ }
488
484
  export default context;
@@ -1,76 +1 @@
1
- export declare class GitHubApi implements IGitApi, IProjectApi {
2
- repoVar: {
3
- owner: string;
4
- repo: string;
5
- };
6
- projectNumber: number | undefined;
7
- graphqlAuth: import("@octokit/graphql/types").graphql;
8
- constructor(token: string, owner: string, repo: string, projectNumber?: number);
9
- getUser(): Promise<{
10
- login: string;
11
- id: number;
12
- }>;
13
- getRepository(label?: string): Promise<{
14
- id: string;
15
- label?: {
16
- id: string;
17
- } | undefined;
18
- projectV2: {
19
- id: string;
20
- field: {
21
- id: string;
22
- name: string;
23
- options: {
24
- name: string;
25
- id: string;
26
- }[];
27
- };
28
- };
29
- }>;
30
- createPullRequest(branchName: string, title: string, body: string): Promise<boolean>;
31
- getColumnValueMap(): Promise<Record<string, string>>;
32
- createIssue(title: string, state?: string, label?: string, milestone?: string, body?: string): Promise<number>;
33
- moveIssue(issueNumber: number, state: string): Promise<boolean>;
34
- assignIssueToMe(issueNumber: number): Promise<boolean>;
35
- getCommit(commitSha: string): Promise<{
36
- id: string;
37
- oid: string;
38
- }>;
39
- assignBranchToIssue(issueNumber: number, branchName: string, commitSha: string): Promise<boolean>;
40
- getIssueState(issueNumber: number): Promise<string>;
41
- getIssueName(title: string): string;
42
- getIssueObject(issueNumber: number): Promise<IIssueObject>;
43
- getIssue(issueNumber: number): Promise<{
44
- id: string;
45
- title: string;
46
- labels: {
47
- nodes: {
48
- name: string;
49
- color: string;
50
- }[];
51
- };
52
- projectItems: {
53
- nodes: {
54
- id: string;
55
- project: {
56
- id: string;
57
- };
58
- fieldValueByName: {
59
- name: string;
60
- id: string;
61
- field: {
62
- id: string;
63
- };
64
- };
65
- }[];
66
- };
67
- linkedBranches: {
68
- nodes: {
69
- ref: {
70
- id: string;
71
- name: string;
72
- };
73
- }[];
74
- };
75
- }>;
76
- }
1
+ export {};