shortcutxl 0.2.7 → 0.2.8
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/dist/custom/preflight.js +36 -5
- package/package.json +1 -1
package/dist/custom/preflight.js
CHANGED
|
@@ -14,6 +14,35 @@ import { resetShellConfig } from '../utils/shell.js';
|
|
|
14
14
|
import { EXCEL_HTTP_URL } from './constants.js';
|
|
15
15
|
import { fetchExcelConfig } from './excel-config.js';
|
|
16
16
|
import { getStableXllDir } from './sync-xll.js';
|
|
17
|
+
// ── PATH refresh ────────────────────────────────────────────────────────
|
|
18
|
+
/**
|
|
19
|
+
* Re-read the Windows PATH from the registry and merge it into process.env.PATH.
|
|
20
|
+
* After winget installs a program (Git, Python, etc.) the system/user PATH is
|
|
21
|
+
* updated, but the running Node process still has the old value. This reads the
|
|
22
|
+
* current registry entries and splices in any new directories.
|
|
23
|
+
*/
|
|
24
|
+
function refreshPath() {
|
|
25
|
+
try {
|
|
26
|
+
const user = spawnSync('reg', ['query', 'HKCU\\Environment', '/v', 'Path'], { encoding: 'utf-8', timeout: 5_000 });
|
|
27
|
+
const system = spawnSync('reg', ['query', 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment', '/v', 'Path'], { encoding: 'utf-8', timeout: 5_000 });
|
|
28
|
+
const extract = (out) => (out.match(/REG_(?:EXPAND_)?SZ\s+(.+)/i)?.[1] ?? '')
|
|
29
|
+
.split(';')
|
|
30
|
+
.map((p) => p.trim())
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
const fresh = new Set([...extract(system.stdout ?? ''), ...extract(user.stdout ?? '')]);
|
|
33
|
+
const current = (process.env.PATH ?? '').split(';').filter(Boolean);
|
|
34
|
+
const currentSet = new Set(current.map((p) => p.toLowerCase()));
|
|
35
|
+
for (const dir of fresh) {
|
|
36
|
+
if (!currentSet.has(dir.toLowerCase())) {
|
|
37
|
+
current.push(dir);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
process.env.PATH = current.join(';');
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Best-effort — if registry read fails, continue with stale PATH
|
|
44
|
+
}
|
|
45
|
+
}
|
|
17
46
|
/** Accumulated log entries, exposed to callers via runPreflight(). */
|
|
18
47
|
const preflightLog = [];
|
|
19
48
|
let currentStep = 'setup';
|
|
@@ -160,12 +189,13 @@ async function ensureGitBash() {
|
|
|
160
189
|
}
|
|
161
190
|
}
|
|
162
191
|
log('Installing Git (you may see a permissions prompt — click Yes)...');
|
|
163
|
-
const result = await runWithProgress('winget install --id Git.Git -e -h --accept-source-agreements --accept-package-agreements', { timeout:
|
|
192
|
+
const result = await runWithProgress('winget install --id Git.Git -e -h --accept-source-agreements --accept-package-agreements', { timeout: 300_000, label: 'Installing Git' });
|
|
164
193
|
if (!result.ok && !result.stdout.includes('already installed')) {
|
|
165
194
|
warn('Install failed — the setup agent will help.');
|
|
166
195
|
return;
|
|
167
196
|
}
|
|
168
|
-
//
|
|
197
|
+
// Refresh PATH so the newly installed git is visible to this process
|
|
198
|
+
refreshPath();
|
|
169
199
|
resetShellConfig();
|
|
170
200
|
const gitCheck = run('git --version');
|
|
171
201
|
if (!gitCheck.ok) {
|
|
@@ -198,12 +228,13 @@ async function ensurePython() {
|
|
|
198
228
|
return;
|
|
199
229
|
}
|
|
200
230
|
log('Installing Python 3.12...');
|
|
201
|
-
const result = await runWithProgress('winget install --id Python.Python.3.12 -e -h --accept-source-agreements --accept-package-agreements', { timeout:
|
|
231
|
+
const result = await runWithProgress('winget install --id Python.Python.3.12 -e -h --accept-source-agreements --accept-package-agreements', { timeout: 600_000, label: 'Installing Python 3.12' });
|
|
202
232
|
if (!result.ok && !result.stdout.includes('already installed')) {
|
|
203
233
|
warn('Install failed — the setup agent will help.');
|
|
204
234
|
return;
|
|
205
235
|
}
|
|
206
236
|
freshInstall = true;
|
|
237
|
+
refreshPath();
|
|
207
238
|
detected = detectPython312();
|
|
208
239
|
if (!detected) {
|
|
209
240
|
warn('Installed but not detected yet — try restarting your terminal.');
|
|
@@ -233,7 +264,7 @@ async function ensurePython() {
|
|
|
233
264
|
}
|
|
234
265
|
// Install pywin32 + openpyxl + playwright + httpx
|
|
235
266
|
log('Installing required packages...');
|
|
236
|
-
const pipResult = await runWithProgress(`${pythonCmd} -m pip install pywin32 openpyxl playwright httpx`, { timeout:
|
|
267
|
+
const pipResult = await runWithProgress(`${pythonCmd} -m pip install pywin32 openpyxl playwright httpx`, { timeout: 300_000, label: 'Installing packages' });
|
|
237
268
|
if (pipResult.ok) {
|
|
238
269
|
ok('Packages installed.');
|
|
239
270
|
}
|
|
@@ -255,7 +286,7 @@ async function ensurePython() {
|
|
|
255
286
|
if (installChrome) {
|
|
256
287
|
log('Installing Chrome for PDF conversion...');
|
|
257
288
|
const pwResult = await runWithProgress(`${pythonCmd} -m playwright install chrome`, {
|
|
258
|
-
timeout:
|
|
289
|
+
timeout: 300_000,
|
|
259
290
|
label: 'Installing Chrome'
|
|
260
291
|
});
|
|
261
292
|
if (pwResult.ok) {
|