Sha256: bfaadc6cc39b57a0473f2ac867ee5b18e04dbb994b5e1c8982f04b799bee3369

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 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 = 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

1 entries across 1 versions & 1 rubygems

Version Path
shopify-cli-1.1.0 lib/project_types/node/commands/generate/billing.rb