2
2
/******/ var __webpack_modules__ = ({
3
3
4
4
/***/ 88:
5
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5
+ /***/ (function (__unused_webpack_module, exports, __nccwpck_require__) {
6
6
7
7
"use strict";
8
8
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
9
32
Object.defineProperty(exports, "__esModule", ({ value: true }));
10
33
exports.parseInputs = void 0;
34
+ const core = __importStar(__nccwpck_require__(2186));
11
35
const utils_1 = __nccwpck_require__(918);
12
36
const parseInputs = () => {
13
- const rootIssueUrl = "https://github.com/maxim-lobanov/build- issue-dependencies-graph/issues/1" ;
37
+ const rootIssueUrl = core.getInput("root- issue-url", { required: true }) ;
14
38
const rootIssue = (0, utils_1.parseIssueUrl)(rootIssueUrl);
15
39
if (!rootIssue) {
16
40
throw new Error(`Failed to extract issue details from url '${rootIssueUrl}'`);
17
41
}
18
42
return {
19
43
rootIssue,
20
- accessToken: "",
21
- sectionTitle: "Spec graph",
22
- dryRun: false
44
+ sectionTitle: core.getInput("section-title", { required: true }),
45
+ includeLegend: core.getBooleanInput('include-legend'),
46
+ accessToken: core.getInput("access-token", { required: true }),
47
+ dryRun: core.getBooleanInput("dry-run"),
23
48
};
24
49
};
25
50
exports.parseInputs = parseInputs;
@@ -152,7 +177,7 @@ class IssueContentParser {
152
177
const contentLines = (_b = (_a = issue.body) === null || _a === void 0 ? void 0 : _a.split("\n")) !== null && _b !== void 0 ? _b : [];
153
178
const sectionStartIndex = contentLines.findIndex(x => this.isMarkdownHeaderLine(x, sectionTitle));
154
179
if (sectionStartIndex === -1) {
155
- throw `Markdown header '${sectionTitle}' is not found in issue body:\n ${issue.body}` ;
180
+ throw new Error( `Markdown header '${sectionTitle}' is not found in issue body.`) ;
156
181
}
157
182
const sectionEndIndex = contentLines.findIndex((x, index) => index > sectionStartIndex && this.isMarkdownHeaderLine(x));
158
183
return [
@@ -176,7 +201,7 @@ class IssueContentParser {
176
201
return trimmedLine.toLowerCase() === sectionTitle.toLocaleLowerCase();
177
202
}
178
203
isTaskListLine(str) {
179
- return str.startsWith("- [ ] ");
204
+ return str.startsWith("- [ ] ") || str.startsWith("- [x] ") ;
180
205
}
181
206
isDependencyLine(str) {
182
207
const dependencyLinePrefixes = ["Dependencies: ", "Predecessors: ", "Depends on ", "Depends on: "];
@@ -230,7 +255,7 @@ const run = async () => {
230
255
const config = (0, config_1.parseInputs)();
231
256
const githubApiClient = new github_api_client_1.GitHubApiClient(config.accessToken);
232
257
const issueContentParser = new issue_content_parser_1.IssueContentParser();
233
- const mermaidRender = new mermaid_render_1.MermaidRender();
258
+ const mermaidRender = new mermaid_render_1.MermaidRender(config.includeLegend );
234
259
const rootIssue = await githubApiClient.getIssue(config.rootIssue);
235
260
const rootIssueTasklist = issueContentParser.extractIssueTasklist(rootIssue);
236
261
core.info(`Found ${rootIssueTasklist.length} work items in task list.`);
@@ -256,15 +281,13 @@ const run = async () => {
256
281
console.log("Action is run in dry-run mode. Root issue won't be updated");
257
282
return;
258
283
}
259
- core.info("Updating root issue...");
284
+ core.info("Updating root issue content ...");
260
285
await githubApiClient.updateIssueContent(config.rootIssue, updatedIssueContent);
261
286
core.info("Root issue is updated.");
262
287
}
263
288
catch (error) {
264
- if (error instanceof Error) {
265
- core.setFailed(error.message);
266
- throw error;
267
- }
289
+ core.setFailed(error instanceof Error ? error.message : error);
290
+ throw error;
268
291
}
269
292
};
270
293
run();
@@ -286,14 +309,32 @@ class MermaidNode {
286
309
this.status = status;
287
310
this.url = url;
288
311
}
312
+ getWrappedTitle() {
313
+ const maxWidth = 40;
314
+ const words = this.title.split(/\s+/);
315
+ let result = words[0];
316
+ let lastLength = result.length;
317
+ for (let wordIndex = 1; wordIndex < words.length; wordIndex++) {
318
+ if (lastLength + words[wordIndex].length >= maxWidth) {
319
+ result += "\n";
320
+ lastLength = 0;
321
+ }
322
+ else {
323
+ result += " ";
324
+ }
325
+ result += words[wordIndex];
326
+ lastLength += words[wordIndex].length;
327
+ }
328
+ return result;
329
+ }
289
330
static createFromGitHubIssue(issue) {
290
331
return new MermaidNode(`issue${issue.id}`, issue.title, MermaidNode.getNodeStatusFromGitHubIssue(issue), issue.html_url);
291
332
}
292
333
static getNodeStatusFromGitHubIssue(issue) {
293
334
if (issue.state !== "open") {
294
335
return "completed";
295
336
}
296
- if (issue.assignee !== null ) {
337
+ if (issue.assignee) {
297
338
return "started";
298
339
}
299
340
return "notstarted";
@@ -318,12 +359,15 @@ exports.MermaidNode = MermaidNode;
318
359
Object.defineProperty(exports, "__esModule", ({ value: true }));
319
360
exports.MermaidRender = void 0;
320
361
class MermaidRender {
362
+ constructor(includeLegend) {
363
+ this.includeLegend = includeLegend;
364
+ }
321
365
render(graph) {
322
366
return `
367
+ ${this.renderLegendSection()}
323
368
\`\`\`mermaid
324
369
flowchart TD
325
370
${this.renderCssSection()}
326
- ${this.renderLegendSection()}
327
371
${this.renderIssuesSection(graph.vertices)}
328
372
${this.renderDependencies(graph.edges)}
329
373
\`\`\`
@@ -341,7 +385,14 @@ classDef completed fill:#ccffd8,color:#000;
341
385
`;
342
386
}
343
387
renderLegendSection() {
388
+ if (!this.includeLegend) {
389
+ return "";
390
+ }
344
391
return `
392
+ \`\`\`mermaid
393
+ flowchart TD
394
+ ${this.renderCssSection()}
395
+
345
396
%% <Legend>
346
397
347
398
subgraph legend["Legend"]
@@ -353,6 +404,7 @@ subgraph legend["Legend"]
353
404
end
354
405
355
406
%% </Legend>
407
+ \`\`\`
356
408
`;
357
409
}
358
410
renderIssuesSection(issues) {
@@ -366,7 +418,7 @@ ${renderedGraphIssues}
366
418
`;
367
419
}
368
420
renderIssue(issue) {
369
- let result = `${issue.nodeId}("${issue.title }"):::${issue.status};`;
421
+ let result = `${issue.nodeId}("${issue.getWrappedTitle() }"):::${issue.status};`;
370
422
if (issue.url) {
371
423
result += `\nclick ${issue.nodeId} href "${issue.url}" _blank;`;
372
424
}
0 commit comments