node-plantuml-2 1.1.0 → 1.1.1
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/lib/dot-resolver.js +41 -0
- package/lib/plantuml-executor.js +101 -1
- package/package.json +8 -8
package/lib/dot-resolver.js
CHANGED
|
@@ -63,6 +63,46 @@ function resolveBundledGraphviz () {
|
|
|
63
63
|
return null
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Get Graphviz library path for bundled Graphviz (for LD_LIBRARY_PATH on Linux)
|
|
68
|
+
*
|
|
69
|
+
* @param {string} dotPath - Path to dot executable (from resolveBundledGraphviz)
|
|
70
|
+
* @returns {string|null} - Path to Graphviz lib directory, or null if not bundled
|
|
71
|
+
*/
|
|
72
|
+
function getBundledGraphvizLibPath (dotPath) {
|
|
73
|
+
if (!dotPath) {
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var platform = os.platform()
|
|
78
|
+
|
|
79
|
+
// Only needed on Linux (and possibly macOS with DYLD_LIBRARY_PATH)
|
|
80
|
+
if (platform !== 'linux' && platform !== 'darwin') {
|
|
81
|
+
return null
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
// Check if this is a bundled Graphviz path
|
|
86
|
+
// Bundled path format: .../node_modules/@node-plantuml-2/graphviz-*/graphviz/bin/dot
|
|
87
|
+
// Handle both / and \ path separators (Windows uses \)
|
|
88
|
+
var isBundled = dotPath.includes('@node-plantuml-2/graphviz-') &&
|
|
89
|
+
(dotPath.includes('/graphviz/bin/') || dotPath.includes('\\graphviz\\bin\\'))
|
|
90
|
+
if (isBundled) {
|
|
91
|
+
// Extract the graphviz directory
|
|
92
|
+
var graphvizDir = path.dirname(path.dirname(dotPath)) // Go up from bin/ to graphviz/
|
|
93
|
+
var libDir = path.join(graphvizDir, 'lib')
|
|
94
|
+
|
|
95
|
+
if (fs.existsSync(libDir)) {
|
|
96
|
+
return libDir
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
// Silently fail
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return null
|
|
104
|
+
}
|
|
105
|
+
|
|
66
106
|
/**
|
|
67
107
|
* Get Graphviz package name based on platform and architecture
|
|
68
108
|
*
|
|
@@ -270,6 +310,7 @@ function verifyDot (dotPath) {
|
|
|
270
310
|
module.exports = {
|
|
271
311
|
resolveDotExecutable: resolveDotExecutable,
|
|
272
312
|
resolveBundledGraphviz: resolveBundledGraphviz,
|
|
313
|
+
getBundledGraphvizLibPath: getBundledGraphvizLibPath,
|
|
273
314
|
getGraphvizPackageName: getGraphvizPackageName,
|
|
274
315
|
getCommonDotPaths: getCommonDotPaths,
|
|
275
316
|
findDotInPath: findDotInPath,
|
package/lib/plantuml-executor.js
CHANGED
|
@@ -5,6 +5,7 @@ var path = require('path')
|
|
|
5
5
|
var nailgun = require('node-nailgun-server')
|
|
6
6
|
var ngClient = require('node-nailgun-client')
|
|
7
7
|
var javaResolver = require('./java-resolver')
|
|
8
|
+
var dotResolver = require('./dot-resolver')
|
|
8
9
|
|
|
9
10
|
var INCLUDED_PLANTUML_JAR = path.join(__dirname, '../vendor/plantuml.jar')
|
|
10
11
|
var PLANTUML_JAR = process.env.PLANTUML_HOME || INCLUDED_PLANTUML_JAR
|
|
@@ -84,7 +85,106 @@ function execWithSpawn (argv, cwd, options, cb) {
|
|
|
84
85
|
'-jar', PLANTUML_JAR
|
|
85
86
|
].concat(argv)
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
// Set LD_LIBRARY_PATH for bundled Graphviz on Linux
|
|
89
|
+
var spawnOptions = {
|
|
90
|
+
cwd: cwd
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Check if we're using bundled Graphviz and need to set library path
|
|
94
|
+
var dotPath = null
|
|
95
|
+
// Extract dot path from argv if present
|
|
96
|
+
for (var i = 0; i < argv.length; i++) {
|
|
97
|
+
if (argv[i] === '-graphvizdot' && i + 1 < argv.length) {
|
|
98
|
+
dotPath = argv[i + 1]
|
|
99
|
+
break
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// If no dot path in argv, try to detect it
|
|
104
|
+
if (!dotPath) {
|
|
105
|
+
dotPath = dotResolver.resolveDotExecutable({ dotPath: null })
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Get library path for bundled Graphviz
|
|
109
|
+
var libPath = dotResolver.getBundledGraphvizLibPath(dotPath)
|
|
110
|
+
var platform = require('os').platform()
|
|
111
|
+
|
|
112
|
+
// Only create new env object if we need to modify it
|
|
113
|
+
var envModified = false
|
|
114
|
+
var env = null
|
|
115
|
+
|
|
116
|
+
if (libPath) {
|
|
117
|
+
env = Object.assign({}, process.env)
|
|
118
|
+
envModified = true
|
|
119
|
+
if (platform === 'linux') {
|
|
120
|
+
// Set LD_LIBRARY_PATH for Linux
|
|
121
|
+
var existingLibPath = env.LD_LIBRARY_PATH || ''
|
|
122
|
+
env.LD_LIBRARY_PATH = libPath + (existingLibPath ? ':' + existingLibPath : '')
|
|
123
|
+
} else if (platform === 'darwin') {
|
|
124
|
+
// Set DYLD_LIBRARY_PATH for macOS
|
|
125
|
+
var existingDyldPath = env.DYLD_LIBRARY_PATH || ''
|
|
126
|
+
env.DYLD_LIBRARY_PATH = libPath + (existingDyldPath ? ':' + existingDyldPath : '')
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// For Windows, add Graphviz bin directory to PATH
|
|
131
|
+
// This is needed for both bundled and system-installed Graphviz to find DLLs
|
|
132
|
+
if (platform === 'win32' && dotPath) {
|
|
133
|
+
if (!env) {
|
|
134
|
+
env = Object.assign({}, process.env)
|
|
135
|
+
envModified = true
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var binDir = path.dirname(dotPath)
|
|
139
|
+
// On Windows, PATH might be Path (case-insensitive but Node.js preserves case)
|
|
140
|
+
var pathKey = 'PATH'
|
|
141
|
+
for (var key in process.env) {
|
|
142
|
+
if (key.toUpperCase() === 'PATH') {
|
|
143
|
+
pathKey = key
|
|
144
|
+
break
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var existingPath = env[pathKey] || env.PATH || ''
|
|
149
|
+
|
|
150
|
+
// Normalize binDir to Windows path format
|
|
151
|
+
binDir = binDir.replace(/\//g, '\\')
|
|
152
|
+
|
|
153
|
+
// Check if bin directory is already in PATH
|
|
154
|
+
var pathEntries = existingPath.split(';')
|
|
155
|
+
var alreadyInPath = false
|
|
156
|
+
for (var i = 0; i < pathEntries.length; i++) {
|
|
157
|
+
var normalizedEntry = pathEntries[i].replace(/\//g, '\\').toLowerCase().trim()
|
|
158
|
+
if (normalizedEntry && normalizedEntry === binDir.toLowerCase()) {
|
|
159
|
+
alreadyInPath = true
|
|
160
|
+
break
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Add bin directory to PATH if not already present
|
|
165
|
+
// Always add it at the beginning to ensure it's found first
|
|
166
|
+
if (!alreadyInPath) {
|
|
167
|
+
env[pathKey] = binDir + (existingPath ? ';' + existingPath : '')
|
|
168
|
+
// Also set PATH (lowercase) for compatibility
|
|
169
|
+
env.PATH = env[pathKey]
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Debug: Log PATH modification (only in development/debug mode)
|
|
173
|
+
if (process.env.DEBUG_PLANTUML) {
|
|
174
|
+
console.log('[DEBUG] Windows PATH modified for Graphviz')
|
|
175
|
+
console.log('[DEBUG] Dot path:', dotPath)
|
|
176
|
+
console.log('[DEBUG] Bin directory:', binDir)
|
|
177
|
+
console.log('[DEBUG] PATH key:', pathKey)
|
|
178
|
+
console.log('[DEBUG] PATH (first 300 chars):', env[pathKey].substring(0, 300))
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Set environment if we modified it
|
|
183
|
+
if (envModified) {
|
|
184
|
+
spawnOptions.env = env
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return childProcess.spawn(javaExe, opts, spawnOptions)
|
|
88
188
|
}
|
|
89
189
|
|
|
90
190
|
module.exports.exec = function (argv, cwd, callbackOrOptions, callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-plantuml-2",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"plantumlVersion": "1.2026.1",
|
|
5
5
|
"description": "Node.js PlantUML renderer with Java backend. Multiple output formats (PNG, SVG, EPS, ASCII, Unicode) with full UTF-8 support",
|
|
6
6
|
"main": "index.js",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"plantuml-encoder": "^1.2.5"
|
|
27
27
|
},
|
|
28
28
|
"optionalDependencies": {
|
|
29
|
-
"@node-plantuml-2/jre-win32-x64": "^1.1.
|
|
30
|
-
"@node-plantuml-2/jre-darwin-arm64": "^1.1.
|
|
31
|
-
"@node-plantuml-2/jre-linux-x64": "^1.1.
|
|
32
|
-
"@node-plantuml-2/graphviz-win32-x64": "^1.1.
|
|
33
|
-
"@node-plantuml-2/graphviz-darwin-arm64": "^1.1.
|
|
34
|
-
"@node-plantuml-2/graphviz-darwin-x64": "^1.1.
|
|
35
|
-
"@node-plantuml-2/graphviz-linux-x64": "^1.1.
|
|
29
|
+
"@node-plantuml-2/jre-win32-x64": "^1.1.1",
|
|
30
|
+
"@node-plantuml-2/jre-darwin-arm64": "^1.1.1",
|
|
31
|
+
"@node-plantuml-2/jre-linux-x64": "^1.1.1",
|
|
32
|
+
"@node-plantuml-2/graphviz-win32-x64": "^1.1.1",
|
|
33
|
+
"@node-plantuml-2/graphviz-darwin-arm64": "^1.1.1",
|
|
34
|
+
"@node-plantuml-2/graphviz-darwin-x64": "^1.1.1",
|
|
35
|
+
"@node-plantuml-2/graphviz-linux-x64": "^1.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"chai": "^4.x",
|