@mostajs/orm-cli 0.5.6 → 0.5.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.
Files changed (2) hide show
  1. package/bin/mostajs.sh +28 -11
  2. package/package.json +1 -1
package/bin/mostajs.sh CHANGED
@@ -1845,23 +1845,23 @@ action_rep_scaffold_services() {
1845
1845
  # Ensure the scaffolders' packages are installed locally
1846
1846
  ensure_pkg "@mostajs/replicator" "@mostajs/replica-monitor" || { pause; return; }
1847
1847
 
1848
- local force_arg=""
1849
- if confirm "Overwrite existing services/*.mjs if present?"; then force_arg="--force"; fi
1848
+ local force_js="false"
1849
+ if confirm "Overwrite existing services/*.mjs if present?"; then force_js="true"; fi
1850
1850
 
1851
1851
  # Call each scaffolder (uses the lib's own emit logic — single source of truth)
1852
1852
  echo
1853
1853
  echo -e "${CYAN}▶ scaffoldReplicatorService${RESET}"
1854
- node --input-type=module -e "
1855
- const { scaffoldReplicatorService } = await import('${PROJECT_ROOT}/node_modules/@mostajs/replicator/dist/scaffold.js');
1856
- const r = scaffoldReplicatorService({ projectDir: '${PROJECT_ROOT}', force: ${force_arg:+true}${force_arg:-false} });
1854
+ FORCE="$force_js" PROJECT="$PROJECT_ROOT" node --input-type=module -e "
1855
+ const { scaffoldReplicatorService } = await import(process.env.PROJECT + '/node_modules/@mostajs/replicator/dist/scaffold.js');
1856
+ const r = scaffoldReplicatorService({ projectDir: process.env.PROJECT, force: process.env.FORCE === 'true' });
1857
1857
  console.log(' ' + (r.wrote ? '✓' : '•') + ' ' + r.action + ' : ' + r.path);
1858
1858
  " 2>&1 | sed 's/^/ /'
1859
1859
 
1860
1860
  echo
1861
1861
  echo -e "${CYAN}▶ scaffoldMonitorService${RESET}"
1862
- node --input-type=module -e "
1863
- const { scaffoldMonitorService } = await import('${PROJECT_ROOT}/node_modules/@mostajs/replica-monitor/dist/scaffold.js');
1864
- const r = scaffoldMonitorService({ projectDir: '${PROJECT_ROOT}', force: ${force_arg:+true}${force_arg:-false} });
1862
+ FORCE="$force_js" PROJECT="$PROJECT_ROOT" node --input-type=module -e "
1863
+ const { scaffoldMonitorService } = await import(process.env.PROJECT + '/node_modules/@mostajs/replica-monitor/dist/scaffold.js');
1864
+ const r = scaffoldMonitorService({ projectDir: process.env.PROJECT, force: process.env.FORCE === 'true' });
1865
1865
  console.log(' ' + (r.wrote ? '✓' : '•') + ' ' + r.action + ' : ' + r.path);
1866
1866
  " 2>&1 | sed 's/^/ /'
1867
1867
 
@@ -2203,10 +2203,27 @@ action_rep_open_monitor() {
2203
2203
  local log_file="$PROJECT_ROOT/.mostajs/monitor.log"
2204
2204
  local pid_file="$PROJECT_ROOT/.mostajs/monitor.pid"
2205
2205
 
2206
- # If already running (pid file exists + process alive) : just open the URL.
2206
+ # If already running : propose to restart (pick up tree changes with
2207
+ # the new tree-only CLI). A stale instance from before 0.2.0 sees an
2208
+ # empty state even when the tree has replicas.
2207
2209
  if [[ -f "$pid_file" ]] && kill -0 "$(cat "$pid_file" 2>/dev/null)" 2>/dev/null; then
2208
- ok "Monitor already running at http://127.0.0.1:${port}"
2209
- else
2210
+ local old_pid
2211
+ old_pid=$(cat "$pid_file")
2212
+ dim " Monitor already running (pid=$old_pid) at http://127.0.0.1:${port}"
2213
+ if confirm "Restart it now? (picks up recent tree-file changes)"; then
2214
+ kill "$old_pid" 2>/dev/null || true
2215
+ sleep 0.5
2216
+ rm -f "$pid_file"
2217
+ else
2218
+ ok " Kept running — re-opening the URL"
2219
+ if command -v xdg-open >/dev/null 2>&1; then
2220
+ xdg-open "http://127.0.0.1:${port}${url_suffix}" >/dev/null 2>&1 &
2221
+ fi
2222
+ pause; return
2223
+ fi
2224
+ fi
2225
+
2226
+ if [[ ! -f "$pid_file" ]]; then
2210
2227
  # Spawn in background
2211
2228
  echo -e " ${DIM}spawning mostajs-monitor …${RESET}"
2212
2229
  MONITOR_TREE="$tree_file" MONITOR_PORT="$port" MONITOR_TOKEN="$token" \
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/orm-cli",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Universal CLI to integrate @mostajs/orm into any project — one-shot `mostajs bootstrap` migrates a Prisma project (codemod + deps + schema convert + DDL) to 13 databases with zero code change.",
5
5
  "author": "Dr Hamid MADANI <drmdh@msn.com>",
6
6
  "license": "AGPL-3.0-or-later",