mendix-ruby-bridge 0.1.1

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 (54) hide show
  1. checksums.yaml +7 -0
  2. data/.mxcli-version +2 -0
  3. data/LICENSE +21 -0
  4. data/README.md +77 -0
  5. data/bin/git-mendix +4 -0
  6. data/bin/mendix-apply +145 -0
  7. data/bin/mendix-desktop +26 -0
  8. data/bin/mendix-git +121 -0
  9. data/bin/mendix-ruby +580 -0
  10. data/bin/mxcli +20 -0
  11. data/bin/setup-tools +25 -0
  12. data/lib/mendix_bridge/backend_server.rb +1404 -0
  13. data/lib/mendix_bridge/change_planner.rb +594 -0
  14. data/lib/mendix_bridge/config.rb +89 -0
  15. data/lib/mendix_bridge/dependency_index.rb +188 -0
  16. data/lib/mendix_bridge/desktop_app.rb +121 -0
  17. data/lib/mendix_bridge/document_parser.rb +120 -0
  18. data/lib/mendix_bridge/domain_parser.rb +103 -0
  19. data/lib/mendix_bridge/dsl.rb +540 -0
  20. data/lib/mendix_bridge/enumeration_parser.rb +32 -0
  21. data/lib/mendix_bridge/git_workflow.rb +321 -0
  22. data/lib/mendix_bridge/html_viewer.rb +672 -0
  23. data/lib/mendix_bridge/importer.rb +415 -0
  24. data/lib/mendix_bridge/inventory.rb +93 -0
  25. data/lib/mendix_bridge/mdl_generator.rb +343 -0
  26. data/lib/mendix_bridge/microflow_parser.rb +131 -0
  27. data/lib/mendix_bridge/migration.rb +290 -0
  28. data/lib/mendix_bridge/migration_executor.rb +234 -0
  29. data/lib/mendix_bridge/model.rb +204 -0
  30. data/lib/mendix_bridge/page_parser.rb +95 -0
  31. data/lib/mendix_bridge/presenter.rb +35 -0
  32. data/lib/mendix_bridge/project_creator.rb +181 -0
  33. data/lib/mendix_bridge/ruby_inventory_generator.rb +63 -0
  34. data/lib/mendix_bridge/security_parser.rb +72 -0
  35. data/lib/mendix_bridge/snapshot_diff.rb +58 -0
  36. data/lib/mendix_bridge/validator.rb +46 -0
  37. data/lib/mendix_bridge/version.rb +5 -0
  38. data/lib/mendix_bridge/visual_entity_plan.rb +176 -0
  39. data/lib/mendix_bridge.rb +127 -0
  40. data/share/applications/mendix-ruby-bridge.desktop +12 -0
  41. data/share/icons/hicolor/128x128/apps/mendix-ruby-bridge.png +0 -0
  42. data/share/icons/hicolor/256x256/apps/mendix-ruby-bridge.png +0 -0
  43. data/share/icons/hicolor/32x32/apps/mendix-ruby-bridge.png +0 -0
  44. data/share/icons/hicolor/48x48/apps/mendix-ruby-bridge.png +0 -0
  45. data/share/icons/hicolor/512x512/apps/mendix-ruby-bridge.png +0 -0
  46. data/share/icons/hicolor/64x64/apps/mendix-ruby-bridge.png +0 -0
  47. data/web/dist/apple-touch-icon.png +0 -0
  48. data/web/dist/assets/index-BO6iPT1P.css +1 -0
  49. data/web/dist/assets/index-JGODw81W.js +27 -0
  50. data/web/dist/brand/mendix-ruby-bridge.png +0 -0
  51. data/web/dist/favicon.png +0 -0
  52. data/web/dist/icons.svg +24 -0
  53. data/web/dist/index.html +17 -0
  54. metadata +179 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6860c21258f02339ff165d3340693f1412e5a65d9d35db0369f266eeb5d3c572
