opendraft 1.4.5 → 1.4.7
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/bin/opendraft.js +69 -12
- package/package.json +1 -1
package/bin/opendraft.js
CHANGED
|
@@ -92,6 +92,29 @@ function checkOpendraftInstalled(pythonCmd) {
|
|
|
92
92
|
|
|
93
93
|
function installOpendraft(pythonCmd) {
|
|
94
94
|
print(`${CYAN}Installing OpenDraft...${RESET}`);
|
|
95
|
+
|
|
96
|
+
// Try pipx first (cleanest for CLI tools)
|
|
97
|
+
try {
|
|
98
|
+
execSync('which pipx', { encoding: 'utf8', stdio: 'pipe' });
|
|
99
|
+
print(`${GRAY}Using pipx...${RESET}`);
|
|
100
|
+
execSync('pipx install opendraft', { encoding: 'utf8', stdio: 'inherit' });
|
|
101
|
+
return true;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
// pipx not available, try pip
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Try pip with --user and --break-system-packages for modern Python
|
|
107
|
+
try {
|
|
108
|
+
execSync(`${pythonCmd} -m pip install --user --break-system-packages --upgrade opendraft`, {
|
|
109
|
+
encoding: 'utf8',
|
|
110
|
+
stdio: 'inherit'
|
|
111
|
+
});
|
|
112
|
+
return true;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
// Try without --break-system-packages for older pip
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Fallback: try basic pip install
|
|
95
118
|
try {
|
|
96
119
|
execSync(`${pythonCmd} -m pip install --upgrade opendraft`, {
|
|
97
120
|
encoding: 'utf8',
|
|
@@ -104,19 +127,53 @@ function installOpendraft(pythonCmd) {
|
|
|
104
127
|
}
|
|
105
128
|
|
|
106
129
|
function runOpendraft(pythonCmd, args) {
|
|
107
|
-
|
|
130
|
+
const home = os.homedir();
|
|
131
|
+
|
|
132
|
+
// Get Python version to find the right Library path
|
|
133
|
+
let pyVersion = '';
|
|
108
134
|
try {
|
|
109
|
-
execSync(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//
|
|
135
|
+
const versionOutput = execSync(`${pythonCmd} -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"`, { encoding: 'utf8' }).trim();
|
|
136
|
+
pyVersion = versionOutput;
|
|
137
|
+
} catch (e) {}
|
|
138
|
+
|
|
139
|
+
// Common locations for pip-installed commands
|
|
140
|
+
const possiblePaths = [
|
|
141
|
+
'opendraft', // In PATH
|
|
142
|
+
`${home}/.local/bin/opendraft`, // pip --user on Linux/Mac
|
|
143
|
+
`${home}/Library/Python/${pyVersion}/bin/opendraft`, // macOS user install for detected version
|
|
144
|
+
`${home}/Library/Python/3.13/bin/opendraft`, // macOS Python 3.13
|
|
145
|
+
`${home}/Library/Python/3.12/bin/opendraft`, // macOS Python 3.12
|
|
146
|
+
`${home}/Library/Python/3.11/bin/opendraft`, // macOS Python 3.11
|
|
147
|
+
`${home}/Library/Python/3.10/bin/opendraft`, // macOS Python 3.10
|
|
148
|
+
`${home}/Library/Python/3.9/bin/opendraft`, // macOS Python 3.9
|
|
149
|
+
'/opt/homebrew/bin/opendraft', // Homebrew
|
|
150
|
+
'/usr/local/bin/opendraft', // System-wide
|
|
151
|
+
'/Library/Frameworks/Python.framework/Versions/3.13/bin/opendraft',
|
|
152
|
+
'/Library/Frameworks/Python.framework/Versions/3.12/bin/opendraft',
|
|
153
|
+
'/Library/Frameworks/Python.framework/Versions/3.11/bin/opendraft',
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
// Try each possible path
|
|
157
|
+
for (const cmdPath of possiblePaths) {
|
|
158
|
+
try {
|
|
159
|
+
if (cmdPath === 'opendraft') {
|
|
160
|
+
execSync('which opendraft', { encoding: 'utf8', stdio: 'pipe' });
|
|
161
|
+
} else {
|
|
162
|
+
execSync(`test -x "${cmdPath}"`, { encoding: 'utf8', stdio: 'pipe' });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const actualCmd = cmdPath === 'opendraft' ? 'opendraft' : cmdPath;
|
|
166
|
+
const proc = spawn(actualCmd, args, {
|
|
167
|
+
stdio: 'inherit',
|
|
168
|
+
env: process.env
|
|
169
|
+
});
|
|
170
|
+
proc.on('close', (code) => {
|
|
171
|
+
process.exit(code);
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
} catch (e) {
|
|
175
|
+
// Try next path
|
|
176
|
+
}
|
|
120
177
|
}
|
|
121
178
|
|
|
122
179
|
// Fallback: run via Python with proper argument handling
|