@pixelbyte-software/pixcode 1.47.2 → 1.47.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/dist/assets/{index-CR14oRxl.js → index-DD3hAStI.js} +91 -91
- package/dist/index.html +1 -1
- package/dist-server/server/cli.js +62 -22
- package/dist-server/server/cli.js.map +1 -1
- package/dist-server/server/index.js +6 -1
- package/dist-server/server/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/smoke/git-install-update.mjs +37 -2
- package/scripts/update-git-install.mjs +7 -0
- package/server/cli.js +72 -24
- package/server/index.js +6 -1
package/server/cli.js
CHANGED
|
@@ -249,10 +249,77 @@ async function checkForUpdates(silent = false) {
|
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
function runInherited(command, args, options = {}) {
|
|
253
|
+
return new Promise((resolve, reject) => {
|
|
254
|
+
const child = spawn(command, args, {
|
|
255
|
+
cwd: options.cwd || APP_ROOT,
|
|
256
|
+
env: options.env || process.env,
|
|
257
|
+
stdio: 'inherit',
|
|
258
|
+
shell: false,
|
|
259
|
+
windowsHide: false,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
child.on('error', reject);
|
|
263
|
+
child.on('close', (code) => {
|
|
264
|
+
if (code === 0) {
|
|
265
|
+
resolve();
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
reject(new Error(`${command} ${args.join(' ')} exited with code ${code}`));
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function maybeRestartDaemonAfterUpdate(options = {}) {
|
|
275
|
+
if (options.restartDaemon) {
|
|
276
|
+
if (!hasInstalledDaemonUnit()) {
|
|
277
|
+
console.log(`${c.warn('[WARN]')} No daemon unit detected; skipping restart.`);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
console.log(`${c.info('[INFO]')} Restarting daemon service...`);
|
|
281
|
+
await handleDaemonCommand(['restart', '--mode=system'], {
|
|
282
|
+
appRoot: APP_ROOT,
|
|
283
|
+
defaultPort: process.env.SERVER_PORT || process.env.PORT || '3001',
|
|
284
|
+
color: c,
|
|
285
|
+
});
|
|
286
|
+
console.log(`${c.ok('[OK]')} Daemon restart completed.`);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (hasInstalledDaemonUnit()) {
|
|
291
|
+
const restartCommand = buildDaemonCliCommand(
|
|
292
|
+
{ subcommand: 'restart', mode: 'system' },
|
|
293
|
+
DAEMON_COMMAND_CONTEXT
|
|
294
|
+
);
|
|
295
|
+
console.log(`${c.tip('[TIP]')} Daemon unit detected. Restart to apply update: ${c.bright(restartCommand)}`);
|
|
296
|
+
console.log(`${c.tip('[TIP]')} Or update + restart in one step: ${c.bright('pixcode update --restart-daemon')}`);
|
|
297
|
+
} else {
|
|
298
|
+
console.log(`${c.tip('[TIP]')} Restart pixcode to use the new version.`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async function updateGitPackage(options = {}) {
|
|
303
|
+
const gitUpdateScript = path.join(APP_ROOT, 'scripts', 'update-git-install.mjs');
|
|
304
|
+
if (!fs.existsSync(gitUpdateScript)) {
|
|
305
|
+
throw new Error(`Git update script was not found: ${gitUpdateScript}`);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
console.log(`${c.info('[INFO]')} Updating Pixcode source checkout...`);
|
|
309
|
+
await runInherited(process.execPath, [gitUpdateScript], { cwd: APP_ROOT });
|
|
310
|
+
console.log(`${c.ok('[OK]')} Source update complete!`);
|
|
311
|
+
await maybeRestartDaemonAfterUpdate(options);
|
|
312
|
+
}
|
|
313
|
+
|
|
252
314
|
// Update the package
|
|
253
315
|
async function updatePackage(options = {}) {
|
|
254
316
|
try {
|
|
255
317
|
const { execSync } = await import('child_process');
|
|
318
|
+
if (installMode === 'git') {
|
|
319
|
+
await updateGitPackage(options);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
256
323
|
console.log(`${c.info('[INFO]')} Checking for updates...`);
|
|
257
324
|
|
|
258
325
|
const { hasUpdate, latestVersion, currentVersion } = await checkForUpdates(true);
|
|
@@ -265,32 +332,13 @@ async function updatePackage(options = {}) {
|
|
|
265
332
|
console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
|
|
266
333
|
execSync('npm update -g @pixelbyte-software/pixcode', { stdio: 'inherit' });
|
|
267
334
|
console.log(`${c.ok('[OK]')} Update complete!`);
|
|
268
|
-
|
|
269
|
-
if (options.restartDaemon) {
|
|
270
|
-
if (!hasInstalledDaemonUnit()) {
|
|
271
|
-
console.log(`${c.warn('[WARN]')} No daemon unit detected; skipping restart.`);
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
console.log(`${c.info('[INFO]')} Restarting daemon service...`);
|
|
275
|
-
await handleDaemonCommand(['restart', '--mode=system'], {
|
|
276
|
-
appRoot: APP_ROOT,
|
|
277
|
-
defaultPort: process.env.SERVER_PORT || process.env.PORT || '3001',
|
|
278
|
-
color: c,
|
|
279
|
-
});
|
|
280
|
-
console.log(`${c.ok('[OK]')} Daemon restart completed.`);
|
|
281
|
-
} else if (hasInstalledDaemonUnit()) {
|
|
282
|
-
const restartCommand = buildDaemonCliCommand(
|
|
283
|
-
{ subcommand: 'restart', mode: 'system' },
|
|
284
|
-
DAEMON_COMMAND_CONTEXT
|
|
285
|
-
);
|
|
286
|
-
console.log(`${c.tip('[TIP]')} Daemon unit detected. Restart to apply update: ${c.bright(restartCommand)}`);
|
|
287
|
-
console.log(`${c.tip('[TIP]')} Or update + restart in one step: ${c.bright('pixcode update --restart-daemon')}`);
|
|
288
|
-
} else {
|
|
289
|
-
console.log(`${c.tip('[TIP]')} Restart pixcode to use the new version.`);
|
|
290
|
-
}
|
|
335
|
+
await maybeRestartDaemonAfterUpdate(options);
|
|
291
336
|
} catch (e) {
|
|
292
337
|
console.error(`${c.error('[ERROR]')} Update failed: ${e.message}`);
|
|
293
|
-
|
|
338
|
+
const fallbackCommand = installMode === 'git'
|
|
339
|
+
? 'pixcode update --restart-daemon'
|
|
340
|
+
: 'npm update -g @pixelbyte-software/pixcode';
|
|
341
|
+
console.log(`${c.tip('[TIP]')} Try running manually: ${fallbackCommand}`);
|
|
294
342
|
}
|
|
295
343
|
}
|
|
296
344
|
|
package/server/index.js
CHANGED
|
@@ -498,6 +498,11 @@ app.post('/api/system/update', authenticateToken, async (req, res) => {
|
|
|
498
498
|
: installMode === 'git'
|
|
499
499
|
? `${JSON.stringify(process.execPath)} ${JSON.stringify(gitUpdateScript)}`
|
|
500
500
|
: 'npm install -g @pixelbyte-software/pixcode@latest';
|
|
501
|
+
const updateCommandLabel = IS_PLATFORM
|
|
502
|
+
? 'Pixcode platform update'
|
|
503
|
+
: installMode === 'git'
|
|
504
|
+
? 'Pixcode source update'
|
|
505
|
+
: 'pixcode update';
|
|
501
506
|
|
|
502
507
|
const updateCwd = IS_PLATFORM || installMode === 'git'
|
|
503
508
|
? projectRoot
|
|
@@ -770,7 +775,7 @@ app.post('/api/system/update', authenticateToken, async (req, res) => {
|
|
|
770
775
|
}
|
|
771
776
|
}
|
|
772
777
|
|
|
773
|
-
send('log', { stream: 'meta', chunk: `Running: ${
|
|
778
|
+
send('log', { stream: 'meta', chunk: `Running: ${updateCommandLabel}\n` });
|
|
774
779
|
|
|
775
780
|
// Cross-platform shell invocation. `detached: true` + `unref()` below
|
|
776
781
|
// means the install child survives if this server process gets killed
|