Sha256: f25536678cb66328497f3da54219066de060a2c5aa431c24cd81064fb59e8b7d

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

module Extension
  module Tasks
    module ExecuteCommands
      module OutdatedExtensionDetection
        class OutdatedCheck
          include ShopifyCLI::MethodObject

          property! :type, accepts: Models::DevelopmentServerRequirements.method(:type_supported?)
          property! :context, accepts: ShopifyCLI::Context
          property! :project, accepts: ShopifyCLI::Project, default: -> { ShopifyCLI::Project.current }

          def call
            return false if valid?(parse_package)
            context.abort(upgrade_instructions)
          end

          private

          def upgrade_instructions
            case type
            when "checkout_ui_extension"
              context.message("errors.outdated_extensions.checkout_ui_extension")
            else
              context.message("errors.outdated_extensions.unknown")
            end
          end

          def parse_package
            File.open(Pathname(project.directory).join("package.json")) do |file|
              Models::NpmPackage.parse(file)
            end
          end

          def valid?(package)
            case type
            when "checkout_ui_extension"
              package.dev_dependency?("@shopify/shopify-cli-extensions") &&
                package.script?("build") &&
                package.script?("develop")
            else
              true
            end
          end
        end

        def call(*)
          return super unless Models::DevelopmentServerRequirements.supported?(type)
          OutdatedCheck.call(type: type, context: context).then { super }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shopify-cli-2.18.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.17.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.16.1 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.16.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb