@mostajs/orm-cli 0.5.1 → 0.5.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/bin/mostajs.sh +61 -0
- package/package.json +1 -1
package/bin/mostajs.sh
CHANGED
|
@@ -1798,6 +1798,7 @@ menu_replicator() {
|
|
|
1798
1798
|
echo -e " ${CYAN}7${RESET}) List CDC rules"
|
|
1799
1799
|
echo -e " ${CYAN}8${RESET}) Run a CDC sync + show stats"
|
|
1800
1800
|
echo -e " ${CYAN}9${RESET}) Remove a CDC rule"
|
|
1801
|
+
echo -e " ${CYAN}m${RESET}) ${BOLD}Open monitor${RESET} (live dashboard — localhost:14499)"
|
|
1801
1802
|
echo -e " ${CYAN}v${RESET}) View the raw tree file"
|
|
1802
1803
|
echo -e " ${CYAN}c${RESET}) Clear (delete the tree file — DESTRUCTIVE)"
|
|
1803
1804
|
echo
|
|
@@ -1815,6 +1816,7 @@ menu_replicator() {
|
|
|
1815
1816
|
7) action_rep_list_rules ;;
|
|
1816
1817
|
8) action_rep_sync ;;
|
|
1817
1818
|
9) action_rep_remove_rule ;;
|
|
1819
|
+
m|M) action_rep_open_monitor ;;
|
|
1818
1820
|
v|V) action_rep_view_tree ;;
|
|
1819
1821
|
c|C) action_rep_clear ;;
|
|
1820
1822
|
b|B) return ;;
|
|
@@ -1963,6 +1965,65 @@ action_rep_remove_rule() {
|
|
|
1963
1965
|
pause
|
|
1964
1966
|
}
|
|
1965
1967
|
|
|
1968
|
+
action_rep_open_monitor() {
|
|
1969
|
+
header
|
|
1970
|
+
echo -e "${BOLD}${MAGENTA}▶ Open replica-monitor dashboard${RESET}"
|
|
1971
|
+
echo
|
|
1972
|
+
# Ensure the monitor package is installed
|
|
1973
|
+
if [[ ! -d "$PROJECT_ROOT/node_modules/@mostajs/replica-monitor" ]]; then
|
|
1974
|
+
warn "@mostajs/replica-monitor not installed in this project."
|
|
1975
|
+
if confirm "Install it now?"; then
|
|
1976
|
+
ensure_pkg "@mostajs/replica-monitor" || { pause; return; }
|
|
1977
|
+
else
|
|
1978
|
+
pause; return
|
|
1979
|
+
fi
|
|
1980
|
+
fi
|
|
1981
|
+
local tree_file
|
|
1982
|
+
tree_file=$(_replicator_tree_file)
|
|
1983
|
+
local port
|
|
1984
|
+
port=$(ask "Port" "14499")
|
|
1985
|
+
local token
|
|
1986
|
+
token=$(ask "Auth token (empty = no auth, local-only)" "")
|
|
1987
|
+
local url_suffix=""
|
|
1988
|
+
[[ -n "$token" ]] && url_suffix="?token=${token}"
|
|
1989
|
+
|
|
1990
|
+
local log_file="$PROJECT_ROOT/.mostajs/monitor.log"
|
|
1991
|
+
local pid_file="$PROJECT_ROOT/.mostajs/monitor.pid"
|
|
1992
|
+
|
|
1993
|
+
# If already running (pid file exists + process alive) : just open the URL.
|
|
1994
|
+
if [[ -f "$pid_file" ]] && kill -0 "$(cat "$pid_file" 2>/dev/null)" 2>/dev/null; then
|
|
1995
|
+
ok "Monitor already running at http://127.0.0.1:${port}"
|
|
1996
|
+
else
|
|
1997
|
+
# Spawn in background
|
|
1998
|
+
echo -e " ${DIM}spawning mostajs-monitor …${RESET}"
|
|
1999
|
+
MONITOR_TREE="$tree_file" MONITOR_PORT="$port" MONITOR_TOKEN="$token" \
|
|
2000
|
+
nohup node "$PROJECT_ROOT/node_modules/@mostajs/replica-monitor/dist/cli.js" \
|
|
2001
|
+
--tree "$tree_file" --port "$port" --runtime "$PROJECT_ROOT" \
|
|
2002
|
+
${token:+--token "$token"} \
|
|
2003
|
+
> "$log_file" 2>&1 &
|
|
2004
|
+
local pid=$!
|
|
2005
|
+
echo "$pid" > "$pid_file"
|
|
2006
|
+
sleep 1
|
|
2007
|
+
if kill -0 "$pid" 2>/dev/null; then
|
|
2008
|
+
ok "Monitor started (pid=$pid) → http://127.0.0.1:${port}${url_suffix}"
|
|
2009
|
+
dim " logs : $log_file"
|
|
2010
|
+
dim " stop : kill \$(cat $pid_file) or menu r → m again then Ctrl+C"
|
|
2011
|
+
else
|
|
2012
|
+
err "Monitor failed to start — check $log_file"
|
|
2013
|
+
cat "$log_file" | tail -10
|
|
2014
|
+
pause; return
|
|
2015
|
+
fi
|
|
2016
|
+
fi
|
|
2017
|
+
|
|
2018
|
+
# Try to open in default browser
|
|
2019
|
+
if command -v xdg-open >/dev/null 2>&1; then
|
|
2020
|
+
xdg-open "http://127.0.0.1:${port}${url_suffix}" >/dev/null 2>&1 &
|
|
2021
|
+
elif command -v open >/dev/null 2>&1; then
|
|
2022
|
+
open "http://127.0.0.1:${port}${url_suffix}" >/dev/null 2>&1 &
|
|
2023
|
+
fi
|
|
2024
|
+
pause
|
|
2025
|
+
}
|
|
2026
|
+
|
|
1966
2027
|
action_rep_view_tree() {
|
|
1967
2028
|
local tree_file
|
|
1968
2029
|
tree_file=$(_replicator_tree_file)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostajs/orm-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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",
|