@mostajs/orm-cli 0.5.7 → 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 +34 -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
 
@@ -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.7",
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",