episoda 0.2.37 → 0.2.38

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/index.js CHANGED
@@ -4951,17 +4951,57 @@ async function checkForUpdates(currentVersion) {
4951
4951
  return { currentVersion, latestVersion: currentVersion, updateAvailable: false, offline: true };
4952
4952
  }
4953
4953
  }
4954
- function performBackgroundUpdate() {
4954
+ function performSyncUpdate() {
4955
4955
  try {
4956
- const child = (0, import_child_process7.spawn)("npm", ["update", "-g", PACKAGE_NAME], {
4956
+ (0, import_child_process7.execSync)(`npm update -g ${PACKAGE_NAME}`, {
4957
+ stdio: ["pipe", "pipe", "pipe"],
4958
+ timeout: 12e4
4959
+ // 2 minute timeout
4960
+ });
4961
+ return { success: true };
4962
+ } catch (error) {
4963
+ return {
4964
+ success: false,
4965
+ error: error instanceof Error ? error.message : String(error)
4966
+ };
4967
+ }
4968
+ }
4969
+ async function restartDaemon() {
4970
+ try {
4971
+ (0, import_child_process7.execSync)("episoda stop", {
4972
+ stdio: ["pipe", "pipe", "pipe"],
4973
+ timeout: 1e4
4974
+ });
4975
+ await new Promise((resolve5) => setTimeout(resolve5, 1e3));
4976
+ const child = (0, import_child_process7.spawn)("episoda", ["dev"], {
4957
4977
  detached: true,
4958
4978
  stdio: "ignore",
4959
- // Use shell on Windows for proper npm execution
4960
- shell: process.platform === "win32"
4979
+ shell: true
4961
4980
  });
4962
4981
  child.unref();
4982
+ return { success: true };
4963
4983
  } catch (error) {
4984
+ return {
4985
+ success: false,
4986
+ error: error instanceof Error ? error.message : String(error)
4987
+ };
4988
+ }
4989
+ }
4990
+ async function updateAndRestartDaemon() {
4991
+ const updateResult = performSyncUpdate();
4992
+ if (!updateResult.success) {
4993
+ return {
4994
+ updateSuccess: false,
4995
+ restartSuccess: false,
4996
+ error: `Update failed: ${updateResult.error}`
4997
+ };
4964
4998
  }
4999
+ const restartResult = await restartDaemon();
5000
+ return {
5001
+ updateSuccess: true,
5002
+ restartSuccess: restartResult.success,
5003
+ error: restartResult.success ? void 0 : `Restart failed: ${restartResult.error}`
5004
+ };
4965
5005
  }
4966
5006
  function getInstalledVersion() {
4967
5007
  try {
@@ -4998,8 +5038,15 @@ async function statusCommand(options = {}) {
4998
5038
  if (!options.skipUpdateCheck) {
4999
5039
  const updateResult = await checkForUpdates(import_core8.VERSION);
5000
5040
  if (updateResult.updateAvailable) {
5001
- status.info(` CLI Version: ${import_core8.VERSION} \u2B06 updating to ${updateResult.latestVersion}...`);
5002
- performBackgroundUpdate();
5041
+ status.info(` CLI Version: ${import_core8.VERSION} \u2192 ${updateResult.latestVersion} (updating...)`);
5042
+ const result = await updateAndRestartDaemon();
5043
+ if (result.updateSuccess && result.restartSuccess) {
5044
+ status.success(` CLI Version: ${updateResult.latestVersion} \u2713 (updated & daemon restarted)`);
5045
+ } else if (result.updateSuccess) {
5046
+ status.warning(` CLI Version: ${updateResult.latestVersion} (updated, restart manually with 'episoda dev')`);
5047
+ } else {
5048
+ status.warning(` CLI Version: ${import_core8.VERSION} (update failed: ${result.error})`);
5049
+ }
5003
5050
  } else {
5004
5051
  status.info(` CLI Version: ${import_core8.VERSION} \u2713`);
5005
5052
  }