Sha256: f79d412bd8f1d9049dfc41096ad9e14bbd66bdb4d37ba91756d3cf90be5b42bd

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

require 'shopify_cli'

module Node
  module Commands
    class Generate
      class Billing < ShopifyCli::SubCommand
        BILLING_TYPES = {
          'recurring-billing' => ['./node_modules/.bin/generate-node-app', 'recurring-billing'],
          'one-time-billing' => ['./node_modules/.bin/generate-node-app', 'one-time-billing'],
        }
        def call(args, _name)
          selected_type = BILLING_TYPES[args[1]]
          unless selected_type
            selected_type = CLI::UI::Prompt.ask(@ctx.message('node.generate.billing.type_select')) do |handler|
              BILLING_TYPES.each do |key, value|
                handler.option(key) { value }
              end
            end
          end
          billing_type_name = BILLING_TYPES.key(selected_type)
          selected_type[0] = File.join(ShopifyCli::Project.current.directory, selected_type[0])
          selected_type[0] = "\"#{selected_type[0]}\""
          selected_type = selected_type.join(' ')

          spin_group = CLI::UI::SpinGroup.new
          spin_group.add(@ctx.message('node.generate.billing.generating', billing_type_name)) do |spinner|
            Node::Commands::Generate.run_generate(selected_type, billing_type_name, @ctx)
            spinner.update_title(@ctx.message('node.generate.billing.generated', billing_type_name))
          end
          spin_group.wait
        end

        def self.help
          ShopifyCli::Context.message('node.generate.billing.help', ShopifyCli::TOOL_NAME)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shopify-cli-1.5.0 lib/project_types/node/commands/generate/billing.rb
shopify-cli-1.4.1 lib/project_types/node/commands/generate/billing.rb
shopify-cli-1.4.0 lib/project_types/node/commands/generate/billing.rb
shopify-cli-1.3.1 lib/project_types/node/commands/generate/billing.rb
shopify-cli-1.3.0 lib/project_types/node/commands/generate/billing.rb
shopify-cli-1.2.0 lib/project_types/node/commands/generate/billing.rb
shopify-cli-1.1.2 lib/project_types/node/commands/generate/billing.rb
shopify-cli-1.1.1 lib/project_types/node/commands/generate/billing.rb