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.



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

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

#name ⇒ Object (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/ember_cli/app.rb', line 13

def name
  @name
end

#options ⇒ Object (readonly)

Returns the value of attribute options.



13
14
15
# File 'lib/ember_cli/app.rb', line 13

def options
  @options
end

#paths ⇒ Object (readonly)

Returns the value of attribute paths.



13
14
15
# File 'lib/ember_cli/app.rb', line 13

def paths
  @paths
end

Instance Method Details

#bower? ⇒ Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/ember_cli/app.rb', line 108

def bower?
  paths.bower_json.exist?
end

#build ⇒ Object



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

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_directories ⇒ Object



40
41
42
# File 'lib/ember_cli/app.rb', line 40

def cached_directories
  paths.cached_directories
end

#check_for_errors! ⇒ Object



88
89
90
# File 'lib/ember_cli/app.rb', line 88

def check_for_errors!
  @build.check!
end

#compile ⇒ Object



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

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

    exit_status.success?
  end
end

#dev_server ⇒ Object



127
128
129
130
131
132
133
134
# File 'lib/ember_cli/app.rb', line 127

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)


138
139
140
141
142
143
# File 'lib/ember_cli/app.rb', line 138

def dev_server?
  strategy = deploy_strategy

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

#dist_path ⇒ Object



36
37
38
# File 'lib/ember_cli/app.rb', line 36

def dist_path
  paths.dist
end

#index_html(head:, body:, mount_point: nil) ⇒ Object



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

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

  html.render
end

#install_dependencies ⇒ Object



78
79
80
# File 'lib/ember_cli/app.rb', line 78

def install_dependencies
  @shell.install
end

#mountable? ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/ember_cli/app.rb', line 92

def mountable?
  deploy.mountable?
end

#node_engine ⇒ Object



112
113
114
# File 'lib/ember_cli/app.rb', line 112

def node_engine
  package_json_value("engines", "node")
end

#package_manager ⇒ Object



96
97
98
# File 'lib/ember_cli/app.rb', line 96

def package_manager
  paths.package_manager
end

#package_manager_spec ⇒ Object

The packageManager field of the application's package.json, such as "[email protected]": the package manager version Corepack and Heroku's NodeJS buildpack install.



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

def package_manager_spec
  package_json_value("packageManager")
end

#pnpm? ⇒ Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/ember_cli/app.rb', line 104

def pnpm?
  paths.pnpm?
end

#root_path ⇒ Object



32
33
34
# File 'lib/ember_cli/app.rb', line 32

def root_path
  paths.root
end

#test ⇒ Object



82
83
84
85
86
# File 'lib/ember_cli/app.rb', line 82

def test
  prepare

  @shell.test.success?
end

#to_rack ⇒ Object



123
124
125
# File 'lib/ember_cli/app.rb', line 123

def to_rack
  deploy.to_rack
end

#yarn? ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/ember_cli/app.rb', line 100

def yarn?
  paths.yarn?
end