Class: EmberCli::PathSet
- Inherits:
-
Object
- Object
- EmberCli::PathSet
- Defined in:
- lib/ember_cli/path_set.rb
Instance Method Summary collapse
- #bower ⇒ Object
- #bower_components ⇒ Object
- #bower_json ⇒ Object
- #build_error_file ⇒ Object
- #bundler ⇒ Object
- #cached_directories ⇒ Object
- #dist ⇒ Object
- #ember ⇒ Object
- #gemfile ⇒ Object
-
#initialize(app:, rails_root:, ember_cli_root:, environment:) ⇒ PathSet
constructor
A new instance of PathSet.
- #lockfile ⇒ Object
- #log ⇒ Object
- #node_modules ⇒ Object
- #npm ⇒ Object
- #root ⇒ Object
- #tee ⇒ Object
- #tmp ⇒ Object
-
#vite? ⇒ Boolean
Apps generated with the Vite-based blueprint (
ember-cli >= 6.8) ship a Vite config file at their root. - #yarn ⇒ Object
Constructor Details
#initialize(app:, rails_root:, ember_cli_root:, environment:) ⇒ PathSet
Returns a new instance of PathSet.
5 6 7 8 9 10 |
# File 'lib/ember_cli/path_set.rb', line 5 def initialize(app:, rails_root:, ember_cli_root:, environment:) @app = app @rails_root = rails_root @environment = environment @ember_cli_root = ember_cli_root end |
Instance Method Details
#bower ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ember_cli/path_set.rb', line 75 def bower @bower ||= begin path_for_executable("bower").tap do |bower_path| if bower_json.exist? && (bower_path.blank? || !bower_path.executable?) fail DependencyError.new <<-MSG.strip_heredoc Bower is required by EmberCLI Install it with: $ npm install -g bower MSG end end end end |
#bower_components ⇒ Object
92 93 94 |
# File 'lib/ember_cli/path_set.rb', line 92 def bower_components @bower_components ||= root.join("bower_components") end |
#bower_json ⇒ Object
38 39 40 |
# File 'lib/ember_cli/path_set.rb', line 38 def bower_json root.join("bower.json") end |
#build_error_file ⇒ Object
71 72 73 |
# File 'lib/ember_cli/path_set.rb', line 71 def build_error_file @build_error_file ||= tmp.join("error.txt") end |
#bundler ⇒ Object
123 124 125 |
# File 'lib/ember_cli/path_set.rb', line 123 def bundler @bundler ||= path_for_executable("bundler") end |
#cached_directories ⇒ Object
127 128 129 130 131 132 |
# File 'lib/ember_cli/path_set.rb', line 127 def cached_directories [ node_modules, (bower_components if bower_json.exist?), ].compact end |
#dist ⇒ Object
30 31 32 |
# File 'lib/ember_cli/path_set.rb', line 30 def dist @dist ||= ember_cli_root.join("apps", app_name).tap(&:mkpath) end |
#ember ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ember_cli/path_set.rb', line 49 def ember @ember ||= begin root.join("node_modules", "ember-cli", "bin", "ember").tap do |path| unless path.executable? fail DependencyError.new <<-MSG.strip_heredoc No `ember-cli` executable found for `#{app_name}`. Install it: $ cd #{root} $ #{package_manager} install MSG end end end end |
#gemfile ⇒ Object
34 35 36 |
# File 'lib/ember_cli/path_set.rb', line 34 def gemfile @gemfile ||= root.join("Gemfile") end |
#lockfile ⇒ Object
67 68 69 |
# File 'lib/ember_cli/path_set.rb', line 67 def lockfile @lockfile ||= tmp.join("build.lock") end |
#log ⇒ Object
26 27 28 |
# File 'lib/ember_cli/path_set.rb', line 26 def log @log ||= logs.join("ember-#{app_name}.#{environment}.log") end |
#node_modules ⇒ Object
115 116 117 |
# File 'lib/ember_cli/path_set.rb', line 115 def node_modules @node_modules ||= root.join("node_modules") end |
#npm ⇒ Object
96 97 98 |
# File 'lib/ember_cli/path_set.rb', line 96 def npm @npm ||= path_for_executable("npm") end |
#root ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/ember_cli/path_set.rb', line 12 def root path = .fetch(:path){ default_root } pathname = Pathname.new(path) if pathname.absolute? pathname else rails_root.join(path) end end |
#tee ⇒ Object
119 120 121 |
# File 'lib/ember_cli/path_set.rb', line 119 def tee @tee ||= path_for_executable("tee") end |
#tmp ⇒ Object
22 23 24 |
# File 'lib/ember_cli/path_set.rb', line 22 def tmp @tmp ||= root.join("tmp").tap(&:mkpath) end |
#vite? ⇒ Boolean
Apps generated with the Vite-based blueprint (ember-cli >= 6.8)
ship a Vite config file at their root.
44 45 46 47 |
# File 'lib/ember_cli/path_set.rb', line 44 def vite? %w[vite.config.mjs vite.config.js vite.config.ts]. any? { |config| root.join(config).exist? } end |
#yarn ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ember_cli/path_set.rb', line 100 def yarn if yarn? @yarn ||= path_for_executable("yarn").tap do |yarn| unless File.executable?(yarn.to_s) fail DependencyError.new(<<-MSG.strip_heredoc) EmberCLI has been configured to install NodeJS dependencies with Yarn, but the Yarn executable is unavailable. Install it by following the instructions at https://yarnpkg.com/lang/en/docs/install/ MSG end end end end |