Class: VueCommand
Constant Summary collapse
- SASS =
%w[sass-loader node-sass].freeze
- SUPPORED_FORMATS =
{ 'pug' => %w[pug-plain-loader pug], 'slm' => %w[slm-loader slm], 'sass' => SASS, 'scss' => SASS, 'less' => %w[less-loader less], 'stylus' => %w[stylus-loader stylus], }.freeze
Instance Method Summary collapse
-
#initialize ⇒ VueCommand
constructor
A new instance of VueCommand.
- #install_format_support(formats) ⇒ Object
- #install_node_dev ⇒ Object
Constructor Details
#initialize ⇒ VueCommand
Returns a new instance of VueCommand.
15 16 17 |
# File 'lib/helpers/scripts/vue_command.rb', line 15 def initialize @pm = VueCli::Rails::Configuration.instance.node_env end |
Instance Method Details
#install_format_support(formats) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/helpers/scripts/vue_command.rb', line 19 def install_format_support(formats) pkgs, unknown = group_formats(formats) if pkgs.empty? msg = unknown.empty? ? 'No formats supplied' : "Unsupported formats #{unknown}" raise(ArgumentError, msg) end STDERR.puts "Unsupported formats #{unknown}" if unknown.any? @pm.add("-D #{pkgs.join(' ')}") end |
#install_node_dev ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/helpers/scripts/vue_command.rb', line 30 def install_node_dev pack_json = ::Rails.root.join('package.json') abort('Not found package.json!') unless pack_json.exist? && pack_json.file? add_deps(pack_json, %w[cross-env npm-run-all]) add_scripts(pack_json, dev: 'run-p rails-s serve', prod: 'cross-env RAILS_ENV=production vue-cli-service build', serve: 'vue-cli-service serve', 'rails-s' => 'cross-env NO_WEBPACK_DEV_SERVER=1 rails s') puts 'Dependencies and scripts have been installed successfully' cmd = @pm.package_manager == :npm ? 'npm run' : 'yarn' puts " Please use `#{cmd} dev` to start dev server" end |