@mostajs/orm-cli 0.5.3 → 0.5.4

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 +33 -4
  2. package/package.json +1 -1
package/bin/mostajs.sh CHANGED
@@ -1933,18 +1933,47 @@ action_rep_scaffold_services() {
1933
1933
  }
1934
1934
 
1935
1935
  action_rep_add_replica() {
1936
+ echo
1937
+ dim " A project is a logical group of replicas (e.g. 'fitzone', 'secuaccess')."
1938
+ dim " Use a SHORT IDENTIFIER here (NOT a database URI — the URI comes later)."
1939
+ echo
1936
1940
  local project name role dialect uri lag
1937
- project=$(ask "Project name" "default")
1938
- name=$(ask "Replica name" "master")
1941
+ project=$(ask "Project name (short id, e.g. 'fitzone')" "fitzone")
1942
+ # Basic validation : reject URIs or paths
1943
+ if [[ "$project" == *"://"* || "$project" == *"/"* ]]; then
1944
+ err " Project name looks like a URI or path. Use a short identifier (e.g. 'fitzone')."
1945
+ pause; return
1946
+ fi
1947
+
1948
+ echo
1949
+ dim " Replica name is a label inside the project (e.g. 'master-oracle', 'slave-pg')."
1950
+ name=$(ask "Replica name (label, e.g. 'master-oracle')" "master")
1951
+ if [[ "$name" == *"://"* ]]; then
1952
+ err " Replica name looks like a URI. Use a short label."
1953
+ pause; return
1954
+ fi
1955
+
1939
1956
  role=$(ask "Role (master|slave)" "master")
1940
- dialect=$(ask "Dialect" "${DB_DIALECT:-postgres}")
1941
- uri=$(ask "URI" "${SGBD_URI:-postgres://user:pass@localhost:5432/db}")
1957
+ dialect=$(ask "Dialect (sqlite|postgres|mysql|mongodb|oracle|mssql|mariadb|cockroachdb|db2|hana|hsqldb|spanner|sybase)" "${DB_DIALECT:-postgres}")
1958
+ uri=$(ask "Connection URI" "${SGBD_URI:-postgres://user:pass@localhost:5432/db}")
1942
1959
  if [[ "$role" == "slave" ]]; then
1943
1960
  lag=$(ask "Lag tolerance (ms)" "5000")
1944
1961
  else
1945
1962
  lag="0"
1946
1963
  fi
1947
1964
  _replicator_run "
1965
+ // Auto-register the project in ProjectManager if it's not already there —
1966
+ // addReplica() requires the project to exist. We use the replica's own
1967
+ // dialect/uri as the project config (it's typically the master).
1968
+ const existing = typeof pm.listProjects === 'function' ? pm.listProjects() : [];
1969
+ const known = Array.isArray(existing) && existing.some(p => (p.name ?? p) === '$project');
1970
+ if (!known) {
1971
+ const method = ['addProject','createProject','registerProject'].find(m => typeof pm[m] === 'function');
1972
+ if (method) {
1973
+ await pm[method]({ name: '$project', dialect: '$dialect', uri: '$uri', schemas: [] });
1974
+ console.log(' ✓ project \\'$project\\' registered in ProjectManager');
1975
+ }
1976
+ }
1948
1977
  await rm.addReplica('$project', {
1949
1978
  name: '$name', role: '$role', dialect: '$dialect', uri: '$uri',
1950
1979
  lagTolerance: $lag,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/orm-cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
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",