Class: Mxrb::Compiler::DeploymentBootstrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/compiler/deployment_bootstrapper.rb

Overview

Creates a deployment workspace from versioned Studio Pro templates without invoking its builders.

Constant Summary collapse

COMMON_TEMPLATE_ROOTS =

rubocop:disable Metrics/ClassLength

%w[data log model native run tmp].freeze
REQUIRED_DIRECTORIES =
%w[
  data/database data/files data/tmp log model/bundles model/lib/userlib model/resources run tmp web/img
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(mpr_path, deployment:, mendix_home: nil) ⇒ DeploymentBootstrapper

Returns a new instance of DeploymentBootstrapper.



18
19
20
21
22
23
24
25
# File 'lib/mxrb/compiler/deployment_bootstrapper.rb', line 18

def initialize(mpr_path, deployment:, mendix_home: nil)
  @mpr_path = File.expand_path(mpr_path)
  @project_root = File.dirname(@mpr_path)
  @deployment = File.expand_path(deployment)
  @source = SourceModel.read(@mpr_path)
  @version_root = resolve_version_root(mendix_home)
  @template_root = File.join(@version_root, 'modeler', 'runtemplates', 'deployment')
end

Instance Method Details

#prepareObject



27
28
29
30
31
32
# File 'lib/mxrb/compiler/deployment_bootstrapper.rb', line 27

def prepare
  return prepare_existing if ready?

  validate_templates!
  prepare_fresh
end

#prepare_existingObject



34
35
36
37
38
39
40
# File 'lib/mxrb/compiler/deployment_bootstrapper.rb', line 34

def prepare_existing
  ensure_web_build_templates if modern_react_web?
  ensure_required_directories
  copy_project_assets
  finalize_web_shell
  DeploymentBootstrap.new(deployment: @deployment, created: false, template_root: @template_root)
end

#prepare_freshObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/mxrb/compiler/deployment_bootstrapper.rb', line 42

def prepare_fresh
  FileUtils.mkdir_p(@deployment)
  copy_version_templates
  ensure_required_directories
  render_templates
  initialize_model
  copy_project_assets
  finalize_web_shell
  DeploymentBootstrap.new(deployment: @deployment, created: true, template_root: @template_root)
end