Class: Node::Commands::Create
- Inherits:
-
ShopifyCli::SubCommand
- Object
- CLI::Kit::BaseCommand
- ShopifyCli::Command
- ShopifyCli::SubCommand
- Node::Commands::Create
- Defined in:
- lib/project_types/node/commands/create.rb
Instance Attribute Summary
Attributes inherited from ShopifyCli::Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ShopifyCli::SubCommand
Methods inherited from ShopifyCli::Command
call, call_help, #initialize, options, prerequisite_task, run_prerequisites, subcommand, subcommand_registry
Methods included from ShopifyCli::Feature::Set
Constructor Details
This class inherits a constructor from ShopifyCli::Command
Class Method Details
.help ⇒ Object
50 51 52 |
# File 'lib/project_types/node/commands/create.rb', line 50 def self.help ShopifyCli::Context.('node.create.help', ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME) end |
Instance Method Details
#call(args, _name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/project_types/node/commands/create.rb', line 15 def call(args, _name) form = Forms::Create.ask(@ctx, args, .flags) return @ctx.puts(self.class.help) if form.nil? check_node check_npm build(form.name) ShopifyCli::Project.write( @ctx, project_type: 'node', organization_id: form.organization_id, ) api_client = ShopifyCli::Tasks::CreateApiClient.call( @ctx, org_id: form.organization_id, title: form.title, type: form.type, ) ShopifyCli::Resources::EnvFile.new( api_key: api_client["apiKey"], secret: api_client["apiSecretKeys"].first["secret"], shop: form.shop_domain, scopes: 'write_products,write_customers,write_draft_orders', ).write(@ctx) partners_url = "https://partners.shopify.com/#{form.organization_id}/apps/#{api_client['id']}" @ctx.puts(@ctx.('node.create.info.created', form.title, partners_url)) @ctx.puts(@ctx.('node.create.info.serve', form.name, ShopifyCli::TOOL_NAME)) @ctx.puts(@ctx.('node.create.info.install', partners_url, form.title)) end |