node-plantuml-2 1.1.2 → 1.1.3
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/node-plantuml.js +9 -1
- package/lib/plantuml-executor.js +50 -15
- package/package.json +8 -8
package/lib/node-plantuml.js
CHANGED
|
@@ -224,8 +224,16 @@ function joinOptions (argv, options) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
if (options.dot) {
|
|
227
|
+
// Ensure dot path is absolute - PlantUML Java process needs absolute path
|
|
228
|
+
var absoluteDotPath = path.resolve(options.dot)
|
|
229
|
+
// Normalize path separators
|
|
230
|
+
if (process.platform === 'win32') {
|
|
231
|
+
absoluteDotPath = absoluteDotPath.replace(/\//g, '\\')
|
|
232
|
+
} else {
|
|
233
|
+
absoluteDotPath = absoluteDotPath.replace(/\\/g, '/')
|
|
234
|
+
}
|
|
227
235
|
argv.push(DOT)
|
|
228
|
-
argv.push(
|
|
236
|
+
argv.push(absoluteDotPath)
|
|
229
237
|
}
|
|
230
238
|
|
|
231
239
|
if (options.charset) {
|
package/lib/plantuml-executor.js
CHANGED
|
@@ -92,10 +92,12 @@ function execWithSpawn (argv, cwd, options, cb) {
|
|
|
92
92
|
|
|
93
93
|
// Check if we're using bundled Graphviz and need to set library path
|
|
94
94
|
var dotPath = null
|
|
95
|
+
var dotPathIndex = -1
|
|
95
96
|
// Extract dot path from argv if present
|
|
96
97
|
for (var i = 0; i < argv.length; i++) {
|
|
97
98
|
if (argv[i] === '-graphvizdot' && i + 1 < argv.length) {
|
|
98
99
|
dotPath = argv[i + 1]
|
|
100
|
+
dotPathIndex = i + 1
|
|
99
101
|
break
|
|
100
102
|
}
|
|
101
103
|
}
|
|
@@ -105,17 +107,55 @@ function execWithSpawn (argv, cwd, options, cb) {
|
|
|
105
107
|
dotPath = dotResolver.resolveDotExecutable({ dotPath: null })
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
// CRITICAL FIX: Ensure dot path is absolute and properly formatted
|
|
111
|
+
// PlantUML Java process needs absolute path to launch Graphviz subprocess
|
|
112
|
+
if (dotPath) {
|
|
113
|
+
// Convert to absolute path
|
|
114
|
+
var absoluteDotPath = path.resolve(dotPath)
|
|
115
|
+
|
|
116
|
+
// Normalize path separators for the platform
|
|
117
|
+
if (process.platform === 'win32') {
|
|
118
|
+
// Windows: Use backslashes and ensure .exe extension
|
|
119
|
+
absoluteDotPath = absoluteDotPath.replace(/\//g, '\\')
|
|
120
|
+
if (!absoluteDotPath.toLowerCase().endsWith('.exe')) {
|
|
121
|
+
// If path doesn't end with .exe, check if it's a directory and add dot.exe
|
|
122
|
+
var fs = require('fs')
|
|
123
|
+
try {
|
|
124
|
+
var stat = fs.statSync(absoluteDotPath)
|
|
125
|
+
if (stat.isDirectory()) {
|
|
126
|
+
absoluteDotPath = path.join(absoluteDotPath, 'dot.exe')
|
|
127
|
+
}
|
|
128
|
+
} catch (e) {
|
|
129
|
+
// Ignore errors
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
// Unix: Use forward slashes
|
|
134
|
+
absoluteDotPath = absoluteDotPath.replace(/\\/g, '/')
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Update argv with absolute path if it was found in argv
|
|
138
|
+
if (dotPathIndex >= 0) {
|
|
139
|
+
argv[dotPathIndex] = absoluteDotPath
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Use absolute path for environment variable setup
|
|
143
|
+
dotPath = absoluteDotPath
|
|
144
|
+
}
|
|
145
|
+
|
|
108
146
|
// Get library path for bundled Graphviz
|
|
109
147
|
var libPath = dotResolver.getBundledGraphvizLibPath(dotPath)
|
|
110
148
|
var platform = require('os').platform()
|
|
111
149
|
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
var env =
|
|
150
|
+
// Always create env object to ensure environment variables are properly set
|
|
151
|
+
// This is critical for Java subprocess to inherit correct environment
|
|
152
|
+
var env = Object.assign({}, process.env)
|
|
153
|
+
var envModified = true
|
|
115
154
|
|
|
116
155
|
if (libPath) {
|
|
117
|
-
|
|
118
|
-
|
|
156
|
+
// Ensure libPath is absolute
|
|
157
|
+
libPath = path.resolve(libPath)
|
|
158
|
+
|
|
119
159
|
if (platform === 'linux') {
|
|
120
160
|
// Set LD_LIBRARY_PATH for Linux
|
|
121
161
|
var existingLibPath = env.LD_LIBRARY_PATH || ''
|
|
@@ -130,12 +170,10 @@ function execWithSpawn (argv, cwd, options, cb) {
|
|
|
130
170
|
// For Windows, add Graphviz bin directory to PATH
|
|
131
171
|
// This is needed for both bundled and system-installed Graphviz to find DLLs
|
|
132
172
|
if (platform === 'win32' && dotPath) {
|
|
133
|
-
if (!env) {
|
|
134
|
-
env = Object.assign({}, process.env)
|
|
135
|
-
envModified = true
|
|
136
|
-
}
|
|
137
|
-
|
|
138
173
|
var binDir = path.dirname(dotPath)
|
|
174
|
+
// Normalize to Windows path format
|
|
175
|
+
binDir = binDir.replace(/\//g, '\\')
|
|
176
|
+
|
|
139
177
|
// On Windows, PATH might be Path (case-insensitive but Node.js preserves case)
|
|
140
178
|
var pathKey = 'PATH'
|
|
141
179
|
for (var key in process.env) {
|
|
@@ -147,14 +185,11 @@ function execWithSpawn (argv, cwd, options, cb) {
|
|
|
147
185
|
|
|
148
186
|
var existingPath = env[pathKey] || env.PATH || ''
|
|
149
187
|
|
|
150
|
-
// Normalize binDir to Windows path format
|
|
151
|
-
binDir = binDir.replace(/\//g, '\\')
|
|
152
|
-
|
|
153
188
|
// Check if bin directory is already in PATH
|
|
154
189
|
var pathEntries = existingPath.split(';')
|
|
155
190
|
var alreadyInPath = false
|
|
156
|
-
for (var
|
|
157
|
-
var normalizedEntry = pathEntries[
|
|
191
|
+
for (var j = 0; j < pathEntries.length; j++) {
|
|
192
|
+
var normalizedEntry = pathEntries[j].replace(/\//g, '\\').toLowerCase().trim()
|
|
158
193
|
if (normalizedEntry && normalizedEntry === binDir.toLowerCase()) {
|
|
159
194
|
alreadyInPath = true
|
|
160
195
|
break
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-plantuml-2",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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.3",
|
|
30
|
+
"@node-plantuml-2/jre-darwin-arm64": "^1.1.3",
|
|
31
|
+
"@node-plantuml-2/jre-linux-x64": "^1.1.3",
|
|
32
|
+
"@node-plantuml-2/graphviz-win32-x64": "^1.1.3",
|
|
33
|
+
"@node-plantuml-2/graphviz-darwin-arm64": "^1.1.3",
|
|
34
|
+
"@node-plantuml-2/graphviz-darwin-x64": "^1.1.3",
|
|
35
|
+
"@node-plantuml-2/graphviz-linux-x64": "^1.1.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"chai": "^4.x",
|