@glock-org/glock 1.1.0 → 1.1.2
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/package.json +1 -1
- package/scripts/postinstall.js +62 -0
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -116,11 +116,73 @@ async function downloadBinary() {
|
|
|
116
116
|
fs.chmodSync(binaryPath, 0o755);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
// Install Python dependencies
|
|
120
|
+
await installPythonDependencies();
|
|
121
|
+
|
|
119
122
|
console.log('Glock installed successfully!');
|
|
120
123
|
console.log('');
|
|
121
124
|
console.log('Run `glock` to start an interactive session.');
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Find available Python command (python3 or python)
|
|
129
|
+
*/
|
|
130
|
+
function findPython() {
|
|
131
|
+
const commands = PLATFORM === 'win32'
|
|
132
|
+
? ['python', 'python3', 'py -3']
|
|
133
|
+
: ['python3', 'python'];
|
|
134
|
+
|
|
135
|
+
for (const cmd of commands) {
|
|
136
|
+
try {
|
|
137
|
+
const result = execSync(`${cmd} --version`, { stdio: 'pipe', encoding: 'utf8' });
|
|
138
|
+
if (result.includes('Python 3')) {
|
|
139
|
+
return cmd;
|
|
140
|
+
}
|
|
141
|
+
} catch (e) {
|
|
142
|
+
// Try next command
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Install required Python packages
|
|
150
|
+
*/
|
|
151
|
+
async function installPythonDependencies() {
|
|
152
|
+
const pythonCmd = findPython();
|
|
153
|
+
|
|
154
|
+
if (!pythonCmd) {
|
|
155
|
+
console.log('');
|
|
156
|
+
console.log('Note: Python 3 not found. Some features may be limited.');
|
|
157
|
+
console.log('Install Python 3.11+ for full functionality.');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
console.log('Installing Python dependencies...');
|
|
162
|
+
|
|
163
|
+
const packages = [
|
|
164
|
+
'pillow>=10.0.0',
|
|
165
|
+
'textual>=0.47.0,<1.0.0', // Pin to 0.x - version 1.0+ has breaking changes
|
|
166
|
+
];
|
|
167
|
+
const pipCmd = `${pythonCmd} -m pip install --user --quiet ${packages.join(' ')}`;
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
execSync(pipCmd, { stdio: 'pipe' });
|
|
171
|
+
console.log('Python dependencies installed.');
|
|
172
|
+
} catch (err) {
|
|
173
|
+
// Try without --user flag (for virtual environments)
|
|
174
|
+
try {
|
|
175
|
+
const pipCmdNoUser = `${pythonCmd} -m pip install --quiet ${packages.join(' ')}`;
|
|
176
|
+
execSync(pipCmdNoUser, { stdio: 'pipe' });
|
|
177
|
+
console.log('Python dependencies installed.');
|
|
178
|
+
} catch (err2) {
|
|
179
|
+
console.log('');
|
|
180
|
+
console.log('Note: Could not install Python dependencies automatically.');
|
|
181
|
+
console.log('For full functionality, run: pip install pillow');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
124
186
|
// Only run if not in CI or if explicitly requested
|
|
125
187
|
const skipDownload = process.env.GLOCK_SKIP_BINARY_DOWNLOAD === '1';
|
|
126
188
|
const isCI = process.env.CI === 'true';
|