Class: Shakapacker::Doctor
- Inherits:
-
Object
- Object
- Shakapacker::Doctor
- Defined in:
- lib/shakapacker/doctor.rb
Defined Under Namespace
Classes: Reporter
Constant Summary collapse
- CATEGORY_ACTION_REQUIRED =
Warning categories for better organization
:action_required- CATEGORY_RECOMMENDED =
:recommended- CATEGORY_INFO =
:info- REQUIRED_BINSTUBS =
{ "bin/shakapacker" => "Main Shakapacker binstub", "bin/shakapacker-dev-server" => "Development server binstub", "bin/shakapacker-config" => "Config export binstub" }.freeze
- OPTIONAL_BINSTUBS =
%w[ bin/shakapacker-watch bin/diff-bundler-config ].freeze
- PACKAGE_MANAGER_LOCKFILES =
{ "bun.lockb" => "bun", "pnpm-lock.yaml" => "pnpm", "yarn.lock" => "yarn", "package-lock.json" => "npm" }.freeze
- SASS_IMPLEMENTATION_PACKAGES =
%w[ sass sass-embedded ].freeze
- SASS_IMPLEMENTATION_DEPENDENCY_MESSAGE =
( "Missing required dependency 'sass' or 'sass-embedded' " \ "for Sass/SCSS implementation" ).freeze
- REQUIRED_RSPACK_DEPS =
{ "@rspack/core" => "^2.0.0", "@rspack/cli" => "^2.0.0", "rspack-manifest-plugin" => "^5.2.2" }.freeze
- RSPACK_DEV_SERVER_DEP =
{ "@rspack/dev-server" => "^2.0.0" }.freeze
- RSPACK_V2_ONLY_DEPS =
REQUIRED_RSPACK_DEPS .slice("@rspack/core", "@rspack/cli") .merge(RSPACK_DEV_SERVER_DEP) .freeze
- OPTIONAL_RSPACK_V2_ONLY_DEPS =
{ "@rspack/plugin-react-refresh" => "^2.0.0" }.freeze
- CUSTOM_HYBRID_LOADER_DEPS =
%w[ babel-loader esbuild-loader ts-loader ].freeze
- BUNDLER_CONFIG_EXTENSIONS =
%w[ ts js ].freeze
- PACKAGE_ROOT_MARKERS =
(["package.json"] + PACKAGE_MANAGER_LOCKFILES.keys + ["node_modules"]).freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(config = nil, root_path = nil, options = {}) ⇒ Doctor
constructor
A new instance of Doctor.
- #run ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(config = nil, root_path = nil, options = {}) ⇒ Doctor
Returns a new instance of Doctor.
75 76 77 78 79 80 81 82 |
# File 'lib/shakapacker/doctor.rb', line 75 def initialize(config = nil, root_path = nil, = {}) @config = config || Shakapacker.config @root_path = root_path || (defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd)) @issues = [] @warnings = [] # Now stores hashes: { category: :symbol, message: "..." } @info = [] @options = end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/shakapacker/doctor.rb', line 8 def config @config end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
8 9 10 |
# File 'lib/shakapacker/doctor.rb', line 8 def info @info end |
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
8 9 10 |
# File 'lib/shakapacker/doctor.rb', line 8 def issues @issues end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/shakapacker/doctor.rb', line 8 def @options end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
8 9 10 |
# File 'lib/shakapacker/doctor.rb', line 8 def root_path @root_path end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
8 9 10 |
# File 'lib/shakapacker/doctor.rb', line 8 def warnings @warnings end |
Instance Method Details
#run ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/shakapacker/doctor.rb', line 84 def run if [:help] print_help return end perform_checks report_results end |
#success? ⇒ Boolean
94 95 96 |
# File 'lib/shakapacker/doctor.rb', line 94 def success? @issues.empty? end |