Class: EmberCli::App

Inherits:
Object
  • Object
show all
Defined in:
lib/ember_cli/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, **options) ⇒ App

Returns a new instance of App.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ember_cli/app.rb', line 13

def initialize(name, **options)
  @name = name.to_s
  @options = options
  @paths = PathSet.new(
    app: self,
    environment: Rails.env,
    rails_root: Rails.root,
    ember_cli_root: EmberCli.root,
  )
  @shell = Shell.new(
    paths: @paths,
    env: env_hash,
    options: options,
  )
  @build = BuildMonitor.new(name, @paths)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/ember_cli/app.rb', line 11

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/ember_cli/app.rb', line 11

def options
  @options
end

#pathsObject (readonly)

Returns the value of attribute paths.



11
12
13
# File 'lib/ember_cli/app.rb', line 11

def paths
  @paths
end

Instance Method Details

#bower?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/ember_cli/app.rb', line 98

def bower?
  paths.bower_json.exist?
end

#buildObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ember_cli/app.rb', line 52

def build
  unless EmberCli.skip?
    if dev_server?
      # Vite's own development server rebuilds and hot-reloads the
      # application, so there is nothing to build ahead of time.
      dev_server.start
    else
      build_for_environment

      @build.wait!
    end
  end
end

#cached_directoriesObject



38
39
40
# File 'lib/ember_cli/app.rb', line 38

def cached_directories
  paths.cached_directories
end

#check_for_errors!Object



86
87
88
# File 'lib/ember_cli/app.rb', line 86

def check_for_errors!
  @build.check!
end

#compileObject



42
43
44
45
46
47
48
49
50
# File 'lib/ember_cli/app.rb', line 42

def compile
  @compiled ||= begin
    prepare
    exit_status = @shell.compile
    @build.check!

    exit_status.success?
  end
end

#dev_serverObject



106
107
108
109
110
111
112
113
# File 'lib/ember_cli/app.rb', line 106

def dev_server
  @dev_server ||= DevServer.new(
    name: name,
    paths: paths,
    shell: @shell,
    options: dev_server_options,
  )
end

#dev_server?Boolean

Whether this application is served by Vite's development server rather than out of the directory ember build writes to.

Returns:

  • (Boolean)


117
118
119
120
121
122
# File 'lib/ember_cli/app.rb', line 117

def dev_server?
  strategy = deploy_strategy

  strategy.is_a?(Class) &&
    strategy.ancestors.include?(EmberCli::Deploy::DevServer)
end

#dist_pathObject



34
35
36
# File 'lib/ember_cli/app.rb', line 34

def dist_path
  paths.dist
end

#index_html(head:, body:) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/ember_cli/app.rb', line 66

def index_html(head:, body:)
  html = HtmlPage::Renderer.new(
    head: head,
    body: body,
    content: deploy.index_html,
  )

  html.render
end

#install_dependenciesObject



76
77
78
# File 'lib/ember_cli/app.rb', line 76

def install_dependencies
  @shell.install
end

#mountable?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/ember_cli/app.rb', line 90

def mountable?
  deploy.mountable?
end

#root_pathObject



30
31
32
# File 'lib/ember_cli/app.rb', line 30

def root_path
  paths.root
end

#testObject



80
81
82
83
84
# File 'lib/ember_cli/app.rb', line 80

def test
  prepare

  @shell.test.success?
end

#to_rackObject



102
103
104
# File 'lib/ember_cli/app.rb', line 102

def to_rack
  deploy.to_rack
end

#yarn_enabled?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/ember_cli/app.rb', line 94

def yarn_enabled?
  options.fetch(:yarn, false)
end