4
+ data.tar.gz: 8a107799572a75488aa14d6e7d6df05b1c95ffc6cb63065eb871d5b07e4dd9bb
5
+ SHA512:
6
+ metadata.gz: 3d05d9fe7f68f731350602aaef1cfa14f02c432c746df8b023a1a2b29c91308058c81984a157031e313ef7ae81d7040c2f5ede828e8295551b7203955c68a870
7
+ data.tar.gz: 41958be09852e670435f0436d371dca0a4caf537bf34ff3c2c820915288038b53c5ac37213d194ca8c6314a0eaa32969d879547788ed2aa24abbe3131d7b88a7
data/.mxcli-version ADDED
@@ -0,0 +1,2 @@
1
+ 0.16.0
2
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mykael
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Mendix Ruby Bridge
2
+
3
+ Ruby DSL for describing Mendix application models: create projects from Ruby,
4
+ import existing `.mpr` projects into a searchable Ruby inventory, plan and
5
+ apply changes safely, and explore everything in an integrated web viewer.
6
+
7
+ ## Installation
8
+
9
+ Install the gem and its pinned `mxcli` tool:
10
+
11
+ ```sh
12
+ gem install mendix-ruby-bridge
13
+ mendix-ruby setup
14
+ ```
15
+
16
+ ## Quick start
17
+
18
+ ```ruby
19
+ model = MendixBridge.app("Customer Portal", version: "1.0") do
20
+ modulo "CRM" do
21
+ entity "Customer" do
22
+ attribute "Name", :string, required: true
23
+ attribute "Active", :boolean, default: true
24
+ association "Customer_Orders",
25
+ target: "Sales.Order",
26
+ cardinality: :many
27
+ end
28
+ end
29
+ end
30
+ ```
31
+
32
+ ```sh
33
+ # Create a new Mendix project from a Ruby model
34
+ bin/mendix-ruby new examples/customer_app.rb --output ../customer-app --version 11.6.8
35
+
36
+ # Import an existing project into a Ruby inventory and explore it
37
+ bin/mendix-ruby import ../app/App.mpr --output ../ruby-inventory
38
+ bin/mendix-ruby serve ../ruby-inventory # http://127.0.0.1:4567
39
+
40
+ # Preview and apply declarative changes with all safety checks
41
+ bin/mendix-ruby plan examples/sandbox_app.rb --inventory ../ruby-inventory
42
+ bin/mendix-apply examples/sandbox_app.rb --project ../app/App.mpr
43
+ ```
44
+
45
+ ## Documentation
46
+
47
+ - [Getting started](docs/getting-started.md) — installation, creating a
48
+ project from Ruby, and project configuration.
49
+ - [Ruby DSL guide](docs/dsl.md) — entities, enumerations, microflows, pages,
50
+ security, navigation, and compiling/applying models.
51
+ - [Explicit migrations and rollback](docs/migrations.md) — destructive and
52
+ security-sensitive changes (renames, drops, role changes) with backup and
53
+ rollback.
54
+ - [Git-controlled Mendix branches](docs/git-workflow.md) — guarded branch
55
+ switching, stash, merge, and rebase with Mendix consistency checks.
56
+ - [Import and the web viewer](docs/import-and-viewer.md) — importing existing
57
+ projects, dependency queries, search/inspect, and the integrated viewer
58
+ (domain explorer, ER diagram, page builder, Git panel, Marketplace).
59
+
60
+ ## Safety model
61
+
62
+ The declarative apply is additive and idempotent; destructive or
63
+ migration-sensitive changes are reported as `BLOCKED` and belong in explicit
64
+ migrations. The web viewer never writes the `.mpr`: visual edits are validated
65
+ with `mxcli check` and stored as reviewable drafts, while real writes go
66
+ through the guarded CLI/Git workflow with Studio Pro closed.
67
+
68
+ ## Development
69
+
70
+ ```sh
71
+ bundle install
72
+ bundle exec rake test
73
+ bundle exec rake build
74
+ ```
75
+
76
+ Tags matching the gem version, such as `v0.1.0`, run the complete test matrix,
77
+ build the gem, and publish it as a GitHub Release.
data/bin/git-mendix ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ exec(File.expand_path("mendix-git", __dir__), *ARGV)
data/bin/mendix-apply ADDED
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "open3"
5
+ require "optparse"
6
+ require "pathname"
7
+ require "tempfile"
8
+ require_relative "../lib/mendix_bridge"
9
+
10
+ options = { allow_dirty: false }
11
+
12
+ parser = OptionParser.new do |opts|
13
+ opts.banner = "Usage: mendix-apply APP.rb --project APP.mpr"
14
+
15
+ opts.on("-p", "--project FILE", "Target Mendix .mpr file") do |file|
16
+ options[:project] = File.expand_path(file)
17
+ end
18
+
19
+ opts.on("--allow-dirty", "Allow a target repository with uncommitted changes") do
20
+ options[:allow_dirty] = true
21
+ end
22
+ end
23
+
24
+ parser.parse!
25
+ project_config = MendixBridge::Config.find
26
+ dsl_file = ARGV.shift || project_config&.model
27
+ options[:project] ||= project_config&.project
28
+
29
+ unless dsl_file && options[:project] && ARGV.empty?
30
+ warn parser
31
+ exit 1
32
+ end
33
+
34
+ dsl_file = File.expand_path(dsl_file)
35
+ project_file = options.fetch(:project)
36
+ project_dir = File.dirname(project_file)
37
+ bridge_dir = File.expand_path("..", __dir__)
38
+ mxcli = File.join(bridge_dir, "bin", "mxcli")
39
+ version_file = File.join(project_dir, ".mendix-version")
40
+
41
+ abort "DSL file does not exist: #{dsl_file}" unless File.file?(dsl_file)
42
+ abort "Mendix project does not exist: #{project_file}" unless File.file?(project_file)
43
+ abort "Missing #{version_file}" unless File.file?(version_file)
44
+
45
+ git_root, git_error, git_status = Open3.capture3(
46
+ "git", "-C", project_dir, "rev-parse", "--show-toplevel"
47
+ )
48
+ abort "Target project must be inside a Git repository: #{git_error}" unless git_status.success?
49
+
50
+ git_root = git_root.strip
51
+ dirty, = Open3.capture2("git", "-C", git_root, "status", "--porcelain")
52
+ if !options[:allow_dirty] && !dirty.empty?
53
+ abort "Target repository has uncommitted changes; commit them or use --allow-dirty"
54
+ end
55
+
56
+ version = File.read(version_file).strip
57
+ mx = File.join(Dir.home, ".mxcli", "mxbuild", version, "modeler", "mx")
58
+ abort "Mendix mx #{version} is not installed: #{mx}" unless File.executable?(mx)
59
+
60
+ model = MendixBridge.load_file(dsl_file)
61
+
62
+ existing_associations = model.modules.flat_map do |app_module|
63
+ output, error, status = Open3.capture3(
64
+ mxcli,
65
+ "-p", project_file,
66
+ "-c", "SHOW ASSOCIATIONS IN #{app_module.name}"
67
+ )
68
+ abort "Could not inspect associations: #{error}" unless status.success?
69
+
70
+ output.scan(/^\|\s+([A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)\s+\|/).flatten
71
+ end
72
+
73
+ declared_associations = model.modules.flat_map do |app_module|
74
+ app_module.entities.flat_map do |entity|
75
+ entity.associations.map { |association| "#{app_module.name}.#{association.name}" }
76
+ end
77
+ end
78
+ skipped_associations = declared_associations & existing_associations
79
+
80
+ unless skipped_associations.empty?
81
+ puts "Keeping existing associations: #{skipped_associations.join(', ')}"
82
+ end
83
+
84
+ existing_module_roles = model.modules.flat_map do |app_module|
85
+ output, error, status = Open3.capture3(
86
+ mxcli,
87
+ "-p", project_file,
88
+ "-c", "SHOW MODULE ROLES IN #{app_module.name};"
89
+ )
90
+ abort "Could not inspect module roles: #{error}" unless status.success?
91
+
92
+ output.scan(
93
+ /^\|\s+([A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)\s+\|/
94
+ ).flatten
95
+ end
96
+ declared_module_roles = model.modules.flat_map do |app_module|
97
+ app_module.module_roles.map { |role| "#{app_module.name}.#{role.name}" }
98
+ end
99
+ skipped_module_roles = declared_module_roles & existing_module_roles
100
+
101
+ user_role_output, user_role_error, user_role_status = Open3.capture3(
102
+ mxcli,
103
+ "-p", project_file,
104
+ "-c", "SHOW USER ROLES;"
105
+ )
106
+ abort "Could not inspect user roles: #{user_role_error}" unless user_role_status.success?
107
+ existing_user_roles = user_role_output.scan(/^\|\s+([A-Za-z_][A-Za-z0-9_]*)\s+\|/).flatten
108
+ declared_user_roles = model.user_roles.map(&:name)
109
+ skipped_user_roles = declared_user_roles & existing_user_roles
110
+
111
+ unless skipped_module_roles.empty?
112
+ puts "Keeping existing module roles: #{skipped_module_roles.join(', ')}"
113
+ end
114
+ unless skipped_user_roles.empty?
115
+ puts "Keeping existing user roles: #{skipped_user_roles.join(', ')}"
116
+ end
117
+
118
+ mdl = MendixBridge.compile(
119
+ model,
120
+ format: :mdl,
121
+ skip_associations: skipped_associations,
122
+ skip_module_roles: skipped_module_roles,
123
+ skip_user_roles: skipped_user_roles
124
+ )
125
+
126
+ Tempfile.create(["mendix-ruby-bridge-", ".mdl"]) do |file|
127
+ file.write(mdl)
128
+ file.flush
129
+
130
+ puts "1/3 Validating generated MDL..."
131
+ abort "MDL validation failed" unless system(mxcli, "check", file.path)
132
+
133
+ puts "2/3 Applying MDL to #{File.basename(project_file)}..."
134
+ abort "mxcli could not apply the model" unless system(
135
+ mxcli, "exec", file.path, "-p", project_file
136
+ )
137
+
138
+ puts "3/3 Running official Mendix consistency check..."
139
+ abort "Mendix consistency check failed" unless system(
140
+ mx, "check", project_file, chdir: project_dir
141
+ )
142
+ end
143
+
144
+ puts "Application completed successfully."
145
+ puts "Review the changes with: git -C #{git_root} status --short"
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "optparse"
5
+ require_relative "../lib/mendix_bridge"
6
+
7
+ parser = OptionParser.new do |opts|
8
+ opts.banner = "Usage: mendix-desktop [IMPORTED_DIR]"
9
+ opts.on("-v", "--version", "Print version") do
10
+ puts MendixBridge::VERSION
11
+ exit
12
+ end
13
+ end
14
+ parser.parse!
15
+
16
+ unless ARGV.length <= 1
17
+ warn parser
18
+ exit 1
19
+ end
20
+
21
+ inventory_dir = File.expand_path(
22
+ ARGV.shift || MendixBridge::Config.find&.inventory || "."
23
+ )
24
+ bridge_dir = File.expand_path("..", __dir__)
25
+
26
+ MendixBridge::DesktopApp.new(inventory_dir:, bridge_dir:).run
data/bin/mendix-git ADDED
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "json"
5
+ require "optparse"
6
+ require_relative "../lib/mendix_bridge"
7
+
8
+ options = { studio_closed: false, fetch: false }
9
+ parser = OptionParser.new do |opts|
10
+ opts.banner = "Usage: mendix-git COMMAND [ARGUMENTS] [--project APP.mpr] [options]"
11
+ opts.on("-p", "--project FILE", "Mendix .mpr file") { |file| options[:project] = File.expand_path(file) }
12
+ opts.on("-i", "--inventory DIR", "Refresh this Ruby inventory after switching") do |dir|
13
+ options[:inventory] = File.expand_path(dir)
14
+ end
15
+ opts.on("--studio-closed", "Confirm Studio Pro is closed") { options[:studio_closed] = true }
16
+ opts.on("--fetch", "Fetch and prune origin before the command") { options[:fetch] = true }
17
+ opts.on("--json", "Print machine-readable JSON") { options[:json] = true }
18
+ opts.on("-m", "--message MESSAGE", "Stash message") { |message| options[:message] = message }
19
+ opts.on("-u", "--include-untracked", "Include untracked files in stash push") do
20
+ options[:include_untracked] = true
21
+ end
22
+ end
23
+
24
+ parser.parse!
25
+ command = ARGV.shift
26
+ arguments = ARGV.dup
27
+ unless options[:project]
28
+ candidates = Dir[File.join(Dir.pwd, "*.mpr")]
29
+ options[:project] = candidates.first if candidates.length == 1
30
+ end
31
+ unless command && options[:project]
32
+ warn parser
33
+ warn "Run inside a directory containing one .mpr file or pass --project."
34
+ exit 1
35
+ end
36
+
37
+ bridge_dir = File.expand_path("..", __dir__)
38
+ begin
39
+ workflow = MendixBridge::GitWorkflow.new(
40
+ options.fetch(:project),
41
+ inventory_dir: options[:inventory],
42
+ mxcli: File.join(bridge_dir, "bin", "mxcli")
43
+ )
44
+ workflow.fetch if options[:fetch]
45
+
46
+ result = case command
47
+ when "status"
48
+ abort "status does not accept arguments" unless arguments.empty?
49
+ workflow.status
50
+ when "branches"
51
+ abort "branches does not accept arguments" unless arguments.empty?
52
+ workflow.branches
53
+ when "switch"
54
+ branch = arguments.shift
55
+ abort "switch requires a branch" unless branch
56
+ abort "switch accepts only one branch" unless arguments.empty?
57
+ workflow.switch(branch, studio_closed: options[:studio_closed])
58
+ when "new"
59
+ branch = arguments.shift
60
+ abort "new requires a branch" unless branch
61
+ abort "new accepts only one branch" unless arguments.empty?
62
+ workflow.create(branch, studio_closed: options[:studio_closed])
63
+ when "stash"
64
+ action = arguments.shift
65
+ reference = arguments.shift
66
+ abort "stash accepts at most an action and reference" unless arguments.empty?
67
+ case action
68
+ when "push"
69
+ abort "stash push does not accept a reference" if reference
70
+ workflow.stash_push(
71
+ studio_closed: options[:studio_closed],
72
+ message: options[:message],
73
+ include_untracked: options[:include_untracked]
74
+ )
75
+ when "list"
76
+ abort "stash list does not accept a reference" if reference
77
+ workflow.stash_list
78
+ when "show"
79
+ workflow.stash_show(reference || "stash@{0}")
80
+ when "apply"
81
+ workflow.stash_apply(
82
+ reference || "stash@{0}",
83
+ studio_closed: options[:studio_closed]
84
+ )
85
+ when "pop"
86
+ workflow.stash_apply(
87
+ reference || "stash@{0}",
88
+ studio_closed: options[:studio_closed],
89
+ drop: true
90
+ )
91
+ when "drop"
92
+ workflow.stash_drop(reference || "stash@{0}")
93
+ else
94
+ abort "stash expects push, list, show, apply, pop, or drop"
95
+ end
96
+ when "merge"
97
+ branch = arguments.shift
98
+ abort "merge requires a branch" unless branch
99
+ abort "merge accepts only one branch" unless arguments.empty?
100
+ workflow.merge(branch, studio_closed: options[:studio_closed])
101
+ when "rebase"
102
+ branch = arguments.shift
103
+ abort "rebase requires a branch" unless branch
104
+ abort "rebase accepts only one branch" unless arguments.empty?
105
+ workflow.rebase(branch, studio_closed: options[:studio_closed])
106
+ else
107
+ abort "unknown command: #{command}; expected status, branches, switch, new, stash, merge, or rebase"
108
+ end
109
+
110
+ if options[:json]
111
+ puts JSON.pretty_generate(result)
112
+ elsif result.is_a?(Array)
113
+ puts result
114
+ elsif result.is_a?(String)
115
+ puts result
116
+ else
117
+ result.each { |key, value| puts "#{key}: #{value}" }
118
+ end
119
+ rescue MendixBridge::GitWorkflowError => error
120
+ abort error.message
121
+ end