Skip to content

Commit 87c99cf

Browse files
committed
feat: improve visualization rendering with professional libraries
1 parent cc1e7fe commit 87c99cf

File tree

14 files changed

+1885
-130
lines changed

14 files changed

+1885
-130
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@noxify/gitlab-ci-builder": minor
3+
---
4+
5+
Improve visualization rendering with professional libraries
6+
7+
- Replace custom ASCII tree rendering with `oo-ascii-tree` for better box-drawing characters
8+
- Replace custom table rendering with `climt` for professional CLI tables
9+
- Change table layout from horizontal to vertical (Stage | Job columns)
10+
- Display one job per row with full ext ends chains

README.md

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -473,20 +473,38 @@ console.log(mermaid)
473473
**Output:**
474474

475475
```mermaid
476-
graph TD
477-
n0["build [build]"]:::job
478-
n1[".base"]:::template
479-
n2["test [test]"]:::job
480-
n0 --> n1
481-
n2 --> n1
476+
---
477+
config:
478+
layout: elk
479+
---
480+
graph LR
482481
classDef template fill:#e1f5ff,stroke:#0366d6
483482
classDef job fill:#fff5e1,stroke:#fb8500
484483
classDef remote fill:#ffe1f5,stroke:#c026d3
484+
485+
subgraph Templates
486+
n1[".build_template"]:::template
487+
n2[".base"]:::template
488+
n4[".test_template"]:::template
489+
end
490+
491+
subgraph "build"
492+
n0["build"]:::job
493+
end
494+
495+
subgraph "test"
496+
n3["test"]:::job
497+
end
498+
499+
n0 --> n1
500+
n1 --> n2
501+
n3 --> n4
502+
n4 --> n2
485503
```
486504

487505
#### ASCII Trees
488506

489-
Generate hierarchical ASCII tree views of job inheritance:
507+
Generate hierarchical ASCII tree views of job inheritance using `oo-ascii-tree` for clean, professional box-drawing characters:
490508

491509
```ts
492510
const ascii = config.generateAsciiTree({
@@ -500,15 +518,19 @@ console.log(ascii)
500518
**Output:**
501519

502520
```
503-
└─ build (build)
504-
└─ .base [T]
505-
└─ test (test)
506-
└─ .base [T]
521+
build (build)
522+
└─┬ .build_template [T]
523+
└── .base [T]
524+
test (test)
525+
└─┬ .test_template [T]
526+
└── .base [T]
507527
```
508528
529+
The ASCII tree uses Unicode box-drawing characters for a clean, readable hierarchy that works great in terminal output and documentation.
530+
509531
#### Stage Tables
510532
511-
Generate tabular views showing jobs organized by stage:
533+
Generate formatted tables using `climt` showing jobs with their full inheritance chains:
512534
513535
```ts
514536
const table = config.generateStageTable({
@@ -521,11 +543,18 @@ console.log(table)
521543
**Output:**
522544

523545
```
524-
build │ test │ deploy
525-
──────────────┼──────────────┼─────────────
526-
build ← .base │ test ← .base │
546+
┌───────┬────────────────────────────────────────────┐
547+
│ STAGE │ JOB │
548+
├───────┼────────────────────────────────────────────┤
549+
│ build │ build-frontend ← .build_template ← .base │
550+
│ build │ build-backend ← .build_template ← .base │
551+
│ test │ test-unit ← .test_template ← .base │
552+
│ test │ test-e2e ← .test_template ← .base │
553+
└───────┴────────────────────────────────────────────┘
527554
```
528555

556+
The table shows one job per row with its complete extends chain, making it easy to understand the full inheritance hierarchy at a glance.
557+
529558
### Visualization Options
530559

531560
All visualization methods accept optional configuration:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@
5252
"prettier": "./prettier.config.mjs",
5353
"dependencies": {
5454
"@commander-js/extra-typings": "^14.0.0",
55+
"climt": "^0.2.0",
5556
"commander": "^14.0.2",
5657
"deepmerge": "4.3.1",
5758
"js-yaml": "4.1.1",
59+
"oo-ascii-tree": "^1.120.0",
5860
"read-pkg": "^10.0.0",
5961
"tinyglobby": "0.2.15",
6062
"typescript": "5.9.3",

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli/commands/visualize.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Examples:
8282
if (result.mermaid) {
8383
// eslint-disable-next-line no-console
8484
console.log("\n=== Mermaid Diagram ===\n")
85+
// eslint-disable-next-line no-console
86+
console.log(result.mermaid)
8587
}
8688

8789
if (result.ascii) {
@@ -99,7 +101,7 @@ Examples:
99101
}
100102
} catch (error) {
101103
// eslint-disable-next-line no-console
102-
console.error("Error:", error instanceof Error ? error.message : String(error))
104+
console.error("Error:", error)
103105
process.exit(1)
104106
}
105107
})
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import yaml from "js-yaml"
22

33
/**
4-
* Custom YAML type for !reference tags
5-
* Converts !reference [.template, script] to string literal
4+
* Custom YAML type for !reference tags - String representation
5+
* Converts !reference [.template, script] to string literal for TypeScript generation
66
*/
77
export const referenceTag = new yaml.Type("!reference", {
88
kind: "sequence",
99
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1010
construct: (data: unknown[]) => `!reference [${(data || []).join(", ")}]`,
1111
})
12+
13+
/**
14+
* Custom YAML type for !reference tags - Object representation
15+
* Stores reference as an object with kind and path for resolution
16+
*/
17+
export const referenceTagResolvable = new yaml.Type("!reference", {
18+
kind: "sequence",
19+
construct: (data: unknown[]) => ({
20+
kind: "reference",
21+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
22+
path: data || [],
23+
}),
24+
})

src/resolution/graph.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export interface ExtendsGraphNode {
88
name: string
99
definition: JobDefinitionNormalized
1010
extends: string[]
11+
/** Original unresolved extends before include resolution */
12+
unresolvedExtends?: string[]
1113
isTemplate: boolean
1214
isRemote: boolean
1315
}

0 commit comments

Comments
 (0)