opendraft 1.4.5 → 1.4.6
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 +57 -13
- 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,40 @@ function installOpendraft(pythonCmd) {
|
|
|
104
127
|
}
|
|
105
128
|
|
|
106
129
|
function runOpendraft(pythonCmd, args) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
130
|
+
const home = os.homedir();
|
|
131
|
+
|
|
132
|
+
// Common locations for pip-installed commands
|
|
133
|
+
const possiblePaths = [
|
|
134
|
+
'opendraft', // In PATH
|
|
135
|
+
`${home}/.local/bin/opendraft`, // pip --user on Linux/Mac
|
|
136
|
+
`${home}/Library/Python/3.11/bin/opendraft`, // macOS Python 3.11
|
|
137
|
+
`${home}/Library/Python/3.12/bin/opendraft`, // macOS Python 3.12
|
|
138
|
+
`${home}/Library/Python/3.13/bin/opendraft`, // macOS Python 3.13
|
|
139
|
+
'/opt/homebrew/bin/opendraft', // Homebrew
|
|
140
|
+
'/usr/local/bin/opendraft', // System-wide
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
// Try each possible path
|
|
144
|
+
for (const cmdPath of possiblePaths) {
|
|
145
|
+
try {
|
|
146
|
+
if (cmdPath === 'opendraft') {
|
|
147
|
+
execSync('which opendraft', { encoding: 'utf8', stdio: 'pipe' });
|
|
148
|
+
} else {
|
|
149
|
+
execSync(`test -x "${cmdPath}"`, { encoding: 'utf8', stdio: 'pipe' });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const actualCmd = cmdPath === 'opendraft' ? 'opendraft' : cmdPath;
|
|
153
|
+
const proc = spawn(actualCmd, args, {
|
|
154
|
+
stdio: 'inherit',
|
|
155
|
+
env: process.env
|
|
156
|
+
});
|
|
157
|
+
proc.on('close', (code) => {
|
|
158
|
+
process.exit(code);
|
|
159
|
+
});
|
|
160
|
+
return;
|
|
161
|
+
} catch (e) {
|
|
162
|
+
// Try next path
|
|
163
|
+
}
|
|
120
164
|
}
|
|
121
165
|
|
|
122
166
|
// Fallback: run via Python with proper argument handling
|