Skip to content

Commit 4359825

Browse files
jowensclaude
andcommitted
graphics/vega: new port
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 02187af commit 4359825

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

graphics/vega/Portfile

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2+
3+
PortSystem 1.0
4+
PortGroup npm 1.0
5+
6+
name vega
7+
version 6.2.0
8+
revision 0
9+
10+
npm.rootname vega-cli
11+
12+
categories graphics devel
13+
license BSD
14+
maintainers nomaintainer
15+
16+
description Vega visualization grammar — declarative interactive visualizations
17+
18+
long_description Vega is a visualization grammar, a declarative language for \
19+
creating, saving, and sharing interactive visualization designs. \
20+
With Vega, you can describe the visual appearance and interactive \
21+
behavior of a visualization in a JSON format, and generate \
22+
web-based views using Canvas or SVG. This port installs the Vega \
23+
command-line utilities (vg2png, vg2svg, vg2pdf) and the Vega \
24+
JavaScript library.
25+
26+
homepage https://vega.github.io/vega/
27+
28+
checksums rmd160 628ebd2ffc088f9eb97cc67b0acbd0bb01087383 \
29+
sha256 b6007efa43e3b8fe8d5ad941a4283affeec3f07770c1dcb4ed50cbe70dbce802 \
30+
size 4080
31+
32+
depends_build-append \
33+
path:bin/pkg-config:pkgconfig
34+
35+
depends_lib-append path:lib/pkgconfig/cairo.pc:cairo \
36+
path:lib/pkgconfig/pango.pc:pango \
37+
path:include/turbojpeg.h:libjpeg-turbo \
38+
port:giflib \
39+
path:lib/pkgconfig/librsvg-2.0.pc:librsvg
40+
41+
platform darwin {
42+
if {${os.major} >= 22} {
43+
npm.nodejs_version 24
44+
npm.version 11
45+
}
46+
}
47+
48+
destroot {
49+
file mkdir ${workpath}/.home
50+
system -W ${workpath} \
51+
"HOME=${workpath}/.home \
52+
${prefix}/bin/npm install -ddd --global \
53+
--prefix=${destroot}${prefix} \
54+
--cache=${workpath}/.npm-cache \
55+
${distpath}/${distfiles}"
56+
57+
# Fix shebangs: npm writes #!/usr/bin/env node — replace with
58+
# the MacPorts-provided node binary
59+
foreach f [glob -nocomplain ${destroot}${prefix}/lib/node_modules/vega-cli/bin/vg2*] {
60+
reinplace "s|#!/usr/bin/env node|#!${prefix}/bin/node|g" ${f}
61+
}
62+
63+
# npm bakes the destroot path into internal metadata files; strip it
64+
foreach f {
65+
lib/node_modules/.package-lock.json
66+
lib/node_modules/vega-cli/package.json
67+
} {
68+
if {[file exists ${destroot}${prefix}/${f}]} {
69+
reinplace -q "s|${destroot}||g" ${destroot}${prefix}/${f}
70+
}
71+
}
72+
}
73+
74+
test.run yes
75+
test {
76+
# 1. Smoke test — vg2svg --help should exit cleanly
77+
system "${prefix}/bin/vg2svg --help"
78+
79+
# 2. Version check — the installed version must match the port
80+
set vg2svg_out [exec ${prefix}/bin/vg2svg --version]
81+
if {![string match "*${version}*" $vg2svg_out]} {
82+
return -code error "version mismatch: expected ${version}, got ${vg2svg_out}"
83+
}
84+
85+
# 3. Functional test — render a minimal Vega spec to SVG
86+
set spec_file [file join ${workpath} test-spec.vg.json]
87+
set svg_file [file join ${workpath} test-output.svg]
88+
set fd [open ${spec_file} w]
89+
puts $fd {
90+
{
91+
"$schema": "https://vega.github.io/schema/vega/v5.json",
92+
"width": 200,
93+
"height": 200,
94+
"marks": [
95+
{
96+
"type": "rect",
97+
"encode": {
98+
"enter": {
99+
"x": {"value": 0},
100+
"y": {"value": 0},
101+
"width": {"value": 100},
102+
"height": {"value": 100},
103+
"fill": {"value": "steelblue"}
104+
}
105+
}
106+
}
107+
]
108+
}
109+
}
110+
close $fd
111+
112+
system "${prefix}/bin/vg2svg ${spec_file} ${svg_file}"
113+
114+
if {![file exists ${svg_file}]} {
115+
return -code error "vg2svg failed to produce output SVG"
116+
}
117+
118+
set svg_content [exec cat ${svg_file}]
119+
if {![string match "*<svg*" $svg_content]} {
120+
return -code error "vg2svg output does not appear to be valid SVG"
121+
}
122+
}
123+
124+
notes "
125+
The following Vega command-line utilities have been installed:
126+
127+
vg2svg — render a Vega spec to SVG
128+
vg2png — render a Vega spec to PNG
129+
vg2pdf — render a Vega spec to PDF
130+
131+
For documentation and examples, visit https://vega.github.io/vega/
132+
"

0 commit comments

Comments
 (0)