@mostajs/orm-cli 0.5.8 → 0.5.9

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 +26 -3
  2. package/package.json +1 -1
package/bin/mostajs.sh CHANGED
@@ -2109,14 +2109,37 @@ action_rep_set_routing() {
2109
2109
 
2110
2110
  action_rep_add_rule() {
2111
2111
  local name source target mode colls conflict
2112
- # Pick source/target from known projects
2113
2112
  source=$(_pick_project)
2114
2113
  local src_default="$source"
2115
2114
  name=$(ask "Rule name (short, e.g. 'pg-to-mongo')" "cdc-${src_default}")
2116
2115
  target=$(ask "Target project" "$src_default")
2117
2116
  mode=$(ask "Mode (snapshot | cdc | bidirectional)" "cdc")
2118
- colls=$(ask "Collections (comma-separated)" "users,clients")
2117
+ echo
2118
+ dim " Collections : '*' = all tables in entities.json (full-DB replication)"
2119
+ dim " or explicit comma-separated list (User,Member,Payment)"
2120
+ colls=$(ask "Collections" "*")
2119
2121
  conflict=$(ask "Conflict resolution (source-wins | target-wins | timestamp)" "source-wins")
2122
+
2123
+ # Expand '*' into the full list of entity NAMES from entities.json. Keeps
2124
+ # the tree self-contained — no special-case needed in replicator.mjs.
2125
+ if [[ "$colls" == "*" ]]; then
2126
+ local ents_json="$GENERATED_DIR/entities.json"
2127
+ if [[ -f "$ents_json" ]]; then
2128
+ colls=$(node -e "try{const e=JSON.parse(require('fs').readFileSync('$ents_json','utf8'));console.log(e.map(x=>x.name).join(','))}catch{console.log('')}" 2>/dev/null)
2129
+ if [[ -z "$colls" ]]; then
2130
+ warn " entities.json empty or unreadable — keeping '*' as wildcard placeholder"
2131
+ colls="*"
2132
+ else
2133
+ local count; count=$(echo "$colls" | tr ',' '\n' | wc -l)
2134
+ ok " expanded '*' → ${count} tables from entities.json"
2135
+ dim " ${colls}"
2136
+ fi
2137
+ else
2138
+ warn " no entities.json found at $ents_json — keeping '*' as wildcard placeholder"
2139
+ warn " (run menu 1 'Convert' first, then re-add the rule to expand)"
2140
+ fi
2141
+ fi
2142
+
2120
2143
  _tree_patch "
2121
2144
  tree.rules['$name'] = {
2122
2145
  source: '$source', target: '$target', mode: '$mode',
@@ -2124,7 +2147,7 @@ action_rep_add_rule() {
2124
2147
  conflictResolution: '$conflict',
2125
2148
  enabled: true,
2126
2149
  };
2127
- console.log(' ✓ rule added : $name ($source → $target, mode=$mode)');
2150
+ console.log(' ✓ rule added : $name ($source → $target, mode=$mode, ' + ('$colls'.split(',').length) + ' collections)');
2128
2151
  "
2129
2152
  pause
2130
2153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/orm-cli",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
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",