Class: Node::Commands::Generate::Page
- Inherits:
-
ShopifyCli::SubCommand
- Object
- CLI::Kit::BaseCommand
- ShopifyCli::Command
- ShopifyCli::SubCommand
- Node::Commands::Generate::Page
- Defined in:
- lib/project_types/node/commands/generate/page.rb
Constant Summary collapse
- PAGE_TYPES =
{ 'empty-state' => ['./node_modules/.bin/generate-node-app', 'empty-state-page'], 'two-column' => ['./node_modules/.bin/generate-node-app', 'two-column-page'], 'annotated' => ['./node_modules/.bin/generate-node-app', 'settings-page'], 'list' => ['./node_modules/.bin/generate-node-app', 'list-page'], }
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
53 54 55 |
# File 'lib/project_types/node/commands/generate/page.rb', line 53 def self.help ShopifyCli::Context.('node.generate.page.help', ShopifyCli::TOOL_NAME) end |
Instance Method Details
#call(args, _name) ⇒ Object
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 49 50 51 |
# File 'lib/project_types/node/commands/generate/page.rb', line 20 def call(args, _name) name = args.first flag = .flags[:type] unless name @ctx.puts(self.class.help) return end selected_type = if flag unless PAGE_TYPES.key?(flag) @ctx.abort(@ctx.('node.generate.page.error.invalid_page_type')) end PAGE_TYPES[flag] else CLI::UI::Prompt.ask(@ctx.('node.generate.page.type_select')) do |handler| PAGE_TYPES.each do |key, value| handler.option(key) { value } end end end page_type_name = PAGE_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.('node.generate.page.generating', page_type_name)) do |spinner| Node::Commands::Generate.run_generate("#{selected_type} #{name}", name, @ctx) spinner.update_title(@ctx.('node.generate.page.generated', name, name)) end spin_group.wait end |