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/context.js
CHANGED
@@ -21,19 +21,20 @@ export var GitServices;
|
|
21
21
|
GitServices["GitHub"] = "github";
|
22
22
|
GitServices["GitLab"] = "gitlab";
|
23
23
|
GitServices["None"] = "none";
|
24
|
-
})(GitServices
|
24
|
+
})(GitServices || (GitServices = {}));
|
25
25
|
export var ProjectServices;
|
26
26
|
(function (ProjectServices) {
|
27
27
|
ProjectServices["GitHub"] = "github";
|
28
28
|
ProjectServices["GitLab"] = "gitlab";
|
29
29
|
ProjectServices["Jira"] = "Jira";
|
30
30
|
ProjectServices["None"] = "none";
|
31
|
-
})(ProjectServices
|
31
|
+
})(ProjectServices || (ProjectServices = {}));
|
32
32
|
const filterProcesses = (fullPath) => fullPath.endsWith(".md"); // && !fullPath.endsWith("intro.md")
|
33
33
|
const ISSUES_TYPES = [{ value: 'feature', title: 'feature' }, { value: 'bug', title: 'bug' }, { value: 'documentation', title: 'documentation' }, { value: 'automation', title: 'automation' }];
|
34
34
|
class Context {
|
35
35
|
constructor() {
|
36
|
-
this.model = 'modelA'; // Default Model
|
36
|
+
this.model = 'modelA'; // Default Model de commands
|
37
|
+
this.modelTemplates = 'modelA'; // Default Model de templates
|
37
38
|
this.gitServices = GitServices.None;
|
38
39
|
this.isGitApi = false;
|
39
40
|
this.projectServices = ProjectServices.None;
|
@@ -46,6 +47,8 @@ class Context {
|
|
46
47
|
// Ultima salida del shell
|
47
48
|
this.salida = '';
|
48
49
|
this.backlogColumn = 'Todo';
|
50
|
+
this.loadConfig();
|
51
|
+
this.loadPackage();
|
49
52
|
}
|
50
53
|
loadProjectApi() {
|
51
54
|
if (!this.isProjectApi) {
|
@@ -118,28 +121,38 @@ class Context {
|
|
118
121
|
this.repositoryRepo = data.repositoryRepo;
|
119
122
|
}
|
120
123
|
loadConfig() {
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
125
|
+
if (!fs.existsSync(CONFIG_FILE)) {
|
126
|
+
logWarning('Bienvenido! La herramienta Autoforce necesita un primer paso de configuracion antes de usarla.');
|
127
|
+
logWarning('- Podes usar el asistente ejecutando npx autoforce config');
|
128
|
+
logWarning('- Podes hacerlo manualmente leyendo la documentacion y creando .autoforce.json manualmente en el root del proyecto (https://sebastianclaros.github.io/autoforce/docs/configuracion)');
|
129
|
+
const answer = yield prompts([
|
130
|
+
{
|
131
|
+
type: "confirm",
|
132
|
+
name: "asistente",
|
133
|
+
message: "Queres ejecutar el asistente ahora?"
|
134
|
+
}
|
135
|
+
]);
|
136
|
+
if (answer.asistente) {
|
137
|
+
yield createConfigurationFile();
|
138
|
+
return true;
|
139
|
+
}
|
140
|
+
return false;
|
133
141
|
}
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
142
|
+
const content = fs.readFileSync(CONFIG_FILE, "utf8");
|
143
|
+
try {
|
144
|
+
const config = JSON.parse(content);
|
145
|
+
for (const key in config) {
|
146
|
+
this.set(key, config[key]);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
catch (_a) {
|
150
|
+
throw new Error(`Verifique que el ${CONFIG_FILE} sea json valido`);
|
151
|
+
}
|
152
|
+
return true;
|
153
|
+
});
|
138
154
|
}
|
139
155
|
init() {
|
140
|
-
// Busca variables de entorno
|
141
|
-
this.loadConfig();
|
142
|
-
this.loadPackage();
|
143
156
|
this.loadProjectApi();
|
144
157
|
this.loadGitApi();
|
145
158
|
//
|
@@ -242,9 +255,17 @@ class Context {
|
|
242
255
|
validate(guards) {
|
243
256
|
return __awaiter(this, void 0, void 0, function* () {
|
244
257
|
for (const guard of guards) {
|
245
|
-
|
246
|
-
if (
|
247
|
-
|
258
|
+
// Chequeo de variables de entorno
|
259
|
+
if (guard[0] === '$') {
|
260
|
+
if (!process.env[guard.substring(1)]) {
|
261
|
+
throw new Error(`La variable de entorno ${guard} no esta configurada.`);
|
262
|
+
}
|
263
|
+
}
|
264
|
+
else {
|
265
|
+
const value = yield this.get(guard);
|
266
|
+
if (!value) {
|
267
|
+
throw new Error(`No se encontro la variable ${guard} en el contexto. Ejecute yarn auto config o lea el index.md para mas informacion.`);
|
268
|
+
}
|
248
269
|
}
|
249
270
|
}
|
250
271
|
});
|
@@ -450,7 +471,7 @@ class Context {
|
|
450
471
|
}
|
451
472
|
setObject(obj) {
|
452
473
|
for (const field in obj) {
|
453
|
-
Object.defineProperty(this, field, obj[field]);
|
474
|
+
Object.defineProperty(this, field, { value: obj[field], writable: true });
|
454
475
|
}
|
455
476
|
}
|
456
477
|
set(key, value) {
|
@@ -512,7 +533,7 @@ const context = new Context();
|
|
512
533
|
let initialized = false;
|
513
534
|
export function initializeContext() {
|
514
535
|
try {
|
515
|
-
if (
|
536
|
+
if (initialized === false) {
|
516
537
|
context.init();
|
517
538
|
initialized = true;
|
518
539
|
}
|
@@ -95,8 +95,8 @@ export class GitHubApi {
|
|
95
95
|
});
|
96
96
|
}
|
97
97
|
assignBranchToIssue(issueNumber, branchName, commitSha) {
|
98
|
-
var _a;
|
99
98
|
return __awaiter(this, void 0, void 0, function* () {
|
99
|
+
var _a;
|
100
100
|
const issue = yield this.getIssue(issueNumber);
|
101
101
|
const commit = yield this.getCommit(commitSha);
|
102
102
|
const mutation = `
|
@@ -3,7 +3,7 @@ export declare class GitHubProjectApi extends GitHubApi implements IProjectApi {
|
|
3
3
|
projectNumber: number;
|
4
4
|
constructor(token: string, owner: string, repo: string, projectNumber: number);
|
5
5
|
getColumnValueMap(): Promise<Record<string, string>>;
|
6
|
-
createIssue(title: string, state?: string, label?: string,
|
6
|
+
createIssue(title: string, state?: string, label?: string, body?: string, milestone?: string): Promise<number>;
|
7
7
|
getIssueState(issueNumber: string): Promise<string>;
|
8
8
|
getIssueName(title: string): string;
|
9
9
|
getIssueObject(issueNumber: string): Promise<IIssueObject>;
|
@@ -11,6 +11,14 @@ export declare class GitHubProjectApi extends GitHubApi implements IProjectApi {
|
|
11
11
|
id: string;
|
12
12
|
title: string;
|
13
13
|
}[]>;
|
14
|
+
getIssuesByMilestone(milestone: string): Promise<{
|
15
|
+
id: string;
|
16
|
+
title: string;
|
17
|
+
}[]>;
|
18
|
+
getIssuesWithFilter(filterBy: string): Promise<{
|
19
|
+
id: string;
|
20
|
+
title: string;
|
21
|
+
}[]>;
|
14
22
|
moveIssue(issueNumber: string, state: string): Promise<boolean>;
|
15
23
|
assignIssueToMe(issueNumber: string): Promise<boolean>;
|
16
24
|
}
|
@@ -42,9 +42,9 @@ export class GitHubProjectApi extends GitHubApi {
|
|
42
42
|
return mapValues;
|
43
43
|
});
|
44
44
|
}
|
45
|
-
createIssue(title, state, label,
|
46
|
-
var _a;
|
45
|
+
createIssue(title, state, label, body, milestone) {
|
47
46
|
return __awaiter(this, void 0, void 0, function* () {
|
47
|
+
var _a;
|
48
48
|
const user = yield this.getUser();
|
49
49
|
const repository = yield this.getRepository(label);
|
50
50
|
const repositoryId = repository.id;
|
@@ -115,8 +115,8 @@ export class GitHubProjectApi extends GitHubApi {
|
|
115
115
|
});
|
116
116
|
}
|
117
117
|
getIssueState(issueNumber) {
|
118
|
-
var _a, _b, _c;
|
119
118
|
return __awaiter(this, void 0, void 0, function* () {
|
119
|
+
var _a, _b, _c;
|
120
120
|
const issue = yield this.getIssue(issueNumber);
|
121
121
|
return (_c = (_b = (_a = issue.projectItems) === null || _a === void 0 ? void 0 : _a.nodes[0]) === null || _b === void 0 ? void 0 : _b.fieldValueByName) === null || _c === void 0 ? void 0 : _c.name;
|
122
122
|
});
|
@@ -145,19 +145,29 @@ export class GitHubProjectApi extends GitHubApi {
|
|
145
145
|
});
|
146
146
|
}
|
147
147
|
getIssues() {
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
149
|
+
return yield this.getIssuesWithFilter(`{ states: OPEN }`);
|
150
|
+
});
|
151
|
+
}
|
152
|
+
getIssuesByMilestone(milestone) {
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
154
|
+
return yield this.getIssuesWithFilter(`{ milestone: ${milestone} }`);
|
155
|
+
});
|
156
|
+
}
|
157
|
+
getIssuesWithFilter(filterBy) {
|
148
158
|
return __awaiter(this, void 0, void 0, function* () {
|
149
159
|
const query = `
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
160
|
+
query getIssues($owner:String!, $repo: String!) {
|
161
|
+
repository(owner: $owner, name: $repo) {
|
162
|
+
issues(last: 10, filterBy: ${filterBy} ) {
|
163
|
+
nodes {
|
164
|
+
title
|
165
|
+
id
|
166
|
+
}
|
167
|
+
}
|
156
168
|
}
|
157
169
|
}
|
158
|
-
|
159
|
-
}
|
160
|
-
`;
|
170
|
+
`;
|
161
171
|
const { repository } = yield this.graphqlAuth(query, this.repoVar);
|
162
172
|
return repository.issues.nodes;
|
163
173
|
});
|
@@ -10,7 +10,8 @@ export declare class GitLabApi implements IGitApi, IProjectApi {
|
|
10
10
|
constructor(token: string, owner: string, repo: string, projectNumber?: number);
|
11
11
|
getIssueObject(issueNumber: string): Promise<{}>;
|
12
12
|
getIssues(): Promise<never[]>;
|
13
|
-
|
13
|
+
getIssuesByMilestone(milestone: string): Promise<never[]>;
|
14
|
+
createIssue(title: string, state?: string, label?: string, body?: string, milestone?: string): Promise<number>;
|
14
15
|
moveIssue(issueNumber: string, state: string): Promise<boolean>;
|
15
16
|
assignIssueToMe(issueNumber: string): Promise<boolean>;
|
16
17
|
getUser(): Promise<{
|
@@ -27,9 +27,14 @@ export class GitLabApi {
|
|
27
27
|
return [];
|
28
28
|
});
|
29
29
|
}
|
30
|
-
|
30
|
+
getIssuesByMilestone(milestone) {
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
32
|
-
|
32
|
+
return [];
|
33
|
+
});
|
34
|
+
}
|
35
|
+
createIssue(title, state, label, body, milestone) {
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
37
|
+
console.log(title, state, label, body, milestone);
|
33
38
|
return 1;
|
34
39
|
});
|
35
40
|
}
|
package/lib/helpers/lwc.js
CHANGED
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
};
|
10
10
|
import sf from "./connect.js";
|
11
11
|
import templateGenerator from "./template.js";
|
12
|
-
|
13
|
-
|
12
|
+
import { DICTIONARY_FOLDER, TEMPLATE_MODEL_FOLDER } from "./util.js";
|
13
|
+
const templateEngine = templateGenerator(`${TEMPLATE_MODEL_FOLDER}/dictionary`, "md");
|
14
|
+
import { sortByName, splitFilename } from "./util.js";
|
14
15
|
function getMetadata(lwc) {
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
16
17
|
try {
|
@@ -59,7 +60,7 @@ function executeLwc(items, filename, folder) {
|
|
59
60
|
templateEngine.render(lwcContext, {
|
60
61
|
helpers: {}
|
61
62
|
});
|
62
|
-
templateEngine.save(filename,
|
63
|
+
templateEngine.save(filename, TEMPLATE_MODEL_FOLDER + "/" + folder);
|
63
64
|
});
|
64
65
|
}
|
65
66
|
const lwcModule = {
|
package/lib/helpers/metadata.js
CHANGED
@@ -10,7 +10,7 @@ const helpers = {
|
|
10
10
|
export default helpers;
|
11
11
|
/*
|
12
12
|
import context from "./context.js";
|
13
|
-
import {
|
13
|
+
import { TEMPLATE_MODEL_FOLDER } from "./util.js";
|
14
14
|
import type { DocumentationModule, IProcessInfo, IMetadataNode, IMetadataComponentNode } from "../types/auto.js";
|
15
15
|
function getMetadataFromContext(components: string[]) {
|
16
16
|
return getMetadataArray(context.getProcessMetadata(), components);
|
@@ -66,7 +66,7 @@ function getMetadataArray(metadata: IProcessInfo[], props: string[]) {
|
|
66
66
|
return items;
|
67
67
|
};
|
68
68
|
|
69
|
-
return getItemsFromTree({ folder:
|
69
|
+
return getItemsFromTree({ folder: TEMPLATE_MODEL_FOLDER, childs: metadata });
|
70
70
|
}
|
71
71
|
|
72
72
|
export async function execute() {
|
package/lib/helpers/object.js
CHANGED
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
};
|
10
10
|
import sf from "./connect.js";
|
11
11
|
import templateGenerator from "./template.js";
|
12
|
-
|
13
|
-
|
12
|
+
import { DICTIONARY_FOLDER, TEMPLATE_MODEL_FOLDER } from "./util.js";
|
13
|
+
const templateEngine = templateGenerator(`${TEMPLATE_MODEL_FOLDER}/dictionary`, "md");
|
14
|
+
import { sortByLabel } from "./util.js";
|
14
15
|
function getMetadata(objetos) {
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
16
17
|
try {
|
@@ -123,7 +124,7 @@ function executeObjects(items, filename, folder) {
|
|
123
124
|
templateEngine.render(objectContext, {
|
124
125
|
helpers: { isManaged, isMetadataFormula, attributesFormula }
|
125
126
|
});
|
126
|
-
templateEngine.save(filename,
|
127
|
+
templateEngine.save(filename, TEMPLATE_MODEL_FOLDER + "/" + folder);
|
127
128
|
});
|
128
129
|
}
|
129
130
|
const objectModule = {
|
package/lib/helpers/openai.js
CHANGED
@@ -12,8 +12,8 @@ const client = new OpenAI({
|
|
12
12
|
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
|
13
13
|
});
|
14
14
|
export function getCommitMessage() {
|
15
|
-
var _a;
|
16
15
|
return __awaiter(this, void 0, void 0, function* () {
|
16
|
+
var _a;
|
17
17
|
if (process.env['OPENAI_API_KEY']) {
|
18
18
|
const params = {
|
19
19
|
messages: [{ role: 'user', content: 'Say this is a test' }],
|
@@ -9,11 +9,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
};
|
10
10
|
import { execSync } from "child_process";
|
11
11
|
import context from "./context.js";
|
12
|
-
import { logError } from "./color.js";
|
12
|
+
import { logError, logInfo } from "./color.js";
|
13
13
|
import metadata from './metadata.js';
|
14
14
|
import prompts from "prompts";
|
15
15
|
import templateGenerator from "./template.js";
|
16
16
|
import { getColored } from "./color.js";
|
17
|
+
import { storeConfig, TEMPLATE_MODEL_FOLDER } from "./util.js";
|
18
|
+
function generateTemplate(templateFolder, templateExtension, template, context) {
|
19
|
+
if (!template || !templateFolder || !templateExtension) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
const templateEngine = templateGenerator(templateFolder, templateExtension);
|
23
|
+
const formulas = {
|
24
|
+
today: Date.now(),
|
25
|
+
};
|
26
|
+
const view = Object.assign(Object.assign({}, formulas), context);
|
27
|
+
templateEngine.read(template);
|
28
|
+
templateEngine.render(view);
|
29
|
+
return templateEngine.rendered;
|
30
|
+
}
|
17
31
|
function createTemplate(templateFolder, templateExtension, template, filename, folder, context) {
|
18
32
|
if (!template || !filename || !templateFolder || !templateExtension) {
|
19
33
|
return;
|
@@ -219,6 +233,14 @@ function getFilesChanged() {
|
|
219
233
|
return files;
|
220
234
|
}
|
221
235
|
export const taskFunctions = {
|
236
|
+
skip() {
|
237
|
+
logInfo('Error omitido por configuracion del step');
|
238
|
+
return true;
|
239
|
+
},
|
240
|
+
storeConfig(variable, value) {
|
241
|
+
storeConfig(variable, value);
|
242
|
+
return true;
|
243
|
+
},
|
222
244
|
docProcess() {
|
223
245
|
return __awaiter(this, void 0, void 0, function* () {
|
224
246
|
if (!context.process) {
|
@@ -312,12 +334,12 @@ export const taskFunctions = {
|
|
312
334
|
console.log('Not implemented');
|
313
335
|
return false;
|
314
336
|
},
|
315
|
-
createIssue(title, label) {
|
337
|
+
createIssue(title, label, body) {
|
316
338
|
return __awaiter(this, void 0, void 0, function* () {
|
317
339
|
if (context.projectApi === undefined) {
|
318
340
|
return false;
|
319
341
|
}
|
320
|
-
const issueNumber = yield context.projectApi.createIssue(title, context.backlogColumn, label);
|
342
|
+
const issueNumber = yield context.projectApi.createIssue(title, context.backlogColumn, label, body);
|
321
343
|
if (issueNumber) {
|
322
344
|
console.log(`Se creo el issue ${issueNumber}`);
|
323
345
|
return true;
|
@@ -448,20 +470,19 @@ export const taskFunctions = {
|
|
448
470
|
});
|
449
471
|
},
|
450
472
|
listIssues() {
|
451
|
-
return __awaiter(this,
|
473
|
+
return __awaiter(this, arguments, void 0, function* (filter = '{state: OPEN}', template = 'openIssues') {
|
452
474
|
if (!context.projectApi) {
|
453
475
|
return false;
|
454
476
|
}
|
455
477
|
const result = yield context.projectApi.getIssues();
|
456
|
-
|
457
|
-
|
458
|
-
}
|
478
|
+
const rendered = generateTemplate(TEMPLATE_MODEL_FOLDER, 'md', template, Object.assign({ issues: result }, context));
|
479
|
+
console.log(rendered);
|
459
480
|
return true;
|
460
481
|
});
|
461
482
|
},
|
462
483
|
checkIssueType(issueNumber) {
|
463
|
-
var _a;
|
464
484
|
return __awaiter(this, void 0, void 0, function* () {
|
485
|
+
var _a;
|
465
486
|
if (!context.projectApi) {
|
466
487
|
return false;
|
467
488
|
}
|
package/lib/helpers/tasks.js
CHANGED
@@ -104,8 +104,8 @@ export function validateTask(task) {
|
|
104
104
|
}
|
105
105
|
return true;
|
106
106
|
}
|
107
|
-
export function runTask(
|
108
|
-
return __awaiter(this,
|
107
|
+
export function runTask(task_1, taskContext_1) {
|
108
|
+
return __awaiter(this, arguments, void 0, function* (task, taskContext, tabs = '') {
|
109
109
|
initializeContext();
|
110
110
|
// Valida que este ya esten las variables de enotorno y configuracion
|
111
111
|
if (task.guards) {
|
@@ -134,8 +134,8 @@ export function runTask(task, taskContext, tabs = '') {
|
|
134
134
|
return true;
|
135
135
|
});
|
136
136
|
}
|
137
|
-
export function previewTask(
|
138
|
-
return __awaiter(this,
|
137
|
+
export function previewTask(task_1) {
|
138
|
+
return __awaiter(this, arguments, void 0, function* (task, tabs = '') {
|
139
139
|
initializeContext();
|
140
140
|
logStep(`${task.name}: ${task.description}`, tabs);
|
141
141
|
for (const step of task.steps) {
|
@@ -178,7 +178,7 @@ function runStep(step, tabs) {
|
|
178
178
|
}
|
179
179
|
else if (typeof step.subtask === 'string') {
|
180
180
|
const subtask = getTask(step.subtask, SUBTASKS_FOLDER);
|
181
|
-
let stepContext = context.mergeArgs(step.arguments);
|
181
|
+
let stepContext = step.arguments ? context.mergeArgs(step.arguments) : {};
|
182
182
|
if (Array.isArray(stepContext)) {
|
183
183
|
stepContext = createObject(subtask.arguments, stepContext);
|
184
184
|
}
|
@@ -206,8 +206,8 @@ function askForContinueOrRetry() {
|
|
206
206
|
function getStepError(step, stepName) {
|
207
207
|
return step.errorMessage ? context.merge(step.errorMessage) : stepName ? `Fallo el step ${stepName}` : '';
|
208
208
|
}
|
209
|
-
function executeStep(
|
210
|
-
return __awaiter(this,
|
209
|
+
function executeStep(step_1, tabs_1) {
|
210
|
+
return __awaiter(this, arguments, void 0, function* (step, tabs, verbose = false) {
|
211
211
|
const stepName = step.name ? context.merge(step.name) : undefined;
|
212
212
|
if (verbose && stepName) {
|
213
213
|
logStep(`[INICIO] ${stepName}`, tabs);
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
declare class TemplateEngine<T> {
|
1
|
+
declare class TemplateEngine {
|
3
2
|
_template: HandlebarsTemplateDelegate | undefined;
|
4
3
|
_rendered: string | undefined;
|
5
4
|
_extension: string;
|
@@ -8,7 +7,8 @@ declare class TemplateEngine<T> {
|
|
8
7
|
getTemplates(): string[];
|
9
8
|
read(templateName: string): void;
|
10
9
|
render(context: object, options?: RuntimeOptions): void;
|
10
|
+
get rendered(): string | undefined;
|
11
11
|
save(filename: string, folder: string, options?: SaveTemplateOptions): void;
|
12
12
|
}
|
13
|
-
declare const _default: (source: string, extension: string) => TemplateEngine
|
13
|
+
declare const _default: (source: string, extension: string) => TemplateEngine;
|
14
14
|
export default _default;
|
package/lib/helpers/template.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
import fs from "fs";
|
2
2
|
import Handlebars from "handlebars";
|
3
3
|
import { merge } from "./merge.js";
|
4
|
-
import {
|
5
|
-
import { getFiles, searchInFolderHierarchy } from "./util.js";
|
6
|
-
const TEMPLATE_ROOT_FOLDER = searchInFolderHierarchy('templates', fileURLToPath(import.meta.url));
|
4
|
+
import { getFiles } from "./util.js";
|
7
5
|
function isObjectEmpty(objectName) {
|
8
6
|
return (objectName &&
|
9
7
|
Object.keys(objectName).length === 0 &&
|
@@ -26,7 +24,7 @@ function openTemplate(sourceFolder, templateName, extension) {
|
|
26
24
|
}
|
27
25
|
class TemplateEngine {
|
28
26
|
constructor(source, extension) {
|
29
|
-
this._sourceFolder =
|
27
|
+
this._sourceFolder = source;
|
30
28
|
if (!fs.existsSync(this._sourceFolder)) {
|
31
29
|
throw new Error(`La carpeta source ${this._sourceFolder} no existe!`);
|
32
30
|
}
|
@@ -53,6 +51,9 @@ class TemplateEngine {
|
|
53
51
|
}
|
54
52
|
this._rendered = this._template(context, options);
|
55
53
|
}
|
54
|
+
get rendered() {
|
55
|
+
return this._rendered;
|
56
|
+
}
|
56
57
|
save(filename, folder, options = { create: true, overwrite: true }) {
|
57
58
|
let accion = "creo";
|
58
59
|
if (folder && !fs.existsSync(folder)) {
|
package/lib/helpers/util.d.ts
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
import prompts, { Choice } from "prompts";
|
2
|
+
import { AnyValue } from "../types/auto.js";
|
3
|
+
export declare const CONFIG_FILE: string;
|
1
4
|
export declare const TEMPLATES_FOLDER: string;
|
5
|
+
export declare const TEMPLATE_MODEL_FOLDER: string;
|
2
6
|
export declare const DICTIONARY_FOLDER: string;
|
3
7
|
export declare const WORKING_FOLDER: string;
|
4
|
-
export declare const CONFIG_FILE: string;
|
5
8
|
export declare const filterJson: (fullPath: string) => boolean;
|
6
9
|
export declare const filterDirectory: (fullPath: string) => boolean;
|
7
10
|
export declare const filterFiles: (fullPath: string) => boolean;
|
@@ -17,7 +20,10 @@ export declare function titlesToChoices(list: string[], titleToValue?: (title: s
|
|
17
20
|
value: string;
|
18
21
|
}[];
|
19
22
|
export declare function getDataFromPackage(): Record<string, string>;
|
23
|
+
export declare function findChoicesPosition(choices: Choice[], value: string): number;
|
20
24
|
export declare function createConfigurationFile(): Promise<boolean>;
|
25
|
+
export declare function getConfig(variable: string, defaultValue: AnyValue): any;
|
26
|
+
export declare function storeConfig(variable: string, value: AnyValue): void;
|
21
27
|
export declare function sortByName(objA: {
|
22
28
|
Name: string;
|
23
29
|
}, objB: {
|
@@ -44,3 +50,4 @@ export declare function searchInFolderHierarchy(element: string, parentFolder: s
|
|
44
50
|
export declare function getFiles(source: string, filter?: (file: string) => boolean, recursive?: boolean, ignoreList?: string[]): string[];
|
45
51
|
export declare function convertNameToKey(name: string): string;
|
46
52
|
export declare function convertKeyToName(key: string): string;
|
53
|
+
export declare function readJsonSync(filename: string): prompts.Choice[];
|