Sha256: 09aec5bc8bb4e68ac5b7b27d3c85503afc014250f3a93287931c3dc26e8be054

Contents?: true

Size: 1.87 KB

Versions: 22

Compression:

Stored size: 1.87 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")
            when "product_subscription"
              context.message("errors.outdated_extensions.product_subscription")
            when "checkout_post_purchase"
              context.message("errors.outdated_extensions.checkout_post_purchase")
            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", "product_subscription", "checkout_post_purchase"
              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

22 entries across 22 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.35.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.34.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.33.1 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.33.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.32.1 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.32.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.31.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.30.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.29.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.28.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.27.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.26.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.25.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.24.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.23.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.22.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.21.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.20.1 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb
shopify-cli-2.20.0 lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb